Skip to content

Commit 57e711c

Browse files
committed
rebase to Chromium 41
1 parent 40150a6 commit 57e711c

11 files changed

+176
-123
lines changed

DEPS

Lines changed: 117 additions & 85 deletions
Large diffs are not rendered by default.

src/api/nw_app_api.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ void NwAppQuitFunction::DoJob(ExtensionService* service, std::string extension_i
5959
chrome::CloseAllBrowsersAndQuit(true);
6060
return;
6161
}
62-
base::MessageLoopCurrent::Get()->task_runner()->PostTask(
63-
FROM_HERE,
64-
base::Bind(&ExtensionService::TerminateExtension,
62+
base::ThreadTaskRunnerHandle::Get().get()->PostTask(
63+
FROM_HERE,
64+
base::Bind(&ExtensionService::TerminateExtension,
6565
service->AsWeakPtr(),
6666
extension_id));
6767
}
@@ -70,7 +70,7 @@ ExtensionFunction::ResponseAction
7070
NwAppQuitFunction::Run() {
7171
ExtensionService* service =
7272
ExtensionSystem::Get(browser_context())->extension_service();
73-
base::MessageLoopCurrent::Get()->task_runner()->PostTask(
73+
base::ThreadTaskRunnerHandle::Get().get()->PostTask(
7474
FROM_HERE,
7575
base::Bind(&NwAppQuitFunction::DoJob,
7676
service,
@@ -96,7 +96,7 @@ NwAppCloseAllWindowsFunction::Run() {
9696
AppWindowRegistry* registry = AppWindowRegistry::Get(browser_context());
9797
if (!registry)
9898
return RespondNow(Error(""));
99-
base::MessageLoopCurrent::Get()->task_runner()->PostTask(
99+
base::ThreadTaskRunnerHandle::Get().get()->PostTask(
100100
FROM_HERE,
101101
base::Bind(&NwAppCloseAllWindowsFunction::DoJob, registry, extension()->id()));
102102

src/api/nw_clipboard_api.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ namespace {
6666
bool ReadText(ClipboardData& data) {
6767
DCHECK(data.type == TYPE_TEXT);
6868
base::string16 text;
69-
clipboard_->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &text);
69+
clipboard_->ReadText(ui::ClipboardType::kCopyPaste, &text);
7070
data.data.reset(new std::string(base::UTF16ToUTF8(text)));
7171
return true;
7272
}
@@ -76,23 +76,23 @@ namespace {
7676
base::string16 text;
7777
std::string src_url;
7878
uint32_t fragment_start, fragment_end;
79-
clipboard_->ReadHTML(ui::CLIPBOARD_TYPE_COPY_PASTE, &text, &src_url, &fragment_start, &fragment_end);
79+
clipboard_->ReadHTML(ui::ClipboardType::kCopyPaste, &text, &src_url, &fragment_start, &fragment_end);
8080
data.data.reset(new std::string(base::UTF16ToUTF8(text)));
8181
return true;
8282
}
8383

8484
bool ReadRTF(ClipboardData& data) {
8585
DCHECK(data.type == TYPE_RTF);
8686
std::string text;
87-
clipboard_->ReadRTF(ui::CLIPBOARD_TYPE_COPY_PASTE, &text);
87+
clipboard_->ReadRTF(ui::ClipboardType::kCopyPaste, &text);
8888
data.data.reset(new std::string(text));
8989
return true;
9090
}
9191

9292
bool ReadImage(ClipboardData& data) {
9393
DCHECK(data.type == TYPE_PNG || data.type == TYPE_JPEG);
9494
std::vector<unsigned char> encoded_image;
95-
SkBitmap bitmap = clipboard_->ReadImage(ui::CLIPBOARD_TYPE_COPY_PASTE);
95+
SkBitmap bitmap = clipboard_->ReadImage(ui::ClipboardType::kCopyPaste);
9696

9797
if (bitmap.isNull()) {
9898
return true;
@@ -135,7 +135,7 @@ namespace {
135135
class ClipboardWriter {
136136
public:
137137
ClipboardWriter() {
138-
scw_.reset(new ui::ScopedClipboardWriter(ui::CLIPBOARD_TYPE_COPY_PASTE));
138+
scw_.reset(new ui::ScopedClipboardWriter(ui::ClipboardType::kCopyPaste));
139139
}
140140

141141
~ClipboardWriter() {
@@ -292,7 +292,7 @@ NwClipboardClearSyncFunction::~NwClipboardClearSyncFunction() {
292292

293293
bool NwClipboardClearSyncFunction::RunNWSync(base::ListValue* response, std::string* error) {
294294
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
295-
clipboard->Clear(ui::CLIPBOARD_TYPE_COPY_PASTE);
295+
clipboard->Clear(ui::ClipboardType::kCopyPaste);
296296
return true;
297297
}
298298

@@ -308,7 +308,7 @@ bool NwClipboardReadAvailableTypesFunction::RunNWSync(base::ListValue* response,
308308
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
309309
bool contains_filenames;
310310
std::vector<base::string16> types;
311-
clipboard->ReadAvailableTypes(ui::CLIPBOARD_TYPE_COPY_PASTE, &types, &contains_filenames);
311+
clipboard->ReadAvailableTypes(ui::ClipboardType::kCopyPaste, &types, &contains_filenames);
312312
for(std::vector<base::string16>::iterator it = types.begin(); it != types.end(); it++) {
313313
if (base::EqualsASCII(*it, ui::kMimeTypeText)) {
314314
response->Append(base::WrapUnique(new base::Value(ToString(TYPE_TEXT))));

src/api/nw_window_api.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,18 @@ NwCurrentWindowInternalCloseFunction::Run() {
214214
if (!browser)
215215
return RespondNow(Error("cannot find browser window"));
216216
if (force)
217-
base::MessageLoopCurrent::Get()->task_runner()->PostTask(FROM_HERE,
217+
base::ThreadTaskRunnerHandle::Get().get()->PostTask(FROM_HERE,
218218
base::Bind(&NwCurrentWindowInternalCloseFunction::DoCloseBrowser, browser));
219219
else if (browser->NWCanClose())
220-
base::MessageLoopCurrent::Get()->task_runner()->PostTask(FROM_HERE,
220+
base::ThreadTaskRunnerHandle::Get().get()->PostTask(FROM_HERE,
221221
base::Bind(&NwCurrentWindowInternalCloseFunction::DoCloseBrowser, browser));
222222
} else {
223223
AppWindow* window = getAppWindow(this);
224224
if (force)
225-
base::MessageLoopCurrent::Get()->task_runner()->PostTask(FROM_HERE,
225+
base::ThreadTaskRunnerHandle::Get().get()->PostTask(FROM_HERE,
226226
base::Bind(&NwCurrentWindowInternalCloseFunction::DoClose, window));
227227
else if (window->NWCanClose())
228-
base::MessageLoopCurrent::Get()->task_runner()->PostTask(FROM_HERE,
228+
base::ThreadTaskRunnerHandle::Get().get()->PostTask(FROM_HERE,
229229
base::Bind(&NwCurrentWindowInternalCloseFunction::DoClose, window));
230230
}
231231

src/browser/menubar_view.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class MenuBarButton : public views::MenuButton {
5252
};
5353

5454
MenuBarView::MenuBarView() {
55-
auto layout = std::make_unique<views::BoxLayout>(views::BoxLayout::kHorizontal, gfx::Insets(), 0);
55+
auto layout = std::make_unique<views::BoxLayout>(views::BoxLayout::Orientation::kHorizontal, gfx::Insets(), 0);
5656
SetLayoutManager(std::move(layout));
5757
SetBackground(views::CreateSolidBackground(GetNativeTheme()->GetSystemColor(
5858
ui::NativeTheme::kColorId_MenuBackgroundColor)));

src/browser/nw_chrome_browser_hooks.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
// chrome
1818
#include "chrome/browser/browser_process.h"
1919
#include "chrome/browser/devtools/devtools_window.h"
20-
#include "chrome/browser/io_thread.h"
2120
#include "chrome/browser/lifetime/application_lifetime.h"
2221
#include "chrome/browser/profiles/profile_manager.h"
2322
#include "components/keep_alive_registry/keep_alive_types.h"
@@ -31,7 +30,7 @@
3130

3231
// content
3332
#include "content/common/dom_storage/dom_storage_map.h"
34-
#include "content/browser/dom_storage/dom_storage_area.h"
33+
//#include "content/browser/dom_storage/dom_storage_area.h"
3534
#include "content/nw/src/common/shell_switches.h"
3635
#include "content/public/browser/browser_thread.h"
3736
#include "content/public/browser/child_process_security_policy.h"
@@ -189,6 +188,7 @@ bool GetDirUserData(base::FilePath *user_data_dir) {
189188
return base::PathService::Get(chrome::DIR_USER_DATA, user_data_dir);
190189
}
191190

191+
#if 0
192192
void SetTrustAnchorsOnIOThread(const scoped_refptr<net::URLRequestContextGetter>& url_request_getter,
193193
IOThread* io_thread,
194194
const net::CertificateList& trust_anchors) {
@@ -213,6 +213,7 @@ void SetTrustAnchors(net::CertificateList& trust_anchors) {
213213
base::BindOnce(SetTrustAnchorsOnIOThread, base::WrapRefCounted(url_request_context_getter),
214214
g_browser_process->io_thread(), trust_anchors));
215215
}
216+
#endif
216217

217218
void SetAppIcon(gfx::Image &icon) {
218219
g_app_icon = icon;
@@ -268,6 +269,7 @@ int MainPartsPreCreateThreadsHook() {
268269
content::DOMStorageMap::SetQuotaOverride(dom_storage_quota_mb * 1024 * 1024);
269270
}
270271

272+
#if 0
271273
base::FilePath user_data_dir;
272274
std::string name, domain;
273275
package->root()->GetString("name", &name);
@@ -356,6 +358,7 @@ int MainPartsPreCreateThreadsHook() {
356358
}
357359
}
358360
}
361+
#endif
359362

360363
}
361364
return service_manager::RESULT_CODE_NORMAL_EXIT;
@@ -387,7 +390,7 @@ void MainPartsPreMainMessageLoopRunHook() {
387390
}
388391
if (!trust_anchors.empty()) {
389392
#if !defined(OS_MACOSX)
390-
SetTrustAnchors(trust_anchors);
393+
//SetTrustAnchors(trust_anchors);
391394
#else
392395
net::TestRootCerts* certs = net::TestRootCerts::GetInstance();
393396
for (size_t i = 0; i < trust_anchors.size(); i++)

src/browser/nw_extensions_browser_hooks.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ void LoadNWAppAsExtensionHook(base::DictionaryValue* manifest,
290290
AmendManifestList(manifest, manifest_keys::kWebURLs, *node_remote_list);
291291
}
292292

293-
if (NWContentVerifierDelegate::GetDefaultMode() == ContentVerifierDelegate::ENFORCE_STRICT)
293+
if (NWContentVerifierDelegate::GetDefaultMode() == NWContentVerifierDelegate::ENFORCE_STRICT)
294294
manifest->SetBoolean(manifest_keys::kNWJSContentVerifyFlag, true);
295295

296296
if (package->temp_dir().IsValid()) {

src/nw_content_verifier_delegate.cc

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const int kNWSignaturesPublicKeySize =
6464
namespace extensions {
6565

6666
// static
67-
ContentVerifierDelegate::Mode NWContentVerifierDelegate::GetDefaultMode() {
67+
NWContentVerifierDelegate::Mode NWContentVerifierDelegate::GetDefaultMode() {
6868
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
6969

7070
Mode experiment_value = NONE;
@@ -74,15 +74,15 @@ ContentVerifierDelegate::Mode NWContentVerifierDelegate::GetDefaultMode() {
7474
std::string switch_value = command_line->GetSwitchValueASCII(
7575
switches::kVerifyContent);
7676
if (switch_value == switches::kExtensionContentVerificationBootstrap)
77-
cmdline_value = ContentVerifierDelegate::BOOTSTRAP;
77+
cmdline_value = NWContentVerifierDelegate::BOOTSTRAP;
7878
else if (switch_value == switches::kExtensionContentVerificationEnforce)
79-
cmdline_value = ContentVerifierDelegate::ENFORCE;
79+
cmdline_value = NWContentVerifierDelegate::ENFORCE;
8080
else if (switch_value ==
8181
switches::kExtensionContentVerificationEnforceStrict)
82-
cmdline_value = ContentVerifierDelegate::ENFORCE_STRICT;
82+
cmdline_value = NWContentVerifierDelegate::ENFORCE_STRICT;
8383
else
8484
// If no value was provided (or the wrong one), just default to enforce.
85-
cmdline_value = ContentVerifierDelegate::ENFORCE;
85+
cmdline_value = NWContentVerifierDelegate::ENFORCE;
8686
}
8787

8888
// We don't want to allow the command-line flags to eg disable enforcement
@@ -99,17 +99,17 @@ NWContentVerifierDelegate::NWContentVerifierDelegate(
9999
NWContentVerifierDelegate::~NWContentVerifierDelegate() {
100100
}
101101

102-
ContentVerifierDelegate::Mode NWContentVerifierDelegate::ShouldBeVerified(
102+
bool NWContentVerifierDelegate::ShouldBeVerified(
103103
const Extension& extension) {
104104

105105
if (extension.is_nwjs_app() && !Manifest::IsComponentLocation(extension.location()))
106-
return default_mode_;
106+
return default_mode_ != NONE;
107107
if (!extension.is_extension() && !extension.is_legacy_packaged_app())
108-
return ContentVerifierDelegate::NONE;
108+
return false;
109109
if (!Manifest::IsAutoUpdateableLocation(extension.location()))
110-
return ContentVerifierDelegate::NONE;
110+
return false;
111111

112-
return default_mode_;
112+
return default_mode_ != NONE;
113113
}
114114

115115
ContentVerifierKey NWContentVerifierDelegate::GetPublicKey() {
@@ -139,8 +139,7 @@ void NWContentVerifierDelegate::VerifyFailed(
139139
if (!extension)
140140
return;
141141
ExtensionSystem* system = ExtensionSystem::Get(context_);
142-
Mode mode = ShouldBeVerified(*extension);
143-
if (mode >= ContentVerifierDelegate::ENFORCE) {
142+
if (ShouldBeVerified(*extension)) {
144143
LoadErrorReporter::GetInstance()->
145144
ReportLoadError(extension->path(), "Extension file corrupted: " + relative_path.AsUTF8Unsafe(),
146145
system->extension_service()->profile(), true);

src/nw_content_verifier_delegate.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,33 @@ namespace extensions {
1515

1616
class NWContentVerifierDelegate : public ContentVerifierDelegate {
1717
public:
18+
enum Mode {
19+
// Do not try to fetch content hashes if they are missing, and do
20+
// not
21+
// enforce them if they are present.
22+
NONE = 0,
23+
24+
// If content hashes are missing, try to fetch them, but do not
25+
// enforce.
26+
BOOTSTRAP,
27+
28+
// If hashes are present, enforce them. If they are missing, try
29+
// to fetch
30+
// them.
31+
ENFORCE,
32+
33+
// Treat the absence of hashes the same as a verification failure.
34+
ENFORCE_STRICT
35+
};
36+
1837
static Mode GetDefaultMode();
1938

2039
explicit NWContentVerifierDelegate(content::BrowserContext* context);
2140

2241
~NWContentVerifierDelegate() override;
2342

2443
// ContentVerifierDelegate:
25-
Mode ShouldBeVerified(const Extension& extension) override;
44+
bool ShouldBeVerified(const Extension& extension) override;
2645
ContentVerifierKey GetPublicKey() override;
2746
GURL GetSignatureFetchUrl(const std::string& extension_id,
2847
const base::Version& version) override;
@@ -34,7 +53,7 @@ class NWContentVerifierDelegate : public ContentVerifierDelegate {
3453
scoped_refptr<ContentVerifyJob> verify_job) override;
3554
void Shutdown() override;
3655
content::BrowserContext* context_;
37-
ContentVerifierDelegate::Mode default_mode_;
56+
Mode default_mode_;
3857

3958
std::set<std::string> would_be_disabled_ids_;
4059

src/nw_version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#define NW_VERSION_H
2323

2424
#define NW_MAJOR_VERSION 0
25-
#define NW_MINOR_VERSION 40
26-
#define NW_PATCH_VERSION 3
25+
#define NW_MINOR_VERSION 41
26+
#define NW_PATCH_VERSION 0
2727

2828
#define NW_VERSION_IS_RELEASE 1
2929

src/nwjs_browsertest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ class MockWebContentsDelegate : public content::WebContentsDelegate {
350350

351351
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
352352
const GURL& security_origin,
353-
blink::MediaStreamType type) override {
353+
blink::mojom::MediaStreamType type) override {
354354
checked_ = true;
355355
if (check_message_loop_runner_.get())
356356
check_message_loop_runner_->Quit();

0 commit comments

Comments
 (0)