From b83676f9e98c4fc679470a02ed74fe770e9b66c5 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 23 Jan 2017 14:12:49 +0900 Subject: [PATCH 01/63] Update to Chrome 56 --- atom/common/chrome_version.h | 2 +- script/lib/config.py | 2 +- script/update-clang.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/atom/common/chrome_version.h b/atom/common/chrome_version.h index 03288b43a86c..2a2a067c4301 100644 --- a/atom/common/chrome_version.h +++ b/atom/common/chrome_version.h @@ -8,7 +8,7 @@ #ifndef ATOM_COMMON_CHROME_VERSION_H_ #define ATOM_COMMON_CHROME_VERSION_H_ -#define CHROME_VERSION_STRING "54.0.2840.101" +#define CHROME_VERSION_STRING "56.0.2924.59" #define CHROME_VERSION "v" CHROME_VERSION_STRING #endif // ATOM_COMMON_CHROME_VERSION_H_ diff --git a/script/lib/config.py b/script/lib/config.py index 7018b5eded21..d5ec0b10ed97 100644 --- a/script/lib/config.py +++ b/script/lib/config.py @@ -9,7 +9,7 @@ import sys BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \ 'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent' LIBCHROMIUMCONTENT_COMMIT = os.getenv('LIBCHROMIUMCONTENT_COMMIT') or \ - 'b4dd78df3f4fa271057ecdaa54441501e63e7c55' + '63227c0c9299e01809bcc705bd7346aecf8b6855' PLATFORM = { 'cygwin': 'win32', diff --git a/script/update-clang.sh b/script/update-clang.sh index 0478973628bf..64a0ac7d6404 100755 --- a/script/update-clang.sh +++ b/script/update-clang.sh @@ -8,7 +8,7 @@ # Do NOT CHANGE this if you don't know what you're doing -- see # https://code.google.com/p/chromium/wiki/UpdatingClang # Reverting problematic clang rolls is safe, though. -CLANG_REVISION=278861 +CLANG_REVISION=284979 # This is incremented when pushing a new build of Clang at the same revision. CLANG_SUB_REVISION=1 From c1df762656bf7e60e65e99d555b6dfd5af469556 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 23 Jan 2017 14:13:10 +0900 Subject: [PATCH 02/63] Update crashpad to 556c4e4 --- vendor/crashpad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/crashpad b/vendor/crashpad index 600292f69f0f..eeac857dfb5b 160000 --- a/vendor/crashpad +++ b/vendor/crashpad @@ -1 +1 @@ -Subproject commit 600292f69f0f935ada02a02876ed489d21402620 +Subproject commit eeac857dfb5b255c899c8763d62654863b4c8890 From 406224edffbb45f5508a7962ad23d7cf7e202169 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 23 Jan 2017 15:51:23 +0900 Subject: [PATCH 03/63] enable_pepper_cdms is now a feature flag So we should not define it anymore. --- atom/app/atom_content_client.cc | 8 ++++---- .../renderer_host/pepper/widevine_cdm_message_filter.cc | 6 +++--- .../renderer_host/pepper/widevine_cdm_message_filter.h | 2 +- chromium_src/chrome/common/chrome_paths.cc | 4 ++-- chromium_src/chrome/common/widevine_cdm_messages.h | 2 +- chromium_src/chrome/renderer/media/chrome_key_systems.cc | 8 ++++---- electron.gyp | 2 +- vendor/brightray | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/atom/app/atom_content_client.cc b/atom/app/atom_content_client.cc index a49b39e45cf3..760a42732b3a 100644 --- a/atom/app/atom_content_client.cc +++ b/atom/app/atom_content_client.cc @@ -23,7 +23,7 @@ #include "ui/base/l10n/l10n_util.h" #include "url/url_constants.h" -#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) #include "chrome/common/widevine_cdm_constants.h" #endif @@ -71,7 +71,7 @@ content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, return plugin; } -#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) content::PepperPluginInfo CreateWidevineCdmInfo(const base::FilePath& path, const std::string& version) { content::PepperPluginInfo widevine_cdm; @@ -135,7 +135,7 @@ void AddPepperFlashFromCommandLine( plugins->push_back(CreatePepperFlashInfo(flash_path, flash_version)); } -#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) void AddWidevineCdmFromCommandLine( std::vector* plugins) { auto command_line = base::CommandLine::ForCurrentProcess(); @@ -187,7 +187,7 @@ void AtomContentClient::AddAdditionalSchemes( void AtomContentClient::AddPepperPlugins( std::vector* plugins) { AddPepperFlashFromCommandLine(plugins); -#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) AddWidevineCdmFromCommandLine(plugins); #endif } diff --git a/chromium_src/chrome/browser/renderer_host/pepper/widevine_cdm_message_filter.cc b/chromium_src/chrome/browser/renderer_host/pepper/widevine_cdm_message_filter.cc index c926b9e94aa7..62427e995463 100644 --- a/chromium_src/chrome/browser/renderer_host/pepper/widevine_cdm_message_filter.cc +++ b/chromium_src/chrome/browser/renderer_host/pepper/widevine_cdm_message_filter.cc @@ -24,7 +24,7 @@ WidevineCdmMessageFilter::WidevineCdmMessageFilter( bool WidevineCdmMessageFilter::OnMessageReceived(const IPC::Message& message) { IPC_BEGIN_MESSAGE_MAP(WidevineCdmMessageFilter, message) -#if defined(ENABLE_PEPPER_CDMS) +#if BUILDFLAG(ENABLE_PEPPER_CDMS) IPC_MESSAGE_HANDLER( ChromeViewHostMsg_IsInternalPluginAvailableForMimeType, OnIsInternalPluginAvailableForMimeType) @@ -34,7 +34,7 @@ bool WidevineCdmMessageFilter::OnMessageReceived(const IPC::Message& message) { return true; } -#if defined(ENABLE_PEPPER_CDMS) +#if BUILDFLAG(ENABLE_PEPPER_CDMS) void WidevineCdmMessageFilter::OnIsInternalPluginAvailableForMimeType( const std::string& mime_type, bool* is_available, @@ -60,7 +60,7 @@ void WidevineCdmMessageFilter::OnIsInternalPluginAvailableForMimeType( *is_available = false; } -#endif // defined(ENABLE_PEPPER_CDMS) +#endif // BUILDFLAG(ENABLE_PEPPER_CDMS) void WidevineCdmMessageFilter::OnDestruct() const { BrowserThread::DeleteOnUIThread::Destruct(this); diff --git a/chromium_src/chrome/browser/renderer_host/pepper/widevine_cdm_message_filter.h b/chromium_src/chrome/browser/renderer_host/pepper/widevine_cdm_message_filter.h index b8f3d562ac78..6cd77fe57c5e 100644 --- a/chromium_src/chrome/browser/renderer_host/pepper/widevine_cdm_message_filter.h +++ b/chromium_src/chrome/browser/renderer_host/pepper/widevine_cdm_message_filter.h @@ -25,7 +25,7 @@ class WidevineCdmMessageFilter : public content::BrowserMessageFilter { virtual ~WidevineCdmMessageFilter(); - #if defined(ENABLE_PEPPER_CDMS) + #if BUILDFLAG(ENABLE_PEPPER_CDMS) // Returns whether any internal plugin supporting |mime_type| is registered // and enabled. Does not determine whether the plugin can actually be // instantiated (e.g. whether it has all its dependencies). diff --git a/chromium_src/chrome/common/chrome_paths.cc b/chromium_src/chrome/common/chrome_paths.cc index d373315beb0b..009953ff5a3a 100644 --- a/chromium_src/chrome/common/chrome_paths.cc +++ b/chromium_src/chrome/common/chrome_paths.cc @@ -360,7 +360,7 @@ bool PathProvider(int key, base::FilePath* result) { #endif cur = cur.Append(FILE_PATH_LITERAL("pnacl")); break; -#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) #if defined(WIDEVINE_CDM_IS_COMPONENT) case chrome::DIR_COMPONENT_WIDEVINE_CDM: if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) @@ -376,7 +376,7 @@ bool PathProvider(int key, base::FilePath* result) { return false; cur = cur.AppendASCII(kWidevineCdmAdapterFileName); break; -#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) case chrome::FILE_RESOURCES_PACK: #if defined(OS_MACOSX) && !defined(OS_IOS) if (base::mac::AmIBundled()) { diff --git a/chromium_src/chrome/common/widevine_cdm_messages.h b/chromium_src/chrome/common/widevine_cdm_messages.h index 17c908776b26..919c673c5670 100644 --- a/chromium_src/chrome/common/widevine_cdm_messages.h +++ b/chromium_src/chrome/common/widevine_cdm_messages.h @@ -13,7 +13,7 @@ // Renderer -> Browser messages. -#if defined(ENABLE_PEPPER_CDMS) +#if BUILDFLAG(ENABLE_PEPPER_CDMS) // Returns whether any internal plugin supporting |mime_type| is registered and // enabled. Does not determine whether the plugin can actually be instantiated // (e.g. whether it has all its dependencies). diff --git a/chromium_src/chrome/renderer/media/chrome_key_systems.cc b/chromium_src/chrome/renderer/media/chrome_key_systems.cc index ef3ab52e59a0..206ac400fba8 100644 --- a/chromium_src/chrome/renderer/media/chrome_key_systems.cc +++ b/chromium_src/chrome/renderer/media/chrome_key_systems.cc @@ -32,7 +32,7 @@ using media::KeySystemProperties; using media::SupportedCodecs; -#if defined(ENABLE_PEPPER_CDMS) +#if BUILDFLAG(ENABLE_PEPPER_CDMS) static const char kExternalClearKeyPepperType[] = "application/x-ppapi-clearkey-cdm"; @@ -264,15 +264,15 @@ static void AddPepperBasedWidevine( #endif // defined(OS_CHROMEOS) } #endif // defined(WIDEVINE_CDM_AVAILABLE) -#endif // defined(ENABLE_PEPPER_CDMS) +#endif // BUILDFLAG(ENABLE_PEPPER_CDMS) void AddChromeKeySystems( std::vector>* key_systems_properties) { -#if defined(ENABLE_PEPPER_CDMS) +#if BUILDFLAG(ENABLE_PEPPER_CDMS) AddExternalClearKey(key_systems_properties); #if defined(WIDEVINE_CDM_AVAILABLE) AddPepperBasedWidevine(key_systems_properties); #endif // defined(WIDEVINE_CDM_AVAILABLE) -#endif // defined(ENABLE_PEPPER_CDMS) +#endif // BUILDFLAG(ENABLE_PEPPER_CDMS) } diff --git a/electron.gyp b/electron.gyp index 9b55182d6245..7ab032532d45 100644 --- a/electron.gyp +++ b/electron.gyp @@ -225,8 +225,8 @@ 'V8_USE_EXTERNAL_STARTUP_DATA', 'V8_SHARED', 'USING_V8_SHARED', + # Remove this after enable_plugins becomes a feature flag. 'ENABLE_PLUGINS', - 'ENABLE_PEPPER_CDMS', 'USE_PROPRIETARY_CODECS', ], 'sources': [ diff --git a/vendor/brightray b/vendor/brightray index e5b56b449785..5f4cf42a6d8f 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit e5b56b4497857734cc8cd4ac7c28a5c1684f071e +Subproject commit 5f4cf42a6d8f611c859efdde20c085dcc4871919 From 074cad9146eaf9721e757b1d587457bc579482e1 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 23 Jan 2017 15:52:27 +0900 Subject: [PATCH 04/63] A few new V8 defines --- electron.gyp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/electron.gyp b/electron.gyp index 7ab032532d45..39c1f1904543 100644 --- a/electron.gyp +++ b/electron.gyp @@ -225,6 +225,8 @@ 'V8_USE_EXTERNAL_STARTUP_DATA', 'V8_SHARED', 'USING_V8_SHARED', + 'USING_V8_PLATFORM_SHARED', + 'USING_V8_BASE_SHARED', # Remove this after enable_plugins becomes a feature flag. 'ENABLE_PLUGINS', 'USE_PROPRIETARY_CODECS', From 0a91779dfa6cf1f563f926efa42b65460a3feb5f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 23 Jan 2017 15:53:29 +0900 Subject: [PATCH 05/63] Node also defines LIKELY --- atom/common/node_includes.h | 1 + 1 file changed, 1 insertion(+) diff --git a/atom/common/node_includes.h b/atom/common/node_includes.h index 01efa6b15470..b6cbf36090c9 100644 --- a/atom/common/node_includes.h +++ b/atom/common/node_includes.h @@ -22,6 +22,7 @@ #undef UNLIKELY #undef DISALLOW_COPY_AND_ASSIGN #undef NO_RETURN +#undef LIKELY #undef arraysize #undef debug_string // This is defined in macOS 10.9 SDK in AssertMacros.h. #include "vendor/node/src/env.h" From d8e9432b0d7393207c028468523c98af8b399d50 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 23 Jan 2017 17:42:39 +0900 Subject: [PATCH 06/63] contentTracing.setWatchEvent/cancelWatchEvent is removed --- atom/browser/api/atom_api_content_tracing.cc | 4 ---- docs-translations/jp/api/content-tracing.md | 12 ------------ docs-translations/ko-KR/api/content-tracing.md | 13 ------------- docs-translations/zh-CN/api/content-tracing.md | 12 ------------ docs/api/content-tracing.md | 14 -------------- 5 files changed, 55 deletions(-) diff --git a/atom/browser/api/atom_api_content_tracing.cc b/atom/browser/api/atom_api_content_tracing.cc index fa275c1c90d0..375196b28318 100644 --- a/atom/browser/api/atom_api_content_tracing.cc +++ b/atom/browser/api/atom_api_content_tracing.cc @@ -69,10 +69,6 @@ void Initialize(v8::Local exports, v8::Local unused, dict.SetMethod("stopRecording", &StopRecording); dict.SetMethod("getTraceBufferUsage", base::Bind( &TracingController::GetTraceBufferUsage, controller)); - dict.SetMethod("setWatchEvent", base::Bind( - &TracingController::SetWatchEvent, controller)); - dict.SetMethod("cancelWatchEvent", base::Bind( - &TracingController::CancelWatchEvent, controller)); } } // namespace diff --git a/docs-translations/jp/api/content-tracing.md b/docs-translations/jp/api/content-tracing.md index d7156baa31ac..2a0347e1f6cc 100644 --- a/docs-translations/jp/api/content-tracing.md +++ b/docs-translations/jp/api/content-tracing.md @@ -115,15 +115,3 @@ EnableRecordingリクエストを受信するとすぐに、子プロセス上 * `callback` Function プロセスのトレースバッファのプロセス間で最大使用量をフルの状態の何%かで取得します。TraceBufferUsage値が設定されていると、 `callback`がコールされます。 - -### `contentTracing.setWatchEvent(categoryName, eventName, callback)` - -* `categoryName` String -* `eventName` String -* `callback` Function - -プロセス上でイベント発生すると、その度に`callback`がコールされます。 - -### `contentTracing.cancelWatchEvent()` - -イベントウオッチをキャンセルします。トレースが有効になっていると、監視イベントのコールバックとの競合状態になる可能性があります。 diff --git a/docs-translations/ko-KR/api/content-tracing.md b/docs-translations/ko-KR/api/content-tracing.md index c360c35e194c..68622e10e0a2 100644 --- a/docs-translations/ko-KR/api/content-tracing.md +++ b/docs-translations/ko-KR/api/content-tracing.md @@ -150,16 +150,3 @@ Child 프로세스는 일반적으로 추적 데이터와 희귀한 플러시 추적 버퍼 % 전체 상태의 프로세스간 최대치를 가져옵니다. TraceBufferUsage 값이 결정되면 `callback`이 한 번 호출됩니다. - -### `contentTracing.setWatchEvent(categoryName, eventName, callback)` - -* `categoryName` String -* `eventName` String -* `callback` Function - -`callback`은 지정된 이벤트가 어떤 작업을 발생시킬 때마다 호출됩니다. - -### `contentTracing.cancelWatchEvent()` - -Watch 이벤트를 중단합니다. 만약 추적이 활성화되어 있다면 이 메서드는 watch 이벤트 -콜백과 race가 일어날 것입니다. diff --git a/docs-translations/zh-CN/api/content-tracing.md b/docs-translations/zh-CN/api/content-tracing.md index f2de76d14819..f30a616b3f53 100644 --- a/docs-translations/zh-CN/api/content-tracing.md +++ b/docs-translations/zh-CN/api/content-tracing.md @@ -115,15 +115,3 @@ contentTracing.startRecording(options, function () { * `callback` Function 通过查找 buffer 进程来获取百分比最大使用量.当确定了TraceBufferUsage 的值确定的时候,就调用 `callback` . - -### `contentTracing.setWatchEvent(categoryName, eventName, callback)` - -* `categoryName` String -* `eventName` String -* `callback` Function - -任意时刻在任何进程上指定事件发生时将调用 `callback` . - -### `contentTracing.cancelWatchEvent()` - -取消 watch 事件. 如果启动查找,这或许会造成 watch 事件的回调函数 出错. \ No newline at end of file diff --git a/docs/api/content-tracing.md b/docs/api/content-tracing.md index 45ea34728965..158427ddb5b4 100644 --- a/docs/api/content-tracing.md +++ b/docs/api/content-tracing.md @@ -163,17 +163,3 @@ request the `callback` will be called with a file that contains the traced data. Get the maximum usage across processes of trace buffer as a percentage of the full state. When the TraceBufferUsage value is determined the `callback` is called. - -### `contentTracing.setWatchEvent(categoryName, eventName, callback)` - -* `categoryName` String -* `eventName` String -* `callback` Function - -`callback` will be called every time the given event occurs on any -process. - -### `contentTracing.cancelWatchEvent()` - -Cancel the watch event. This may lead to a race condition with the watch event -callback if tracing is enabled. From c10eb7316673b0afa39e41ced27140aa7bab6a02 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 23 Jan 2017 17:44:42 +0900 Subject: [PATCH 07/63] Signature of OnCreateWindow has changed --- atom/browser/api/atom_api_app.cc | 2 +- atom/browser/api/atom_api_app.h | 2 +- atom/browser/api/atom_api_web_contents.cc | 2 +- atom/browser/api/atom_api_web_contents.h | 2 +- atom/browser/atom_browser_client.cc | 2 +- atom/browser/atom_browser_client.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 99cd5ffa8b14..caaee9d25cb3 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -558,7 +558,7 @@ void App::OnCreateWindow( const GURL& target_url, const std::string& frame_name, WindowOpenDisposition disposition, - const std::vector& features, + const std::vector& features, const scoped_refptr& body, int render_process_id, int render_frame_id) { diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index 2bd977f46b05..c7e62927c594 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -53,7 +53,7 @@ class App : public AtomBrowserClient::Delegate, const GURL& target_url, const std::string& frame_name, WindowOpenDisposition disposition, - const std::vector& features, + const std::vector& features, const scoped_refptr& body, int render_process_id, int render_frame_id); diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index a8f864c775bd..6b448b533502 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -392,7 +392,7 @@ void WebContents::OnCreateWindow( const GURL& target_url, const std::string& frame_name, WindowOpenDisposition disposition, - const std::vector& features, + const std::vector& features, const scoped_refptr& body) { if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) Emit("-new-window", target_url, frame_name, disposition, features, body); diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 22f6b8775f99..385aa63f49a0 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -184,7 +184,7 @@ class WebContents : public mate::TrackableObject, const GURL& target_url, const std::string& frame_name, WindowOpenDisposition disposition, - const std::vector& features, + const std::vector& features, const scoped_refptr& body); // Returns the web preferences of current WebContents. diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index 97a13fe6d6b0..bad2999ed6d9 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -300,7 +300,7 @@ bool AtomBrowserClient::CanCreateWindow( const std::string& frame_name, WindowOpenDisposition disposition, const blink::WebWindowFeatures& features, - const std::vector& additional_features, + const std::vector& additional_features, const scoped_refptr& body, bool user_gesture, bool opener_suppressed, diff --git a/atom/browser/atom_browser_client.h b/atom/browser/atom_browser_client.h index 0956158717b2..c2a7d5edd0f4 100644 --- a/atom/browser/atom_browser_client.h +++ b/atom/browser/atom_browser_client.h @@ -88,7 +88,7 @@ class AtomBrowserClient : public brightray::BrowserClient, const std::string& frame_name, WindowOpenDisposition disposition, const blink::WebWindowFeatures& features, - const std::vector& additional_features, + const std::vector& additional_features, const scoped_refptr& body, bool user_gesture, bool opener_suppressed, From 7a7b72ce0466391021fc84da2790aa3c88b88e32 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 23 Jan 2017 17:53:53 +0900 Subject: [PATCH 08/63] SimpleMenuModel::MenuClosed renamed to MenuWillClose --- atom/browser/ui/atom_menu_model.cc | 6 +++--- atom/browser/ui/atom_menu_model.h | 4 ++-- atom/browser/ui/cocoa/atom_menu_controller.mm | 4 ++-- atom/browser/ui/tray_icon_cocoa.h | 2 +- atom/browser/ui/tray_icon_cocoa.mm | 2 +- vendor/brightray | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/atom/browser/ui/atom_menu_model.cc b/atom/browser/ui/atom_menu_model.cc index 3f0d1bbfa8a2..b6a9ba6a7265 100644 --- a/atom/browser/ui/atom_menu_model.cc +++ b/atom/browser/ui/atom_menu_model.cc @@ -40,9 +40,9 @@ bool AtomMenuModel::GetAcceleratorAtWithParams( return false; } -void AtomMenuModel::MenuClosed() { - ui::SimpleMenuModel::MenuClosed(); - FOR_EACH_OBSERVER(Observer, observers_, MenuClosed()); +void AtomMenuModel::MenuWillClose() { + ui::SimpleMenuModel::MenuWillClose(); + FOR_EACH_OBSERVER(Observer, observers_, MenuWillClose()); } AtomMenuModel* AtomMenuModel::GetSubmenuModelAt(int index) { diff --git a/atom/browser/ui/atom_menu_model.h b/atom/browser/ui/atom_menu_model.h index e7d6fc92c00e..7bf734b74c3d 100644 --- a/atom/browser/ui/atom_menu_model.h +++ b/atom/browser/ui/atom_menu_model.h @@ -37,7 +37,7 @@ class AtomMenuModel : public ui::SimpleMenuModel { virtual ~Observer() {} // Notifies the menu has been closed. - virtual void MenuClosed() {} + virtual void MenuWillClose() {} }; explicit AtomMenuModel(Delegate* delegate); @@ -53,7 +53,7 @@ class AtomMenuModel : public ui::SimpleMenuModel { ui::Accelerator* accelerator) const; // ui::SimpleMenuModel: - void MenuClosed() override; + void MenuWillClose() override; using SimpleMenuModel::GetSubmenuModelAt; AtomMenuModel* GetSubmenuModelAt(int index); diff --git a/atom/browser/ui/cocoa/atom_menu_controller.mm b/atom/browser/ui/cocoa/atom_menu_controller.mm index 365317f653c3..6bdaa4c7805e 100644 --- a/atom/browser/ui/cocoa/atom_menu_controller.mm +++ b/atom/browser/ui/cocoa/atom_menu_controller.mm @@ -90,7 +90,7 @@ Role kRolesMap[] = { - (void)cancel { if (isMenuOpen_) { [menu_ cancelTracking]; - model_->MenuClosed(); + model_->MenuWillClose(); isMenuOpen_ = NO; } } @@ -265,7 +265,7 @@ Role kRolesMap[] = { - (void)menuDidClose:(NSMenu*)menu { if (isMenuOpen_) { - model_->MenuClosed(); + model_->MenuWillClose(); isMenuOpen_ = NO; } } diff --git a/atom/browser/ui/tray_icon_cocoa.h b/atom/browser/ui/tray_icon_cocoa.h index fb66a6b3f147..7680b6f30f83 100644 --- a/atom/browser/ui/tray_icon_cocoa.h +++ b/atom/browser/ui/tray_icon_cocoa.h @@ -35,7 +35,7 @@ class TrayIconCocoa : public TrayIcon, protected: // AtomMenuModel::Observer: - void MenuClosed() override; + void MenuWillClose() override; private: // Atom custom view for NSStatusItem. diff --git a/atom/browser/ui/tray_icon_cocoa.mm b/atom/browser/ui/tray_icon_cocoa.mm index b3f5e647d3bf..1ecd51fe566a 100644 --- a/atom/browser/ui/tray_icon_cocoa.mm +++ b/atom/browser/ui/tray_icon_cocoa.mm @@ -405,7 +405,7 @@ gfx::Rect TrayIconCocoa::GetBounds() { return bounds; } -void TrayIconCocoa::MenuClosed() { +void TrayIconCocoa::MenuWillClose() { [status_item_view_ setNeedsDisplay:YES]; } diff --git a/vendor/brightray b/vendor/brightray index 5f4cf42a6d8f..d24b1b907ad3 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 5f4cf42a6d8f611c859efdde20c085dcc4871919 +Subproject commit d24b1b907ad366dc01d4d3d5da981b6164868230 From d4e3dade394f24b2b452931ef5abe23b11b7b47c Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 23 Jan 2017 18:47:30 +0900 Subject: [PATCH 09/63] WindowCapturer and ScreenCapturer are merged to DesktopCapturer --- atom/browser/api/atom_api_desktop_capturer.cc | 13 ++++--- .../media/native_desktop_media_list.cc | 38 +++++++++---------- .../browser/media/native_desktop_media_list.h | 11 +++--- 3 files changed, 30 insertions(+), 32 deletions(-) diff --git a/atom/browser/api/atom_api_desktop_capturer.cc b/atom/browser/api/atom_api_desktop_capturer.cc index 1ff5aadc0fac..118b3e3bdc66 100644 --- a/atom/browser/api/atom_api_desktop_capturer.cc +++ b/atom/browser/api/atom_api_desktop_capturer.cc @@ -10,8 +10,7 @@ #include "chrome/browser/media/desktop_media_list.h" #include "native_mate/dictionary.h" #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" -#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" -#include "third_party/webrtc/modules/desktop_capture/window_capturer.h" +#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" #include "atom/common/node_includes.h" @@ -61,10 +60,12 @@ void DesktopCapturer::StartHandling(bool capture_window, options.set_disable_effects(false); #endif - std::unique_ptr screen_capturer( - capture_screen ? webrtc::ScreenCapturer::Create(options) : nullptr); - std::unique_ptr window_capturer( - capture_window ? webrtc::WindowCapturer::Create(options) : nullptr); + std::unique_ptr screen_capturer( + capture_screen ? webrtc::DesktopCapturer::CreateScreenCapturer(options) + : nullptr); + std::unique_ptr window_capturer( + capture_window ? webrtc::DesktopCapturer::CreateWindowCapturer(options) + : nullptr); media_list_.reset(new NativeDesktopMediaList( std::move(screen_capturer), std::move(window_capturer))); diff --git a/chromium_src/chrome/browser/media/native_desktop_media_list.cc b/chromium_src/chrome/browser/media/native_desktop_media_list.cc index 2652c27f01b1..391bdd50a313 100644 --- a/chromium_src/chrome/browser/media/native_desktop_media_list.cc +++ b/chromium_src/chrome/browser/media/native_desktop_media_list.cc @@ -19,8 +19,7 @@ #include "third_party/libyuv/include/libyuv/scale_argb.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" -#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" -#include "third_party/webrtc/modules/desktop_capture/window_capturer.h" +#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/skia_util.h" @@ -86,8 +85,8 @@ class NativeDesktopMediaList::Worker : public webrtc::DesktopCapturer::Callback { public: Worker(base::WeakPtr media_list, - std::unique_ptr screen_capturer, - std::unique_ptr window_capturer); + std::unique_ptr screen_capturer, + std::unique_ptr window_capturer); ~Worker() override; void Refresh(const gfx::Size& thumbnail_size, @@ -102,8 +101,8 @@ class NativeDesktopMediaList::Worker base::WeakPtr media_list_; - std::unique_ptr screen_capturer_; - std::unique_ptr window_capturer_; + std::unique_ptr screen_capturer_; + std::unique_ptr window_capturer_; std::unique_ptr current_frame_; @@ -114,8 +113,8 @@ class NativeDesktopMediaList::Worker NativeDesktopMediaList::Worker::Worker( base::WeakPtr media_list, - std::unique_ptr screen_capturer, - std::unique_ptr window_capturer) + std::unique_ptr screen_capturer, + std::unique_ptr window_capturer) : media_list_(media_list), screen_capturer_(std::move(screen_capturer)), window_capturer_(std::move(window_capturer)) { @@ -133,8 +132,8 @@ void NativeDesktopMediaList::Worker::Refresh( std::vector sources; if (screen_capturer_) { - webrtc::ScreenCapturer::ScreenList screens; - if (screen_capturer_->GetScreenList(&screens)) { + webrtc::DesktopCapturer::SourceList screens; + if (screen_capturer_->GetSourceList(&screens)) { bool mutiple_screens = screens.size() > 1; base::string16 title; for (size_t i = 0; i < screens.size(); ++i) { @@ -150,10 +149,9 @@ void NativeDesktopMediaList::Worker::Refresh( } if (window_capturer_) { - webrtc::WindowCapturer::WindowList windows; - if (window_capturer_->GetWindowList(&windows)) { - for (webrtc::WindowCapturer::WindowList::iterator it = windows.begin(); - it != windows.end(); ++it) { + webrtc::DesktopCapturer::SourceList windows; + if (window_capturer_->GetSourceList(&windows)) { + for (auto it = windows.begin(); it != windows.end(); ++it) { // Skip the picker dialog window. if (it->id != view_dialog_id) { sources.push_back(SourceDescription( @@ -176,15 +174,15 @@ void NativeDesktopMediaList::Worker::Refresh( SourceDescription& source = sources[i]; switch (source.id.type) { case DesktopMediaID::TYPE_SCREEN: - if (!screen_capturer_->SelectScreen(source.id.id)) + if (!screen_capturer_->SelectSource(source.id.id)) continue; - screen_capturer_->Capture(webrtc::DesktopRegion()); + screen_capturer_->CaptureFrame(); break; case DesktopMediaID::TYPE_WINDOW: - if (!window_capturer_->SelectWindow(source.id.id)) + if (!window_capturer_->SelectSource(source.id.id)) continue; - window_capturer_->Capture(webrtc::DesktopRegion()); + window_capturer_->CaptureFrame(); break; default: @@ -225,8 +223,8 @@ void NativeDesktopMediaList::Worker::OnCaptureResult( } NativeDesktopMediaList::NativeDesktopMediaList( - std::unique_ptr screen_capturer, - std::unique_ptr window_capturer) + std::unique_ptr screen_capturer, + std::unique_ptr window_capturer) : screen_capturer_(std::move(screen_capturer)), window_capturer_(std::move(window_capturer)), update_period_(base::TimeDelta::FromMilliseconds(kDefaultUpdatePeriod)), diff --git a/chromium_src/chrome/browser/media/native_desktop_media_list.h b/chromium_src/chrome/browser/media/native_desktop_media_list.h index 9814849a290b..270377520bd9 100644 --- a/chromium_src/chrome/browser/media/native_desktop_media_list.h +++ b/chromium_src/chrome/browser/media/native_desktop_media_list.h @@ -12,8 +12,7 @@ #include "ui/gfx/image/image_skia.h" namespace webrtc { -class ScreenCapturer; -class WindowCapturer; +class DesktopCapturer; } // Implementation of DesktopMediaList that shows native screens and @@ -24,8 +23,8 @@ class NativeDesktopMediaList : public DesktopMediaList { // types of sources the model should be populated with (e.g. it will only // contain windows, if |screen_capturer| is NULL). NativeDesktopMediaList( - std::unique_ptr screen_capturer, - std::unique_ptr window_capturer); + std::unique_ptr screen_capturer, + std::unique_ptr window_capturer); ~NativeDesktopMediaList() override; // DesktopMediaList interface. @@ -65,8 +64,8 @@ class NativeDesktopMediaList : public DesktopMediaList { void OnRefreshFinished(); // Capturers specified in SetCapturers() and passed to the |worker_| later. - std::unique_ptr screen_capturer_; - std::unique_ptr window_capturer_; + std::unique_ptr screen_capturer_; + std::unique_ptr window_capturer_; // Time interval between mode updates. base::TimeDelta update_period_; From 231173aa90ed5da6cc61a6c90234bba60c837ec6 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 23 Jan 2017 18:53:05 +0900 Subject: [PATCH 10/63] Namespace of ChangeCause has changed --- atom/browser/api/atom_api_cookies.cc | 16 ++++++++-------- atom/browser/api/atom_api_cookies.h | 2 +- atom/browser/net/atom_cookie_delegate.cc | 8 ++++++-- atom/browser/net/atom_cookie_delegate.h | 6 +++--- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/atom/browser/api/atom_api_cookies.cc b/atom/browser/api/atom_api_cookies.cc index 763052e1b128..117f8c88239a 100644 --- a/atom/browser/api/atom_api_cookies.cc +++ b/atom/browser/api/atom_api_cookies.cc @@ -56,19 +56,19 @@ struct Converter { }; template<> -struct Converter { +struct Converter { static v8::Local ToV8(v8::Isolate* isolate, - const AtomCookieDelegate::ChangeCause& val) { + const net::CookieStore::ChangeCause& val) { switch (val) { - case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_EXPLICIT: + case net::CookieStore::ChangeCause::EXPLICIT: return mate::StringToV8(isolate, "explicit"); - case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_OVERWRITE: + case net::CookieStore::ChangeCause::OVERWRITE: return mate::StringToV8(isolate, "overwrite"); - case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_EXPIRED: + case net::CookieStore::ChangeCause::EXPIRED: return mate::StringToV8(isolate, "expired"); - case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_EVICTED: + case net::CookieStore::ChangeCause::EVICTED: return mate::StringToV8(isolate, "evicted"); - case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_EXPIRED_OVERWRITE: + case net::CookieStore::ChangeCause::EXPIRED_OVERWRITE: return mate::StringToV8(isolate, "expired-overwrite"); default: return mate::StringToV8(isolate, "unknown"); @@ -266,7 +266,7 @@ void Cookies::Set(const base::DictionaryValue& details, void Cookies::OnCookieChanged(const net::CanonicalCookie& cookie, bool removed, - AtomCookieDelegate::ChangeCause cause) { + net::CookieStore::ChangeCause cause) { Emit("changed", cookie, cause, removed); } diff --git a/atom/browser/api/atom_api_cookies.h b/atom/browser/api/atom_api_cookies.h index a27a7780e5af..3a7a98fbafd9 100644 --- a/atom/browser/api/atom_api_cookies.h +++ b/atom/browser/api/atom_api_cookies.h @@ -57,7 +57,7 @@ class Cookies : public mate::TrackableObject, // AtomCookieDelegate::Observer: void OnCookieChanged(const net::CanonicalCookie& cookie, bool removed, - AtomCookieDelegate::ChangeCause cause) override; + net::CookieStore::ChangeCause cause) override; private: net::URLRequestContextGetter* request_context_getter_; diff --git a/atom/browser/net/atom_cookie_delegate.cc b/atom/browser/net/atom_cookie_delegate.cc index 5024a34ada3e..a03588913bb1 100644 --- a/atom/browser/net/atom_cookie_delegate.cc +++ b/atom/browser/net/atom_cookie_delegate.cc @@ -23,14 +23,18 @@ void AtomCookieDelegate::RemoveObserver(Observer* observer) { } void AtomCookieDelegate::NotifyObservers( - const net::CanonicalCookie& cookie, bool removed, ChangeCause cause) { + const net::CanonicalCookie& cookie, + bool removed, + net::CookieStore::ChangeCause cause) { FOR_EACH_OBSERVER(Observer, observers_, OnCookieChanged(cookie, removed, cause)); } void AtomCookieDelegate::OnCookieChanged( - const net::CanonicalCookie& cookie, bool removed, ChangeCause cause) { + const net::CanonicalCookie& cookie, + bool removed, + net::CookieStore::ChangeCause cause) { content::BrowserThread::PostTask( content::BrowserThread::UI, FROM_HERE, diff --git a/atom/browser/net/atom_cookie_delegate.h b/atom/browser/net/atom_cookie_delegate.h index 20acbd3b7ca9..8c58aa6ada04 100644 --- a/atom/browser/net/atom_cookie_delegate.h +++ b/atom/browser/net/atom_cookie_delegate.h @@ -19,7 +19,7 @@ class AtomCookieDelegate : public net::CookieMonsterDelegate { public: virtual void OnCookieChanged(const net::CanonicalCookie& cookie, bool removed, - ChangeCause cause) {} + net::CookieStore::ChangeCause cause) {} protected: virtual ~Observer() {} }; @@ -30,7 +30,7 @@ class AtomCookieDelegate : public net::CookieMonsterDelegate { // net::CookieMonsterDelegate: void OnCookieChanged(const net::CanonicalCookie& cookie, bool removed, - ChangeCause cause) override; + net::CookieStore::ChangeCause cause) override; private: @@ -38,7 +38,7 @@ class AtomCookieDelegate : public net::CookieMonsterDelegate { void NotifyObservers(const net::CanonicalCookie& cookie, bool removed, - ChangeCause cause); + net::CookieStore::ChangeCause cause); DISALLOW_COPY_AND_ASSIGN(AtomCookieDelegate); }; From 1d29b236627bca84178e0c4d4261b7ffdf77cf60 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 23 Jan 2017 18:59:40 +0900 Subject: [PATCH 11/63] Update api::WebContents --- atom/browser/api/atom_api_web_contents.cc | 22 ++++++++------ atom/browser/api/atom_api_web_contents.h | 22 ++++++++------ atom/browser/common_web_contents_delegate.cc | 32 +++++++++++--------- atom/browser/common_web_contents_delegate.h | 2 +- 4 files changed, 44 insertions(+), 34 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 6b448b533502..083a39ad7b0a 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -375,11 +375,11 @@ WebContents::~WebContents() { } } -bool WebContents::AddMessageToConsole(content::WebContents* source, - int32_t level, - const base::string16& message, - int32_t line_no, - const base::string16& source_id) { +bool WebContents::DidAddMessageToConsole(content::WebContents* source, + int32_t level, + const base::string16& message, + int32_t line_no, + const base::string16& source_id) { if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) { return false; } else { @@ -401,6 +401,7 @@ void WebContents::OnCreateWindow( } void WebContents::WebContentsCreated(content::WebContents* source_contents, + int opener_render_process_id, int opener_render_frame_id, const std::string& frame_name, const GURL& target_url, @@ -530,7 +531,9 @@ void WebContents::ExitFullscreenModeForTab(content::WebContents* source) { Emit("leave-html-full-screen"); } -void WebContents::RendererUnresponsive(content::WebContents* source) { +void WebContents::RendererUnresponsive( + content::WebContents* source, + const content::WebContentsUnresponsiveState& unresponsive_state) { Emit("unresponsive"); if ((type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) && owner_window()) owner_window()->RendererUnresponsive(source); @@ -640,11 +643,13 @@ void WebContents::PluginCrashed(const base::FilePath& plugin_path, Emit("plugin-crashed", info.name, info.version); } -void WebContents::MediaStartedPlaying(const MediaPlayerId& id) { +void WebContents::MediaStartedPlaying(const MediaPlayerInfo& video_type, + const MediaPlayerId& id) { Emit("media-started-playing"); } -void WebContents::MediaStoppedPlaying(const MediaPlayerId& id) { +void WebContents::MediaStoppedPlaying(const MediaPlayerInfo& video_type, + const MediaPlayerId& id) { Emit("media-paused"); } @@ -698,7 +703,6 @@ void WebContents::DidGetResourceResponseStart( } void WebContents::DidGetRedirectForResourceRequest( - content::RenderFrameHost* render_frame_host, const content::ResourceRedirectDetails& details) { Emit("did-get-redirect-request", details.url, diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 385aa63f49a0..81472ccd97cf 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -213,12 +213,13 @@ class WebContents : public mate::TrackableObject, const mate::Dictionary& options); // content::WebContentsDelegate: - bool AddMessageToConsole(content::WebContents* source, - int32_t level, - const base::string16& message, - int32_t line_no, - const base::string16& source_id) override; + bool DidAddMessageToConsole(content::WebContents* source, + int32_t level, + const base::string16& message, + int32_t line_no, + const base::string16& source_id) override; void WebContentsCreated(content::WebContents* source_contents, + int opener_render_process_id, int opener_render_frame_id, const std::string& frame_name, const GURL& target_url, @@ -250,7 +251,9 @@ class WebContents : public mate::TrackableObject, void EnterFullscreenModeForTab(content::WebContents* source, const GURL& origin) override; void ExitFullscreenModeForTab(content::WebContents* source) override; - void RendererUnresponsive(content::WebContents* source) override; + void RendererUnresponsive( + content::WebContents* source, + const content::WebContentsUnresponsiveState& unresponsive_state) override; void RendererResponsive(content::WebContents* source) override; bool HandleContextMenu(const content::ContextMenuParams& params) override; bool OnGoToEntryOffset(int offset) override; @@ -295,7 +298,6 @@ class WebContents : public mate::TrackableObject, void DidGetResourceResponseStart( const content::ResourceRequestDetails& details) override; void DidGetRedirectForResourceRequest( - content::RenderFrameHost* render_frame_host, const content::ResourceRedirectDetails& details) override; void DidFinishNavigation( content::NavigationHandle* navigation_handle) override; @@ -308,8 +310,10 @@ class WebContents : public mate::TrackableObject, const std::vector& urls) override; void PluginCrashed(const base::FilePath& plugin_path, base::ProcessId plugin_pid) override; - void MediaStartedPlaying(const MediaPlayerId& id) override; - void MediaStoppedPlaying(const MediaPlayerId& id) override; + void MediaStartedPlaying(const MediaPlayerInfo& video_type, + const MediaPlayerId& id) override; + void MediaStoppedPlaying(const MediaPlayerInfo& video_type, + const MediaPlayerId& id) override; void DidChangeThemeColor(SkColor theme_color) override; // brightray::InspectableWebContentsDelegate: diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index bc01bda1efec..8c0b4a3f0e31 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -144,22 +144,24 @@ bool IsDevToolsFileSystemAdded( return file_system_paths.find(file_system_path) != file_system_paths.end(); } -content::SecurityStyle SecurityLevelToSecurityStyle( - SecurityStateModel::SecurityLevel security_level) { +blink::WebSecurityStyle SecurityLevelToSecurityStyle( + security_state::SecurityLevel security_level) { switch (security_level) { - case SecurityStateModel::NONE: - return content::SECURITY_STYLE_UNAUTHENTICATED; - case SecurityStateModel::SECURITY_WARNING: - case SecurityStateModel::SECURITY_POLICY_WARNING: - return content::SECURITY_STYLE_WARNING; - case SecurityStateModel::EV_SECURE: - case SecurityStateModel::SECURE: - return content::SECURITY_STYLE_AUTHENTICATED; - case SecurityStateModel::SECURITY_ERROR: - return content::SECURITY_STYLE_AUTHENTICATION_BROKEN; + case security_state::NONE: + case security_state::HTTP_SHOW_WARNING: + return blink::WebSecurityStyleUnauthenticated; + case security_state::SECURITY_WARNING: + case security_state::SECURE_WITH_POLICY_INSTALLED_CERT: + return blink::WebSecurityStyleWarning; + case security_state::EV_SECURE: + case security_state::SECURE: + return blink::WebSecurityStyleAuthenticated; + case security_state::DANGEROUS: + return blink::WebSecurityStyleAuthenticationBroken; } - return content::SECURITY_STYLE_UNKNOWN; + NOTREACHED(); + return blink::WebSecurityStyleUnknown; } } // namespace @@ -290,7 +292,7 @@ bool CommonWebContentsDelegate::IsFullscreenForTabOrPending( return html_fullscreen_; } -content::SecurityStyle CommonWebContentsDelegate::GetSecurityStyle( +blink::WebSecurityStyle CommonWebContentsDelegate::GetSecurityStyle( content::WebContents* web_contents, content::SecurityStyleExplanations* explanations) { auto model_client = @@ -299,7 +301,7 @@ content::SecurityStyle CommonWebContentsDelegate::GetSecurityStyle( const SecurityStateModel::SecurityInfo& security_info = model_client->GetSecurityInfo(); - const content::SecurityStyle security_style = + const blink::WebSecurityStyle security_style = SecurityLevelToSecurityStyle(security_info.security_level); explanations->ran_insecure_content_style = diff --git a/atom/browser/common_web_contents_delegate.h b/atom/browser/common_web_contents_delegate.h index 67d4d6f0376f..c08f8d246cee 100644 --- a/atom/browser/common_web_contents_delegate.h +++ b/atom/browser/common_web_contents_delegate.h @@ -81,7 +81,7 @@ class CommonWebContentsDelegate void ExitFullscreenModeForTab(content::WebContents* source) override; bool IsFullscreenForTabOrPending( const content::WebContents* source) const override; - content::SecurityStyle GetSecurityStyle( + blink::WebSecurityStyle GetSecurityStyle( content::WebContents* web_contents, content::SecurityStyleExplanations* explanations) override; void HandleKeyboardEvent( From 3224c3937196dae05ea5c643ea01fc48320c5020 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 23 Jan 2017 19:05:49 +0900 Subject: [PATCH 12/63] Mac's version checking function has changed --- atom/browser/native_window_mac.mm | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 430fe48ee96f..e3cf300bbaa5 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -228,7 +228,7 @@ bool ScopedDisableResize::disable_resize_ = false; - (void)windowWillEnterFullScreen:(NSNotification*)notification { // Hide the native toolbar before entering fullscreen, so there is no visual // artifacts. - if (base::mac::IsOSYosemiteOrLater() && + if (base::mac::IsOS10_10() && shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) { NSWindow* window = shell_->GetNativeWindow(); [window setToolbar:nil]; @@ -243,7 +243,7 @@ bool ScopedDisableResize::disable_resize_ = false; // have to set one, because title bar is visible here. NSWindow* window = shell_->GetNativeWindow(); if ((shell_->transparent() || !shell_->has_frame()) && - base::mac::IsOSYosemiteOrLater() && + base::mac::IsOS10_10() && // FIXME(zcbenz): Showing titlebar for hiddenInset window is weird under // fullscreen mode. shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET) { @@ -252,7 +252,7 @@ bool ScopedDisableResize::disable_resize_ = false; // Restore the native toolbar immediately after entering fullscreen, if we do // this before leaving fullscreen, traffic light buttons will be jumping. - if (base::mac::IsOSYosemiteOrLater() && + if (base::mac::IsOS10_10() && shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) { base::scoped_nsobject toolbar( [[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]); @@ -269,13 +269,13 @@ bool ScopedDisableResize::disable_resize_ = false; // Restore the titlebar visibility. NSWindow* window = shell_->GetNativeWindow(); if ((shell_->transparent() || !shell_->has_frame()) && - base::mac::IsOSYosemiteOrLater() && + base::mac::IsOS10_10() && shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET) { [window setTitleVisibility:NSWindowTitleHidden]; } // Turn off the style for toolbar. - if (base::mac::IsOSYosemiteOrLater() && + if (base::mac::IsOS10_10() && shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) { shell_->SetStyleMask(false, NSFullSizeContentViewWindowMask); } @@ -712,7 +712,7 @@ NativeWindowMac::NativeWindowMac( [window_ setDisableKeyOrMainWindow:YES]; if (transparent() || !has_frame()) { - if (base::mac::IsOSYosemiteOrLater()) { + if (base::mac::IsOS10_10()) { // Don't show title bar. [window_ setTitleVisibility:NSWindowTitleHidden]; } @@ -725,7 +725,7 @@ NativeWindowMac::NativeWindowMac( // Hide the title bar. if (title_bar_style_ == HIDDEN_INSET) { - if (base::mac::IsOSYosemiteOrLater()) { + if (base::mac::IsOS10_10()) { [window_ setTitlebarAppearsTransparent:YES]; base::scoped_nsobject toolbar( [[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]); @@ -1104,7 +1104,7 @@ void NativeWindowMac::Center() { void NativeWindowMac::SetTitle(const std::string& title) { // For macOS <= 10.9, the setTitleVisibility API is not available, we have // to avoid calling setTitle for frameless window. - if (!base::mac::IsOSYosemiteOrLater() && (transparent() || !has_frame())) + if (!base::mac::IsOS10_10() && (transparent() || !has_frame())) return; [window_ setTitle:base::SysUTF8ToNSString(title)]; @@ -1275,7 +1275,7 @@ void NativeWindowMac::SetAutoHideCursor(bool auto_hide) { } void NativeWindowMac::SetVibrancy(const std::string& type) { - if (!base::mac::IsOSYosemiteOrLater()) return; + if (!base::mac::IsOS10_10()) return; NSView* vibrant_view = [window_ vibrantView]; @@ -1314,7 +1314,7 @@ void NativeWindowMac::SetVibrancy(const std::string& type) { vibrancyType = NSVisualEffectMaterialTitlebar; } - if (base::mac::IsOSElCapitanOrLater()) { + if (base::mac::IsOS10_11()) { // TODO(kevinsawicki): Use NSVisualEffectMaterial* constants directly once // they are available in the minimum SDK version if (type == "selection") { @@ -1419,7 +1419,7 @@ void NativeWindowMac::InstallView() { // Make sure the bottom corner is rounded for non-modal windows: http://crbug.com/396264. // But do not enable it on OS X 10.9 for transparent window, otherwise a // semi-transparent frame would show. - if (!(transparent() && base::mac::IsOSMavericks()) && !is_modal()) + if (!(transparent() && base::mac::IsOS10_9()) && !is_modal()) [[window_ contentView] setWantsLayer:YES]; NSView* view = inspectable_web_contents()->GetView()->GetNativeView(); @@ -1444,7 +1444,7 @@ void NativeWindowMac::InstallView() { [[window_ standardWindowButton:NSWindowFullScreenButton] setHidden:YES]; if (title_bar_style_ != NORMAL) { - if (base::mac::IsOSMavericks()) { + if (base::mac::IsOS10_9()) { ShowWindowButton(NSWindowZoomButton); ShowWindowButton(NSWindowMiniaturizeButton); ShowWindowButton(NSWindowCloseButton); From 13a1d79ca6474b42ee831bfde2d7fce4b7e388c0 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 10:51:11 +0900 Subject: [PATCH 13/63] Deperecate AtomSecurityStateModelClient with SecurityStateTabHelper --- atom/browser/api/atom_api_web_contents.cc | 4 +- .../atom_security_state_model_client.cc | 106 --------- .../atom_security_state_model_client.h | 42 ---- atom/browser/common_web_contents_delegate.cc | 106 +-------- .../browser/ssl/security_state_tab_helper.cc | 213 ++++++++++++++++++ .../browser/ssl/security_state_tab_helper.h | 70 ++++++ filenames.gypi | 4 +- 7 files changed, 298 insertions(+), 247 deletions(-) delete mode 100644 atom/browser/atom_security_state_model_client.cc delete mode 100644 atom/browser/atom_security_state_model_client.h create mode 100644 chromium_src/chrome/browser/ssl/security_state_tab_helper.cc create mode 100644 chromium_src/chrome/browser/ssl/security_state_tab_helper.h diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 083a39ad7b0a..f3a00f9a6c12 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -13,7 +13,6 @@ #include "atom/browser/atom_browser_client.h" #include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_browser_main_parts.h" -#include "atom/browser/atom_security_state_model_client.h" #include "atom/browser/lib/bluetooth_chooser.h" #include "atom/browser/native_window.h" #include "atom/browser/net/atom_network_delegate.h" @@ -45,6 +44,7 @@ #include "brightray/browser/inspectable_web_contents_view.h" #include "chrome/browser/printing/print_preview_message_handler.h" #include "chrome/browser/printing/print_view_manager_basic.h" +#include "chrome/browser/ssl/security_state_tab_helper.h" #include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/common/view_messages.h" @@ -336,7 +336,7 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate, // Intialize permission helper. WebContentsPermissionHelper::CreateForWebContents(web_contents); // Intialize security state client. - AtomSecurityStateModelClient::CreateForWebContents(web_contents); + SecurityStateTabHelper::CreateForWebContents(web_contents); web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent()); diff --git a/atom/browser/atom_security_state_model_client.cc b/atom/browser/atom_security_state_model_client.cc deleted file mode 100644 index e69db91eab72..000000000000 --- a/atom/browser/atom_security_state_model_client.cc +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (c) 2016 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "atom/browser/atom_security_state_model_client.h" - -#include "content/public/browser/cert_store.h" -#include "content/public/browser/navigation_entry.h" -#include "content/public/browser/web_contents.h" -#include "content/public/common/origin_util.h" -#include "content/public/common/ssl_status.h" -#include "net/cert/x509_certificate.h" - -DEFINE_WEB_CONTENTS_USER_DATA_KEY(atom::AtomSecurityStateModelClient); - -using security_state::SecurityStateModel; - -namespace atom { - -namespace { - -SecurityStateModel::SecurityLevel GetSecurityLevelForSecurityStyle( - content::SecurityStyle style) { - switch (style) { - case content::SECURITY_STYLE_UNKNOWN: - return SecurityStateModel::NONE; - case content::SECURITY_STYLE_UNAUTHENTICATED: - return SecurityStateModel::NONE; - case content::SECURITY_STYLE_AUTHENTICATION_BROKEN: - return SecurityStateModel::SECURITY_ERROR; - case content::SECURITY_STYLE_WARNING: - return SecurityStateModel::SECURITY_WARNING; - case content::SECURITY_STYLE_AUTHENTICATED: - return SecurityStateModel::SECURE; - } - return SecurityStateModel::NONE; -} - -} // namespace - -AtomSecurityStateModelClient::AtomSecurityStateModelClient( - content::WebContents* web_contents) - : web_contents_(web_contents), - security_state_model_(new SecurityStateModel()) { - security_state_model_->SetClient(this); -} - -AtomSecurityStateModelClient::~AtomSecurityStateModelClient() { -} - -const SecurityStateModel::SecurityInfo& -AtomSecurityStateModelClient::GetSecurityInfo() const { - return security_state_model_->GetSecurityInfo(); -} - -bool AtomSecurityStateModelClient::RetrieveCert( - scoped_refptr* cert) { - content::NavigationEntry* entry = - web_contents_->GetController().GetVisibleEntry(); - if (!entry) - return false; - return content::CertStore::GetInstance()->RetrieveCert( - entry->GetSSL().cert_id, cert); -} - -bool AtomSecurityStateModelClient::UsedPolicyInstalledCertificate() { - return false; -} - -bool AtomSecurityStateModelClient::IsOriginSecure(const GURL& url) { - return content::IsOriginSecure(url); -} - -void AtomSecurityStateModelClient::GetVisibleSecurityState( - SecurityStateModel::VisibleSecurityState* state) { - content::NavigationEntry* entry = - web_contents_->GetController().GetVisibleEntry(); - if (!entry || - entry->GetSSL().security_style == content::SECURITY_STYLE_UNKNOWN) { - *state = SecurityStateModel::VisibleSecurityState(); - return; - } - - state->connection_info_initialized = true; - state->url = entry->GetURL(); - const content::SSLStatus& ssl = entry->GetSSL(); - state->initial_security_level = - GetSecurityLevelForSecurityStyle(ssl.security_style); - state->cert_id = ssl.cert_id; - state->cert_status = ssl.cert_status; - state->connection_status = ssl.connection_status; - state->security_bits = ssl.security_bits; - state->sct_verify_statuses.clear(); - state->sct_verify_statuses.insert(state->sct_verify_statuses.begin(), - ssl.sct_statuses.begin(), - ssl.sct_statuses.end()); - state->displayed_mixed_content = - (ssl.content_status & content::SSLStatus::DISPLAYED_INSECURE_CONTENT) - ? true - : false; - state->ran_mixed_content = - (ssl.content_status & content::SSLStatus::RAN_INSECURE_CONTENT) ? true - : false; -} - -} // namespace atom diff --git a/atom/browser/atom_security_state_model_client.h b/atom/browser/atom_security_state_model_client.h deleted file mode 100644 index 0dd3aa66c125..000000000000 --- a/atom/browser/atom_security_state_model_client.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2016 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#ifndef ATOM_BROWSER_ATOM_SECURITY_STATE_MODEL_CLIENT_H_ -#define ATOM_BROWSER_ATOM_SECURITY_STATE_MODEL_CLIENT_H_ - -#include "components/security_state/security_state_model.h" -#include "components/security_state/security_state_model_client.h" -#include "content/public/browser/web_contents_user_data.h" - -namespace atom { - -class AtomSecurityStateModelClient - : public security_state::SecurityStateModelClient, - public content::WebContentsUserData { - public: - ~AtomSecurityStateModelClient() override; - - const security_state::SecurityStateModel::SecurityInfo& - GetSecurityInfo() const; - - // security_state::SecurityStateModelClient: - void GetVisibleSecurityState( - security_state::SecurityStateModel::VisibleSecurityState* state) override; - bool RetrieveCert(scoped_refptr* cert) override; - bool UsedPolicyInstalledCertificate() override; - bool IsOriginSecure(const GURL& url) override; - - private: - explicit AtomSecurityStateModelClient(content::WebContents* web_contents); - friend class content::WebContentsUserData; - - content::WebContents* web_contents_; - std::unique_ptr security_state_model_; - - DISALLOW_COPY_AND_ASSIGN(AtomSecurityStateModelClient); -}; - -} // namespace atom - -#endif // ATOM_BROWSER_ATOM_SECURITY_STATE_MODEL_CLIENT_H_ diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index 8c0b4a3f0e31..ac1f9d4c494d 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -10,7 +10,6 @@ #include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_javascript_dialog_manager.h" -#include "atom/browser/atom_security_state_model_client.h" #include "atom/browser/native_window.h" #include "atom/browser/ui/file_dialog.h" #include "atom/browser/web_dialog_helper.h" @@ -18,10 +17,13 @@ #include "base/files/file_util.h" #include "chrome/browser/printing/print_preview_message_handler.h" #include "chrome/browser/printing/print_view_manager_basic.h" +#include "chrome/browser/ssl/security_state_tab_helper.h" #include "chrome/browser/ui/browser_dialogs.h" #include "chrome/common/pref_names.h" #include "components/prefs/pref_service.h" #include "components/prefs/scoped_user_pref_update.h" +#include "components/security_state/content/content_utils.h" +#include "components/security_state/core/security_state.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/render_process_host.h" @@ -32,7 +34,6 @@ #include "storage/browser/fileapi/isolated_context.h" using content::BrowserThread; -using security_state::SecurityStateModel; namespace atom { @@ -144,26 +145,6 @@ bool IsDevToolsFileSystemAdded( return file_system_paths.find(file_system_path) != file_system_paths.end(); } -blink::WebSecurityStyle SecurityLevelToSecurityStyle( - security_state::SecurityLevel security_level) { - switch (security_level) { - case security_state::NONE: - case security_state::HTTP_SHOW_WARNING: - return blink::WebSecurityStyleUnauthenticated; - case security_state::SECURITY_WARNING: - case security_state::SECURE_WITH_POLICY_INSTALLED_CERT: - return blink::WebSecurityStyleWarning; - case security_state::EV_SECURE: - case security_state::SECURE: - return blink::WebSecurityStyleAuthenticated; - case security_state::DANGEROUS: - return blink::WebSecurityStyleAuthenticationBroken; - } - - NOTREACHED(); - return blink::WebSecurityStyleUnknown; -} - } // namespace CommonWebContentsDelegate::CommonWebContentsDelegate() @@ -294,79 +275,14 @@ bool CommonWebContentsDelegate::IsFullscreenForTabOrPending( blink::WebSecurityStyle CommonWebContentsDelegate::GetSecurityStyle( content::WebContents* web_contents, - content::SecurityStyleExplanations* explanations) { - auto model_client = - AtomSecurityStateModelClient::FromWebContents(web_contents); - - const SecurityStateModel::SecurityInfo& security_info = - model_client->GetSecurityInfo(); - - const blink::WebSecurityStyle security_style = - SecurityLevelToSecurityStyle(security_info.security_level); - - explanations->ran_insecure_content_style = - SecurityLevelToSecurityStyle( - SecurityStateModel::kRanInsecureContentLevel); - explanations->displayed_insecure_content_style = - SecurityLevelToSecurityStyle( - SecurityStateModel::kDisplayedInsecureContentLevel); - - explanations->scheme_is_cryptographic = security_info.scheme_is_cryptographic; - if (!security_info.scheme_is_cryptographic) - return security_style; - - if (security_info.sha1_deprecation_status == - SecurityStateModel::DEPRECATED_SHA1_MAJOR) { - explanations->broken_explanations.push_back( - content::SecurityStyleExplanation( - kSHA1Certificate, - kSHA1MajorDescription, - security_info.cert_id)); - } else if (security_info.sha1_deprecation_status == - SecurityStateModel::DEPRECATED_SHA1_MINOR) { - explanations->unauthenticated_explanations.push_back( - content::SecurityStyleExplanation( - kSHA1Certificate, - kSHA1MinorDescription, - security_info.cert_id)); - } - - explanations->ran_insecure_content = - security_info.mixed_content_status == - security_state::SecurityStateModel::CONTENT_STATUS_RAN || - security_info.mixed_content_status == - security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN; - explanations->displayed_insecure_content = - security_info.mixed_content_status == - security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED || - security_info.mixed_content_status == - security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN; - - if (net::IsCertStatusError(security_info.cert_status)) { - std::string error_string = net::ErrorToString( - net::MapCertStatusToNetError(security_info.cert_status)); - - content::SecurityStyleExplanation explanation( - kCertificateError, - "There are issues with the site's certificate chain " + error_string, - security_info.cert_id); - - if (net::IsCertStatusMinorError(security_info.cert_status)) - explanations->unauthenticated_explanations.push_back(explanation); - else - explanations->broken_explanations.push_back(explanation); - } else { - if (security_info.sha1_deprecation_status == - SecurityStateModel::NO_DEPRECATED_SHA1) { - explanations->secure_explanations.push_back( - content::SecurityStyleExplanation( - kValidCertificate, - kValidCertificateDescription, - security_info.cert_id)); - } - } - - return security_style; + content::SecurityStyleExplanations* security_style_explanations) { + SecurityStateTabHelper* helper = + SecurityStateTabHelper::FromWebContents(web_contents); + DCHECK(helper); + security_state::SecurityInfo security_info; + helper->GetSecurityInfo(&security_info); + return security_state::GetSecurityStyle(security_info, + security_style_explanations); } void CommonWebContentsDelegate::DevToolsSaveToFile( diff --git a/chromium_src/chrome/browser/ssl/security_state_tab_helper.cc b/chromium_src/chrome/browser/ssl/security_state_tab_helper.cc new file mode 100644 index 000000000000..816bd17b8be8 --- /dev/null +++ b/chromium_src/chrome/browser/ssl/security_state_tab_helper.cc @@ -0,0 +1,213 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ssl/security_state_tab_helper.h" + +#include "base/bind.h" +#include "base/metrics/histogram_macros.h" +#include "base/time/time.h" +#include "build/build_config.h" +#if 0 +#include "chrome/browser/browser_process.h" +#include "chrome/browser/chromeos/policy/policy_cert_service.h" +#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/safe_browsing/safe_browsing_service.h" +#include "chrome/browser/safe_browsing/ui_manager.h" +#endif +#include "components/prefs/pref_service.h" +#include "components/security_state/content/content_utils.h" +#include "components/ssl_config/ssl_config_prefs.h" +#include "content/public/browser/navigation_entry.h" +#include "content/public/browser/navigation_handle.h" +#include "content/public/browser/render_frame_host.h" +#include "content/public/browser/web_contents.h" +#include "content/public/common/origin_util.h" +#include "net/base/net_errors.h" +#include "net/cert/x509_certificate.h" +#include "net/ssl/ssl_cipher_suite_names.h" +#include "net/ssl/ssl_connection_status_flags.h" +#include "third_party/boringssl/src/include/openssl/ssl.h" +#include "ui/base/l10n/l10n_util.h" + +DEFINE_WEB_CONTENTS_USER_DATA_KEY(SecurityStateTabHelper); + +#if 0 +using safe_browsing::SafeBrowsingUIManager; +#endif + +SecurityStateTabHelper::SecurityStateTabHelper( + content::WebContents* web_contents) + : content::WebContentsObserver(web_contents), + logged_http_warning_on_current_navigation_(false) {} + +SecurityStateTabHelper::~SecurityStateTabHelper() {} + +void SecurityStateTabHelper::GetSecurityInfo( + security_state::SecurityInfo* result) const { + security_state::GetSecurityInfo(GetVisibleSecurityState(), + UsedPolicyInstalledCertificate(), + base::Bind(&content::IsOriginSecure), result); +} + +void SecurityStateTabHelper::VisibleSecurityStateChanged() { + if (logged_http_warning_on_current_navigation_) + return; + + security_state::SecurityInfo security_info; + GetSecurityInfo(&security_info); + if (!security_info.displayed_password_field_on_http && + !security_info.displayed_credit_card_field_on_http) { + return; + } + + DCHECK(time_of_http_warning_on_current_navigation_.is_null()); + time_of_http_warning_on_current_navigation_ = base::Time::Now(); + + std::string warning; + bool warning_is_user_visible = false; + switch (security_info.security_level) { + case security_state::HTTP_SHOW_WARNING: + warning = + "This page includes a password or credit card input in a non-secure " + "context. A warning has been added to the URL bar. For more " + "information, see https://goo.gl/zmWq3m."; + warning_is_user_visible = true; + break; + case security_state::NONE: + case security_state::DANGEROUS: + warning = + "This page includes a password or credit card input in a non-secure " + "context. A warning will be added to the URL bar in Chrome 56 (Jan " + "2017). For more information, see https://goo.gl/zmWq3m."; + break; + default: + return; + } + + logged_http_warning_on_current_navigation_ = true; + web_contents()->GetMainFrame()->AddMessageToConsole( + content::CONSOLE_MESSAGE_LEVEL_WARNING, warning); + + if (security_info.displayed_credit_card_field_on_http) { + UMA_HISTOGRAM_BOOLEAN( + "Security.HTTPBad.UserWarnedAboutSensitiveInput.CreditCard", + warning_is_user_visible); + } + if (security_info.displayed_password_field_on_http) { + UMA_HISTOGRAM_BOOLEAN( + "Security.HTTPBad.UserWarnedAboutSensitiveInput.Password", + warning_is_user_visible); + } +} + +void SecurityStateTabHelper::DidStartNavigation( + content::NavigationHandle* navigation_handle) { + if (time_of_http_warning_on_current_navigation_.is_null() || + !navigation_handle->IsInMainFrame() || navigation_handle->IsSamePage()) { + return; + } + // Record how quickly a user leaves a site after encountering an + // HTTP-bad warning. A navigation here only counts if it is a + // main-frame, not-same-page navigation, since it aims to measure how + // quickly a user leaves a site after seeing the HTTP warning. + UMA_HISTOGRAM_LONG_TIMES( + "Security.HTTPBad.NavigationStartedAfterUserWarnedAboutSensitiveInput", + base::Time::Now() - time_of_http_warning_on_current_navigation_); + // After recording the histogram, clear the time of the warning. A + // timing histogram will not be recorded again on this page, because + // the time is only set the first time the HTTP-bad warning is shown + // per page. + time_of_http_warning_on_current_navigation_ = base::Time(); +} + +void SecurityStateTabHelper::DidFinishNavigation( + content::NavigationHandle* navigation_handle) { + if (navigation_handle->IsInMainFrame() && !navigation_handle->IsSamePage()) { + // Only reset the console message flag for main-frame navigations, + // and not for same-page navigations like reference fragments and pushState. + logged_http_warning_on_current_navigation_ = false; + } +} + +void SecurityStateTabHelper::WebContentsDestroyed() { + if (time_of_http_warning_on_current_navigation_.is_null()) { + return; + } + // Record how quickly the tab is closed after a user encounters an + // HTTP-bad warning. This histogram will only be recorded if the + // WebContents is destroyed before another navigation begins. + UMA_HISTOGRAM_LONG_TIMES( + "Security.HTTPBad.WebContentsDestroyedAfterUserWarnedAboutSensitiveInput", + base::Time::Now() - time_of_http_warning_on_current_navigation_); +} + +bool SecurityStateTabHelper::UsedPolicyInstalledCertificate() const { +#if defined(OS_CHROMEOS) + policy::PolicyCertService* service = + policy::PolicyCertServiceFactory::GetForProfile( + Profile::FromBrowserContext(web_contents()->GetBrowserContext())); + if (service && service->UsedPolicyCertificates()) + return true; +#endif + return false; +} + +#if 0 +security_state::MaliciousContentStatus +SecurityStateTabHelper::GetMaliciousContentStatus() const { + content::NavigationEntry* entry = + web_contents()->GetController().GetVisibleEntry(); + if (!entry) + return security_state::MALICIOUS_CONTENT_STATUS_NONE; + safe_browsing::SafeBrowsingService* sb_service = + g_browser_process->safe_browsing_service(); + if (!sb_service) + return security_state::MALICIOUS_CONTENT_STATUS_NONE; + scoped_refptr sb_ui_manager = sb_service->ui_manager(); + safe_browsing::SBThreatType threat_type; + if (sb_ui_manager->IsUrlWhitelistedOrPendingForWebContents( + entry->GetURL(), false, entry, web_contents(), false, &threat_type)) { + switch (threat_type) { + case safe_browsing::SB_THREAT_TYPE_UNUSED: + case safe_browsing::SB_THREAT_TYPE_SAFE: + break; + case safe_browsing::SB_THREAT_TYPE_URL_PHISHING: + case safe_browsing::SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL: + return security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING; + break; + case safe_browsing::SB_THREAT_TYPE_URL_MALWARE: + case safe_browsing::SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL: + return security_state::MALICIOUS_CONTENT_STATUS_MALWARE; + break; + case safe_browsing::SB_THREAT_TYPE_URL_UNWANTED: + return security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE; + break; + case safe_browsing::SB_THREAT_TYPE_BINARY_MALWARE_URL: + case safe_browsing::SB_THREAT_TYPE_EXTENSION: + case safe_browsing::SB_THREAT_TYPE_BLACKLISTED_RESOURCE: + case safe_browsing::SB_THREAT_TYPE_API_ABUSE: + // These threat types are not currently associated with + // interstitials, and thus resources with these threat types are + // not ever whitelisted or pending whitelisting. + NOTREACHED(); + break; + } + } + return security_state::MALICIOUS_CONTENT_STATUS_NONE; +} +#endif + +std::unique_ptr +SecurityStateTabHelper::GetVisibleSecurityState() const { + auto state = security_state::GetVisibleSecurityState(web_contents()); + +#if 0 + // Malware status might already be known even if connection security + // information is still being initialized, thus no need to check for that. + state->malicious_content_status = GetMaliciousContentStatus(); +#endif + + return state; +} diff --git a/chromium_src/chrome/browser/ssl/security_state_tab_helper.h b/chromium_src/chrome/browser/ssl/security_state_tab_helper.h new file mode 100644 index 000000000000..13b256737c6e --- /dev/null +++ b/chromium_src/chrome/browser/ssl/security_state_tab_helper.h @@ -0,0 +1,70 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_SSL_SECURITY_STATE_TAB_HELPER_H_ +#define CHROME_BROWSER_SSL_SECURITY_STATE_TAB_HELPER_H_ + +#include + +#include "base/macros.h" +#include "components/security_state/core/security_state.h" +#include "content/public/browser/web_contents_observer.h" +#include "content/public/browser/web_contents_user_data.h" +#include "third_party/WebKit/public/platform/WebSecurityStyle.h" + +namespace content { +class NavigationHandle; +class WebContents; +} // namespace content + +// Tab helper provides the page's security status. Also logs console warnings +// for private data on insecure pages. +class SecurityStateTabHelper + : public content::WebContentsObserver, + public content::WebContentsUserData { + public: + ~SecurityStateTabHelper() override; + + // See security_state::GetSecurityInfo. + void GetSecurityInfo( + security_state::SecurityInfo* result) const; + + // Called when the NavigationEntry's SSLStatus or other security + // information changes. + void VisibleSecurityStateChanged(); + + // content::WebContentsObserver: + void DidStartNavigation( + content::NavigationHandle* navigation_handle) override; + void DidFinishNavigation( + content::NavigationHandle* navigation_handle) override; + void WebContentsDestroyed() override; + + private: + explicit SecurityStateTabHelper(content::WebContents* web_contents); + friend class content::WebContentsUserData; + + bool UsedPolicyInstalledCertificate() const; +#if 0 + security_state::MaliciousContentStatus GetMaliciousContentStatus() const; +#endif + std::unique_ptr + GetVisibleSecurityState() const; + + // True if a console message has been logged about an omnibox warning that + // will be shown in future versions of Chrome for insecure HTTP pages. This + // message should only be logged once per main-frame navigation. + bool logged_http_warning_on_current_navigation_; + + // The time that a console or omnibox warning was shown for insecure + // HTTP pages that contain password or credit card fields. This is set + // at most once per main-frame navigation (the first time that an HTTP + // warning triggers on that navigation) and is used for UMA + // histogramming. + base::Time time_of_http_warning_on_current_navigation_; + + DISALLOW_COPY_AND_ASSIGN(SecurityStateTabHelper); +}; + +#endif // CHROME_BROWSER_SSL_SECURITY_STATE_TAB_HELPER_H_ diff --git a/filenames.gypi b/filenames.gypi index 6fe7612a55d8..0f7597d09ef1 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -189,8 +189,6 @@ 'atom/browser/atom_quota_permission_context.h', 'atom/browser/atom_resource_dispatcher_host_delegate.cc', 'atom/browser/atom_resource_dispatcher_host_delegate.h', - 'atom/browser/atom_security_state_model_client.cc', - 'atom/browser/atom_security_state_model_client.h', 'atom/browser/atom_speech_recognition_manager_delegate.cc', 'atom/browser/atom_speech_recognition_manager_delegate.h', 'atom/browser/bridge_task_runner.cc', @@ -539,6 +537,8 @@ 'chromium_src/chrome/browser/speech/tts_platform.cc', 'chromium_src/chrome/browser/speech/tts_platform.h', 'chromium_src/chrome/browser/speech/tts_win.cc', + 'chromium_src/chrome/browser/ssl/security_state_tab_helper.cc', + 'chromium_src/chrome/browser/ssl/security_state_tab_helper.h', 'chromium_src/chrome/browser/ui/browser_dialogs.h', 'chromium_src/chrome/browser/ui/cocoa/color_chooser_mac.mm', 'chromium_src/chrome/browser/ui/views/color_chooser_aura.cc', From 6eaa30e94c00e18b1b281b87dd331fa5778208f2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 12:16:29 +0900 Subject: [PATCH 14/63] Update AtomResourceDispatcherHostDelegate --- .../browser/atom_resource_dispatcher_host_delegate.cc | 11 +++-------- atom/browser/atom_resource_dispatcher_host_delegate.h | 10 ++-------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/atom/browser/atom_resource_dispatcher_host_delegate.cc b/atom/browser/atom_resource_dispatcher_host_delegate.cc index 95175d364eda..78589112c55c 100644 --- a/atom/browser/atom_resource_dispatcher_host_delegate.cc +++ b/atom/browser/atom_resource_dispatcher_host_delegate.cc @@ -64,17 +64,12 @@ AtomResourceDispatcherHostDelegate::AtomResourceDispatcherHostDelegate() { bool AtomResourceDispatcherHostDelegate::HandleExternalProtocol( const GURL& url, - int child_id, - const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, - bool is_main_frame, - ui::PageTransition transition, - bool has_user_gesture, - content::ResourceContext* resource_context) { + content::ResourceRequestInfo* info) { BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(&HandleExternalProtocolInUI, url, - web_contents_getter, - has_user_gesture)); + info->GetWebContentsGetterForRequest(), + info->HasUserGesture())); return true; } diff --git a/atom/browser/atom_resource_dispatcher_host_delegate.h b/atom/browser/atom_resource_dispatcher_host_delegate.h index 1f55492c4ce9..681fec6f6fbc 100644 --- a/atom/browser/atom_resource_dispatcher_host_delegate.h +++ b/atom/browser/atom_resource_dispatcher_host_delegate.h @@ -15,14 +15,8 @@ class AtomResourceDispatcherHostDelegate AtomResourceDispatcherHostDelegate(); // content::ResourceDispatcherHostDelegate: - bool HandleExternalProtocol( - const GURL& url, - int child_id, - const content::ResourceRequestInfo::WebContentsGetter&, - bool is_main_frame, - ui::PageTransition transition, - bool has_user_gesture, - content::ResourceContext* resource_context) override; + bool HandleExternalProtocol(const GURL& url, + content::ResourceRequestInfo* info) override; content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate( net::AuthChallengeInfo* auth_info, net::URLRequest* request) override; From 85749e4dbd7e2ffbc4bddbd71db86d183e30b49f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 12:18:56 +0900 Subject: [PATCH 15/63] Update AtomJavaScriptDialogManager --- atom/browser/atom_javascript_dialog_manager.cc | 6 ++++++ atom/browser/atom_javascript_dialog_manager.h | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/atom/browser/atom_javascript_dialog_manager.cc b/atom/browser/atom_javascript_dialog_manager.cc index dd574af9dbff..24197915e61e 100644 --- a/atom/browser/atom_javascript_dialog_manager.cc +++ b/atom/browser/atom_javascript_dialog_manager.cc @@ -58,6 +58,12 @@ void AtomJavaScriptDialogManager::RunBeforeUnloadDialog( callback.Run(false, base::ASCIIToUTF16("This should not be displayed")); } +void AtomJavaScriptDialogManager::CancelDialogs( + content::WebContents* web_contents, + bool suppress_callbacks, + bool reset_state) { +} + // static void AtomJavaScriptDialogManager::OnMessageBoxCallback( const DialogClosedCallback& callback, int code) { diff --git a/atom/browser/atom_javascript_dialog_manager.h b/atom/browser/atom_javascript_dialog_manager.h index af94d7cec884..e5bb6114bc92 100644 --- a/atom/browser/atom_javascript_dialog_manager.h +++ b/atom/browser/atom_javascript_dialog_manager.h @@ -26,9 +26,9 @@ class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager { content::WebContents* web_contents, bool is_reload, const DialogClosedCallback& callback) override; - void CancelActiveAndPendingDialogs( - content::WebContents* web_contents) override {} - void ResetDialogState(content::WebContents* web_contents) override {}; + void CancelDialogs(content::WebContents* web_contents, + bool suppress_callbacks, + bool reset_state) override; private: static void OnMessageBoxCallback(const DialogClosedCallback& callback, From e91eed6758657cd5233664a3ca6ecb8b06f69de2 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 12:34:39 +0900 Subject: [PATCH 16/63] FOR_EACH_OBSERVER is removed --- atom/browser/browser.cc | 52 +++++++------ atom/browser/browser_mac.mm | 5 +- atom/browser/native_window.cc | 99 ++++++++++++++---------- atom/browser/net/atom_cookie_delegate.cc | 5 +- atom/browser/ui/atom_menu_model.cc | 3 +- atom/browser/ui/tray_icon.cc | 38 +++++---- atom/browser/window_list.cc | 19 ++--- 7 files changed, 123 insertions(+), 98 deletions(-) diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index 31e354c7d409..0b20d4f226c9 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -7,6 +7,7 @@ #include #include "atom/browser/atom_browser_main_parts.h" +#include "atom/browser/browser_observer.h" #include "atom/browser/native_window.h" #include "atom/browser/window_list.h" #include "base/files/file_util.h" @@ -82,7 +83,8 @@ void Browser::Shutdown() { is_shutdown_ = true; is_quiting_ = true; - FOR_EACH_OBSERVER(BrowserObserver, observers_, OnQuit()); + for (BrowserObserver& observer : observers_) + observer.OnQuit(); if (base::MessageLoop::current()) { base::ThreadTaskRunnerHandle::Get()->PostTask( @@ -127,25 +129,25 @@ int Browser::GetBadgeCount() { bool Browser::OpenFile(const std::string& file_path) { bool prevent_default = false; - FOR_EACH_OBSERVER(BrowserObserver, - observers_, - OnOpenFile(&prevent_default, file_path)); + for (BrowserObserver& observer : observers_) + observer.OnOpenFile(&prevent_default, file_path); return prevent_default; } void Browser::OpenURL(const std::string& url) { - FOR_EACH_OBSERVER(BrowserObserver, observers_, OnOpenURL(url)); + for (BrowserObserver& observer : observers_) + observer.OnOpenURL(url); } void Browser::Activate(bool has_visible_windows) { - FOR_EACH_OBSERVER(BrowserObserver, - observers_, - OnActivate(has_visible_windows)); + for (BrowserObserver& observer : observers_) + observer.OnActivate(has_visible_windows); } void Browser::WillFinishLaunching() { - FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillFinishLaunching()); + for (BrowserObserver& observer : observers_) + observer.OnWillFinishLaunching(); } void Browser::DidFinishLaunching(const base::DictionaryValue& launch_info) { @@ -155,22 +157,20 @@ void Browser::DidFinishLaunching(const base::DictionaryValue& launch_info) { base::CreateDirectoryAndGetError(user_data, nullptr); is_ready_ = true; - FOR_EACH_OBSERVER(BrowserObserver, observers_, - OnFinishLaunching(launch_info)); + for (BrowserObserver& observer : observers_) + observer.OnFinishLaunching(launch_info); } void Browser::OnAccessibilitySupportChanged() { - FOR_EACH_OBSERVER(BrowserObserver, - observers_, - OnAccessibilitySupportChanged()); + for (BrowserObserver& observer : observers_) + observer.OnAccessibilitySupportChanged(); } void Browser::RequestLogin( LoginHandler* login_handler, std::unique_ptr request_details) { - FOR_EACH_OBSERVER(BrowserObserver, - observers_, - OnLogin(login_handler, *(request_details.get()))); + for (BrowserObserver& observer : observers_) + observer.OnLogin(login_handler, *(request_details.get())); } void Browser::NotifyAndShutdown() { @@ -178,7 +178,8 @@ void Browser::NotifyAndShutdown() { return; bool prevent_default = false; - FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillQuit(&prevent_default)); + for (BrowserObserver& observer : observers_) + observer.OnWillQuit(&prevent_default); if (prevent_default) { is_quiting_ = false; @@ -190,9 +191,8 @@ void Browser::NotifyAndShutdown() { bool Browser::HandleBeforeQuit() { bool prevent_default = false; - FOR_EACH_OBSERVER(BrowserObserver, - observers_, - OnBeforeQuit(&prevent_default)); + for (BrowserObserver& observer : observers_) + observer.OnBeforeQuit(&prevent_default); return !prevent_default; } @@ -205,12 +205,14 @@ void Browser::OnWindowCloseCancelled(NativeWindow* window) { } void Browser::OnWindowAllClosed() { - if (is_exiting_) + if (is_exiting_) { Shutdown(); - else if (is_quiting_) + } else if (is_quiting_) { NotifyAndShutdown(); - else - FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWindowAllClosed()); + } else { + for (BrowserObserver& observer : observers_) + observer.OnWindowAllClosed(); + } } } // namespace atom diff --git a/atom/browser/browser_mac.mm b/atom/browser/browser_mac.mm index afb291bc3b33..c318cf850701 100644 --- a/atom/browser/browser_mac.mm +++ b/atom/browser/browser_mac.mm @@ -146,9 +146,8 @@ std::string Browser::GetCurrentActivityType() { bool Browser::ContinueUserActivity(const std::string& type, const base::DictionaryValue& user_info) { bool prevent_default = false; - FOR_EACH_OBSERVER(BrowserObserver, - observers_, - OnContinueUserActivity(&prevent_default, type, user_info)); + for (BrowserObserver& observer : observers_) + observer.OnContinueUserActivity(&prevent_default, type, user_info); return prevent_default; } diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index ccd9b619c213..1ef70f2c73dd 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -390,9 +390,8 @@ void NativeWindow::CloseFilePreview() { void NativeWindow::RequestToClosePage() { bool prevent_default = false; - FOR_EACH_OBSERVER(NativeWindowObserver, - observers_, - WillCloseWindow(&prevent_default)); + for (NativeWindowObserver& observer : observers_) + observer.WillCloseWindow(&prevent_default); if (prevent_default) { WindowList::WindowCloseCancelled(this); return; @@ -423,8 +422,8 @@ void NativeWindow::CloseContents(content::WebContents* source) { inspectable_web_contents_ = nullptr; Observe(nullptr); - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, - WillDestroyNativeObject()); + for (NativeWindowObserver& observer : observers_) + observer.WillDestroyNativeObject(); // When the web contents is gone, close the window immediately, but the // memory will not be freed until you call delete. @@ -450,7 +449,8 @@ void NativeWindow::RendererUnresponsive(content::WebContents* source) { void NativeWindow::RendererResponsive(content::WebContents* source) { window_unresposive_closure_.Cancel(); - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererResponsive()); + for (NativeWindowObserver& observer : observers_) + observer.OnRendererResponsive(); } void NativeWindow::NotifyWindowClosed() { @@ -460,104 +460,116 @@ void NativeWindow::NotifyWindowClosed() { WindowList::RemoveWindow(this); is_closed_ = true; - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowClosed()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowClosed(); } void NativeWindow::NotifyWindowBlur() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowBlur()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowBlur(); } void NativeWindow::NotifyWindowFocus() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowFocus()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowFocus(); } void NativeWindow::NotifyWindowShow() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowShow()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowShow(); } void NativeWindow::NotifyWindowHide() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowHide()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowHide(); } void NativeWindow::NotifyWindowMaximize() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowMaximize()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowMaximize(); } void NativeWindow::NotifyWindowUnmaximize() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowUnmaximize()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowUnmaximize(); } void NativeWindow::NotifyWindowMinimize() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowMinimize()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowMinimize(); } void NativeWindow::NotifyWindowRestore() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowRestore()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowRestore(); } void NativeWindow::NotifyWindowResize() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowResize()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowResize(); } void NativeWindow::NotifyWindowMove() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowMove()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowMove(); } void NativeWindow::NotifyWindowMoved() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowMoved()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowMoved(); } void NativeWindow::NotifyWindowEnterFullScreen() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, - OnWindowEnterFullScreen()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowEnterFullScreen(); } void NativeWindow::NotifyWindowScrollTouchBegin() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, - OnWindowScrollTouchBegin()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowScrollTouchBegin(); } void NativeWindow::NotifyWindowScrollTouchEnd() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, - OnWindowScrollTouchEnd()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowScrollTouchEdge(); } void NativeWindow::NotifyWindowScrollTouchEdge() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, - OnWindowScrollTouchEdge()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowScrollTouchEdge(); } void NativeWindow::NotifyWindowSwipe(const std::string& direction) { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, - OnWindowSwipe(direction)); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowSwipe(direction); } void NativeWindow::NotifyWindowLeaveFullScreen() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, - OnWindowLeaveFullScreen()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowLeaveFullScreen(); } void NativeWindow::NotifyWindowEnterHtmlFullScreen() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, - OnWindowEnterHtmlFullScreen()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowEnterHtmlFullScreen(); } void NativeWindow::NotifyWindowLeaveHtmlFullScreen() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, - OnWindowLeaveHtmlFullScreen()); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowLeaveHtmlFullScreen(); } void NativeWindow::NotifyWindowExecuteWindowsCommand( const std::string& command) { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, - OnExecuteWindowsCommand(command)); + for (NativeWindowObserver& observer : observers_) + observer.OnExecuteWindowsCommand(command); } #if defined(OS_WIN) void NativeWindow::NotifyWindowMessage( UINT message, WPARAM w_param, LPARAM l_param) { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, - OnWindowMessage(message, w_param, l_param)); + for (NativeWindowObserver& observer : observers_) + observer.OnWindowMessage(message, w_param, l_param); } #endif @@ -645,14 +657,15 @@ void NativeWindow::ScheduleUnresponsiveEvent(int ms) { void NativeWindow::NotifyWindowUnresponsive() { window_unresposive_closure_.Cancel(); - if (!is_closed_ && !IsUnresponsiveEventSuppressed() && IsEnabled()) - FOR_EACH_OBSERVER(NativeWindowObserver, - observers_, - OnRendererUnresponsive()); + if (!is_closed_ && !IsUnresponsiveEventSuppressed() && IsEnabled()) { + for (NativeWindowObserver& observer : observers_) + observer.OnRendererUnresponsive(); + } } void NativeWindow::NotifyReadyToShow() { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnReadyToShow()); + for (NativeWindowObserver& observer : observers_) + observer.OnReadyToShow(); } } // namespace atom diff --git a/atom/browser/net/atom_cookie_delegate.cc b/atom/browser/net/atom_cookie_delegate.cc index a03588913bb1..b94f396d981e 100644 --- a/atom/browser/net/atom_cookie_delegate.cc +++ b/atom/browser/net/atom_cookie_delegate.cc @@ -26,9 +26,8 @@ void AtomCookieDelegate::NotifyObservers( const net::CanonicalCookie& cookie, bool removed, net::CookieStore::ChangeCause cause) { - FOR_EACH_OBSERVER(Observer, - observers_, - OnCookieChanged(cookie, removed, cause)); + for (Observer& observer : observers_) + observer.OnCookieChanged(cookie, removed, cause); } void AtomCookieDelegate::OnCookieChanged( diff --git a/atom/browser/ui/atom_menu_model.cc b/atom/browser/ui/atom_menu_model.cc index b6a9ba6a7265..1ec6b3c09f5c 100644 --- a/atom/browser/ui/atom_menu_model.cc +++ b/atom/browser/ui/atom_menu_model.cc @@ -42,7 +42,8 @@ bool AtomMenuModel::GetAcceleratorAtWithParams( void AtomMenuModel::MenuWillClose() { ui::SimpleMenuModel::MenuWillClose(); - FOR_EACH_OBSERVER(Observer, observers_, MenuWillClose()); + for (Observer& observer : observers_) + observer.MenuWillClose(); } AtomMenuModel* AtomMenuModel::GetSubmenuModelAt(int index) { diff --git a/atom/browser/ui/tray_icon.cc b/atom/browser/ui/tray_icon.cc index 273f5c084391..882a2ba27a0f 100644 --- a/atom/browser/ui/tray_icon.cc +++ b/atom/browser/ui/tray_icon.cc @@ -35,53 +35,63 @@ gfx::Rect TrayIcon::GetBounds() { } void TrayIcon::NotifyClicked(const gfx::Rect& bounds, int modifiers) { - FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnClicked(bounds, modifiers)); + for (TrayIconObserver& observer : observers_) + observer.OnClicked(bounds, modifiers); } void TrayIcon::NotifyDoubleClicked(const gfx::Rect& bounds, int modifiers) { - FOR_EACH_OBSERVER(TrayIconObserver, observers_, - OnDoubleClicked(bounds, modifiers)); + for (TrayIconObserver& observer : observers_) + observer.OnDoubleClicked(bounds, modifiers); } void TrayIcon::NotifyBalloonShow() { - FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnBalloonShow()); + for (TrayIconObserver& observer : observers_) + observer.OnBalloonShow(); } void TrayIcon::NotifyBalloonClicked() { - FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnBalloonClicked()); + for (TrayIconObserver& observer : observers_) + observer.OnBalloonClicked(); } void TrayIcon::NotifyBalloonClosed() { - FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnBalloonClosed()); + for (TrayIconObserver& observer : observers_) + observer.OnBalloonClosed(); } void TrayIcon::NotifyRightClicked(const gfx::Rect& bounds, int modifiers) { - FOR_EACH_OBSERVER(TrayIconObserver, observers_, - OnRightClicked(bounds, modifiers)); + for (TrayIconObserver& observer : observers_) + observer.OnRightClicked(bounds, modifiers); } void TrayIcon::NotifyDrop() { - FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDrop()); + for (TrayIconObserver& observer : observers_) + observer.OnDrop(); } void TrayIcon::NotifyDropFiles(const std::vector& files) { - FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDropFiles(files)); + for (TrayIconObserver& observer : observers_) + observer.OnDropFiles(files); } void TrayIcon::NotifyDropText(const std::string& text) { - FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDropText(text)); + for (TrayIconObserver& observer : observers_) + observer.OnDropText(text); } void TrayIcon::NotifyDragEntered() { - FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDragEntered()); + for (TrayIconObserver& observer : observers_) + observer.OnDragEntered(); } void TrayIcon::NotifyDragExited() { - FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDragExited()); + for (TrayIconObserver& observer : observers_) + observer.OnDragExited(); } void TrayIcon::NotifyDragEnded() { - FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDragEnded()); + for (TrayIconObserver& observer : observers_) + observer.OnDragEnded(); } } // namespace atom diff --git a/atom/browser/window_list.cc b/atom/browser/window_list.cc index b8e5a8256530..b835e07e752a 100644 --- a/atom/browser/window_list.cc +++ b/atom/browser/window_list.cc @@ -33,8 +33,8 @@ void WindowList::AddWindow(NativeWindow* window) { WindowVector& windows = GetInstance()->windows_; windows.push_back(window); - FOR_EACH_OBSERVER(WindowListObserver, observers_.Get(), - OnWindowAdded(window)); + for (WindowListObserver& observer : observers_.Get()) + observer.OnWindowAdded(window); } // static @@ -43,18 +43,19 @@ void WindowList::RemoveWindow(NativeWindow* window) { windows.erase(std::remove(windows.begin(), windows.end(), window), windows.end()); - FOR_EACH_OBSERVER(WindowListObserver, observers_.Get(), - OnWindowRemoved(window)); + for (WindowListObserver& observer : observers_.Get()) + observer.OnWindowRemoved(window); - if (windows.size() == 0) - FOR_EACH_OBSERVER(WindowListObserver, observers_.Get(), - OnWindowAllClosed()); + if (windows.size() == 0) { + for (WindowListObserver& observer : observers_.Get()) + observer.OnWindowAllClosed(); + } } // static void WindowList::WindowCloseCancelled(NativeWindow* window) { - FOR_EACH_OBSERVER(WindowListObserver, observers_.Get(), - OnWindowCloseCancelled(window)); + for (WindowListObserver& observer : observers_.Get()) + observer.OnWindowCloseCancelled(window); } // static From a95bd227c39155c058f24ec4d58866a9b309cce8 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 12:38:46 +0900 Subject: [PATCH 17/63] Update atom::Browser --- atom/browser/browser.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index 0b20d4f226c9..9b7423cd7d9f 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -12,6 +12,7 @@ #include "atom/browser/window_list.h" #include "base/files/file_util.h" #include "base/path_service.h" +#include "base/run_loop.h" #include "base/threading/thread_task_runner_handle.h" #include "brightray/browser/brightray_paths.h" @@ -86,7 +87,7 @@ void Browser::Shutdown() { for (BrowserObserver& observer : observers_) observer.OnQuit(); - if (base::MessageLoop::current()) { + if (base::ThreadTaskRunnerHandle::IsSet()) { base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); } else { From c2f3bbb3e6eaa493836d80d7451b890b3ed62e93 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 14:06:48 +0900 Subject: [PATCH 18/63] Update OffScreenWebContentsView --- atom/browser/osr/osr_web_contents_view.cc | 23 ++++++++++++----------- atom/browser/osr/osr_web_contents_view.h | 14 +++++++------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/atom/browser/osr/osr_web_contents_view.cc b/atom/browser/osr/osr_web_contents_view.cc index 59200d15855d..0d9c52743bc1 100644 --- a/atom/browser/osr/osr_web_contents_view.cc +++ b/atom/browser/osr/osr_web_contents_view.cc @@ -109,15 +109,15 @@ void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled) { } void OffScreenWebContentsView::GetScreenInfo( - blink::WebScreenInfo* web_screen_info) const { - web_screen_info->rect = gfx::Rect(view_->size()); - web_screen_info->availableRect = gfx::Rect(view_->size()); - web_screen_info->depth = 24; - web_screen_info->depthPerComponent = 8; - web_screen_info->deviceScaleFactor = view_->scale_factor(); - web_screen_info->orientationAngle = 0; - web_screen_info->orientationType = - blink::WebScreenOrientationLandscapePrimary; + content::ScreenInfo* screen_info) const { + screen_info->rect = gfx::Rect(view_->size()); + screen_info->available_rect = gfx::Rect(view_->size()); + screen_info->depth = 24; + screen_info->depth_per_component = 8; + screen_info->device_scale_factor = view_->scale_factor(); + screen_info->orientation_angle = 0; + screen_info->orientation_type = + content::SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY; } #if defined(OS_MACOSX) @@ -141,9 +141,10 @@ void OffScreenWebContentsView::StartDragging( blink::WebDragOperationsMask allowed_ops, const gfx::ImageSkia& image, const gfx::Vector2d& image_offset, - const content::DragEventSourceInfo& event_info) { + const content::DragEventSourceInfo& event_info, + content::RenderWidgetHostImpl* source_rwh) { if (web_contents_) - web_contents_->SystemDragEnded(); + web_contents_->SystemDragEnded(source_rwh); } void OffScreenWebContentsView::UpdateDragCursor( diff --git a/atom/browser/osr/osr_web_contents_view.h b/atom/browser/osr/osr_web_contents_view.h index 08e1d731e354..8e4e24299473 100644 --- a/atom/browser/osr/osr_web_contents_view.h +++ b/atom/browser/osr/osr_web_contents_view.h @@ -51,7 +51,7 @@ class OffScreenWebContentsView : public content::WebContentsView, void RenderViewCreated(content::RenderViewHost* host) override; void RenderViewSwappedIn(content::RenderViewHost* host) override; void SetOverscrollControllerEnabled(bool enabled) override; - void GetScreenInfo(blink::WebScreenInfo* web_screen_info) const override; + void GetScreenInfo(content::ScreenInfo* screen_info) const override; #if defined(OS_MACOSX) void SetAllowOtherViews(bool allow) override; @@ -61,12 +61,12 @@ class OffScreenWebContentsView : public content::WebContentsView, #endif // content::RenderViewHostDelegateView - void StartDragging( - const content::DropData& drop_data, - blink::WebDragOperationsMask allowed_ops, - const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset, - const content::DragEventSourceInfo& event_info) override; + void StartDragging(const content::DropData& drop_data, + blink::WebDragOperationsMask allowed_ops, + const gfx::ImageSkia& image, + const gfx::Vector2d& image_offset, + const content::DragEventSourceInfo& event_info, + content::RenderWidgetHostImpl* source_rwh) override; void UpdateDragCursor(blink::WebDragOperation operation) override; private: From 9882e87fbdc3cd9618081180a115746a118156bf Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 14:11:38 +0900 Subject: [PATCH 19/63] Update OffScreenOutputDevice --- atom/browser/osr/osr_output_device.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/atom/browser/osr/osr_output_device.cc b/atom/browser/osr/osr_output_device.cc index dd806136338e..5f605f668c9b 100644 --- a/atom/browser/osr/osr_output_device.cc +++ b/atom/browser/osr/osr_output_device.cc @@ -22,8 +22,6 @@ OffScreenOutputDevice::~OffScreenOutputDevice() { void OffScreenOutputDevice::Resize( const gfx::Size& pixel_size, float scale_factor) { - scale_factor_ = scale_factor; - if (viewport_pixel_size_ == pixel_size) return; viewport_pixel_size_ = pixel_size; From c0697d8abeb45fc6d02eaedcee63126b30b4a544 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 14:16:23 +0900 Subject: [PATCH 20/63] SetupFilter is replaced with SetUpSourceStream --- atom/browser/net/asar/url_request_asar_job.cc | 10 +++++++--- atom/browser/net/asar/url_request_asar_job.h | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/atom/browser/net/asar/url_request_asar_job.cc b/atom/browser/net/asar/url_request_asar_job.cc index 586aa42a5a49..8bacf1124bf6 100644 --- a/atom/browser/net/asar/url_request_asar_job.cc +++ b/atom/browser/net/asar/url_request_asar_job.cc @@ -21,7 +21,7 @@ #include "net/base/load_flags.h" #include "net/base/mime_util.h" #include "net/base/net_errors.h" -#include "net/filter/filter.h" +#include "net/filter/gzip_source_stream.h" #include "net/http/http_util.h" #include "net/url_request/url_request_status.h" @@ -179,10 +179,14 @@ bool URLRequestAsarJob::IsRedirectResponse(GURL* location, #endif } -std::unique_ptr URLRequestAsarJob::SetupFilter() const { +std::unique_ptr URLRequestAsarJob::SetUpSourceStream() { + std::unique_ptr source = + net::URLRequestJob::SetUpSourceStream(); // Bug 9936 - .svgz files needs to be decompressed. return base::LowerCaseEqualsASCII(file_path_.Extension(), ".svgz") - ? net::Filter::GZipFactory() : nullptr; + ? net::GzipSourceStream::Create(std::move(source), + net::SourceStream::TYPE_GZIP) + : std::move(source); } bool URLRequestAsarJob::GetMimeType(std::string* mime_type) const { diff --git a/atom/browser/net/asar/url_request_asar_job.h b/atom/browser/net/asar/url_request_asar_job.h index 7af88da7696c..9808be88189e 100644 --- a/atom/browser/net/asar/url_request_asar_job.h +++ b/atom/browser/net/asar/url_request_asar_job.h @@ -56,7 +56,7 @@ class URLRequestAsarJob : public net::URLRequestJob { void Kill() override; int ReadRawData(net::IOBuffer* buf, int buf_size) override; bool IsRedirectResponse(GURL* location, int* http_status_code) override; - std::unique_ptr SetupFilter() const override; + std::unique_ptr SetUpSourceStream() override; bool GetMimeType(std::string* mime_type) const override; void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) override; int GetResponseCode() const override; From 3ea6d88763528de43fdaf54e6b384986eebc4ac6 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 14:17:43 +0900 Subject: [PATCH 21/63] Update AtomCertVerifier --- atom/browser/net/atom_cert_verifier.cc | 2 +- atom/browser/net/atom_cert_verifier.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/atom/browser/net/atom_cert_verifier.cc b/atom/browser/net/atom_cert_verifier.cc index 9892845cc83f..61c7439e2733 100644 --- a/atom/browser/net/atom_cert_verifier.cc +++ b/atom/browser/net/atom_cert_verifier.cc @@ -46,7 +46,7 @@ int AtomCertVerifier::Verify( net::CertVerifyResult* verify_result, const net::CompletionCallback& callback, std::unique_ptr* out_req, - const net::BoundNetLog& net_log) { + const net::NetLogWithSource& net_log) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (verify_proc_.is_null()) { diff --git a/atom/browser/net/atom_cert_verifier.h b/atom/browser/net/atom_cert_verifier.h index 7582fae74f61..e321f7d3d933 100644 --- a/atom/browser/net/atom_cert_verifier.h +++ b/atom/browser/net/atom_cert_verifier.h @@ -33,7 +33,7 @@ class AtomCertVerifier : public net::CertVerifier { net::CertVerifyResult* verify_result, const net::CompletionCallback& callback, std::unique_ptr* out_req, - const net::BoundNetLog& net_log) override; + const net::NetLogWithSource& net_log) override; bool SupportsOCSPStapling() override; private: From dc9000f344e4df79d625200c9e29d40c98eb0d0e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 14:21:00 +0900 Subject: [PATCH 22/63] --ssl-version-fallback-min is removed by Chrome --- atom/browser/net/atom_ssl_config_service.cc | 6 ------ atom/common/options_switches.cc | 4 ---- atom/common/options_switches.h | 1 - docs-translations/es/api/chrome-command-line-switches.md | 5 ----- docs-translations/jp/api/chrome-command-line-switches.md | 4 ---- docs-translations/ko-KR/api/chrome-command-line-switches.md | 4 ---- docs-translations/zh-CN/api/chrome-command-line-switches.md | 4 ---- docs/api/chrome-command-line-switches.md | 5 ----- 8 files changed, 33 deletions(-) diff --git a/atom/browser/net/atom_ssl_config_service.cc b/atom/browser/net/atom_ssl_config_service.cc index 1c9d39258f14..84d3583a530b 100644 --- a/atom/browser/net/atom_ssl_config_service.cc +++ b/atom/browser/net/atom_ssl_config_service.cc @@ -50,12 +50,6 @@ std::vector ParseCipherSuites( AtomSSLConfigService::AtomSSLConfigService() { auto cmd_line = base::CommandLine::ForCurrentProcess(); - if (cmd_line->HasSwitch(switches::kSSLVersionFallbackMin)) { - auto version_string = - cmd_line->GetSwitchValueASCII(switches::kSSLVersionFallbackMin); - config_.version_fallback_min = GetSSLProtocolVersion(version_string); - } - if (cmd_line->HasSwitch(switches::kCipherSuiteBlacklist)) { auto cipher_strings = base::SplitString( cmd_line->GetSwitchValueASCII(switches::kCipherSuiteBlacklist), diff --git a/atom/common/options_switches.cc b/atom/common/options_switches.cc index f247025f36d8..51bba5f9272b 100644 --- a/atom/common/options_switches.cc +++ b/atom/common/options_switches.cc @@ -150,10 +150,6 @@ const char kRegisterServiceWorkerSchemes[] = "register-service-worker-schemes"; // Register schemes as secure. const char kSecureSchemes[] = "secure-schemes"; -// The minimum SSL/TLS version ("tls1", "tls1.1", or "tls1.2") that -// TLS fallback will accept. -const char kSSLVersionFallbackMin[] = "ssl-version-fallback-min"; - // Comma-separated list of SSL cipher suites to disable. const char kCipherSuiteBlacklist[] = "cipher-suite-blacklist"; diff --git a/atom/common/options_switches.h b/atom/common/options_switches.h index e368b0a5fc1d..340b130998e8 100644 --- a/atom/common/options_switches.h +++ b/atom/common/options_switches.h @@ -78,7 +78,6 @@ extern const char kDisableHttpCache[]; extern const char kStandardSchemes[]; extern const char kRegisterServiceWorkerSchemes[]; extern const char kSecureSchemes[]; -extern const char kSSLVersionFallbackMin[]; extern const char kCipherSuiteBlacklist[]; extern const char kAppUserModelId[]; diff --git a/docs-translations/es/api/chrome-command-line-switches.md b/docs-translations/es/api/chrome-command-line-switches.md index 8e63f973fef4..2160da565c5a 100644 --- a/docs-translations/es/api/chrome-command-line-switches.md +++ b/docs-translations/es/api/chrome-command-line-switches.md @@ -87,11 +87,6 @@ Asigna la versión `version` del pepper flash plugin. Permite guardar y escribir eventos de registros de red en `path`. -## --ssl-version-fallback-min=`version` - -Establece la versión mínima de SSL/TLS ("tls1", "tls1.1" o "tls1.2") que -el repliegue de TLC aceptará. - ## --enable-logging Imprime el registro de Chromium en consola. diff --git a/docs-translations/jp/api/chrome-command-line-switches.md b/docs-translations/jp/api/chrome-command-line-switches.md index 2ac9da014112..63a6ca57366b 100644 --- a/docs-translations/jp/api/chrome-command-line-switches.md +++ b/docs-translations/jp/api/chrome-command-line-switches.md @@ -97,10 +97,6 @@ pepper flash pluginの`version`を設定します。 ネットログイベントを保存し、`path`に書き込みを有効化します。 -## --ssl-version-fallback-min=`version` - -TLSフォールバックを許可する最小のSSL/TLSバージョン ("tls1"や"tls1.1" 、 "tls1.2")を設定します。 - ## --cipher-suite-blacklist=`cipher_suites` 無効にするために、SSL暗号スイートのカンマ区切りのリストを指定します。 diff --git a/docs-translations/ko-KR/api/chrome-command-line-switches.md b/docs-translations/ko-KR/api/chrome-command-line-switches.md index 3078a594c2c2..53cd1a549646 100644 --- a/docs-translations/ko-KR/api/chrome-command-line-switches.md +++ b/docs-translations/ko-KR/api/chrome-command-line-switches.md @@ -138,10 +138,6 @@ Pepper 플래시 플러그인의 버전을 설정합니다. Net log 이벤트를 활성화하고 `path`에 로그를 기록합니다. -## --ssl-version-fallback-min=`version` - -TLS fallback에서 사용할 SSL/TLS 최소 버전을 지정합니다. (`tls1`, `tls1.1`, `tls1.2`) - ## --cipher-suite-blacklist=`cipher_suites` SSL 암호화를 비활성화할 대상 목록을 지정합니다. (`,`로 구분) diff --git a/docs-translations/zh-CN/api/chrome-command-line-switches.md b/docs-translations/zh-CN/api/chrome-command-line-switches.md index 976a61736d79..782617cbf101 100644 --- a/docs-translations/zh-CN/api/chrome-command-line-switches.md +++ b/docs-translations/zh-CN/api/chrome-command-line-switches.md @@ -102,10 +102,6 @@ app.commandLine.appendSwitch('proxy-bypass-list', ';*.google.com;*foo.com 使网络日志事件能够被读写到 `path`. -## --ssl-version-fallback-min=`version` - -设置最简化的 SSL/TLS 版本号 ("tls1", "tls1.1" or "tls1.2"),TLS 可接受回退. - ## --cipher-suite-blacklist=`cipher_suites` 指定逗号分隔的 SSL 密码套件 列表实效. diff --git a/docs/api/chrome-command-line-switches.md b/docs/api/chrome-command-line-switches.md index 7920fe5e20ec..5849b24aab86 100644 --- a/docs/api/chrome-command-line-switches.md +++ b/docs/api/chrome-command-line-switches.md @@ -136,11 +136,6 @@ Sets the `version` of the pepper flash plugin. Enables net log events to be saved and writes them to `path`. -## --ssl-version-fallback-min=`version` - -Sets the minimum SSL/TLS version (`tls1`, `tls1.1` or `tls1.2`) that TLS -fallback will accept. - ## --cipher-suite-blacklist=`cipher_suites` Specifies comma-separated list of SSL cipher suites to disable. From 1a15b457364f521ddd2d4001996b1d4c5a8e4a6a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 14:26:54 +0900 Subject: [PATCH 23/63] --cipher-suite-blacklist is also removed --- atom/browser/atom_browser_context.cc | 5 -- atom/browser/atom_browser_context.h | 1 - atom/browser/net/atom_ssl_config_service.cc | 68 ------------------- atom/browser/net/atom_ssl_config_service.h | 28 -------- atom/common/options_switches.cc | 3 - atom/common/options_switches.h | 1 - .../jp/api/chrome-command-line-switches.md | 4 -- .../ko-KR/api/chrome-command-line-switches.md | 4 -- .../zh-CN/api/chrome-command-line-switches.md | 4 -- docs/api/chrome-command-line-switches.md | 4 -- filenames.gypi | 2 - 11 files changed, 124 deletions(-) delete mode 100644 atom/browser/net/atom_ssl_config_service.cc delete mode 100644 atom/browser/net/atom_ssl_config_service.h diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc index 1bab4a968d38..d20d653c7d93 100644 --- a/atom/browser/atom_browser_context.cc +++ b/atom/browser/atom_browser_context.cc @@ -15,7 +15,6 @@ #include "atom/browser/net/atom_cert_verifier.h" #include "atom/browser/net/atom_ct_delegate.h" #include "atom/browser/net/atom_network_delegate.h" -#include "atom/browser/net/atom_ssl_config_service.h" #include "atom/browser/net/atom_url_request_job_factory.h" #include "atom/browser/net/http_protocol_handler.h" #include "atom/browser/web_view_manager.h" @@ -198,10 +197,6 @@ std::unique_ptr AtomBrowserContext::CreateCertVerifier() { return base::WrapUnique(new AtomCertVerifier(ct_delegate_.get())); } -net::SSLConfigService* AtomBrowserContext::CreateSSLConfigService() { - return new AtomSSLConfigService; -} - std::vector AtomBrowserContext::GetCookieableSchemes() { auto default_schemes = brightray::BrowserContext::GetCookieableSchemes(); const auto& standard_schemes = atom::api::GetStandardSchemes(); diff --git a/atom/browser/atom_browser_context.h b/atom/browser/atom_browser_context.h index f149e62cb279..340c8f46626f 100644 --- a/atom/browser/atom_browser_context.h +++ b/atom/browser/atom_browser_context.h @@ -41,7 +41,6 @@ class AtomBrowserContext : public brightray::BrowserContext { net::HttpCache::BackendFactory* CreateHttpCacheBackendFactory( const base::FilePath& base_path) override; std::unique_ptr CreateCertVerifier() override; - net::SSLConfigService* CreateSSLConfigService() override; std::vector GetCookieableSchemes() override; net::TransportSecurityState::RequireCTDelegate* GetRequireCTDelegate() override; diff --git a/atom/browser/net/atom_ssl_config_service.cc b/atom/browser/net/atom_ssl_config_service.cc deleted file mode 100644 index 84d3583a530b..000000000000 --- a/atom/browser/net/atom_ssl_config_service.cc +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 2015 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "atom/browser/net/atom_ssl_config_service.h" - -#include -#include - -#include "atom/common/options_switches.h" -#include "base/command_line.h" -#include "base/strings/string_split.h" -#include "content/public/browser/browser_thread.h" -#include "net/socket/ssl_client_socket.h" -#include "net/ssl/ssl_cipher_suite_names.h" - -namespace atom { - -namespace { - -uint16_t GetSSLProtocolVersion(const std::string& version_string) { - uint16_t version = 0; // Invalid - if (version_string == "tls1") - version = net::SSL_PROTOCOL_VERSION_TLS1; - else if (version_string == "tls1.1") - version = net::SSL_PROTOCOL_VERSION_TLS1_1; - else if (version_string == "tls1.2") - version = net::SSL_PROTOCOL_VERSION_TLS1_2; - return version; -} - -std::vector ParseCipherSuites( - const std::vector& cipher_strings) { - std::vector cipher_suites; - cipher_suites.reserve(cipher_strings.size()); - - for (auto& cipher_string : cipher_strings) { - uint16_t cipher_suite = 0; - if (!net::ParseSSLCipherString(cipher_string, &cipher_suite)) { - LOG(ERROR) << "Ignoring unrecognised cipher suite : " - << cipher_string; - continue; - } - cipher_suites.push_back(cipher_suite); - } - return cipher_suites; -} - -} // namespace - -AtomSSLConfigService::AtomSSLConfigService() { - auto cmd_line = base::CommandLine::ForCurrentProcess(); - if (cmd_line->HasSwitch(switches::kCipherSuiteBlacklist)) { - auto cipher_strings = base::SplitString( - cmd_line->GetSwitchValueASCII(switches::kCipherSuiteBlacklist), - ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); - config_.disabled_cipher_suites = ParseCipherSuites(cipher_strings); - } -} - -AtomSSLConfigService::~AtomSSLConfigService() { -} - -void AtomSSLConfigService::GetSSLConfig(net::SSLConfig* config) { - *config = config_; -} - -} // namespace atom diff --git a/atom/browser/net/atom_ssl_config_service.h b/atom/browser/net/atom_ssl_config_service.h deleted file mode 100644 index 2e3ac4f6c597..000000000000 --- a/atom/browser/net/atom_ssl_config_service.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2015 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#ifndef ATOM_BROWSER_NET_ATOM_SSL_CONFIG_SERVICE_H_ -#define ATOM_BROWSER_NET_ATOM_SSL_CONFIG_SERVICE_H_ - -#include "net/ssl/ssl_config_service.h" - -namespace atom { - -class AtomSSLConfigService : public net::SSLConfigService { - public: - AtomSSLConfigService(); - ~AtomSSLConfigService() override; - - // net::SSLConfigService: - void GetSSLConfig(net::SSLConfig* config) override; - - private: - net::SSLConfig config_; - - DISALLOW_COPY_AND_ASSIGN(AtomSSLConfigService); -}; - -} // namespace atom - -#endif // ATOM_BROWSER_NET_ATOM_SSL_CONFIG_SERVICE_H_ diff --git a/atom/common/options_switches.cc b/atom/common/options_switches.cc index 51bba5f9272b..4729a28127db 100644 --- a/atom/common/options_switches.cc +++ b/atom/common/options_switches.cc @@ -150,9 +150,6 @@ const char kRegisterServiceWorkerSchemes[] = "register-service-worker-schemes"; // Register schemes as secure. const char kSecureSchemes[] = "secure-schemes"; -// Comma-separated list of SSL cipher suites to disable. -const char kCipherSuiteBlacklist[] = "cipher-suite-blacklist"; - // The browser process app model ID const char kAppUserModelId[] = "app-user-model-id"; diff --git a/atom/common/options_switches.h b/atom/common/options_switches.h index 340b130998e8..c81ab529cfeb 100644 --- a/atom/common/options_switches.h +++ b/atom/common/options_switches.h @@ -78,7 +78,6 @@ extern const char kDisableHttpCache[]; extern const char kStandardSchemes[]; extern const char kRegisterServiceWorkerSchemes[]; extern const char kSecureSchemes[]; -extern const char kCipherSuiteBlacklist[]; extern const char kAppUserModelId[]; extern const char kBackgroundColor[]; diff --git a/docs-translations/jp/api/chrome-command-line-switches.md b/docs-translations/jp/api/chrome-command-line-switches.md index 63a6ca57366b..d8845c8ef770 100644 --- a/docs-translations/jp/api/chrome-command-line-switches.md +++ b/docs-translations/jp/api/chrome-command-line-switches.md @@ -97,10 +97,6 @@ pepper flash pluginの`version`を設定します。 ネットログイベントを保存し、`path`に書き込みを有効化します。 -## --cipher-suite-blacklist=`cipher_suites` - -無効にするために、SSL暗号スイートのカンマ区切りのリストを指定します。 - ## --disable-renderer-backgrounding 不可視のページのレンダラープロセスの優先度を下げることからChromiumを防ぎます。 diff --git a/docs-translations/ko-KR/api/chrome-command-line-switches.md b/docs-translations/ko-KR/api/chrome-command-line-switches.md index 53cd1a549646..b2178fa3633f 100644 --- a/docs-translations/ko-KR/api/chrome-command-line-switches.md +++ b/docs-translations/ko-KR/api/chrome-command-line-switches.md @@ -138,10 +138,6 @@ Pepper 플래시 플러그인의 버전을 설정합니다. Net log 이벤트를 활성화하고 `path`에 로그를 기록합니다. -## --cipher-suite-blacklist=`cipher_suites` - -SSL 암호화를 비활성화할 대상 목록을 지정합니다. (`,`로 구분) - ## --disable-renderer-backgrounding Chromium이 렌더러 프로세스의 보이지 않는 페이지의 우선순위를 낮추는 것을 방지합니다. diff --git a/docs-translations/zh-CN/api/chrome-command-line-switches.md b/docs-translations/zh-CN/api/chrome-command-line-switches.md index 782617cbf101..8bb540e44278 100644 --- a/docs-translations/zh-CN/api/chrome-command-line-switches.md +++ b/docs-translations/zh-CN/api/chrome-command-line-switches.md @@ -102,10 +102,6 @@ app.commandLine.appendSwitch('proxy-bypass-list', ';*.google.com;*foo.com 使网络日志事件能够被读写到 `path`. -## --cipher-suite-blacklist=`cipher_suites` - -指定逗号分隔的 SSL 密码套件 列表实效. - ## --disable-renderer-backgrounding 防止 Chromium 降低隐藏的渲染进程优先级. diff --git a/docs/api/chrome-command-line-switches.md b/docs/api/chrome-command-line-switches.md index 5849b24aab86..5bc1a99e9527 100644 --- a/docs/api/chrome-command-line-switches.md +++ b/docs/api/chrome-command-line-switches.md @@ -136,10 +136,6 @@ Sets the `version` of the pepper flash plugin. Enables net log events to be saved and writes them to `path`. -## --cipher-suite-blacklist=`cipher_suites` - -Specifies comma-separated list of SSL cipher suites to disable. - ## --disable-renderer-backgrounding Prevents Chromium from lowering the priority of invisible pages' renderer diff --git a/filenames.gypi b/filenames.gypi index 0f7597d09ef1..636cbb606385 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -245,8 +245,6 @@ 'atom/browser/net/atom_cookie_delegate.h', 'atom/browser/net/atom_network_delegate.cc', 'atom/browser/net/atom_network_delegate.h', - 'atom/browser/net/atom_ssl_config_service.cc', - 'atom/browser/net/atom_ssl_config_service.h', 'atom/browser/net/atom_url_request.cc', 'atom/browser/net/atom_url_request.h', 'atom/browser/net/atom_url_request_job_factory.cc', From 5162905fe451f68281001ea827ec624e237e38eb Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 14:31:45 +0900 Subject: [PATCH 24/63] Update widevine_cdm_messages.h --- chromium_src/chrome/common/widevine_cdm_messages.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chromium_src/chrome/common/widevine_cdm_messages.h b/chromium_src/chrome/common/widevine_cdm_messages.h index 919c673c5670..df5558f67a5e 100644 --- a/chromium_src/chrome/common/widevine_cdm_messages.h +++ b/chromium_src/chrome/common/widevine_cdm_messages.h @@ -7,7 +7,7 @@ #include #include "ipc/ipc_message_macros.h" -// #include "ipc/ipc_param_traits.h" +#include "ppapi/features/features.h" #define IPC_MESSAGE_START ChromeMsgStart From 5cf2873b77d89f06784db879f5f983655291f221 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 14:33:21 +0900 Subject: [PATCH 25/63] net::FtpProtocolHandler has changed its constructor --- atom/browser/api/atom_api_session.cc | 2 +- atom/browser/atom_browser_context.cc | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index 5786dd2221e5..6aa834eb8dea 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -255,7 +255,7 @@ class ResolveProxyHelper { // Start the request. int result = proxy_service->ResolveProxy( url, "GET", &proxy_info_, completion_callback, &pac_req_, nullptr, - net::BoundNetLog()); + net::NetLogWithSource()); // Completed synchronously. if (result != net::ERR_IO_PENDING) diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc index d20d653c7d93..76a23cdcda4e 100644 --- a/atom/browser/atom_browser_context.cc +++ b/atom/browser/atom_browser_context.cc @@ -155,8 +155,7 @@ AtomBrowserContext::CreateURLRequestJobFactory( url_request_context_getter()->GetURLRequestContext()->host_resolver(); job_factory->SetProtocolHandler( url::kFtpScheme, - base::WrapUnique(new net::FtpProtocolHandler( - new net::FtpNetworkLayer(host_resolver)))); + net::FtpProtocolHandler::Create(host_resolver)); return std::move(job_factory); } From 47c1bc9f666afe3b66964b79cb8fb93068c31b73 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 14:35:26 +0900 Subject: [PATCH 26/63] Update ResponsePiper --- atom/browser/net/url_request_fetch_job.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/net/url_request_fetch_job.cc b/atom/browser/net/url_request_fetch_job.cc index efca0d168464..e1d60e50cf89 100644 --- a/atom/browser/net/url_request_fetch_job.cc +++ b/atom/browser/net/url_request_fetch_job.cc @@ -64,7 +64,7 @@ class ResponsePiper : public net::URLFetcherResponseWriter { } return job_->DataAvailable(buffer, num_bytes, callback); } - int Finish(const net::CompletionCallback& callback) override { + int Finish(int net_error, const net::CompletionCallback& callback) override { return net::OK; } From 2e0780308c7ef2258422efd34c968091d7cd5b65 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 14:42:02 +0900 Subject: [PATCH 27/63] allowDisplayingInsecureContent is removed by Chrome --- atom/browser/atom_browser_client.cc | 1 - atom/browser/web_contents_preferences.cc | 3 --- docs-translations/fr-FR/tutorial/security.md | 1 - docs-translations/jp/tutorial/security.md | 1 - docs-translations/ko-KR/api/browser-window.md | 5 +---- docs-translations/ko-KR/api/webview-tag.md | 2 +- docs-translations/ko-KR/tutorial/security.md | 1 - docs-translations/pt-BR/api/browser-window.md | 3 +-- docs-translations/pt-BR/tutorial/security.md | 1 - docs-translations/zh-CN/api/browser-window.md | 4 +--- docs/api/browser-window.md | 6 ++---- docs/api/webview-tag.md | 2 +- docs/tutorial/security.md | 1 - 13 files changed, 7 insertions(+), 24 deletions(-) diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index bad2999ed6d9..d0bbf4ad535f 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -160,7 +160,6 @@ void AtomBrowserClient::OverrideWebkitPrefs( prefs->allow_universal_access_from_file_urls = true; prefs->allow_file_access_from_file_urls = true; prefs->experimental_webgl_enabled = true; - prefs->allow_displaying_insecure_content = false; prefs->allow_running_insecure_content = false; // Custom preferences of guest page. diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index 05ee1e3ffc91..5afa3070f06f 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -233,11 +233,8 @@ void WebContentsPreferences::OverrideWebkitPrefs( prefs->experimental_webgl_enabled = b; if (self->web_preferences_.GetBoolean("webSecurity", &b)) { prefs->web_security_enabled = b; - prefs->allow_displaying_insecure_content = !b; prefs->allow_running_insecure_content = !b; } - if (self->web_preferences_.GetBoolean("allowDisplayingInsecureContent", &b)) - prefs->allow_displaying_insecure_content = b; if (self->web_preferences_.GetBoolean("allowRunningInsecureContent", &b)) prefs->allow_running_insecure_content = b; const base::DictionaryValue* fonts = nullptr; diff --git a/docs-translations/fr-FR/tutorial/security.md b/docs-translations/fr-FR/tutorial/security.md index 7b228991777c..d398a07436cb 100644 --- a/docs-translations/fr-FR/tutorial/security.md +++ b/docs-translations/fr-FR/tutorial/security.md @@ -46,7 +46,6 @@ Il ne s'agit pas d'une liste exhaustive, mais au moins, pour palier aux problèm , et utiliser des règles strictes (i.e. `script-src 'self'`) * [Surcharger et désactiver `eval`](https://github.com/nylas/N1/blob/0abc5d5defcdb057120d726b271933425b75b415/static/index.js#L6-L8) , qui permet à des chaines de caractères d'être exécutées comme du code. -* Ne pas assigner `allowDisplayingInsecureContent` à true. * Ne pas assigner `allowRunningInsecureContent` à true. * Ne pas activer `experimentalFeatures` ou `experimentalCanvasFeatures` à moins d'être sûr ce que vous faites. * Ne pas utiliser `blinkFeatures` à moins d'être sûr ce que vous faites. diff --git a/docs-translations/jp/tutorial/security.md b/docs-translations/jp/tutorial/security.md index 57c47e4de734..70b84cce70f8 100644 --- a/docs-translations/jp/tutorial/security.md +++ b/docs-translations/jp/tutorial/security.md @@ -32,7 +32,6 @@ Electronは新しいバージョンのChromiumを出来るだけ早くサポー * `webSecurity`を無効にしないください。無効にすると、same-origin policyが無効になります。 * [`Content-Security-Policy`](http://www.html5rocks.com/en/tutorials/security/content-security-policy/)を定義して、スクリプトの読み込み元を制限してください。(例: `script-src 'self'`) * [`eval`を無効にしてください。](https://github.com/nylas/N1/blob/0abc5d5defcdb057120d726b271933425b75b415/static/index.js#L6) evalは文字列をコードとして実行してしまいます。 -* `allowDisplayingInsecureContent` を有効にしないでください。 * `allowRunningInsecureContent` を有効にしないでください。 * しっかり理解していない限りは`experimentalFeatures`や`experimentalCanvasFeatures`を有効にしないでください。 * しっかり理解していない限りは`blinkFeatures`を有効にしないでください。 diff --git a/docs-translations/ko-KR/api/browser-window.md b/docs-translations/ko-KR/api/browser-window.md index 106f8aad3b02..3c94b8746448 100644 --- a/docs-translations/ko-KR/api/browser-window.md +++ b/docs-translations/ko-KR/api/browser-window.md @@ -229,12 +229,9 @@ On Windows it is * `javascript` Boolean - 자바스크립트를 활성화합니다. 기본값은 `false`입니다. * `webSecurity` Boolean - `false`로 지정하면 same-origin 정책을 비활성화 합니다. (이 속성은 보통 사람들에 의해 웹 사이트를 테스트할 때 사용합니다) - 그리고 `allowDisplayingInsecureContent`와 `allowRunningInsecureContent` 두 + 그리고`allowRunningInsecureContent` 두 속성을 사용자가 `true`로 지정되지 않은 경우 `true`로 지정합니다. 기본값은 `true`입니다. - * `allowDisplayingInsecureContent` Boolean - https 페이지에서 http URL에서 - 로드한 이미지 같은 리소스를 표시할 수 있도록 허용합니다. 기본값은 `false` - 입니다. * `allowRunningInsecureContent` Boolean - https 페이지에서 http URL에서 로드한 JavaScript와 CSS 또는 플러그인을 실행시킬 수 있도록 허용합니다. 기본값은 `false`입니다. diff --git a/docs-translations/ko-KR/api/webview-tag.md b/docs-translations/ko-KR/api/webview-tag.md index ed8105ce8f88..b40dc0605b47 100644 --- a/docs-translations/ko-KR/api/webview-tag.md +++ b/docs-translations/ko-KR/api/webview-tag.md @@ -190,7 +190,7 @@ API를 사용할 수 있습니다. 이를 지정하면 내부에서 로우레벨 ### `webpreferences` ```html - + ``` 웹뷰에 설정될 웹 환경설정을 나타내는 `,` 로 구분된 문자열의 목록입니다. 지원되는 환경설정 문자열의 전체 목록은 diff --git a/docs-translations/ko-KR/tutorial/security.md b/docs-translations/ko-KR/tutorial/security.md index e13cd1e999b1..1f80bbac299e 100644 --- a/docs-translations/ko-KR/tutorial/security.md +++ b/docs-translations/ko-KR/tutorial/security.md @@ -61,7 +61,6 @@ Electron이 새로운 버전의 Chromium을 가능한 한 빠르게 지원하려 를 정의하고, 한정적인 규칙을 사용하세요 (i.e. `script-src 'self'`) * 문자열을 코드로 실행할 수 있는 [`eval`을 덮어쓰고 비활성화](https://github.com/nylas/N1/blob/0abc5d5defcdb057120d726b271933425b75b415/static/index.js#L6-L8)하세요. -* `allowDisplayingInsecureContent`를 `true`로 설정하지 마세요. * `allowRunningInsecureContent`를 `true`로 설정하지 마세요. * 무엇을 하고 있는지 확실히 알고 있지않는 이상 `experimentalFeatures` 또는 `experimentalCanvasFeatures`를 활성화하지 마세요. diff --git a/docs-translations/pt-BR/api/browser-window.md b/docs-translations/pt-BR/api/browser-window.md index f03411efaebf..8080cf5f90ab 100644 --- a/docs-translations/pt-BR/api/browser-window.md +++ b/docs-translations/pt-BR/api/browser-window.md @@ -66,9 +66,8 @@ Ela cria uma nova `BrowserWindow` com propriedades nativas definidas pelo `optio * `partition` String - Define a sessão utilizada pela página. Se `partition` começa com `persist:`, a página irá utilizar uma sessão persistente disponível para todas as páginas do aplicativo com a mesma `partition`. Se não houver o prefixo `persist:`, a página irá utilizar uma sessão em memória. Ao utilizar a mesma `partition`, várias páginas podem compartilhar a mesma sessão. Se a `partition` for indefinida, então a sessão padrão do aplicativo será utilizada. * `zoomFactor` Number - O fator de *zoom* da página, `3.0` representa `300%`. O padrão é `1.0`. * `javascript` Boolean - Habilita suporte à JavaScript. O padrão é `true`. - * `webSecurity` Boolean - Quando definido como `false`, irá desabilitar a política de mesma origem (Geralmente usando sites de teste por pessoas), e definir `allowDisplayingInsecureContent` e `allowRunningInsecureContent` como + * `webSecurity` Boolean - Quando definido como `false`, irá desabilitar a política de mesma origem (Geralmente usando sites de teste por pessoas), e definir `allowRunningInsecureContent` como `true` se estas duas opções não tiverem sido definidas pelo usuário. O padrão é `true`. - * `allowDisplayingInsecureContent` Boolean - Permite que uma página https exiba conteúdo como imagens de URLs http. O padrão é `false`. * `allowRunningInsecureContent` Boolean - Permite que uma página https rode JavaScript, CSS ou plugins de URLs http. O padrão é `false`. * `images` Boolean - Habilita suporte a imagens. O padrão é `true`. * `java` Boolean - Habilita suporte a Java. O padrão é `false`. diff --git a/docs-translations/pt-BR/tutorial/security.md b/docs-translations/pt-BR/tutorial/security.md index 8832db541930..c566756c736b 100644 --- a/docs-translations/pt-BR/tutorial/security.md +++ b/docs-translations/pt-BR/tutorial/security.md @@ -27,7 +27,6 @@ Este não é á prova de balas, mas, ao menos, você deve tentar o seguinte: * Não desative `webSecurity`. Destivá-lo irá desativar a política de mesma origem. * Definir um [`Content-Security-Policy`](http://www.html5rocks.com/en/tutorials/security/content-security-policy/), e usar regras restritivas (i.e. `script-src 'self'`) * [Substituir e desativar `eval`](https://github.com/nylas/N1/blob/0abc5d5defcdb057120d726b271933425b75b415/static/index.js#L6-L8), que permite strings para ser executadas como código. -* Não defina `allowDisplayingInsecureContent` para true. * Nao defina `allowRunningInsecureContent` para true. * Não ative `experimentalFeatures` ou `experimentalCanvasFeatures` se você não sabe o que está fazendo. * Não use `blinkFeatures` se você não sabe o que está fazendo. diff --git a/docs-translations/zh-CN/api/browser-window.md b/docs-translations/zh-CN/api/browser-window.md index e36407bc0367..9faa90850331 100644 --- a/docs-translations/zh-CN/api/browser-window.md +++ b/docs-translations/zh-CN/api/browser-window.md @@ -100,9 +100,7 @@ win.show() `300%`. 默认 `1.0`. * `javascript` Boolean - 开启javascript支持. 默认为`true`. * `webSecurity` Boolean - 当设置为 `false`, 它将禁用同源策略 (通常用来测试网站), 并且如果有2个非用户设置的参数,就设置 - `allowDisplayingInsecureContent` 和 `allowRunningInsecureContent` 的值为 - `true`. 默认为 `true`. -* `allowDisplayingInsecureContent` Boolean -允许一个使用 https的界面来展示由 http URLs 传过来的资源. 默认`false`. + `allowRunningInsecureContent` 的值为`true`. 默认为 `true`. * `allowRunningInsecureContent` Boolean - Boolean -允许一个使用 https的界面来渲染由 http URLs 提交的html,css,javascript. 默认为 `false`. * `images` Boolean - 开启图片使用支持. 默认 `true`. * `textAreasAreResizable` Boolean - textArea 可以编辑. 默认为 `true`. diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 1dbb92508a05..370902be9998 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -238,10 +238,8 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. * `javascript` Boolean (optional) - Enables JavaScript support. Default is `true`. * `webSecurity` Boolean (optional) - When `false`, it will disable the same-origin policy (usually using testing websites by people), and set - `allowDisplayingInsecureContent` and `allowRunningInsecureContent` to - `true` if these two options are not set by user. Default is `true`. - * `allowDisplayingInsecureContent` Boolean (optional) - Allow an https page to display - content like images from http URLs. Default is `false`. + `allowRunningInsecureContent` to `true` if this options has not been set + by user. Default is `true`. * `allowRunningInsecureContent` Boolean (optional) - Allow an https page to run JavaScript, CSS or plugins from http URLs. Default is `false`. * `images` Boolean (optional) - Enables image support. Default is `true`. diff --git a/docs/api/webview-tag.md b/docs/api/webview-tag.md index 4d6273948479..b0e1721ad275 100644 --- a/docs/api/webview-tag.md +++ b/docs/api/webview-tag.md @@ -203,7 +203,7 @@ windows. Popups are disabled by default. ### `webpreferences` ```html - + ``` A list of strings which specifies the web preferences to be set on the webview, separated by `,`. diff --git a/docs/tutorial/security.md b/docs/tutorial/security.md index 6962f79256aa..1af370c3f330 100644 --- a/docs/tutorial/security.md +++ b/docs/tutorial/security.md @@ -64,7 +64,6 @@ This is not bulletproof, but at the least, you should attempt the following: , and use restrictive rules (i.e. `script-src 'self'`) * [Override and disable `eval`](https://github.com/nylas/N1/blob/0abc5d5defcdb057120d726b271933425b75b415/static/index.js#L6-L8) , which allows strings to be executed as code. -* Do not set `allowDisplayingInsecureContent` to true. * Do not set `allowRunningInsecureContent` to true. * Do not enable `experimentalFeatures` or `experimentalCanvasFeatures` unless you know what you're doing. From e7f3a25626bd326292a4d3a0332f0874e79b9777 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 14:46:13 +0900 Subject: [PATCH 28/63] Update OffScreenRenderWidgetHostView --- atom/browser/osr/osr_render_widget_host_view_mac.mm | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/atom/browser/osr/osr_render_widget_host_view_mac.mm b/atom/browser/osr/osr_render_widget_host_view_mac.mm index 527a39df02f9..664261947d1d 100644 --- a/atom/browser/osr/osr_render_widget_host_view_mac.mm +++ b/atom/browser/osr/osr_render_widget_host_view_mac.mm @@ -47,16 +47,6 @@ class MacHelper : is_swap_ack, resources)); } - void BrowserCompositorMacOnLostCompositorResources() override { - view_->render_widget_host()->ScheduleComposite(); - } - - void BrowserCompositorMacUpdateVSyncParameters( - const base::TimeTicks& timebase, - const base::TimeDelta& interval) override { - view_->render_widget_host()->UpdateVSyncParameters(timebase, interval); - } - void BrowserCompositorMacSendBeginFrame( const cc::BeginFrameArgs& args) override { view_->render_widget_host()->Send( From 53bf82dd7cc336248060b14db59be793ab8cb41f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 14:47:43 +0900 Subject: [PATCH 29/63] Update URLRequestFetchJob --- atom/browser/net/url_request_fetch_job.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/atom/browser/net/url_request_fetch_job.cc b/atom/browser/net/url_request_fetch_job.cc index e1d60e50cf89..a8c13483e6a8 100644 --- a/atom/browser/net/url_request_fetch_job.cc +++ b/atom/browser/net/url_request_fetch_job.cc @@ -97,8 +97,8 @@ void URLRequestFetchJob::BeforeStartInUI( // We have to create the URLRequestContextGetter on UI thread. url_request_context_getter_ = new brightray::URLRequestContextGetter( this, nullptr, nullptr, base::FilePath(), true, - BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO), - BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE), + BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), + BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), nullptr, content::URLRequestInterceptorScopedVector()); } else { mate::Handle session; From 6d323dd6fefc27b6f111617ecdcdafda28bf3eda Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 14:48:55 +0900 Subject: [PATCH 30/63] web/WebInputEvent.h is moved to platform/WebInputEvent.h --- atom/browser/api/atom_api_web_contents.cc | 2 +- atom/common/keyboard_util.cc | 2 +- atom/common/native_mate_converters/blink_converter.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index f3a00f9a6c12..4dfc5bca7ae5 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -69,7 +69,7 @@ #include "native_mate/object_template_builder.h" #include "net/url_request/url_request_context.h" #include "third_party/WebKit/public/web/WebFindOptions.h" -#include "third_party/WebKit/public/web/WebInputEvent.h" +#include "third_party/WebKit/public/platform/WebInputEvent.h" #include "ui/display/screen.h" #if !defined(OS_MACOSX) diff --git a/atom/common/keyboard_util.cc b/atom/common/keyboard_util.cc index 541cacbcf8c1..31ed023520ab 100644 --- a/atom/common/keyboard_util.cc +++ b/atom/common/keyboard_util.cc @@ -7,7 +7,7 @@ #include "atom/common/keyboard_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" -#include "third_party/WebKit/public/web/WebInputEvent.h" +#include "third_party/WebKit/public/platform/WebInputEvent.h" #include "ui/events/event_constants.h" namespace atom { diff --git a/atom/common/native_mate_converters/blink_converter.cc b/atom/common/native_mate_converters/blink_converter.cc index 8403b2336889..7f6e67f6839a 100644 --- a/atom/common/native_mate_converters/blink_converter.cc +++ b/atom/common/native_mate_converters/blink_converter.cc @@ -16,7 +16,7 @@ #include "third_party/WebKit/public/web/WebCache.h" #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" #include "third_party/WebKit/public/web/WebFindOptions.h" -#include "third_party/WebKit/public/web/WebInputEvent.h" +#include "third_party/WebKit/public/platform/WebInputEvent.h" #include "ui/base/clipboard/clipboard.h" #include "ui/events/keycodes/dom/keycode_converter.h" #include "ui/events/keycodes/keyboard_code_conversion.h" From 5e43ea227ed148bac1503ff8f5e2f4fbc9924e5c Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 14:51:28 +0900 Subject: [PATCH 31/63] purgedSize and purgeableSize are removed by Chrome --- atom/common/native_mate_converters/blink_converter.cc | 3 --- .../ko-KR/api/structures/memory-usage-details.md | 3 --- docs-translations/ko-KR/api/web-frame.md | 5 +---- .../zh-TW/api/structures/memory-usage-details.md | 3 --- docs/api/structures/memory-usage-details.md | 3 --- docs/api/web-frame.md | 5 +---- 6 files changed, 2 insertions(+), 20 deletions(-) diff --git a/atom/common/native_mate_converters/blink_converter.cc b/atom/common/native_mate_converters/blink_converter.cc index 7f6e67f6839a..16e26da9cf29 100644 --- a/atom/common/native_mate_converters/blink_converter.cc +++ b/atom/common/native_mate_converters/blink_converter.cc @@ -445,9 +445,6 @@ v8::Local Converter::ToV8( dict.Set("count", static_cast(stat.count)); dict.Set("size", static_cast(stat.size)); dict.Set("liveSize", static_cast(stat.liveSize)); - dict.Set("decodedSize", static_cast(stat.decodedSize)); - dict.Set("purgedSize", static_cast(stat.purgedSize)); - dict.Set("purgeableSize", static_cast(stat.purgeableSize)); return dict.GetHandle(); } diff --git a/docs-translations/ko-KR/api/structures/memory-usage-details.md b/docs-translations/ko-KR/api/structures/memory-usage-details.md index 228a4452907b..d77e07dedfc2 100644 --- a/docs-translations/ko-KR/api/structures/memory-usage-details.md +++ b/docs-translations/ko-KR/api/structures/memory-usage-details.md @@ -3,6 +3,3 @@ * `count` Number * `size` Number * `liveSize` Number -* `decodedSize` Number -* `purgedSize` Number -* `purgeableSize` Number diff --git a/docs-translations/ko-KR/api/web-frame.md b/docs-translations/ko-KR/api/web-frame.md index 64b78eb13459..e901aa5e12f1 100644 --- a/docs-translations/ko-KR/api/web-frame.md +++ b/docs-translations/ko-KR/api/web-frame.md @@ -144,10 +144,7 @@ console.log(webFrame.getResourceUsage()) images: { count: 22, size: 2549, - liveSize: 2542, - decodedSize: 478, - purgedSize: 0, - purgeableSize: 0 + liveSize: 2542 }, cssStyleSheets: { /* same with "images" */ }, xslStyleSheets: { /* same with "images" */ }, diff --git a/docs-translations/zh-TW/api/structures/memory-usage-details.md b/docs-translations/zh-TW/api/structures/memory-usage-details.md index b19eb413293d..e0deb5a265b4 100644 --- a/docs-translations/zh-TW/api/structures/memory-usage-details.md +++ b/docs-translations/zh-TW/api/structures/memory-usage-details.md @@ -3,6 +3,3 @@ * `count` 數字 * `size` 數字 * `liveSize` 數字 -* `decodedSize` 數字 -* `purgedSize` 數字 -* `purgeableSize` 數字 diff --git a/docs/api/structures/memory-usage-details.md b/docs/api/structures/memory-usage-details.md index 228a4452907b..d77e07dedfc2 100644 --- a/docs/api/structures/memory-usage-details.md +++ b/docs/api/structures/memory-usage-details.md @@ -3,6 +3,3 @@ * `count` Number * `size` Number * `liveSize` Number -* `decodedSize` Number -* `purgedSize` Number -* `purgeableSize` Number diff --git a/docs/api/web-frame.md b/docs/api/web-frame.md index a8a430c7c5a2..25ae3480f938 100644 --- a/docs/api/web-frame.md +++ b/docs/api/web-frame.md @@ -167,10 +167,7 @@ This will generate: images: { count: 22, size: 2549, - liveSize: 2542, - decodedSize: 478, - purgedSize: 0, - purgeableSize: 0 + liveSize: 2542 }, cssStyleSheets: { /* same with "images" */ }, xslStyleSheets: { /* same with "images" */ }, From 6d5339b74e55f83c64cfe2990333f0a9ffa30172 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 16:45:26 +0900 Subject: [PATCH 32/63] insertText is deprecated --- atom/common/node_bindings.h | 1 + atom/renderer/api/atom_api_web_frame.cc | 6 +++++- atom/renderer/guest_view_container.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/atom/common/node_bindings.h b/atom/common/node_bindings.h index 4866ba25f060..663b0acf0779 100644 --- a/atom/common/node_bindings.h +++ b/atom/common/node_bindings.h @@ -7,6 +7,7 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" +#include "base/single_thread_task_runner.h" #include "v8/include/v8.h" #include "vendor/node/deps/uv/include/uv.h" diff --git a/atom/renderer/api/atom_api_web_frame.cc b/atom/renderer/api/atom_api_web_frame.cc index ede945a24b49..c750a455decd 100644 --- a/atom/renderer/api/atom_api_web_frame.cc +++ b/atom/renderer/api/atom_api_web_frame.cc @@ -17,6 +17,8 @@ #include "native_mate/object_template_builder.h" #include "third_party/WebKit/public/web/WebCache.h" #include "third_party/WebKit/public/web/WebDocument.h" +#include "third_party/WebKit/public/web/WebFrameWidget.h" +#include "third_party/WebKit/public/web/WebInputMethodController.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebScriptExecutionCallback.h" #include "third_party/WebKit/public/web/WebScriptSource.h" @@ -187,7 +189,9 @@ void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& scheme, } void WebFrame::InsertText(const std::string& text) { - web_frame_->insertText(blink::WebString::fromUTF8(text)); + web_frame_->frameWidget() + ->getActiveWebInputMethodController() + ->commitText(blink::WebString::fromUTF8(text), 0); } void WebFrame::InsertCSS(const std::string& css) { diff --git a/atom/renderer/guest_view_container.h b/atom/renderer/guest_view_container.h index eefec7bf74b3..81e6313358a9 100644 --- a/atom/renderer/guest_view_container.h +++ b/atom/renderer/guest_view_container.h @@ -7,6 +7,7 @@ #include "base/callback.h" #include "content/public/renderer/browser_plugin_delegate.h" +#include "content/public/renderer/render_frame.h" namespace gfx { class Size; From 4a14b172559326e3eb4f36910ee078f30b7c1c9f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 16:50:02 +0900 Subject: [PATCH 33/63] WindowOpenDisposition has become enum class --- atom/browser/api/atom_api_web_contents.cc | 28 ++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 4dfc5bca7ae5..656bea63ba63 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -130,12 +130,24 @@ struct Converter { WindowOpenDisposition val) { std::string disposition = "other"; switch (val) { - case CURRENT_TAB: disposition = "default"; break; - case NEW_FOREGROUND_TAB: disposition = "foreground-tab"; break; - case NEW_BACKGROUND_TAB: disposition = "background-tab"; break; - case NEW_POPUP: case NEW_WINDOW: disposition = "new-window"; break; - case SAVE_TO_DISK: disposition = "save-to-disk"; break; - default: break; + case WindowOpenDisposition::CURRENT_TAB: + disposition = "default"; + break; + case WindowOpenDisposition::NEW_FOREGROUND_TAB: + disposition = "foreground-tab"; + break; + case WindowOpenDisposition::NEW_BACKGROUND_TAB: + disposition = "background-tab"; + break; + case WindowOpenDisposition::NEW_POPUP: + case WindowOpenDisposition::NEW_WINDOW: + disposition = "new-window"; + break; + case WindowOpenDisposition::SAVE_TO_DISK: + disposition = "save-to-disk"; + break; + default: + break; } return mate::ConvertToV8(isolate, disposition); } @@ -431,7 +443,7 @@ void WebContents::AddNewContents(content::WebContents* source, content::WebContents* WebContents::OpenURLFromTab( content::WebContents* source, const content::OpenURLParams& params) { - if (params.disposition != CURRENT_TAB) { + if (params.disposition != WindowOpenDisposition::CURRENT_TAB) { if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) Emit("-new-window", params.url, "", params.disposition); else @@ -1080,7 +1092,7 @@ void WebContents::InspectServiceWorker() { for (const auto& agent_host : content::DevToolsAgentHost::GetOrCreateAll()) { if (agent_host->GetType() == - content::DevToolsAgentHost::TYPE_SERVICE_WORKER) { + content::DevToolsAgentHost::kTypeServiceWorker) { OpenDevTools(nullptr); managed_web_contents()->AttachTo(agent_host); break; From 8a6fd685e36285cb9e968587c673df2665d4374f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 16:57:55 +0900 Subject: [PATCH 34/63] Interface of crashpad_client.StartHandler has changed Refs: https://chromium.googlesource.com/chromium/src/+/7b9234c4b2a7f4f4fa84c80ecb22d41c54899f6a%5E%21/ --- atom/common/crash_reporter/crash_reporter_mac.mm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/atom/common/crash_reporter/crash_reporter_mac.mm b/atom/common/crash_reporter/crash_reporter_mac.mm index d5107b5edb99..cdaa5d2f52e6 100644 --- a/atom/common/crash_reporter/crash_reporter_mac.mm +++ b/atom/common/crash_reporter/crash_reporter_mac.mm @@ -44,13 +44,12 @@ void CrashReporterMac::InitBreakpad(const std::string& product_name, framework_bundle_path.Append("Resources").Append("crashpad_handler"); crashpad::CrashpadClient crashpad_client; - if (crashpad_client.StartHandler(handler_path, crashes_dir, - submit_url, - StringMap(), - std::vector(), - true)) { - crashpad_client.UseHandler(); - } + crashpad_client.StartHandler(handler_path, crashes_dir, crashes_dir, + submit_url, + StringMap(), + std::vector(), + true, + false); } // @autoreleasepool } From 411696ca1943e8dae02a9e96213918155d09c0d1 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 17:06:09 +0900 Subject: [PATCH 35/63] Clear is replaced with ClearEntriesAddedWithin --- atom/browser/api/atom_api_session.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index 6aa834eb8dea..75854caa6338 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -371,7 +371,7 @@ void ClearAuthCacheInIO( options.origin, options.realm, options.auth_scheme, net::AuthCredentials(options.username, options.password)); } else { - auth_cache->Clear(); + auth_cache->ClearEntriesAddedWithin(base::TimeDelta::Max()); } } else if (options.type == "clientCertificate") { auto client_auth_cache = network_session->ssl_client_auth_cache(); From 234e1bb81186edbee74bc7579e4d85f053334375 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 17:06:24 +0900 Subject: [PATCH 36/63] base::Bind now prevents the case with no arguments --- atom/browser/api/atom_api_session.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index 75854caa6338..45bb9c2cf3bf 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -271,6 +271,9 @@ class ResolveProxyHelper { }; // Runs the callback in UI thread. +void RunCallbackInUI(const base::Callback& callback) { + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); +} template void RunCallbackInUI(const base::Callback& callback, T... result) { BrowserThread::PostTask( From 81784827ffaf2344d679bce76811cd503e85d6db Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 17:24:19 +0900 Subject: [PATCH 37/63] PrintWebViewHelper is attached to RenderFrame --- atom/renderer/atom_renderer_client.cc | 2 +- .../atom_sandboxed_renderer_client.cc | 2 +- .../printing/print_web_view_helper.cc | 63 +++++++++---------- .../renderer/printing/print_web_view_helper.h | 15 ++--- 4 files changed, 39 insertions(+), 43 deletions(-) diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index a2500cc69904..9979aae9000b 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -257,6 +257,7 @@ void AtomRendererClient::RenderFrameCreated( new PepperHelper(render_frame); new AtomRenderFrameObserver(render_frame, this); new ContentSettingsObserver(render_frame); + new printing::PrintWebViewHelper(render_frame); // Allow file scheme to handle service worker by default. // FIXME(zcbenz): Can this be moved elsewhere? @@ -271,7 +272,6 @@ void AtomRendererClient::RenderFrameCreated( } void AtomRendererClient::RenderViewCreated(content::RenderView* render_view) { - new printing::PrintWebViewHelper(render_view); new AtomRenderViewObserver(render_view, this); blink::WebFrameWidget* web_frame_widget = render_view->GetWebFrameWidget(); diff --git a/atom/renderer/atom_sandboxed_renderer_client.cc b/atom/renderer/atom_sandboxed_renderer_client.cc index d1de0e17cd39..6c3f3e5b490a 100644 --- a/atom/renderer/atom_sandboxed_renderer_client.cc +++ b/atom/renderer/atom_sandboxed_renderer_client.cc @@ -123,11 +123,11 @@ AtomSandboxedRendererClient::~AtomSandboxedRendererClient() { void AtomSandboxedRendererClient::RenderFrameCreated( content::RenderFrame* render_frame) { new AtomSandboxedRenderFrameObserver(render_frame, this); + new printing::PrintWebViewHelper(render_frame); } void AtomSandboxedRendererClient::RenderViewCreated( content::RenderView* render_view) { - new printing::PrintWebViewHelper(render_view); new AtomSandboxedRenderViewObserver(render_view, this); } diff --git a/chromium_src/chrome/renderer/printing/print_web_view_helper.cc b/chromium_src/chrome/renderer/printing/print_web_view_helper.cc index 6fd28f6bb3af..d78d9975783a 100644 --- a/chromium_src/chrome/renderer/printing/print_web_view_helper.cc +++ b/chromium_src/chrome/renderer/printing/print_web_view_helper.cc @@ -4,6 +4,7 @@ #include "chrome/renderer/printing/print_web_view_helper.h" +#include #include #include "base/auto_reset.h" @@ -334,7 +335,7 @@ blink::WebLocalFrame* FrameReference::GetFrame() { if (view_ == NULL || frame_ == NULL) return NULL; for (blink::WebFrame* frame = view_->mainFrame(); frame != NULL; - frame = frame->traverseNext(false)) { + frame = frame->traverseNext()) { if (frame == frame_) return frame_; } @@ -353,19 +354,8 @@ float PrintWebViewHelper::RenderPageContent(blink::WebFrame* frame, double scale_factor, blink::WebCanvas* canvas) { SkAutoCanvasRestore auto_restore(canvas, true); - if (content_area != canvas_area) { - canvas->translate((content_area.x() - canvas_area.x()) / scale_factor, - (content_area.y() - canvas_area.y()) / scale_factor); - SkRect clip_rect( - SkRect::MakeXYWH(content_area.origin().x() / scale_factor, - content_area.origin().y() / scale_factor, - content_area.size().width() / scale_factor, - content_area.size().height() / scale_factor)); - SkIRect clip_int_rect; - clip_rect.roundOut(&clip_int_rect); - SkRegion clip_region(clip_int_rect); - canvas->setClipRegion(clip_region); - } + canvas->translate((content_area.x() - canvas_area.x()) / scale_factor, + (content_area.y() - canvas_area.y()) / scale_factor); return frame->printPage(page_number, canvas); } @@ -413,7 +403,7 @@ class PrepareFrameAndViewForPrint : public blink::WebViewClient, bool allowsBrokenNullLayerTreeView() const override; // blink::WebFrameClient: - blink::WebFrame* createChildFrame( + blink::WebLocalFrame* createChildFrame( blink::WebLocalFrame* parent, blink::WebTreeScopeType scope, const blink::WebString& name, @@ -491,10 +481,16 @@ void PrepareFrameAndViewForPrint::ResizeForPrinting() { if (!frame()) return; + + // Backup size and offset if it's a local frame. blink::WebView* web_view = frame_.view(); // Backup size and offset. if (blink::WebFrame* web_frame = web_view->mainFrame()) prev_scroll_offset_ = web_frame->scrollOffset(); + if (blink::WebFrame* web_frame = web_view->mainFrame()) { + if (web_frame->isWebLocalFrame()) + prev_scroll_offset_ = web_frame->scrollOffset(); + } prev_view_size_ = web_view->size(); web_view->resize(print_layout_size); @@ -562,14 +558,14 @@ void PrepareFrameAndViewForPrint::didStopLoading() { weak_ptr_factory_.GetWeakPtr())); } -blink::WebFrame* PrepareFrameAndViewForPrint::createChildFrame( +blink::WebLocalFrame* PrepareFrameAndViewForPrint::createChildFrame( blink::WebLocalFrame* parent, blink::WebTreeScopeType scope, const blink::WebString& name, const blink::WebString& unique_name, blink::WebSandboxFlags sandbox_flags, const blink::WebFrameOwnerProperties& frame_owner_properties) { - blink::WebFrame* frame = blink::WebLocalFrame::create(scope, this); + blink::WebLocalFrame* frame = blink::WebLocalFrame::create(scope, this); parent->appendChild(frame); return frame; } @@ -579,10 +575,13 @@ void PrepareFrameAndViewForPrint::CallOnReady() { } void PrepareFrameAndViewForPrint::RestoreSize() { - if (frame()) { - blink::WebView* web_view = frame_.GetFrame()->view(); - web_view->resize(prev_view_size_); - if (blink::WebFrame* web_frame = web_view->mainFrame()) + if (!frame()) + return; + + blink::WebView* web_view = frame_.GetFrame()->view(); + web_view->resize(prev_view_size_); + if (blink::WebFrame* web_frame = web_view->mainFrame()) { + if (web_frame->isWebLocalFrame()) web_frame->setScrollOffset(prev_scroll_offset_); } } @@ -609,9 +608,9 @@ void PrepareFrameAndViewForPrint::FinishPrinting() { on_ready_.Reset(); } -PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view) - : content::RenderViewObserver(render_view), - content::RenderViewObserverTracker(render_view), +PrintWebViewHelper::PrintWebViewHelper(content::RenderFrame* render_frame) + : content::RenderFrameObserver(render_frame), + content::RenderFrameObserverTracker(render_frame), reset_prep_frame_view_(false), is_print_ready_metafile_sent_(false), ignore_css_margins_(false), @@ -628,10 +627,8 @@ PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view) PrintWebViewHelper::~PrintWebViewHelper() {} // Prints |frame| which called window.print(). -void PrintWebViewHelper::PrintPage(blink::WebLocalFrame* frame, - bool user_initiated) { - DCHECK(frame); - Print(frame, blink::WebNode()); +void PrintWebViewHelper::ScriptedPrint(bool user_initiated) { + Print(render_frame()->GetWebFrame(), blink::WebNode()); } bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) { @@ -665,8 +662,7 @@ void PrintWebViewHelper::OnPrintPages(bool silent, bool print_background) { if (ipc_nesting_level_> 1) return; - blink::WebLocalFrame* frame = - render_view()->GetMainRenderFrame()->GetWebFrame(); + blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); Print(frame, blink::WebNode(), silent, print_background); } #endif // !DISABLE_BASIC_PRINTING @@ -707,8 +703,7 @@ void PrintWebViewHelper::OnPrintPreview(const base::DictionaryValue& settings) { if (ipc_nesting_level_ > 1) return; - blink::WebLocalFrame* frame = - render_view()->GetMainRenderFrame()->GetWebFrame(); + blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); print_preview_context_.InitWithFrame(frame); if (!print_preview_context_.source_frame()) { @@ -745,7 +740,7 @@ void PrintWebViewHelper::PrepareFrameForPreviewDocument() { print_params, print_preview_context_.source_frame(), print_preview_context_.source_node(), ignore_css_margins_)); prep_frame_view_->CopySelectionIfNeeded( - render_view()->GetWebkitPreferences(), + render_frame()->GetWebkitPreferences(), base::Bind(&PrintWebViewHelper::OnFramePreparedForPreviewDocument, base::Unretained(this))); } @@ -1142,7 +1137,7 @@ bool PrintWebViewHelper::RenderPagesForPrint(blink::WebLocalFrame* frame, DCHECK(!print_pages_params_->params.selection_only || print_pages_params_->pages.empty()); prep_frame_view_->CopySelectionIfNeeded( - render_view()->GetWebkitPreferences(), + render_frame()->GetWebkitPreferences(), base::Bind(&PrintWebViewHelper::OnFramePreparedForPrintPages, base::Unretained(this))); return true; diff --git a/chromium_src/chrome/renderer/printing/print_web_view_helper.h b/chromium_src/chrome/renderer/printing/print_web_view_helper.h index f91f7f3cb809..4929477a1ba2 100644 --- a/chromium_src/chrome/renderer/printing/print_web_view_helper.h +++ b/chromium_src/chrome/renderer/printing/print_web_view_helper.h @@ -13,10 +13,11 @@ #include "base/memory/shared_memory.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" -#include "content/public/renderer/render_view_observer.h" -#include "content/public/renderer/render_view_observer_tracker.h" +#include "content/public/renderer/render_frame_observer.h" +#include "content/public/renderer/render_frame_observer_tracker.h" #include "printing/pdf_metafile_skia.h" #include "third_party/WebKit/public/platform/WebCanvas.h" +#include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebNode.h" #include "third_party/WebKit/public/web/WebPrintParams.h" #include "ui/gfx/geometry/size.h" @@ -63,10 +64,10 @@ class FrameReference { // We plan on making print asynchronous and that will require copying the DOM // of the document and creating a new WebView with the contents. class PrintWebViewHelper - : public content::RenderViewObserver, - public content::RenderViewObserverTracker { + : public content::RenderFrameObserver, + public content::RenderFrameObserverTracker { public: - explicit PrintWebViewHelper(content::RenderView* render_view); + explicit PrintWebViewHelper(content::RenderFrame* render_frame); virtual ~PrintWebViewHelper(); void PrintNode(const blink::WebNode& node); @@ -91,10 +92,10 @@ class PrintWebViewHelper PREVIEW_ERROR_LAST_ENUM // Always last. }; - // RenderViewObserver implementation. + // RenderFrameObserver implementation. bool OnMessageReceived(const IPC::Message& message) override; - void PrintPage(blink::WebLocalFrame* frame, bool user_initiated) override; void OnDestruct() override; + void ScriptedPrint(bool user_initiated) override; // Message handlers --------------------------------------------------------- #if !defined(DISABLE_BASIC_PRINTING) From 676397731656b5dc3608758b8944c34ae966928e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 17:29:35 +0900 Subject: [PATCH 38/63] Update URLPattern to its latest version --- atom/browser/api/atom_api_web_request.cc | 6 +- atom/browser/net/atom_network_delegate.h | 4 +- chromium_src/extensions/common/url_pattern.cc | 174 ++++++++++-------- chromium_src/extensions/common/url_pattern.h | 30 +-- 4 files changed, 113 insertions(+), 101 deletions(-) diff --git a/atom/browser/api/atom_api_web_request.cc b/atom/browser/api/atom_api_web_request.cc index 2a39347d02ab..ff1e2254b89b 100644 --- a/atom/browser/api/atom_api_web_request.cc +++ b/atom/browser/api/atom_api_web_request.cc @@ -20,13 +20,13 @@ using content::BrowserThread; namespace mate { template<> -struct Converter { +struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, - extensions::URLPattern* out) { + URLPattern* out) { std::string pattern; if (!ConvertFromV8(isolate, val, &pattern)) return false; - return out->Parse(pattern) == extensions::URLPattern::PARSE_SUCCESS; + return out->Parse(pattern) == URLPattern::PARSE_SUCCESS; } }; diff --git a/atom/browser/net/atom_network_delegate.h b/atom/browser/net/atom_network_delegate.h index b931a480d981..7a50d6076f2f 100644 --- a/atom/browser/net/atom_network_delegate.h +++ b/atom/browser/net/atom_network_delegate.h @@ -19,13 +19,11 @@ #include "net/http/http_request_headers.h" #include "net/http/http_response_headers.h" -namespace extensions { class URLPattern; -} namespace atom { -using URLPatterns = std::set; +using URLPatterns = std::set; const char* ResourceTypeToString(content::ResourceType type); diff --git a/chromium_src/extensions/common/url_pattern.cc b/chromium_src/extensions/common/url_pattern.cc index 4303689fe81c..f7d2fb757439 100644 --- a/chromium_src/extensions/common/url_pattern.cc +++ b/chromium_src/extensions/common/url_pattern.cc @@ -4,8 +4,11 @@ #include "extensions/common/url_pattern.h" +#include + #include +#include "base/macros.h" #include "base/strings/pattern.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" @@ -17,31 +20,28 @@ #include "url/gurl.h" #include "url/url_util.h" -const char extensions::URLPattern::kAllUrlsPattern[] = ""; +const char URLPattern::kAllUrlsPattern[] = ""; const char kExtensionScheme[] = "chrome-extension"; namespace { // TODO(aa): What about more obscure schemes like data: and javascript: ? // Note: keep this array in sync with kValidSchemeMasks. -const char* kValidSchemes[] = { - url::kHttpScheme, - url::kHttpsScheme, - url::kFileScheme, - url::kFtpScheme, - content::kChromeUIScheme, - kExtensionScheme, +const char* const kValidSchemes[] = { + url::kHttpScheme, url::kHttpsScheme, + url::kFileScheme, url::kFtpScheme, + content::kChromeUIScheme, kExtensionScheme, url::kFileSystemScheme, }; const int kValidSchemeMasks[] = { - extensions::URLPattern::SCHEME_HTTP, - extensions::URLPattern::SCHEME_HTTPS, - extensions::URLPattern::SCHEME_FILE, - extensions::URLPattern::SCHEME_FTP, - extensions::URLPattern::SCHEME_CHROMEUI, - extensions::URLPattern::SCHEME_EXTENSION, - extensions::URLPattern::SCHEME_FILESYSTEM, + URLPattern::SCHEME_HTTP, + URLPattern::SCHEME_HTTPS, + URLPattern::SCHEME_FILE, + URLPattern::SCHEME_FTP, + URLPattern::SCHEME_CHROMEUI, + URLPattern::SCHEME_EXTENSION, + URLPattern::SCHEME_FILESYSTEM, }; static_assert(arraysize(kValidSchemes) == arraysize(kValidSchemeMasks), @@ -70,26 +70,26 @@ const char* const kParseResultMessages[] = { kParseErrorInvalidHost, }; -static_assert(extensions::URLPattern::NUM_PARSE_RESULTS == arraysize(kParseResultMessages), +static_assert(URLPattern::NUM_PARSE_RESULTS == arraysize(kParseResultMessages), "must add message for each parse result"); const char kPathSeparator[] = "/"; -bool IsStandardScheme(const std::string& scheme) { +bool IsStandardScheme(base::StringPiece scheme) { // "*" gets the same treatment as a standard scheme. if (scheme == "*") return true; - return url::IsStandard(scheme.c_str(), + return url::IsStandard(scheme.data(), url::Component(0, static_cast(scheme.length()))); } -bool IsValidPortForScheme(const std::string& scheme, const std::string& port) { +bool IsValidPortForScheme(base::StringPiece scheme, base::StringPiece port) { if (port == "*") return true; // Only accept non-wildcard ports if the scheme uses ports. - if (url::DefaultPortForScheme(scheme.c_str(), scheme.length()) == + if (url::DefaultPortForScheme(scheme.data(), scheme.length()) == url::PORT_UNSPECIFIED) { return false; } @@ -107,17 +107,23 @@ bool IsValidPortForScheme(const std::string& scheme, const std::string& port) { // the path will have only a single wildcard at the end. This makes figuring // out overlap much easier. It seems like there is probably a computer-sciency // way to solve the general case, but we don't need that yet. -std::string StripTrailingWildcard(const std::string& path) { - size_t wildcard_index = path.find('*'); - size_t path_last = path.size() - 1; - return wildcard_index == path_last ? path.substr(0, path_last) : path; +base::StringPiece StripTrailingWildcard(base::StringPiece path) { + if (path.ends_with("*")) + path.remove_suffix(1); + return path; +} + +// Removes trailing dot from |host_piece| if any. +base::StringPiece CanonicalizeHostForMatching(base::StringPiece host_piece) { + if (host_piece.ends_with(".")) + host_piece.remove_suffix(1); + return host_piece; } } // namespace -namespace extensions { // static -bool URLPattern::IsValidSchemeForExtensions(const std::string& scheme) { +bool URLPattern::IsValidSchemeForExtensions(base::StringPiece scheme) { for (size_t i = 0; i < arraysize(kValidSchemes); ++i) { if (scheme == kValidSchemes[i]) return true; @@ -126,7 +132,7 @@ bool URLPattern::IsValidSchemeForExtensions(const std::string& scheme) { } URLPattern::URLPattern() - : valid_schemes_(SCHEME_ALL), + : valid_schemes_(SCHEME_NONE), match_all_urls_(false), match_subdomains_(false), port_("*") {} @@ -137,7 +143,7 @@ URLPattern::URLPattern(int valid_schemes) match_subdomains_(false), port_("*") {} -URLPattern::URLPattern(int valid_schemes, const std::string& pattern) +URLPattern::URLPattern(int valid_schemes, base::StringPiece pattern) // Strict error checking is used, because this constructor is only // appropriate when we know |pattern| is valid. : valid_schemes_(valid_schemes), @@ -149,6 +155,8 @@ URLPattern::URLPattern(int valid_schemes, const std::string& pattern) NOTREACHED() << "URLPattern invalid: " << pattern << " result " << result; } +URLPattern::URLPattern(const URLPattern& other) = default; + URLPattern::~URLPattern() { } @@ -168,7 +176,7 @@ std::ostream& operator<<(std::ostream& out, const URLPattern& url_pattern) { return out << '"' << url_pattern.GetAsString() << '"'; } -URLPattern::ParseResult URLPattern::Parse(const std::string& pattern) { +URLPattern::ParseResult URLPattern::Parse(base::StringPiece pattern) { spec_.clear(); SetMatchAllURLs(false); SetMatchSubdomains(false); @@ -185,12 +193,12 @@ URLPattern::ParseResult URLPattern::Parse(const std::string& pattern) { bool has_standard_scheme_separator = true; // Some urls also use ':' alone as the scheme separator. - if (scheme_end_pos == std::string::npos) { + if (scheme_end_pos == base::StringPiece::npos) { scheme_end_pos = pattern.find(':'); has_standard_scheme_separator = false; } - if (scheme_end_pos == std::string::npos) + if (scheme_end_pos == base::StringPiece::npos) return PARSE_ERROR_MISSING_SCHEME_SEPARATOR; if (!SetScheme(pattern.substr(0, scheme_end_pos))) @@ -214,7 +222,7 @@ URLPattern::ParseResult URLPattern::Parse(const std::string& pattern) { path_start_pos = host_start_pos; } else if (scheme_ == url::kFileScheme) { size_t host_end_pos = pattern.find(kPathSeparator, host_start_pos); - if (host_end_pos == std::string::npos) { + if (host_end_pos == base::StringPiece::npos) { // Allow hostname omission. // e.g. file://* is interpreted as file:///*, // file://foo* is interpreted as file:///foo*. @@ -231,10 +239,13 @@ URLPattern::ParseResult URLPattern::Parse(const std::string& pattern) { if (host_start_pos == host_end_pos) return PARSE_ERROR_EMPTY_HOST; - if (host_end_pos == std::string::npos) + if (host_end_pos == base::StringPiece::npos) return PARSE_ERROR_EMPTY_PATH; - host_ = pattern.substr(host_start_pos, host_end_pos - host_start_pos); + // TODO(devlin): This whole series is expensive. Luckily we don't do it + // *too* often, but it could be optimized. + pattern.substr(host_start_pos, host_end_pos - host_start_pos) + .CopyToString(&host_); // The first component can optionally be '*' to match all subdomains. std::vector host_components = base::SplitString( @@ -282,9 +293,9 @@ void URLPattern::SetValidSchemes(int valid_schemes) { valid_schemes_ = valid_schemes; } -void URLPattern::SetHost(const std::string& host) { +void URLPattern::SetHost(base::StringPiece host) { spec_.clear(); - host_ = host; + host.CopyToString(&host_); } void URLPattern::SetMatchAllURLs(bool val) { @@ -304,9 +315,9 @@ void URLPattern::SetMatchSubdomains(bool val) { match_subdomains_ = val; } -bool URLPattern::SetScheme(const std::string& scheme) { +bool URLPattern::SetScheme(base::StringPiece scheme) { spec_.clear(); - scheme_ = scheme; + scheme.CopyToString(&scheme_); if (scheme_ == "*") { valid_schemes_ &= (SCHEME_HTTP | SCHEME_HTTPS); } else if (!IsValidScheme(scheme_)) { @@ -315,7 +326,7 @@ bool URLPattern::SetScheme(const std::string& scheme) { return true; } -bool URLPattern::IsValidScheme(const std::string& scheme) const { +bool URLPattern::IsValidScheme(base::StringPiece scheme) const { if (valid_schemes_ == SCHEME_ALL) return true; @@ -327,18 +338,18 @@ bool URLPattern::IsValidScheme(const std::string& scheme) const { return false; } -void URLPattern::SetPath(const std::string& path) { +void URLPattern::SetPath(base::StringPiece path) { spec_.clear(); - path_ = path; + path.CopyToString(&path_); path_escaped_ = path_; base::ReplaceSubstringsAfterOffset(&path_escaped_, 0, "\\", "\\\\"); base::ReplaceSubstringsAfterOffset(&path_escaped_, 0, "?", "\\?"); } -bool URLPattern::SetPort(const std::string& port) { +bool URLPattern::SetPort(base::StringPiece port) { spec_.clear(); if (IsValidPortForScheme(scheme_, port)) { - port_ = port; + port.CopyToString(&port_); return true; } return false; @@ -354,15 +365,17 @@ bool URLPattern::MatchesURL(const GURL& test) const { test_url = test.inner_url(); } - if (!MatchesScheme(test_url->scheme())) + if (!MatchesScheme(test_url->scheme_piece())) return false; if (match_all_urls_) return true; std::string path_for_request = test.PathForRequest(); - if (has_inner_url) - path_for_request = test_url->path() + path_for_request; + if (has_inner_url) { + path_for_request = base::StringPrintf("%s%s", test_url->path_piece().data(), + path_for_request.c_str()); + } return MatchesSecurityOriginHelper(*test_url) && MatchesPath(path_for_request); @@ -387,30 +400,33 @@ bool URLPattern::MatchesSecurityOrigin(const GURL& test) const { return MatchesSecurityOriginHelper(*test_url); } -bool URLPattern::MatchesScheme(const std::string& test) const { +bool URLPattern::MatchesScheme(base::StringPiece test) const { if (!IsValidScheme(test)) return false; return scheme_ == "*" || test == scheme_; } -bool URLPattern::MatchesHost(const std::string& host) const { - std::string test(url::kHttpScheme); - test += url::kStandardSchemeSeparator; - test += host; - test += "/"; - return MatchesHost(GURL(test)); +bool URLPattern::MatchesHost(base::StringPiece host) const { + // TODO(devlin): This is a bit sad. Parsing urls is expensive. + return MatchesHost( + GURL(base::StringPrintf("%s%s%s/", url::kHttpScheme, + url::kStandardSchemeSeparator, host.data()))); } bool URLPattern::MatchesHost(const GURL& test) const { + const base::StringPiece test_host( + CanonicalizeHostForMatching(test.host_piece())); + const base::StringPiece pattern_host(CanonicalizeHostForMatching(host_)); + // If the hosts are exactly equal, we have a match. - if (test.host() == host_) + if (test_host == pattern_host) return true; // If we're matching subdomains, and we have no host in the match pattern, // that means that we're matching all hosts, which means we have a match no // matter what the test host is. - if (match_subdomains_ && host_.empty()) + if (match_subdomains_ && pattern_host.empty()) return true; // Otherwise, we can only match if our match pattern matches subdomains. @@ -423,14 +439,13 @@ bool URLPattern::MatchesHost(const GURL& test) const { return false; // Check if the test host is a subdomain of our host. - if (test.host().length() <= (host_.length() + 1)) + if (test_host.length() <= (pattern_host.length() + 1)) return false; - if (test.host().compare(test.host().length() - host_.length(), - host_.length(), host_) != 0) + if (!test_host.ends_with(pattern_host)) return false; - return test.host()[test.host().length() - host_.length() - 1] == '.'; + return test_host[test_host.length() - pattern_host.length() - 1] == '.'; } bool URLPattern::ImpliesAllHosts() const { @@ -444,28 +459,24 @@ bool URLPattern::ImpliesAllHosts() const { if (!match_subdomains_) return false; - // If |host_| is a recognized TLD, this will be 0. We don't include private - // TLDs, so that, e.g., *.appspot.com does not imply all hosts. - size_t registry_length = net::registry_controlled_domains::GetRegistryLength( - host_, - net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, - net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); // If there was more than just a TLD in the host (e.g., *.foobar.com), it - // doesn't imply all hosts. - if (registry_length > 0) + // doesn't imply all hosts. We don't include private TLDs, so that, e.g., + // *.appspot.com does not imply all hosts. + if (net::registry_controlled_domains::HostHasRegistryControlledDomain( + host_, net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, + net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES)) return false; // At this point the host could either be just a TLD ("com") or some unknown // TLD-like string ("notatld"). To disambiguate between them construct a - // fake URL, and check the registry. This returns 0 if the TLD is - // unrecognized, or the length of the recognized TLD. - registry_length = net::registry_controlled_domains::GetRegistryLength( - base::StringPrintf("foo.%s", host_.c_str()), + // fake URL, and check the registry. + // + // If we recognized this TLD, then this is a pattern like *.com, and it + // should imply all hosts. + return net::registry_controlled_domains::HostHasRegistryControlledDomain( + "notatld." + host_, net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES, net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); - // If we recognized this TLD, then this is a pattern like *.com, and it - // should imply all hosts. Otherwise, this doesn't imply all hosts. - return registry_length > 0; } bool URLPattern::MatchesSingleOrigin() const { @@ -474,11 +485,16 @@ bool URLPattern::MatchesSingleOrigin() const { return !ImpliesAllHosts() && scheme_ != "*" && !match_subdomains_; } -bool URLPattern::MatchesPath(const std::string& test) const { +bool URLPattern::MatchesPath(base::StringPiece test) const { // Make the behaviour of OverlapsWith consistent with MatchesURL, which is // need to match hosted apps on e.g. 'google.com' also run on 'google.com/'. - if (test + "/*" == path_escaped_) + // The below if is a no-copy way of doing (test + "/*" == path_escaped_). + if (path_escaped_.length() == test.length() + 2 && + base::StartsWith(path_escaped_.c_str(), test, + base::CompareCase::SENSITIVE) && + base::EndsWith(path_escaped_, "/*", base::CompareCase::SENSITIVE)) { return true; + } return base::MatchPattern(test, path_escaped_); } @@ -516,7 +532,7 @@ const std::string& URLPattern::GetAsString() const { if (!path_.empty()) spec += path_; - spec_ = spec; + spec_ = std::move(spec); return spec_; } @@ -574,7 +590,7 @@ bool URLPattern::MatchesSecurityOriginHelper(const GURL& test) const { return true; } -bool URLPattern::MatchesPortPattern(const std::string& port) const { +bool URLPattern::MatchesPortPattern(base::StringPiece port) const { return port_ == "*" || port_ == port; } @@ -615,5 +631,3 @@ const char* URLPattern::GetParseResultString( URLPattern::ParseResult parse_result) { return kParseResultMessages[parse_result]; } - -} // namespace extensions diff --git a/chromium_src/extensions/common/url_pattern.h b/chromium_src/extensions/common/url_pattern.h index fa9b6495e317..d844a1baa4a0 100644 --- a/chromium_src/extensions/common/url_pattern.h +++ b/chromium_src/extensions/common/url_pattern.h @@ -9,9 +9,10 @@ #include #include +#include "base/strings/string_piece.h" + class GURL; -namespace extensions { // A pattern that can be used to match URLs. A URLPattern is a very restricted // subset of URL syntax: // @@ -82,15 +83,16 @@ class URLPattern { static const char kAllUrlsPattern[]; // Returns true if the given |scheme| is considered valid for extensions. - static bool IsValidSchemeForExtensions(const std::string& scheme); + static bool IsValidSchemeForExtensions(base::StringPiece scheme); explicit URLPattern(int valid_schemes); // Convenience to construct a URLPattern from a string. If the string is not // known ahead of time, use Parse() instead, which returns success or failure. - URLPattern(int valid_schemes, const std::string& pattern); + URLPattern(int valid_schemes, base::StringPiece pattern); URLPattern(); + URLPattern(const URLPattern& other); ~URLPattern(); bool operator<(const URLPattern& other) const; @@ -101,7 +103,7 @@ class URLPattern { // URLPattern::PARSE_SUCCESS on success, or an error code otherwise. On // failure, this instance will have some intermediate values and is in an // invalid state. - ParseResult Parse(const std::string& pattern_str); + ParseResult Parse(base::StringPiece pattern_str); // Gets the bitmask of valid schemes. int valid_schemes() const { return valid_schemes_; } @@ -110,7 +112,7 @@ class URLPattern { // Gets the host the pattern matches. This can be an empty string if the // pattern matches all hosts (the input was ://*/). const std::string& host() const { return host_; } - void SetHost(const std::string& host); + void SetHost(base::StringPiece host); // Gets whether to match subdomains of host(). bool match_subdomains() const { return match_subdomains_; } @@ -119,7 +121,7 @@ class URLPattern { // Gets the path the pattern matches with the leading slash. This can have // embedded asterisks which are interpreted using glob rules. const std::string& path() const { return path_; } - void SetPath(const std::string& path); + void SetPath(base::StringPiece path); // Returns true if this pattern matches all urls. bool match_all_urls() const { return match_all_urls_; } @@ -128,14 +130,14 @@ class URLPattern { // Sets the scheme for pattern matches. This can be a single '*' if the // pattern matches all valid schemes (as defined by the valid_schemes_ // property). Returns false on failure (if the scheme is not valid). - bool SetScheme(const std::string& scheme); + bool SetScheme(base::StringPiece scheme); // Note: You should use MatchesScheme() instead of this getter unless you // absolutely need the exact scheme. This is exposed for testing. const std::string& scheme() const { return scheme_; } // Returns true if the specified scheme can be used in this URL pattern, and // false otherwise. Uses valid_schemes_ to determine validity. - bool IsValidScheme(const std::string& scheme) const; + bool IsValidScheme(base::StringPiece scheme) const; // Returns true if this instance matches the specified URL. bool MatchesURL(const GURL& test) const; @@ -147,14 +149,14 @@ class URLPattern { // Note that if test is "filesystem", this may fail whereas MatchesURL // may succeed. MatchesURL is smart enough to look at the inner_url instead // of the outer "filesystem:" part. - bool MatchesScheme(const std::string& test) const; + bool MatchesScheme(base::StringPiece test) const; // Returns true if |test| matches our host. - bool MatchesHost(const std::string& test) const; + bool MatchesHost(base::StringPiece test) const; bool MatchesHost(const GURL& test) const; // Returns true if |test| matches our path. - bool MatchesPath(const std::string& test) const; + bool MatchesPath(base::StringPiece test) const; // Returns true if the pattern is vague enough that it implies all hosts, // such as *://*/*. @@ -168,7 +170,7 @@ class URLPattern { bool MatchesSingleOrigin() const; // Sets the port. Returns false if the port is invalid. - bool SetPort(const std::string& port); + bool SetPort(base::StringPiece port); const std::string& port() const { return port_; } // Returns a string representing this instance. @@ -216,7 +218,7 @@ class URLPattern { bool MatchesSecurityOriginHelper(const GURL& test) const; // Returns true if our port matches the |port| pattern (it may be "*"). - bool MatchesPortPattern(const std::string& port) const; + bool MatchesPortPattern(base::StringPiece port) const; // If the URLPattern contains a wildcard scheme, returns a list of // equivalent literal schemes, otherwise returns the current scheme. @@ -259,6 +261,4 @@ std::ostream& operator<<(std::ostream& out, const URLPattern& url_pattern); typedef std::vector URLPatternList; -} // namespace extensions - #endif // EXTENSIONS_COMMON_URL_PATTERN_H_ From eb3b77f43be4883c0d8fee5d45a25398507bbc09 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 17:31:03 +0900 Subject: [PATCH 39/63] ScopedTempDir::path is replaced with GetPath --- chromium_src/chrome/browser/process_singleton_posix.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chromium_src/chrome/browser/process_singleton_posix.cc b/chromium_src/chrome/browser/process_singleton_posix.cc index 28629ac1af60..7d5677031f40 100644 --- a/chromium_src/chrome/browser/process_singleton_posix.cc +++ b/chromium_src/chrome/browser/process_singleton_posix.cc @@ -985,16 +985,16 @@ bool ProcessSingleton::Create() { // Check that the directory was created with the correct permissions. int dir_mode = 0; - CHECK(base::GetPosixFilePermissions(socket_dir_.path(), &dir_mode) && + CHECK(base::GetPosixFilePermissions(socket_dir_.GetPath(), &dir_mode) && dir_mode == base::FILE_PERMISSION_USER_MASK) << "Temp directory mode is not 700: " << std::oct << dir_mode; // Setup the socket symlink and the two cookies. base::FilePath socket_target_path = - socket_dir_.path().Append(kSingletonSocketFilename); + socket_dir_.GetPath().Append(kSingletonSocketFilename); base::FilePath cookie(GenerateCookie()); base::FilePath remote_cookie_path = - socket_dir_.path().Append(kSingletonCookieFilename); + socket_dir_.GetPath().Append(kSingletonCookieFilename); UnlinkPath(socket_path_); UnlinkPath(cookie_path_); if (!SymlinkPath(socket_target_path, socket_path_) || From fa4b8cff45fe330591ff1f2e7236d362b62f6b03 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 17:34:45 +0900 Subject: [PATCH 40/63] Fix error due to search for openssl headers --- chromium_src/chrome/browser/ssl/security_state_tab_helper.cc | 2 ++ vendor/brightray | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/chromium_src/chrome/browser/ssl/security_state_tab_helper.cc b/chromium_src/chrome/browser/ssl/security_state_tab_helper.cc index 816bd17b8be8..81da2802ab29 100644 --- a/chromium_src/chrome/browser/ssl/security_state_tab_helper.cc +++ b/chromium_src/chrome/browser/ssl/security_state_tab_helper.cc @@ -18,7 +18,9 @@ #endif #include "components/prefs/pref_service.h" #include "components/security_state/content/content_utils.h" +#if 0 #include "components/ssl_config/ssl_config_prefs.h" +#endif #include "content/public/browser/navigation_entry.h" #include "content/public/browser/navigation_handle.h" #include "content/public/browser/render_frame_host.h" diff --git a/vendor/brightray b/vendor/brightray index d24b1b907ad3..61b927f73678 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit d24b1b907ad366dc01d4d3d5da981b6164868230 +Subproject commit 61b927f736780462169538eb2bcd2fb37d4c061b From 0a7c51b9aa33306114733536eef4ec9c2f63a5d7 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Jan 2017 17:39:18 +0900 Subject: [PATCH 41/63] Fix linking on Mac --- script/lib/config.py | 2 +- vendor/brightray | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script/lib/config.py b/script/lib/config.py index d5ec0b10ed97..ae4d4488dbd6 100644 --- a/script/lib/config.py +++ b/script/lib/config.py @@ -9,7 +9,7 @@ import sys BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \ 'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent' LIBCHROMIUMCONTENT_COMMIT = os.getenv('LIBCHROMIUMCONTENT_COMMIT') or \ - '63227c0c9299e01809bcc705bd7346aecf8b6855' + '455a133fe14b5e33ac6b4fc7f8844ace1cd0a221' PLATFORM = { 'cygwin': 'win32', diff --git a/vendor/brightray b/vendor/brightray index 61b927f73678..593011033fee 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 61b927f736780462169538eb2bcd2fb37d4c061b +Subproject commit 593011033feed39fa037fa147648cfe93a4759bf From c72438f09f7d76e26028feeefbb4b9305835ad68 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 25 Jan 2017 08:44:01 +0900 Subject: [PATCH 42/63] WebInspector has been split up --- lib/renderer/inspector.js | 3 ++- spec/api-browser-window-spec.js | 4 ++-- spec/fixtures/pages/webview-devtools.html | 4 ++-- spec/package.json | 6 ++++-- vendor/brightray | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/renderer/inspector.js b/lib/renderer/inspector.js index 81642dd6cf09..21aabbd347fb 100644 --- a/lib/renderer/inspector.js +++ b/lib/renderer/inspector.js @@ -3,7 +3,8 @@ window.onload = function () { window.InspectorFrontendHost.showContextMenuAtPoint = createMenu // Use dialog API to override file chooser dialog. - window.WebInspector.createFileSelectorElement = createFileSelectorElement + // Note: It will be moved to UI after Chrome 57. + window.Bindings.createFileSelectorElement = createFileSelectorElement } window.confirm = function (message, title) { diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 213d917ae936..81d512212c39 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -1689,8 +1689,8 @@ describe('BrowserWindow module', function () { } const showLastPanel = function () { - const lastPanelId = WebInspector.inspectorView._tabbedPane._tabs.peekLast().id - WebInspector.inspectorView.showPanel(lastPanelId) + const lastPanelId = UI.inspectorView._tabbedPane._tabs.peekLast().id + UI.inspectorView.showPanel(lastPanelId) } devToolsWebContents.executeJavaScript(`(${showLastPanel})()`, false, () => { showPanelTimeoutId = setTimeout(show, 100) diff --git a/spec/fixtures/pages/webview-devtools.html b/spec/fixtures/pages/webview-devtools.html index c16dbb2f8f14..8928c4ea7988 100644 --- a/spec/fixtures/pages/webview-devtools.html +++ b/spec/fixtures/pages/webview-devtools.html @@ -13,8 +13,8 @@ var showPanelIntevalId = setInterval(function () { if (webContents.devToolsWebContents) { webContents.devToolsWebContents.executeJavaScript('(' + (function () { - var lastPanelId = WebInspector.inspectorView._tabbedPane._tabs.peekLast().id - WebInspector.inspectorView.showPanel(lastPanelId) + var lastPanelId = UI.inspectorView._tabbedPane._tabs.peekLast().id + UI.inspectorView.showPanel(lastPanelId) }).toString() + ')()') } else { clearInterval(showPanelIntevalId) diff --git a/spec/package.json b/spec/package.json index d0829f5db394..46aa8404c679 100644 --- a/spec/package.json +++ b/spec/package.json @@ -28,8 +28,10 @@ "serviceworker": true }, "globals": [ - "WebView", - "WebInspector" + "Bindings", + "Components", + "UI", + "WebView" ] } } diff --git a/vendor/brightray b/vendor/brightray index 593011033fee..a400856b41aa 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 593011033feed39fa037fa147648cfe93a4759bf +Subproject commit a400856b41aa0485a4b43ba1714c84fef4bb06f8 From 09fcb7fb271acd71962135bb0c9126fdefe1a0f1 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 25 Jan 2017 10:44:58 +0900 Subject: [PATCH 43/63] Fix crash when using webview --- atom/browser/web_view_guest_delegate.cc | 12 ++++++++++++ atom/browser/web_view_guest_delegate.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/atom/browser/web_view_guest_delegate.cc b/atom/browser/web_view_guest_delegate.cc index 7f5a9261b93d..cfb326496355 100644 --- a/atom/browser/web_view_guest_delegate.cc +++ b/atom/browser/web_view_guest_delegate.cc @@ -151,4 +151,16 @@ gfx::Size WebViewGuestDelegate::GetDefaultSize() const { } } +bool WebViewGuestDelegate::CanBeEmbeddedInsideCrossProcessFrames() { + return true; +} + +content::RenderWidgetHost* WebViewGuestDelegate::GetOwnerRenderWidgetHost() { + return embedder_web_contents_->GetRenderViewHost()->GetWidget(); +} + +content::SiteInstance* WebViewGuestDelegate::GetOwnerSiteInstance() { + return embedder_web_contents_->GetSiteInstance(); +} + } // namespace atom diff --git a/atom/browser/web_view_guest_delegate.h b/atom/browser/web_view_guest_delegate.h index f63a46cf76ce..eade31234c2c 100644 --- a/atom/browser/web_view_guest_delegate.h +++ b/atom/browser/web_view_guest_delegate.h @@ -59,6 +59,9 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate, int element_instance_id, bool is_full_page_plugin, const base::Closure& completion_callback) final; + bool CanBeEmbeddedInsideCrossProcessFrames() override; + content::RenderWidgetHost* GetOwnerRenderWidgetHost() override; + content::SiteInstance* GetOwnerSiteInstance() override; private: // This method is invoked when the contents auto-resized to give the container From 6165d363512dbe217709bf7c5b788db2d7de62d0 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 25 Jan 2017 15:38:49 +0900 Subject: [PATCH 44/63] There is a new INSERTED type of ChangeCause For the purpose of compatibility, we treat it as "explicit". --- atom/browser/api/atom_api_cookies.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/atom/browser/api/atom_api_cookies.cc b/atom/browser/api/atom_api_cookies.cc index 117f8c88239a..ddb6910b509a 100644 --- a/atom/browser/api/atom_api_cookies.cc +++ b/atom/browser/api/atom_api_cookies.cc @@ -60,6 +60,7 @@ struct Converter { static v8::Local ToV8(v8::Isolate* isolate, const net::CookieStore::ChangeCause& val) { switch (val) { + case net::CookieStore::ChangeCause::INSERTED: case net::CookieStore::ChangeCause::EXPLICIT: return mate::StringToV8(isolate, "explicit"); case net::CookieStore::ChangeCause::OVERWRITE: From 55d4d44f02856f3f46b1eae2f719ead8b5567dac Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 26 Jan 2017 16:10:28 +0900 Subject: [PATCH 45/63] Fix Debug building on Windows --- .../osr/osr_render_widget_host_view.cc | 19 ++++------- .../browser/osr/osr_render_widget_host_view.h | 9 ++--- atom/browser/ui/drag_util_views.cc | 2 +- atom/browser/ui/file_dialog_win.cc | 19 ++++++----- atom/browser/ui/message_box_win.cc | 2 +- atom/browser/ui/views/submenu_button.cc | 33 ++++++++----------- atom/browser/ui/views/submenu_button.h | 4 +-- atom/browser/ui/win/notify_icon_host.cc | 5 ++- .../browser/printing/pdf_to_emf_converter.cc | 2 +- .../chrome/browser/printing/print_job.cc | 2 +- .../browser/ui/views/color_chooser_dialog.cc | 2 +- .../chrome/utility/printing_handler_win.cc | 27 +++++---------- common.gypi | 1 + script/lib/config.py | 2 +- vendor/brightray | 2 +- 15 files changed, 52 insertions(+), 79 deletions(-) diff --git a/atom/browser/osr/osr_render_widget_host_view.cc b/atom/browser/osr/osr_render_widget_host_view.cc index d5452a7abf36..7355f1a0c1e2 100644 --- a/atom/browser/osr/osr_render_widget_host_view.cc +++ b/atom/browser/osr/osr_render_widget_host_view.cc @@ -20,6 +20,7 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/context_factory.h" #include "content/public/browser/render_widget_host_view_frame_subscriber.h" +#include "ui/compositor/compositor.h" #include "ui/compositor/layer.h" #include "ui/compositor/layer_type.h" #include "ui/events/latency_info.h" @@ -349,14 +350,16 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView( is_showing_(!render_widget_host_->is_hidden()), size_(native_window->GetSize()), painting_(true), -#if !defined(OS_MACOSX) - delegated_frame_host_(new content::DelegatedFrameHost(this)), -#endif weak_ptr_factory_(this) { DCHECK(render_widget_host_); render_widget_host_->SetView(this); #if !defined(OS_MACOSX) + content::ImageTransportFactory* factory = + content::ImageTransportFactory::GetInstance(); + delegated_frame_host_ = base::MakeUnique( + factory->GetContextFactory()->AllocateFrameSinkId(), this); + root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); #endif @@ -743,16 +746,6 @@ OffScreenRenderWidgetHostView::DelegatedFrameHostSendReclaimCompositorResources( resources)); } -void OffScreenRenderWidgetHostView:: - DelegatedFrameHostOnLostCompositorResources() { - render_widget_host_->ScheduleComposite(); -} - -void OffScreenRenderWidgetHostView::DelegatedFrameHostUpdateVSyncParameters( - const base::TimeTicks& timebase, const base::TimeDelta& interval) { - render_widget_host_->UpdateVSyncParameters(timebase, interval); -} - void OffScreenRenderWidgetHostView::SetBeginFrameSource( cc::BeginFrameSource* source) { } diff --git a/atom/browser/osr/osr_render_widget_host_view.h b/atom/browser/osr/osr_render_widget_host_view.h index ca5dae52f9de..7380476bee6f 100644 --- a/atom/browser/osr/osr_render_widget_host_view.h +++ b/atom/browser/osr/osr_render_widget_host_view.h @@ -160,12 +160,9 @@ class OffScreenRenderWidgetHostView bool defer_compositor_lock) override; void DelegatedFrameHostResizeLockWasReleased(void) override; void DelegatedFrameHostSendReclaimCompositorResources( - int output_surface_id, - bool is_swap_ack, - const cc::ReturnedResourceArray& resources) override; - void DelegatedFrameHostOnLostCompositorResources(void) override; - void DelegatedFrameHostUpdateVSyncParameters( - const base::TimeTicks &, const base::TimeDelta &) override; + int output_surface_id, + bool is_swap_ack, + const cc::ReturnedResourceArray& resources) override; void SetBeginFrameSource(cc::BeginFrameSource* source) override; #endif // !defined(OS_MACOSX) diff --git a/atom/browser/ui/drag_util_views.cc b/atom/browser/ui/drag_util_views.cc index 058aed443c1c..2c7857412ae3 100644 --- a/atom/browser/ui/drag_util_views.cc +++ b/atom/browser/ui/drag_util_views.cc @@ -12,7 +12,7 @@ #include "ui/display/screen.h" #include "ui/gfx/geometry/point.h" #include "ui/views/widget/widget.h" -#include "ui/wm/public/drag_drop_client.h" +#include "ui/aura/client/drag_drop_client.h" namespace atom { diff --git a/atom/browser/ui/file_dialog_win.cc b/atom/browser/ui/file_dialog_win.cc index cab4e2140184..8e973432f5af 100644 --- a/atom/browser/ui/file_dialog_win.cc +++ b/atom/browser/ui/file_dialog_win.cc @@ -18,6 +18,7 @@ #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/threading/thread.h" +#include "base/threading/thread_task_runner_handle.h" #include "base/win/registry.h" #include "third_party/wtl/include/atlapp.h" #include "third_party/wtl/include/atldlgs.h" @@ -143,7 +144,7 @@ class FileDialog { struct RunState { base::Thread* dialog_thread; - base::MessageLoop* ui_message_loop; + scoped_refptr ui_task_runner; }; bool CreateDialogThread(RunState* run_state) { @@ -154,7 +155,7 @@ bool CreateDialogThread(RunState* run_state) { return false; run_state->dialog_thread = thread.release(); - run_state->ui_message_loop = base::MessageLoop::current(); + run_state->ui_task_runner = base::ThreadTaskRunnerHandle::Get(); return true; } @@ -169,9 +170,9 @@ void RunOpenDialogInNewThread(const RunState& run_state, std::vector paths; bool result = ShowOpenDialog(parent, title, button_label, default_path, filters, properties, &paths); - run_state.ui_message_loop->PostTask(FROM_HERE, + run_state.ui_task_runner->PostTask(FROM_HERE, base::Bind(callback, result, paths)); - run_state.ui_message_loop->DeleteSoon(FROM_HERE, run_state.dialog_thread); + run_state.ui_task_runner->DeleteSoon(FROM_HERE, run_state.dialog_thread); } void RunSaveDialogInNewThread(const RunState& run_state, @@ -184,9 +185,9 @@ void RunSaveDialogInNewThread(const RunState& run_state, base::FilePath path; bool result = ShowSaveDialog(parent, title, button_label, default_path, filters, &path); - run_state.ui_message_loop->PostTask(FROM_HERE, - base::Bind(callback, result, path)); - run_state.ui_message_loop->DeleteSoon(FROM_HERE, run_state.dialog_thread); + run_state.ui_task_runner->PostTask(FROM_HERE, + base::Bind(callback, result, path)); + run_state.ui_task_runner->DeleteSoon(FROM_HERE, run_state.dialog_thread); } } // namespace @@ -256,7 +257,7 @@ void ShowOpenDialog(atom::NativeWindow* parent, return; } - run_state.dialog_thread->message_loop()->PostTask( + run_state.dialog_thread->task_runner()->PostTask( FROM_HERE, base::Bind(&RunOpenDialogInNewThread, run_state, parent, title, button_label, default_path, filters, properties, callback)); @@ -295,7 +296,7 @@ void ShowSaveDialog(atom::NativeWindow* parent, return; } - run_state.dialog_thread->message_loop()->PostTask( + run_state.dialog_thread->task_runner()->PostTask( FROM_HERE, base::Bind(&RunSaveDialogInNewThread, run_state, parent, title, button_label, default_path, filters, callback)); diff --git a/atom/browser/ui/message_box_win.cc b/atom/browser/ui/message_box_win.cc index 074e13bad232..b6777fb1da23 100644 --- a/atom/browser/ui/message_box_win.cc +++ b/atom/browser/ui/message_box_win.cc @@ -233,7 +233,7 @@ void ShowMessageBox(NativeWindow* parent, } base::Thread* unretained = thread.release(); - unretained->message_loop()->PostTask( + unretained->task_runner()->PostTask( FROM_HERE, base::Bind(&RunMessageBoxInNewThread, base::Unretained(unretained), parent, type, buttons, default_id, cancel_id, options, title, diff --git a/atom/browser/ui/views/submenu_button.cc b/atom/browser/ui/views/submenu_button.cc index f8257b002749..d2a4cb60cc20 100644 --- a/atom/browser/ui/views/submenu_button.cc +++ b/atom/browser/ui/views/submenu_button.cc @@ -10,6 +10,7 @@ #include "ui/gfx/color_utils.h" #include "ui/gfx/text_utils.h" #include "ui/views/animation/flood_fill_ink_drop_ripple.h" +#include "ui/views/animation/ink_drop_impl.h" #include "ui/views/animation/ink_drop_host_view.h" #include "ui/views/controls/button/label_button_border.h" @@ -59,28 +60,20 @@ SubmenuButton::~SubmenuButton() { std::unique_ptr SubmenuButton::CreateInkDropRipple() const { - return base::MakeUnique( - GetLocalBounds(), - GetInkDropCenterBasedOnLastEvent(), - GetInkDropBaseColor(), - ink_drop_visible_opacity()); + std::unique_ptr ripple( + new views::FloodFillInkDropRipple( + size(), + GetInkDropCenterBasedOnLastEvent(), + GetInkDropBaseColor(), + ink_drop_visible_opacity())); + return ripple; } -std::unique_ptr - SubmenuButton::CreateInkDropHighlight() const { - if (!ShouldShowInkDropHighlight()) - return nullptr; - - gfx::Size size = GetLocalBounds().size(); - return base::MakeUnique( - size, - kInkDropSmallCornerRadius, - gfx::RectF(gfx::SizeF(size)).CenterPoint(), - GetInkDropBaseColor()); -} - -bool SubmenuButton::ShouldShowInkDropForFocus() const { - return false; +std::unique_ptr SubmenuButton::CreateInkDrop() { + std::unique_ptr ink_drop = + CustomButton::CreateDefaultInkDropImpl(); + ink_drop->SetShowHighlightOnHover(false); + return std::move(ink_drop); } void SubmenuButton::SetAcceleratorVisibility(bool visible) { diff --git a/atom/browser/ui/views/submenu_button.h b/atom/browser/ui/views/submenu_button.h index 02e25cd0deb5..901234fdf54c 100644 --- a/atom/browser/ui/views/submenu_button.h +++ b/atom/browser/ui/views/submenu_button.h @@ -31,9 +31,7 @@ class SubmenuButton : public views::MenuButton { // views::InkDropHostView: std::unique_ptr CreateInkDropRipple() const override; - std::unique_ptr CreateInkDropHighlight() - const override; - bool ShouldShowInkDropForFocus() const override; + std::unique_ptr CreateInkDrop() override; private: bool GetUnderlinePosition(const base::string16& text, diff --git a/atom/browser/ui/win/notify_icon_host.cc b/atom/browser/ui/win/notify_icon_host.cc index d63df9097b00..ee5c8bab0931 100644 --- a/atom/browser/ui/win/notify_icon_host.cc +++ b/atom/browser/ui/win/notify_icon_host.cc @@ -86,9 +86,8 @@ NotifyIconHost::~NotifyIconHost() { if (atom_) UnregisterClass(MAKEINTATOM(atom_), instance_); - NotifyIcons copied_container(notify_icons_); - base::STLDeleteContainerPointers( - copied_container.begin(), copied_container.end()); + for (NotifyIcon* ptr : notify_icons_) + delete ptr; } NotifyIcon* NotifyIconHost::CreateNotifyIcon() { diff --git a/chromium_src/chrome/browser/printing/pdf_to_emf_converter.cc b/chromium_src/chrome/browser/printing/pdf_to_emf_converter.cc index 17c379631abe..503d192feec5 100644 --- a/chromium_src/chrome/browser/printing/pdf_to_emf_converter.cc +++ b/chromium_src/chrome/browser/printing/pdf_to_emf_converter.cc @@ -38,7 +38,7 @@ class RefCountedTempDir public: RefCountedTempDir() { ignore_result(temp_dir_.CreateUniqueTempDir()); } bool IsValid() const { return temp_dir_.IsValid(); } - const base::FilePath& GetPath() const { return temp_dir_.path(); } + const base::FilePath& GetPath() const { return temp_dir_.GetPath(); } private: friend struct BrowserThread::DeleteOnThread; diff --git a/chromium_src/chrome/browser/printing/print_job.cc b/chromium_src/chrome/browser/printing/print_job.cc index 1707a6f684a7..5dce9ccdc55d 100644 --- a/chromium_src/chrome/browser/printing/print_job.cc +++ b/chromium_src/chrome/browser/printing/print_job.cc @@ -418,7 +418,7 @@ void PrintJob::ControlledWorkerShutdown() { // Delay shutdown until the worker terminates. We want this code path // to wait on the thread to quit before continuing. if (worker_->IsRunning()) { - base::MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::Bind(&PrintJob::ControlledWorkerShutdown, this), base::TimeDelta::FromMilliseconds(100)); diff --git a/chromium_src/chrome/browser/ui/views/color_chooser_dialog.cc b/chromium_src/chrome/browser/ui/views/color_chooser_dialog.cc index 347f1043aac1..5c7882b1fc1d 100644 --- a/chromium_src/chrome/browser/ui/views/color_chooser_dialog.cc +++ b/chromium_src/chrome/browser/ui/views/color_chooser_dialog.cc @@ -36,7 +36,7 @@ ColorChooserDialog::ColorChooserDialog(views::ColorChooserListener* listener, HWND owning_hwnd = views::HWNDForNativeWindow(owning_window); ExecuteOpenParams execute_params(initial_color, BeginRun(owning_hwnd), owning_hwnd); - execute_params.run_state.dialog_thread->message_loop()->PostTask(FROM_HERE, + execute_params.run_state.dialog_thread->task_runner()->PostTask(FROM_HERE, base::Bind(&ColorChooserDialog::ExecuteOpen, this, execute_params)); } diff --git a/chromium_src/chrome/utility/printing_handler_win.cc b/chromium_src/chrome/utility/printing_handler_win.cc index 105e574f7358..c29dd5f9f694 100644 --- a/chromium_src/chrome/utility/printing_handler_win.cc +++ b/chromium_src/chrome/utility/printing_handler_win.cc @@ -105,30 +105,21 @@ bool PrintingHandlerWin::RenderPdfPageToMetafile(int page_number, // original coordinates and we'll be able to print in full resolution. // Before playback we'll need to counter the scaling up that will happen // in the service (print_system_win.cc). - *scale_factor = - gfx::CalculatePageScale(metafile.context(), - pdf_rendering_settings_.area().right(), - pdf_rendering_settings_.area().bottom()); + *scale_factor = gfx::CalculatePageScale( + metafile.context(), pdf_rendering_settings_.area.right(), + pdf_rendering_settings_.area.bottom()); gfx::ScaleDC(metafile.context(), *scale_factor); // The underlying metafile is of type Emf and ignores the arguments passed // to StartPage. metafile.StartPage(gfx::Size(), gfx::Rect(), 1); if (!chrome_pdf::RenderPDFPageToDC( - &pdf_data_.front(), - pdf_data_.size(), - page_number, - metafile.context(), - pdf_rendering_settings_.dpi(), - pdf_rendering_settings_.area().x(), - pdf_rendering_settings_.area().y(), - pdf_rendering_settings_.area().width(), - pdf_rendering_settings_.area().height(), - true, - false, - true, - true, - pdf_rendering_settings_.autorotate())) { + &pdf_data_.front(), pdf_data_.size(), page_number, metafile.context(), + pdf_rendering_settings_.dpi, pdf_rendering_settings_.area.x(), + pdf_rendering_settings_.area.y(), + pdf_rendering_settings_.area.width(), + pdf_rendering_settings_.area.height(), true, false, true, true, + pdf_rendering_settings_.autorotate)) { return false; } metafile.FinishPage(); diff --git a/common.gypi b/common.gypi index 58c0854052ce..21685f116aea 100644 --- a/common.gypi +++ b/common.gypi @@ -277,6 +277,7 @@ 'msvs_disabled_warnings': [ 4005, # (node.h) macro redefinition 4091, # (node_extern.h) '__declspec(dllimport)' : ignored on left of 'node::Environment' when no variable is declared + 4099, # (pdf_render_settings.h) type name first seen using 'class' now seen using 'struct' 4189, # local variable is initialized but not referenced 4201, # (uv.h) nameless struct/union 4267, # conversion from 'size_t' to 'int', possible loss of data diff --git a/script/lib/config.py b/script/lib/config.py index ae4d4488dbd6..6cfffc776087 100644 --- a/script/lib/config.py +++ b/script/lib/config.py @@ -9,7 +9,7 @@ import sys BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \ 'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent' LIBCHROMIUMCONTENT_COMMIT = os.getenv('LIBCHROMIUMCONTENT_COMMIT') or \ - '455a133fe14b5e33ac6b4fc7f8844ace1cd0a221' + 'b71afafe59998daf0cb275b50140378b8c88b101' PLATFORM = { 'cygwin': 'win32', diff --git a/vendor/brightray b/vendor/brightray index a400856b41aa..51b4ff84b282 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit a400856b41aa0485a4b43ba1714c84fef4bb06f8 +Subproject commit 51b4ff84b282d11d559a425253845f850bf3279b From 820c0827c0695bfa87614fb071a884b4b7257055 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 26 Jan 2017 16:21:26 +0900 Subject: [PATCH 46/63] Fix cpplint warnings --- atom/browser/api/atom_api_web_contents.cc | 2 +- atom/browser/ui/drag_util_views.cc | 2 +- atom/browser/ui/views/submenu_button.cc | 2 +- atom/common/native_mate_converters/blink_converter.cc | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 656bea63ba63..1ecec4d0bea9 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -68,8 +68,8 @@ #include "native_mate/dictionary.h" #include "native_mate/object_template_builder.h" #include "net/url_request/url_request_context.h" -#include "third_party/WebKit/public/web/WebFindOptions.h" #include "third_party/WebKit/public/platform/WebInputEvent.h" +#include "third_party/WebKit/public/web/WebFindOptions.h" #include "ui/display/screen.h" #if !defined(OS_MACOSX) diff --git a/atom/browser/ui/drag_util_views.cc b/atom/browser/ui/drag_util_views.cc index 2c7857412ae3..b7215e5dd48e 100644 --- a/atom/browser/ui/drag_util_views.cc +++ b/atom/browser/ui/drag_util_views.cc @@ -4,6 +4,7 @@ #include "atom/browser/ui/drag_util.h" +#include "ui/aura/client/drag_drop_client.h" #include "ui/aura/window.h" #include "ui/base/dragdrop/drag_drop_types.h" #include "ui/base/dragdrop/drag_utils.h" @@ -12,7 +13,6 @@ #include "ui/display/screen.h" #include "ui/gfx/geometry/point.h" #include "ui/views/widget/widget.h" -#include "ui/aura/client/drag_drop_client.h" namespace atom { diff --git a/atom/browser/ui/views/submenu_button.cc b/atom/browser/ui/views/submenu_button.cc index d2a4cb60cc20..b398d84deec8 100644 --- a/atom/browser/ui/views/submenu_button.cc +++ b/atom/browser/ui/views/submenu_button.cc @@ -10,8 +10,8 @@ #include "ui/gfx/color_utils.h" #include "ui/gfx/text_utils.h" #include "ui/views/animation/flood_fill_ink_drop_ripple.h" -#include "ui/views/animation/ink_drop_impl.h" #include "ui/views/animation/ink_drop_host_view.h" +#include "ui/views/animation/ink_drop_impl.h" #include "ui/views/controls/button/label_button_border.h" namespace atom { diff --git a/atom/common/native_mate_converters/blink_converter.cc b/atom/common/native_mate_converters/blink_converter.cc index 16e26da9cf29..d4ee1e448915 100644 --- a/atom/common/native_mate_converters/blink_converter.cc +++ b/atom/common/native_mate_converters/blink_converter.cc @@ -13,10 +13,10 @@ #include "base/strings/utf_string_conversions.h" #include "content/public/browser/native_web_keyboard_event.h" #include "native_mate/dictionary.h" +#include "third_party/WebKit/public/platform/WebInputEvent.h" #include "third_party/WebKit/public/web/WebCache.h" #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" #include "third_party/WebKit/public/web/WebFindOptions.h" -#include "third_party/WebKit/public/platform/WebInputEvent.h" #include "ui/base/clipboard/clipboard.h" #include "ui/events/keycodes/dom/keycode_converter.h" #include "ui/events/keycodes/keyboard_code_conversion.h" From be29ea4dada68db1b4f29cf41bfa9ad18c41a3ed Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 26 Jan 2017 19:55:19 +0900 Subject: [PATCH 47/63] libgtk2ui => libgtkui --- atom/browser/atom_browser_main_parts.cc | 4 ++-- atom/browser/browser_linux.cc | 2 +- atom/browser/common_web_contents_delegate.cc | 6 ++++-- atom/browser/native_window_views.cc | 2 +- atom/browser/ui/file_dialog_gtk.cc | 8 ++++---- atom/browser/ui/message_box_gtk.cc | 12 ++++++------ atom/browser/ui/tray_icon_gtk.cc | 10 +++++----- atom/browser/ui/views/menu_bar.cc | 12 ++++++------ atom/common/chrome_version.h | 2 +- script/lib/config.py | 2 +- vendor/brightray | 2 +- 11 files changed, 32 insertions(+), 30 deletions(-) diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index 1507a976fdb9..e386e678a47c 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -24,7 +24,7 @@ #include "v8/include/v8-debug.h" #if defined(USE_X11) -#include "chrome/browser/ui/libgtk2ui/gtk2_util.h" +#include "chrome/browser/ui/libgtkui/gtk_util.h" #include "ui/events/devices/x11/touch_factory_x11.h" #endif @@ -170,7 +170,7 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() { bridge_task_runner_ = nullptr; #if defined(USE_X11) - libgtk2ui::GtkInitFromCommandLine(*base::CommandLine::ForCurrentProcess()); + libgtkui::GtkInitFromCommandLine(*base::CommandLine::ForCurrentProcess()); #endif #if !defined(OS_MACOSX) diff --git a/atom/browser/browser_linux.cc b/atom/browser/browser_linux.cc index 1adf992aec13..6abfcf5c3481 100644 --- a/atom/browser/browser_linux.cc +++ b/atom/browser/browser_linux.cc @@ -10,7 +10,7 @@ #include "atom/browser/window_list.h" #include "atom/common/atom_version.h" #include "brightray/common/application_info.h" -#include "chrome/browser/ui/libgtk2ui/unity_service.h" +#include "chrome/browser/ui/libgtkui/unity_service.h" namespace atom { diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index ac1f9d4c494d..ed0fd5e4ba38 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -94,8 +94,10 @@ FileSystem CreateFileSystemStruct( return FileSystem(file_system_name, root_url, file_system_path); } -base::DictionaryValue* CreateFileSystemValue(const FileSystem& file_system) { - auto* file_system_value = new base::DictionaryValue(); +std::unique_ptr CreateFileSystemValue( + const FileSystem& file_system) { + std::unique_ptr file_system_value( + new base::DictionaryValue()); file_system_value->SetString("fileSystemName", file_system.file_system_name); file_system_value->SetString("rootURL", file_system.root_url); file_system_value->SetString("fileSystemPath", file_system.file_system_path); diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 16a10b3532ca..3270add58356 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -41,7 +41,7 @@ #include "atom/browser/ui/x/window_state_watcher.h" #include "atom/browser/ui/x/x_window_utils.h" #include "base/strings/string_util.h" -#include "chrome/browser/ui/libgtk2ui/unity_service.h" +#include "chrome/browser/ui/libgtkui/unity_service.h" #include "ui/base/x/x11_util.h" #include "ui/gfx/x/x11_types.h" #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" diff --git a/atom/browser/ui/file_dialog_gtk.cc b/atom/browser/ui/file_dialog_gtk.cc index b6233d2054c8..18f53eba6fbe 100644 --- a/atom/browser/ui/file_dialog_gtk.cc +++ b/atom/browser/ui/file_dialog_gtk.cc @@ -9,8 +9,8 @@ #include "base/callback.h" #include "base/files/file_util.h" #include "base/strings/string_util.h" -#include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" -#include "chrome/browser/ui/libgtk2ui/gtk2_util.h" +#include "chrome/browser/ui/libgtkui/gtk_signal.h" +#include "chrome/browser/ui/libgtkui/gtk_util.h" #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" namespace file_dialog { @@ -61,7 +61,7 @@ class FileChooserDialog { NULL); if (parent_) { parent_->SetEnabled(false); - libgtk2ui::SetGtkTransientForAura(dialog_, parent_->GetNativeWindow()); + libgtkui::SetGtkTransientForAura(dialog_, parent_->GetNativeWindow()); gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE); } @@ -109,7 +109,7 @@ class FileChooserDialog { // We need to call gtk_window_present after making the widgets visible to // make sure window gets correctly raised and gets focus. - int time = views::X11DesktopHandler::get()->wm_user_time_ms(); + int time = ui::X11EventSource::GetInstance()->GetTimestamp(); gtk_window_present_with_time(GTK_WINDOW(dialog_), time); } diff --git a/atom/browser/ui/message_box_gtk.cc b/atom/browser/ui/message_box_gtk.cc index f0ebc705b553..0717d4d06d6c 100644 --- a/atom/browser/ui/message_box_gtk.cc +++ b/atom/browser/ui/message_box_gtk.cc @@ -11,9 +11,9 @@ #include "base/callback.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" -#include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" -#include "chrome/browser/ui/libgtk2ui/gtk2_util.h" -#include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h" +#include "chrome/browser/ui/libgtkui/gtk_signal.h" +#include "chrome/browser/ui/libgtkui/gtk_util.h" +#include "chrome/browser/ui/libgtkui/skia_utils_gtk.h" #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" #define ANSI_FOREGROUND_RED "\x1b[31m" @@ -54,7 +54,7 @@ class GtkMessageBox : public NativeWindowObserver { // Set dialog's icon. if (!icon.isNull()) { - GdkPixbuf* pixbuf = libgtk2ui::GdkPixbufFromSkBitmap(*icon.bitmap()); + GdkPixbuf* pixbuf = libgtkui::GdkPixbufFromSkBitmap(*icon.bitmap()); GtkIconSource* iconsource = gtk_icon_source_new(); GtkIconSet* iconset = gtk_icon_set_new(); gtk_icon_source_set_pixbuf(iconsource, pixbuf); @@ -80,7 +80,7 @@ class GtkMessageBox : public NativeWindowObserver { if (parent_) { parent_->AddObserver(this); parent_->SetEnabled(false); - libgtk2ui::SetGtkTransientForAura(dialog_, parent_->GetNativeWindow()); + libgtkui::SetGtkTransientForAura(dialog_, parent_->GetNativeWindow()); gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE); } } @@ -126,7 +126,7 @@ class GtkMessageBox : public NativeWindowObserver { gtk_widget_show_all(dialog_); // We need to call gtk_window_present after making the widgets visible to // make sure window gets correctly raised and gets focus. - int time = views::X11DesktopHandler::get()->wm_user_time_ms(); + int time = ui::X11EventSource::GetInstance()->GetTimestamp(); gtk_window_present_with_time(GTK_WINDOW(dialog_), time); } diff --git a/atom/browser/ui/tray_icon_gtk.cc b/atom/browser/ui/tray_icon_gtk.cc index 3286a95a7c99..e1836ad68985 100644 --- a/atom/browser/ui/tray_icon_gtk.cc +++ b/atom/browser/ui/tray_icon_gtk.cc @@ -7,8 +7,8 @@ #include "atom/browser/browser.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" -#include "chrome/browser/ui/libgtk2ui/app_indicator_icon.h" -#include "chrome/browser/ui/libgtk2ui/gtk2_status_icon.h" +#include "chrome/browser/ui/libgtkui/app_indicator_icon.h" +#include "chrome/browser/ui/libgtkui/gtk_status_icon.h" #include "ui/gfx/image/image.h" namespace atom { @@ -33,15 +33,15 @@ void TrayIconGtk::SetImage(const gfx::Image& image) { } base::string16 empty; - if (libgtk2ui::AppIndicatorIcon::CouldOpen()) { + if (libgtkui::AppIndicatorIcon::CouldOpen()) { ++indicators_count; - icon_.reset(new libgtk2ui::AppIndicatorIcon( + icon_.reset(new libgtkui::AppIndicatorIcon( base::StringPrintf( "%s%d", Browser::Get()->GetName().c_str(), indicators_count), image.AsImageSkia(), empty)); } else { - icon_.reset(new libgtk2ui::Gtk2StatusIcon(image.AsImageSkia(), empty)); + icon_.reset(new libgtkui::Gtk2StatusIcon(image.AsImageSkia(), empty)); } icon_->set_delegate(this); } diff --git a/atom/browser/ui/views/menu_bar.cc b/atom/browser/ui/views/menu_bar.cc index f01edaa5b38e..5d9b7152788f 100644 --- a/atom/browser/ui/views/menu_bar.cc +++ b/atom/browser/ui/views/menu_bar.cc @@ -17,7 +17,7 @@ #if defined(OS_WIN) #include "ui/gfx/color_utils.h" #elif defined(USE_X11) -#include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h" +#include "chrome/browser/ui/libgtkui/skia_utils_gtk.h" #endif namespace atom { @@ -35,11 +35,11 @@ void GetMenuBarColor(SkColor* enabled, SkColor* disabled, SkColor* highlight, GtkWidget* menu_bar = gtk_menu_bar_new(); GtkStyle* style = gtk_rc_get_style(menu_bar); - *enabled = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_NORMAL]); - *disabled = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_INSENSITIVE]); - *highlight = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_SELECTED]); - *hover = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_PRELIGHT]); - *background = libgtk2ui::GdkColorToSkColor(style->bg[GTK_STATE_NORMAL]); + *enabled = libgtkui::GdkColorToSkColor(style->fg[GTK_STATE_NORMAL]); + *disabled = libgtkui::GdkColorToSkColor(style->fg[GTK_STATE_INSENSITIVE]); + *highlight = libgtkui::GdkColorToSkColor(style->fg[GTK_STATE_SELECTED]); + *hover = libgtkui::GdkColorToSkColor(style->fg[GTK_STATE_PRELIGHT]); + *background = libgtkui::GdkColorToSkColor(style->bg[GTK_STATE_NORMAL]); gtk_widget_destroy(menu_bar); } diff --git a/atom/common/chrome_version.h b/atom/common/chrome_version.h index 2a2a067c4301..782973f792a2 100644 --- a/atom/common/chrome_version.h +++ b/atom/common/chrome_version.h @@ -8,7 +8,7 @@ #ifndef ATOM_COMMON_CHROME_VERSION_H_ #define ATOM_COMMON_CHROME_VERSION_H_ -#define CHROME_VERSION_STRING "56.0.2924.59" +#define CHROME_VERSION_STRING "56.0.2924.67" #define CHROME_VERSION "v" CHROME_VERSION_STRING #endif // ATOM_COMMON_CHROME_VERSION_H_ diff --git a/script/lib/config.py b/script/lib/config.py index 6cfffc776087..68536a7f07cc 100644 --- a/script/lib/config.py +++ b/script/lib/config.py @@ -9,7 +9,7 @@ import sys BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \ 'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent' LIBCHROMIUMCONTENT_COMMIT = os.getenv('LIBCHROMIUMCONTENT_COMMIT') or \ - 'b71afafe59998daf0cb275b50140378b8c88b101' + '0360b49dc59dcaad80bc056c9c9678273d4200e6' PLATFORM = { 'cygwin': 'win32', diff --git a/vendor/brightray b/vendor/brightray index 51b4ff84b282..e7ef0ea4e7d4 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 51b4ff84b282d11d559a425253845f850bf3279b +Subproject commit e7ef0ea4e7d45549128d6304c2faf732daedca2d From a98e69a80dd71275353081729209bd1b56c7fab4 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 26 Jan 2017 20:07:59 +0900 Subject: [PATCH 48/63] Work around the compilation error of v8_value_converter.cc We should apply this patch in future: https://chromium.googlesource.com/chromium/src/+/0232f57400b65505a27db30b1de5e918bf2481b1%5E%21/ --- atom/common/native_mate_converters/v8_value_converter.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/common/native_mate_converters/v8_value_converter.cc b/atom/common/native_mate_converters/v8_value_converter.cc index 046e6ef8f366..a064526557f9 100644 --- a/atom/common/native_mate_converters/v8_value_converter.cc +++ b/atom/common/native_mate_converters/v8_value_converter.cc @@ -361,7 +361,7 @@ base::Value* V8ValueConverter::FromV8Array( base::Value* child = FromV8ValueImpl(state, child_v8, isolate); if (child) - result->Append(child); + result->Append(std::unique_ptr(child)); else // JSON.stringify puts null in places where values don't serialize, for // example undefined and functions. Emulate that behavior. From 41f356a94dd8569d12d6abcd8a429faddbebcac6 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 27 Jan 2017 16:02:53 +0900 Subject: [PATCH 49/63] icu's namespace has become icu_58 --- common.gypi | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/common.gypi b/common.gypi index 21685f116aea..7bd2df8b092a 100644 --- a/common.gypi +++ b/common.gypi @@ -162,32 +162,32 @@ 'conditions': [ ['target_arch=="ia32"', { 'reference_symbols': [ - '_u_errorName_56', - '_ubidi_setPara_56', - '_ucsdet_getName_56', - '_uidna_openUTS46_56', - '_ulocdata_close_56', - '_unorm_normalize_56', - '_uregex_matches_56', - '_uscript_getCode_56', - '_uspoof_open_56', - '_usearch_setPattern_56', - '?createInstance@Transliterator@icu_56@@SAPAV12@ABVUnicodeString@2@W4UTransDirection@@AAW4UErrorCode@@@Z', - '??0MeasureFormat@icu_56@@QAE@ABVLocale@1@W4UMeasureFormatWidth@@AAW4UErrorCode@@@Z', + '_u_errorName_58', + '_ubidi_setPara_58', + '_ucsdet_getName_58', + '_uidna_openUTS46_58', + '_ulocdata_close_58', + '_unorm_normalize_58', + '_uregex_matches_58', + '_uscript_getCode_58', + '_uspoof_open_58', + '_usearch_setPattern_58', + '?createInstance@Transliterator@icu_58@@SAPAV12@ABVUnicodeString@2@W4UTransDirection@@AAW4UErrorCode@@@Z', + '??0MeasureFormat@icu_58@@QAE@ABVLocale@1@W4UMeasureFormatWidth@@AAW4UErrorCode@@@Z', ], }, { 'reference_symbols': [ - 'u_errorName_56', - 'ubidi_setPara_56', - 'ucsdet_getName_56', - 'uidna_openUTS46_56', - 'ulocdata_close_56', - 'unorm_normalize_56', - 'uregex_matches_56', - 'uspoof_open_56', - 'usearch_setPattern_56', - '?createInstance@Transliterator@icu_56@@SAPEAV12@AEBVUnicodeString@2@W4UTransDirection@@AEAW4UErrorCode@@@Z', - '??0MeasureFormat@icu_56@@QEAA@AEBVLocale@1@W4UMeasureFormatWidth@@AEAW4UErrorCode@@@Z', + 'u_errorName_58', + 'ubidi_setPara_58', + 'ucsdet_getName_58', + 'uidna_openUTS46_58', + 'ulocdata_close_58', + 'unorm_normalize_58', + 'uregex_matches_58', + 'uspoof_open_58', + 'usearch_setPattern_58', + '?createInstance@Transliterator@icu_58@@SAPEAV12@AEBVUnicodeString@2@W4UTransDirection@@AEAW4UErrorCode@@@Z', + '??0MeasureFormat@icu_58@@QEAA@AEBVLocale@1@W4UMeasureFormatWidth@@AEAW4UErrorCode@@@Z', ], }], ], From 82d796ded460494285d40dcc0faa40c8bc6d1613 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 27 Jan 2017 18:51:20 +0900 Subject: [PATCH 50/63] Fix missing of symbols issue on Release build --- atom/node/osfhandle.cc | 11 +++++++++++ atom/node/osfhandle.h | 3 +++ common.gypi | 8 +++++++- script/lib/config.py | 2 +- vendor/brightray | 2 +- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/atom/node/osfhandle.cc b/atom/node/osfhandle.cc index 33403dc52371..022acf186861 100644 --- a/atom/node/osfhandle.cc +++ b/atom/node/osfhandle.cc @@ -6,6 +6,9 @@ #include +#include "v8-profiler.h" +#include "v8-inspector.h" + namespace node { int open_osfhandle(intptr_t osfhandle, int flags) { @@ -16,4 +19,12 @@ int close(int fd) { return _close(fd); } +void ReferenceSymbols() { + // Following symbols are used by electron.exe but got stripped by compiler, + // for some reason, adding them to ForceSymbolReferences does not work, + // probably because of VC++ bugs. + v8::TracingCpuProfiler::Create(nullptr); + reinterpret_cast(nullptr)->unmuteMetrics(0); +} + } // namespace node diff --git a/atom/node/osfhandle.h b/atom/node/osfhandle.h index 3933236e5091..1427bb895115 100644 --- a/atom/node/osfhandle.h +++ b/atom/node/osfhandle.h @@ -21,6 +21,9 @@ namespace node { __declspec(dllexport) int open_osfhandle(intptr_t osfhandle, int flags); __declspec(dllexport) int close(int fd); +// A trick to force referencing symbols. +__declspec(dllexport) void ReferenceSymbols(); + } // namespace node #endif // ATOM_NODE_OSFHANDLE_H_ diff --git a/common.gypi b/common.gypi index 7bd2df8b092a..ca143b1897e6 100644 --- a/common.gypi +++ b/common.gypi @@ -155,13 +155,15 @@ '-ldbghelp.lib', '-lshlwapi.lib', ], - # Fix the linking error with icu. + # Force referencing symbols of ICU and v8_inspector to make sure + # they are included in the final DLL. 'conditions': [ ['libchromiumcontent_component==0', { 'variables': { 'conditions': [ ['target_arch=="ia32"', { 'reference_symbols': [ + # ICU symbols: '_u_errorName_58', '_ubidi_setPara_58', '_ucsdet_getName_58', @@ -177,6 +179,7 @@ ], }, { 'reference_symbols': [ + # ICU symbols: 'u_errorName_58', 'ubidi_setPara_58', 'ucsdet_getName_58', @@ -188,6 +191,9 @@ 'usearch_setPattern_58', '?createInstance@Transliterator@icu_58@@SAPEAV12@AEBVUnicodeString@2@W4UTransDirection@@AEAW4UErrorCode@@@Z', '??0MeasureFormat@icu_58@@QEAA@AEBVLocale@1@W4UMeasureFormatWidth@@AEAW4UErrorCode@@@Z', + # v8_inspector symbols: + '?DOM@ReasonEnum@Paused@API@Debugger@protocol@v8_inspector@@3PEBDEB', + '?canDispatchMethod@V8InspectorSession@v8_inspector@@SA_NAEBVStringView@2@@Z', ], }], ], diff --git a/script/lib/config.py b/script/lib/config.py index 68536a7f07cc..161295d97ef5 100644 --- a/script/lib/config.py +++ b/script/lib/config.py @@ -9,7 +9,7 @@ import sys BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \ 'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent' LIBCHROMIUMCONTENT_COMMIT = os.getenv('LIBCHROMIUMCONTENT_COMMIT') or \ - '0360b49dc59dcaad80bc056c9c9678273d4200e6' + '628ae34823d133842faf8f45c2b2741e4ca74e53' PLATFORM = { 'cygwin': 'win32', diff --git a/vendor/brightray b/vendor/brightray index e7ef0ea4e7d4..280492556cfc 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit e7ef0ea4e7d45549128d6304c2faf732daedca2d +Subproject commit 280492556cfcdf56274d18bccb4f9560f43a2a91 From c69626336d8d318519c122e3b73cef395aff6c26 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 30 Jan 2017 15:31:15 +0900 Subject: [PATCH 51/63] Link with xcb on Linux --- script/install-sysroot.py | 12 ++++++------ vendor/brightray | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/script/install-sysroot.py b/script/install-sysroot.py index be68fbad0ad7..7cf2f7caab51 100755 --- a/script/install-sysroot.py +++ b/script/install-sysroot.py @@ -30,15 +30,15 @@ from lib.util import get_host_arch SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) URL_PREFIX = 'https://github.com' URL_PATH = 'atom/debian-sysroot-image-creator/releases/download' -REVISION_AMD64 = 'v0.4.0' -REVISION_I386 = 'v0.4.0' -REVISION_ARM = 'v0.4.0' +REVISION_AMD64 = 'v0.5.0' +REVISION_I386 = 'v0.5.0' +REVISION_ARM = 'v0.5.0' TARBALL_AMD64 = 'debian_wheezy_amd64_sysroot.tgz' TARBALL_I386 = 'debian_wheezy_i386_sysroot.tgz' TARBALL_ARM = 'debian_wheezy_arm_sysroot.tgz' -TARBALL_AMD64_SHA1SUM = 'a7e8faa99b681317969ac450a27233925bdeed62' -TARBALL_I386_SHA1SUM = '9fc827eddc26e562c0a0b2586be5dc075e570e10' -TARBALL_ARM_SHA1SUM = 'bfa4233708ab937d682a14e8d87ddba3cadb6eae' +TARBALL_AMD64_SHA1SUM = '981b2440d446156801c6fdecffb5edcadf27593c' +TARBALL_I386_SHA1SUM = '2e4e43c1e8718595e37c6b6ab89256dae53adf23' +TARBALL_ARM_SHA1SUM = '448e635f38e99d6d860db538a9db85ac74d36e41' SYSROOT_DIR_AMD64 = 'debian_wheezy_amd64-sysroot' SYSROOT_DIR_I386 = 'debian_wheezy_i386-sysroot' SYSROOT_DIR_ARM = 'debian_wheezy_arm-sysroot' diff --git a/vendor/brightray b/vendor/brightray index 280492556cfc..d5ac0caf9995 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 280492556cfcdf56274d18bccb4f9560f43a2a91 +Subproject commit d5ac0caf9995d7736391d9d34158d1d2f7af9de7 From 85961a0dd9b18049fff003fa05dad37174f331ce Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 30 Jan 2017 15:34:58 +0900 Subject: [PATCH 52/63] Update libchromiumcontent to fix duplicate main functions --- script/lib/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/lib/config.py b/script/lib/config.py index 161295d97ef5..5637571e3c93 100644 --- a/script/lib/config.py +++ b/script/lib/config.py @@ -9,7 +9,7 @@ import sys BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \ 'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent' LIBCHROMIUMCONTENT_COMMIT = os.getenv('LIBCHROMIUMCONTENT_COMMIT') or \ - '628ae34823d133842faf8f45c2b2741e4ca74e53' + 'd8397c07461e726caad74dfe0cfe6ec284951667' PLATFORM = { 'cygwin': 'win32', From 75627ba6ad35639a658074bdfd29fbbc4942edfd Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 31 Jan 2017 14:22:18 +0900 Subject: [PATCH 53/63] Fix sync printing not working --- atom/browser/api/atom_api_web_contents.cc | 4 +++- .../printing/print_view_manager_base.cc | 23 +++++++++++-------- .../printing/print_view_manager_base.h | 6 +++-- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 1ecec4d0bea9..9d5c8f8684d9 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -1137,7 +1137,9 @@ void WebContents::Print(mate::Arguments* args) { } printing::PrintViewManagerBasic::FromWebContents(web_contents())-> - PrintNow(settings.silent, settings.print_background); + PrintNow(web_contents()->GetMainFrame(), + settings.silent, + settings.print_background); } void WebContents::PrintToPDF(const base::DictionaryValue& setting, diff --git a/chromium_src/chrome/browser/printing/print_view_manager_base.cc b/chromium_src/chrome/browser/printing/print_view_manager_base.cc index e61cc10d5364..67caebb63ecf 100644 --- a/chromium_src/chrome/browser/printing/print_view_manager_base.cc +++ b/chromium_src/chrome/browser/printing/print_view_manager_base.cc @@ -8,6 +8,7 @@ #include "base/bind.h" #include "base/memory/ref_counted_memory.h" +#include "base/memory/ptr_util.h" #include "base/run_loop.h" #include "base/strings/utf_string_conversions.h" #include "base/timer/timer.h" @@ -25,6 +26,7 @@ #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "printing/pdf_metafile_skia.h" @@ -64,9 +66,12 @@ PrintViewManagerBase::~PrintViewManagerBase() { } #if !defined(DISABLE_BASIC_PRINTING) -bool PrintViewManagerBase::PrintNow(bool silent, bool print_background) { - return PrintNowInternal(new PrintMsg_PrintPages( - routing_id(), silent, print_background)); +bool PrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh, + bool silent, bool print_background) { + int32_t id = rfh->GetRoutingID(); + return PrintNowInternal( + rfh, + base::MakeUnique(id, silent, print_background)); } #endif // !DISABLE_BASIC_PRINTING @@ -467,13 +472,13 @@ bool PrintViewManagerBase::OpportunisticallyCreatePrintJob(int cookie) { return true; } -bool PrintViewManagerBase::PrintNowInternal(IPC::Message* message) { - // Don't print / print preview interstitials. - if (web_contents()->ShowingInterstitialPage()) { - delete message; +bool PrintViewManagerBase::PrintNowInternal( + content::RenderFrameHost* rfh, + std::unique_ptr message) { + // Don't print / print preview interstitials or crashed tabs. + if (web_contents()->ShowingInterstitialPage() || web_contents()->IsCrashed()) return false; - } - return Send(message); + return rfh->Send(message.release()); } void PrintViewManagerBase::ReleasePrinterQuery() { diff --git a/chromium_src/chrome/browser/printing/print_view_manager_base.h b/chromium_src/chrome/browser/printing/print_view_manager_base.h index 78e5729a5fb1..fbf2e2ffd022 100644 --- a/chromium_src/chrome/browser/printing/print_view_manager_base.h +++ b/chromium_src/chrome/browser/printing/print_view_manager_base.h @@ -39,7 +39,8 @@ class PrintViewManagerBase : public content::NotificationObserver, // Prints the current document immediately. Since the rendering is // asynchronous, the actual printing will not be completed on the return of // this function. Returns false if printing is impossible at the moment. - virtual bool PrintNow(bool silent, bool print_background); + virtual bool PrintNow(content::RenderFrameHost* rfh, + bool silent, bool print_background); #endif // !DISABLE_BASIC_PRINTING // PrintedPagesSource implementation. @@ -49,7 +50,8 @@ class PrintViewManagerBase : public content::NotificationObserver, explicit PrintViewManagerBase(content::WebContents* web_contents); // Helper method for Print*Now(). - bool PrintNowInternal(IPC::Message* message); + bool PrintNowInternal(content::RenderFrameHost* rfh, + std::unique_ptr message); // Terminates or cancels the print job if one was pending. virtual void RenderProcessGone(base::TerminationStatus status) override; From ab783413a211edaa504acc86b5103e8cfcd89ac1 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 31 Jan 2017 17:38:05 +0900 Subject: [PATCH 54/63] Update printing code to latest --- .../chrome/browser/printing/print_job.cc | 122 +++++----- .../chrome/browser/printing/print_job.h | 53 +++-- .../browser/printing/print_job_manager.cc | 32 +-- .../browser/printing/print_job_manager.h | 11 +- .../browser/printing/print_job_worker.cc | 115 ++++----- .../browser/printing/print_job_worker.h | 27 +-- .../printing/print_job_worker_owner.cc | 7 +- .../browser/printing/print_job_worker_owner.h | 5 +- .../printing/print_preview_message_handler.cc | 5 +- .../chrome/browser/printing/printer_query.cc | 57 ++--- .../chrome/browser/printing/printer_query.h | 31 +-- .../printing/printing_message_filter.cc | 219 +++++------------- .../printing/printing_message_filter.h | 57 ++--- chromium_src/chrome/common/print_messages.cc | 49 ++-- chromium_src/chrome/common/print_messages.h | 31 ++- .../printing/print_web_view_helper.cc | 16 +- 16 files changed, 374 insertions(+), 463 deletions(-) diff --git a/chromium_src/chrome/browser/printing/print_job.cc b/chromium_src/chrome/browser/printing/print_job.cc index 5dce9ccdc55d..70bdb9004589 100644 --- a/chromium_src/chrome/browser/printing/print_job.cc +++ b/chromium_src/chrome/browser/printing/print_job.cc @@ -4,14 +4,20 @@ #include "chrome/browser/printing/print_job.h" +#include +#include + #include "base/bind.h" #include "base/bind_helpers.h" +#include "base/location.h" +#include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/threading/thread_restrictions.h" #include "base/threading/thread_task_runner_handle.h" #include "base/threading/worker_pool.h" -#include "base/timer/timer.h" +#include "build/build_config.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/printing/print_job_worker.h" #include "content/public/browser/browser_thread.h" @@ -24,25 +30,22 @@ #include "printing/pdf_render_settings.h" #endif - using base::TimeDelta; +namespace printing { + namespace { // Helper function to ensure |owner| is valid until at least |callback| returns. -void HoldRefCallback(const scoped_refptr& owner, +void HoldRefCallback(const scoped_refptr& owner, const base::Closure& callback) { callback.Run(); } } // namespace -namespace printing { - PrintJob::PrintJob() - : source_(NULL), - worker_(), - settings_(), + : source_(nullptr), is_job_pending_(false), is_canceling_(false), quit_factory_(this) { @@ -65,12 +68,12 @@ void PrintJob::Initialize(PrintJobWorkerOwner* job, PrintedPagesSource* source, int page_count) { DCHECK(!source_); - DCHECK(!worker_.get()); + DCHECK(!worker_); DCHECK(!is_job_pending_); DCHECK(!is_canceling_); DCHECK(!document_.get()); source_ = source; - worker_.reset(job->DetachWorker(this)); + worker_ = job->DetachWorker(this); settings_ = job->settings(); PrintedDocument* new_doc = @@ -90,15 +93,9 @@ void PrintJob::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { DCHECK(RunsTasksOnCurrentThread()); - switch (type) { - case chrome::NOTIFICATION_PRINT_JOB_EVENT: { - OnNotifyPrintJobEvent(*content::Details(details).ptr()); - break; - } - default: { - break; - } - } + DCHECK_EQ(chrome::NOTIFICATION_PRINT_JOB_EVENT, type); + + OnNotifyPrintJobEvent(*content::Details(details).ptr()); } void PrintJob::GetSettingsDone(const PrintSettings& new_settings, @@ -106,9 +103,10 @@ void PrintJob::GetSettingsDone(const PrintSettings& new_settings, NOTREACHED(); } -PrintJobWorker* PrintJob::DetachWorker(PrintJobWorkerOwner* new_owner) { +std::unique_ptr PrintJob::DetachWorker( + PrintJobWorkerOwner* new_owner) { NOTREACHED(); - return NULL; + return nullptr; } const PrintSettings& PrintJob::settings() const { @@ -116,23 +114,22 @@ const PrintSettings& PrintJob::settings() const { } int PrintJob::cookie() const { + // Always use an invalid cookie in this case. if (!document_.get()) - // Always use an invalid cookie in this case. return 0; return document_->cookie(); } void PrintJob::StartPrinting() { DCHECK(RunsTasksOnCurrentThread()); - DCHECK(worker_->IsRunning()); - DCHECK(!is_job_pending_); - if (!worker_->IsRunning() || is_job_pending_) + if (!worker_->IsRunning() || is_job_pending_) { + NOTREACHED(); return; + } // Real work is done in PrintJobWorker::StartPrinting(). worker_->PostTask(FROM_HERE, - base::Bind(&HoldRefCallback, - make_scoped_refptr(this), + base::Bind(&HoldRefCallback, make_scoped_refptr(this), base::Bind(&PrintJobWorker::StartPrinting, base::Unretained(worker_.get()), base::RetainedRef(document_)))); @@ -141,7 +138,7 @@ void PrintJob::StartPrinting() { // Tell everyone! scoped_refptr details( - new JobEventDetails(JobEventDetails::NEW_DOC, document_.get(), NULL)); + new JobEventDetails(JobEventDetails::NEW_DOC, document_.get(), nullptr)); content::NotificationService::current()->Notify( chrome::NOTIFICATION_PRINT_JOB_EVENT, content::Source(this), @@ -165,7 +162,8 @@ void PrintJob::Stop() { ControlledWorkerShutdown(); } else { // Flush the cached document. - UpdatePrintedDocument(NULL); + is_job_pending_ = false; + UpdatePrintedDocument(nullptr); } } @@ -185,7 +183,7 @@ void PrintJob::Cancel() { } // Make sure a Cancel() is broadcast. scoped_refptr details( - new JobEventDetails(JobEventDetails::FAILED, NULL, NULL)); + new JobEventDetails(JobEventDetails::FAILED, nullptr, nullptr)); content::NotificationService::current()->Notify( chrome::NOTIFICATION_PRINT_JOB_EVENT, content::Source(this), @@ -210,7 +208,7 @@ bool PrintJob::FlushJob(base::TimeDelta timeout) { } void PrintJob::DisconnectSource() { - source_ = NULL; + source_ = nullptr; if (document_.get()) document_->DisconnectSource(); } @@ -237,8 +235,10 @@ class PrintJob::PdfToEmfState { void Start(const scoped_refptr& data, const PdfRenderSettings& conversion_settings, + bool print_text_with_gdi, const PdfToEmfConverter::StartCallback& start_callback) { - converter_->Start(data, conversion_settings, start_callback); + converter_->Start(data, conversion_settings, print_text_with_gdi, + start_callback); } void GetMorePages( @@ -273,48 +273,51 @@ class PrintJob::PdfToEmfState { std::unique_ptr converter_; }; +void PrintJob::AppendPrintedPage(int page_number) { + pdf_page_mapping_.push_back(page_number); +} + void PrintJob::StartPdfToEmfConversion( const scoped_refptr& bytes, const gfx::Size& page_size, - const gfx::Rect& content_area) { - DCHECK(!ptd_to_emf_state_.get()); - ptd_to_emf_state_.reset(new PdfToEmfState(page_size, content_area)); + const gfx::Rect& content_area, + bool print_text_with_gdi) { + DCHECK(!pdf_to_emf_state_); + pdf_to_emf_state_ = base::MakeUnique(page_size, content_area); const int kPrinterDpi = settings().dpi(); - ptd_to_emf_state_->Start( - bytes, - printing::PdfRenderSettings(content_area, kPrinterDpi, true), - base::Bind(&PrintJob::OnPdfToEmfStarted, this)); + pdf_to_emf_state_->Start( + bytes, PdfRenderSettings(content_area, kPrinterDpi, true), + print_text_with_gdi, base::Bind(&PrintJob::OnPdfToEmfStarted, this)); } void PrintJob::OnPdfToEmfStarted(int page_count) { if (page_count <= 0) { - ptd_to_emf_state_.reset(); + pdf_to_emf_state_.reset(); Cancel(); return; } - ptd_to_emf_state_->set_page_count(page_count); - ptd_to_emf_state_->GetMorePages( + pdf_to_emf_state_->set_page_count(page_count); + pdf_to_emf_state_->GetMorePages( base::Bind(&PrintJob::OnPdfToEmfPageConverted, this)); } void PrintJob::OnPdfToEmfPageConverted(int page_number, float scale_factor, std::unique_ptr emf) { - DCHECK(ptd_to_emf_state_); - if (!document_.get() || !emf) { - ptd_to_emf_state_.reset(); + DCHECK(pdf_to_emf_state_); + if (!document_.get() || !emf || page_number < 0 || + static_cast(page_number) >= pdf_page_mapping_.size()) { + pdf_to_emf_state_.reset(); Cancel(); return; } // Update the rendered document. It will send notifications to the listener. - document_->SetPage(page_number, - std::move(emf), - scale_factor, - ptd_to_emf_state_->page_size(), - ptd_to_emf_state_->content_area()); + document_->SetPage(pdf_page_mapping_[page_number], std::move(emf), + scale_factor, pdf_to_emf_state_->page_size(), + pdf_to_emf_state_->content_area()); - ptd_to_emf_state_->GetMorePages( + pdf_to_emf_state_->GetMorePages( base::Bind(&PrintJob::OnPdfToEmfPageConverted, this)); } @@ -326,16 +329,14 @@ void PrintJob::UpdatePrintedDocument(PrintedDocument* new_document) { document_ = new_document; - if (document_.get()) { + if (document_.get()) settings_ = document_->settings(); - } if (worker_) { DCHECK(!is_job_pending_); // Sync the document with the worker. worker_->PostTask(FROM_HERE, - base::Bind(&HoldRefCallback, - make_scoped_refptr(this), + base::Bind(&HoldRefCallback, make_scoped_refptr(this), base::Bind(&PrintJobWorker::OnDocumentChanged, base::Unretained(worker_.get()), base::RetainedRef(document_)))); @@ -371,9 +372,9 @@ void PrintJob::OnNotifyPrintJobEvent(const JobEventDetails& event_details) { } case JobEventDetails::PAGE_DONE: #if defined(OS_WIN) - ptd_to_emf_state_->OnPageProcessed( + pdf_to_emf_state_->OnPageProcessed( base::Bind(&PrintJob::OnPdfToEmfPageConverted, this)); -#endif // OS_WIN +#endif // defined(OS_WIN) break; default: { NOTREACHED(); @@ -391,7 +392,7 @@ void PrintJob::OnDocumentDone() { Stop(); scoped_refptr details( - new JobEventDetails(JobEventDetails::JOB_DONE, document_.get(), NULL)); + new JobEventDetails(JobEventDetails::JOB_DONE, document_.get(), nullptr)); content::NotificationService::current()->Notify( chrome::NOTIFICATION_PRINT_JOB_EVENT, content::Source(this), @@ -419,8 +420,7 @@ void PrintJob::ControlledWorkerShutdown() { // to wait on the thread to quit before continuing. if (worker_->IsRunning()) { base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, - base::Bind(&PrintJob::ControlledWorkerShutdown, this), + FROM_HERE, base::Bind(&PrintJob::ControlledWorkerShutdown, this), base::TimeDelta::FromMilliseconds(100)); return; } @@ -437,7 +437,7 @@ void PrintJob::ControlledWorkerShutdown() { is_job_pending_ = false; registrar_.RemoveAll(); - UpdatePrintedDocument(NULL); + UpdatePrintedDocument(nullptr); } void PrintJob::HoldUntilStopIsCalled() { diff --git a/chromium_src/chrome/browser/printing/print_job.h b/chromium_src/chrome/browser/printing/print_job.h index 420622a7e968..e5c77aeb2345 100644 --- a/chromium_src/chrome/browser/printing/print_job.h +++ b/chromium_src/chrome/browser/printing/print_job.h @@ -6,15 +6,15 @@ #define CHROME_BROWSER_PRINTING_PRINT_JOB_H_ #include +#include +#include "base/macros.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop.h" +#include "build/build_config.h" #include "chrome/browser/printing/print_job_worker_owner.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" -class Thread; - namespace base { class RefCountedMemory; } @@ -49,16 +49,17 @@ class PrintJob : public PrintJobWorkerOwner, int page_count); // content::NotificationObserver implementation. - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) override; + void Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) override; // PrintJobWorkerOwner implementation. - virtual void GetSettingsDone(const PrintSettings& new_settings, - PrintingContext::Result result) override; - virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner) override; - virtual const PrintSettings& settings() const override; - virtual int cookie() const override; + void GetSettingsDone(const PrintSettings& new_settings, + PrintingContext::Result result) override; + std::unique_ptr DetachWorker( + PrintJobWorkerOwner* new_owner) override; + const PrintSettings& settings() const override; + int cookie() const override; // Starts the actual printing. Signals the worker that it should begin to // spool as soon as data is available. @@ -91,23 +92,21 @@ class PrintJob : public PrintJobWorkerOwner, PrintedDocument* document() const; #if defined(OS_WIN) + // Let the PrintJob know the 0-based |page_number| of a given printed page. + void AppendPrintedPage(int page_number); + void StartPdfToEmfConversion( const scoped_refptr& bytes, const gfx::Size& page_size, - const gfx::Rect& content_area); - - void OnPdfToEmfStarted(int page_count); - void OnPdfToEmfPageConverted(int page_number, - float scale_factor, - std::unique_ptr emf); - -#endif // OS_WIN + const gfx::Rect& content_area, + bool print_text_with_gdi); +#endif // defined(OS_WIN) protected: - virtual ~PrintJob(); + ~PrintJob() override; private: - // Updates document_ to a new instance. + // Updates |document_| to a new instance. void UpdatePrintedDocument(PrintedDocument* new_document); // Processes a NOTIFY_PRINT_JOB_EVENT notification. @@ -126,6 +125,13 @@ class PrintJob : public PrintJobWorkerOwner, void HoldUntilStopIsCalled(); +#if defined(OS_WIN) + void OnPdfToEmfStarted(int page_count); + void OnPdfToEmfPageConverted(int page_number, + float scale_factor, + std::unique_ptr emf); +#endif // defined(OS_WIN) + content::NotificationRegistrar registrar_; // Source that generates the PrintedPage's (i.e. a WebContents). It will be @@ -152,8 +158,9 @@ class PrintJob : public PrintJobWorkerOwner, #if defined(OS_WIN) class PdfToEmfState; - std::unique_ptr ptd_to_emf_state_; -#endif // OS_WIN + std::unique_ptr pdf_to_emf_state_; + std::vector pdf_page_mapping_; +#endif // defined(OS_WIN) // Used at shutdown so that we can quit a nested message loop. base::WeakPtrFactory quit_factory_; diff --git a/chromium_src/chrome/browser/printing/print_job_manager.cc b/chromium_src/chrome/browser/printing/print_job_manager.cc index ec08a9892335..96d10d2a9fa4 100644 --- a/chromium_src/chrome/browser/printing/print_job_manager.cc +++ b/chromium_src/chrome/browser/printing/print_job_manager.cc @@ -35,7 +35,7 @@ scoped_refptr PrintQueriesQueue::PopPrinterQuery( for (PrinterQueries::iterator itr = queued_queries_.begin(); itr != queued_queries_.end(); ++itr) { if ((*itr)->cookie() == document_cookie && !(*itr)->is_callback_pending()) { - scoped_refptr current_query(*itr); + scoped_refptr current_query(*itr); queued_queries_.erase(itr); DCHECK(current_query->is_valid()); return current_query; @@ -46,10 +46,9 @@ scoped_refptr PrintQueriesQueue::PopPrinterQuery( scoped_refptr PrintQueriesQueue::CreatePrinterQuery( int render_process_id, - int render_view_id) { - scoped_refptr job = - new printing::PrinterQuery(render_process_id, render_view_id); - return job; + int render_frame_id) { + return make_scoped_refptr( + new PrinterQuery(render_process_id, render_frame_id)); } void PrintQueriesQueue::Shutdown() { @@ -76,14 +75,14 @@ PrintJobManager::~PrintJobManager() { } scoped_refptr PrintJobManager::queue() { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); if (!queue_.get()) queue_ = new PrintQueriesQueue(); return queue_; } void PrintJobManager::Shutdown() { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK(!is_shutdown_); is_shutdown_ = true; registrar_.RemoveAll(); @@ -94,7 +93,7 @@ void PrintJobManager::Shutdown() { } void PrintJobManager::StopJobs(bool wait_for_finish) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); // Copy the array since it can be modified in transit. PrintJobs to_stop; to_stop.swap(current_jobs_); @@ -111,18 +110,11 @@ void PrintJobManager::StopJobs(bool wait_for_finish) { void PrintJobManager::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - switch (type) { - case chrome::NOTIFICATION_PRINT_JOB_EVENT: { - OnPrintJobEvent(content::Source(source).ptr(), - *content::Details(details).ptr()); - break; - } - default: { - NOTREACHED(); - break; - } - } + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + DCHECK_EQ(chrome::NOTIFICATION_PRINT_JOB_EVENT, type); + + OnPrintJobEvent(content::Source(source).ptr(), + *content::Details(details).ptr()); } void PrintJobManager::OnPrintJobEvent( diff --git a/chromium_src/chrome/browser/printing/print_job_manager.h b/chromium_src/chrome/browser/printing/print_job_manager.h index ddb4e97b42bf..e4970d41d32c 100644 --- a/chromium_src/chrome/browser/printing/print_job_manager.h +++ b/chromium_src/chrome/browser/printing/print_job_manager.h @@ -10,6 +10,7 @@ #include #include "base/logging.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/synchronization/lock.h" #include "base/threading/non_thread_safe.h" @@ -37,7 +38,7 @@ class PrintQueriesQueue : public base::RefCountedThreadSafe { // Creates new query. scoped_refptr CreatePrinterQuery(int render_process_id, - int render_view_id); + int render_frame_id); void Shutdown(); @@ -58,15 +59,15 @@ class PrintQueriesQueue : public base::RefCountedThreadSafe { class PrintJobManager : public content::NotificationObserver { public: PrintJobManager(); - virtual ~PrintJobManager(); + ~PrintJobManager() override; // On browser quit, we should wait to have the print job finished. void Shutdown(); // content::NotificationObserver - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) override; + void Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) override; // Returns queries queue. Never returns NULL. Must be called on Browser UI // Thread. Reference could be stored and used from any thread. diff --git a/chromium_src/chrome/browser/printing/print_job_worker.cc b/chromium_src/chrome/browser/printing/print_job_worker.cc index 4a39272c9900..0c56c200d082 100644 --- a/chromium_src/chrome/browser/printing/print_job_worker.cc +++ b/chromium_src/chrome/browser/printing/print_job_worker.cc @@ -4,19 +4,25 @@ #include "chrome/browser/printing/print_job_worker.h" +#include + #include "base/bind.h" #include "base/bind_helpers.h" #include "base/callback.h" #include "base/compiler_specific.h" +#include "base/location.h" +#include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" #include "base/threading/thread_task_runner_handle.h" #include "base/values.h" +#include "build/build_config.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/printing/print_job.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" -#include "content/public/browser/render_view_host.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" #include "printing/print_job_constants.h" #include "printing/printed_document.h" @@ -31,41 +37,45 @@ namespace printing { namespace { // Helper function to ensure |owner| is valid until at least |callback| returns. -void HoldRefCallback(const scoped_refptr& owner, +void HoldRefCallback(const scoped_refptr& owner, const base::Closure& callback) { callback.Run(); } class PrintingContextDelegate : public PrintingContext::Delegate { public: - PrintingContextDelegate(int render_process_id, int render_view_id); - virtual ~PrintingContextDelegate(); + PrintingContextDelegate(int render_process_id, int render_frame_id); + ~PrintingContextDelegate() override; - virtual gfx::NativeView GetParentView() override; - virtual std::string GetAppLocale() override; + gfx::NativeView GetParentView() override; + std::string GetAppLocale() override; + + // Not exposed to PrintingContext::Delegate because of dependency issues. + content::WebContents* GetWebContents(); private: - int render_process_id_; - int render_view_id_; + const int render_process_id_; + const int render_frame_id_; }; PrintingContextDelegate::PrintingContextDelegate(int render_process_id, - int render_view_id) + int render_frame_id) : render_process_id_(render_process_id), - render_view_id_(render_view_id) { -} + render_frame_id_(render_frame_id) {} PrintingContextDelegate::~PrintingContextDelegate() { } gfx::NativeView PrintingContextDelegate::GetParentView() { + content::WebContents* wc = GetWebContents(); + return wc ? wc->GetNativeView() : nullptr; +} + +content::WebContents* PrintingContextDelegate::GetWebContents() { DCHECK_CURRENTLY_ON(BrowserThread::UI); - content::RenderViewHost* view = - content::RenderViewHost::FromID(render_process_id_, render_view_id_); - if (!view) - return NULL; - content::WebContents* wc = content::WebContents::FromRenderViewHost(view); - return wc ? wc->GetNativeView() : NULL; + auto* rfh = + content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); + return rfh ? content::WebContents::FromRenderFrameHost(rfh) : nullptr; } std::string PrintingContextDelegate::GetAppLocale() { @@ -84,17 +94,24 @@ void NotificationCallback(PrintJobWorkerOwner* print_job, content::Details(details)); } +void PostOnOwnerThread(const scoped_refptr& owner, + const PrintingContext::PrintSettingsCallback& callback, + PrintingContext::Result result) { + owner->PostTask(FROM_HERE, base::Bind(&HoldRefCallback, owner, + base::Bind(callback, result))); +} + } // namespace PrintJobWorker::PrintJobWorker(int render_process_id, - int render_view_id, + int render_frame_id, PrintJobWorkerOwner* owner) : owner_(owner), thread_("Printing_Worker"), weak_factory_(this) { // The object is created in the IO thread. DCHECK(owner_->RunsTasksOnCurrentThread()); - printing_context_delegate_.reset( - new PrintingContextDelegate(render_process_id, render_view_id)); + printing_context_delegate_ = base::MakeUnique( + render_process_id, render_frame_id); printing_context_ = PrintingContext::Create(printing_context_delegate_.get()); } @@ -111,11 +128,12 @@ void PrintJobWorker::SetNewOwner(PrintJobWorkerOwner* new_owner) { owner_ = new_owner; } -void PrintJobWorker::GetSettings( - bool ask_user_for_settings, - int document_page_count, - bool has_selection, - MarginType margin_type) { +void PrintJobWorker::GetSettings(bool ask_user_for_settings, + int document_page_count, + bool has_selection, + MarginType margin_type, + bool is_scripted, + bool is_modifiable) { DCHECK(task_runner_->RunsTasksOnCurrentThread()); DCHECK_EQ(page_number_, PageNumber::npos()); @@ -126,6 +144,7 @@ void PrintJobWorker::GetSettings( // should happen on the same thread. See http://crbug.com/73466 // MessageLoop::current()->SetNestableTasksAllowed(true); printing_context_->set_margin_type(margin_type); + printing_context_->set_is_modifiable(is_modifiable); // When we delegate to a destination, we don't ask the user for settings. // TODO(mad): Ask the destination for settings. @@ -136,7 +155,8 @@ void PrintJobWorker::GetSettings( base::Bind(&PrintJobWorker::GetSettingsWithUI, base::Unretained(this), document_page_count, - has_selection))); + has_selection, + is_scripted))); } else { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, @@ -188,23 +208,16 @@ void PrintJobWorker::GetSettingsDone(PrintingContext::Result result) { void PrintJobWorker::GetSettingsWithUI( int document_page_count, - bool has_selection) { + bool has_selection, + bool is_scripted) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - printing_context_->AskUserForSettings( - document_page_count, - has_selection, - false, - base::Bind(&PrintJobWorker::GetSettingsWithUIDone, - base::Unretained(this))); -} -void PrintJobWorker::GetSettingsWithUIDone(PrintingContext::Result result) { - PostTask(FROM_HERE, - base::Bind(&HoldRefCallback, - make_scoped_refptr(owner_), - base::Bind(&PrintJobWorker::GetSettingsDone, - base::Unretained(this), - result))); + // weak_factory_ creates pointers valid only on owner_ thread. + printing_context_->AskUserForSettings( + document_page_count, has_selection, is_scripted, + base::Bind(&PostOnOwnerThread, make_scoped_refptr(owner_), + base::Bind(&PrintJobWorker::GetSettingsDone, + weak_factory_.GetWeakPtr()))); } void PrintJobWorker::UseDefaultSettings() { @@ -225,8 +238,6 @@ void PrintJobWorker::StartPrinting(PrintedDocument* new_document) { base::string16 document_name = printing::SimplifyDocumentTitle(document_->name()); - if (document_name.empty()) { - } PrintingContext::Result result = printing_context_->NewDocument(document_name); if (result != PrintingContext::OK) { @@ -352,10 +363,11 @@ void PrintJobWorker::SpoolPage(PrintedPage* page) { DCHECK_NE(page_number_, PageNumber::npos()); // Signal everyone that the page is about to be printed. - owner_->PostTask(FROM_HERE, - base::Bind(&NotificationCallback, base::RetainedRef(owner_), - JobEventDetails::NEW_PAGE, base::RetainedRef(document_), - base::RetainedRef(page))); + owner_->PostTask( + FROM_HERE, + base::Bind(&NotificationCallback, base::RetainedRef(owner_), + JobEventDetails::NEW_PAGE, base::RetainedRef(document_), + base::RetainedRef(page))); // Preprocess. if (printing_context_->NewPage() != PrintingContext::OK) { @@ -390,11 +402,10 @@ void PrintJobWorker::OnFailure() { // We may loose our last reference by broadcasting the FAILED event. scoped_refptr handle(owner_); - owner_->PostTask( - FROM_HERE, - base::Bind(&NotificationCallback, base::RetainedRef(owner_), - JobEventDetails::FAILED, - base::RetainedRef(document_), nullptr)); + owner_->PostTask(FROM_HERE, + base::Bind(&NotificationCallback, base::RetainedRef(owner_), + JobEventDetails::FAILED, + base::RetainedRef(document_), nullptr)); Cancel(); // Makes sure the variables are reinitialized. diff --git a/chromium_src/chrome/browser/printing/print_job_worker.h b/chromium_src/chrome/browser/printing/print_job_worker.h index 343c0fa15f29..e001a86b840e 100644 --- a/chromium_src/chrome/browser/printing/print_job_worker.h +++ b/chromium_src/chrome/browser/printing/print_job_worker.h @@ -7,9 +7,11 @@ #include +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/threading/thread.h" +#include "chrome/browser/printing/printer_query.h" #include "content/public/browser/browser_thread.h" #include "printing/page_number.h" #include "printing/print_job_constants.h" @@ -34,19 +36,22 @@ class PrintedPage; class PrintJobWorker { public: PrintJobWorker(int render_process_id, - int render_view_id, + int render_frame_id, PrintJobWorkerOwner* owner); virtual ~PrintJobWorker(); void SetNewOwner(PrintJobWorkerOwner* new_owner); // Initializes the print settings. If |ask_user_for_settings| is true, a - // Print... dialog box will be shown to ask the user his preference. - void GetSettings( - bool ask_user_for_settings, - int document_page_count, - bool has_selection, - MarginType margin_type); + // Print... dialog box will be shown to ask the user their preference. + // |is_scripted| should be true for calls coming straight from window.print(). + // |is_modifiable| implies HTML and not other formats like PDF. + void GetSettings(bool ask_user_for_settings, + int document_page_count, + bool has_selection, + MarginType margin_type, + bool is_scripted, + bool is_modifiable); // Set the new print settings. void SetSettings(std::unique_ptr new_settings); @@ -109,12 +114,8 @@ class PrintJobWorker { // but sticks with this for consistency. void GetSettingsWithUI( int document_page_count, - bool has_selection); - - // The callback used by PrintingContext::GetSettingsWithUI() to notify this - // object that the print settings are set. This is needed in order to bounce - // back into the IO thread for GetSettingsDone(). - void GetSettingsWithUIDone(PrintingContext::Result result); + bool has_selection, + bool is_scripted); // Called on the UI thread to update the print settings. void UpdatePrintSettings(std::unique_ptr new_settings); diff --git a/chromium_src/chrome/browser/printing/print_job_worker_owner.cc b/chromium_src/chrome/browser/printing/print_job_worker_owner.cc index 843ab4616d18..acddfd293178 100644 --- a/chromium_src/chrome/browser/printing/print_job_worker_owner.cc +++ b/chromium_src/chrome/browser/printing/print_job_worker_owner.cc @@ -4,13 +4,14 @@ #include "chrome/browser/printing/print_job_worker_owner.h" -#include "base/message_loop/message_loop.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/threading/thread_task_runner_handle.h" namespace printing { PrintJobWorkerOwner::PrintJobWorkerOwner() - : task_runner_(base::MessageLoop::current()->task_runner()) { -} + : task_runner_(base::ThreadTaskRunnerHandle::Get()) {} PrintJobWorkerOwner::~PrintJobWorkerOwner() { } diff --git a/chromium_src/chrome/browser/printing/print_job_worker_owner.h b/chromium_src/chrome/browser/printing/print_job_worker_owner.h index 00a561a39bb6..d7a9d0ad1586 100644 --- a/chromium_src/chrome/browser/printing/print_job_worker_owner.h +++ b/chromium_src/chrome/browser/printing/print_job_worker_owner.h @@ -5,6 +5,8 @@ #ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__ #define CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__ +#include + #include "base/memory/ref_counted.h" #include "printing/printing_context.h" @@ -34,7 +36,8 @@ class PrintJobWorkerOwner PrintingContext::Result result) = 0; // Detach the PrintJobWorker associated to this object. - virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner) = 0; + virtual std::unique_ptr DetachWorker( + PrintJobWorkerOwner* new_owner) = 0; // Access the current settings. virtual const PrintSettings& settings() const = 0; diff --git a/chromium_src/chrome/browser/printing/print_preview_message_handler.cc b/chromium_src/chrome/browser/printing/print_preview_message_handler.cc index 91a6c5167c4c..05f4ca9ed98c 100644 --- a/chromium_src/chrome/browser/printing/print_preview_message_handler.cc +++ b/chromium_src/chrome/browser/printing/print_preview_message_handler.cc @@ -11,6 +11,7 @@ #include "chrome/browser/printing/printer_query.h" #include "chrome/common/print_messages.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "printing/page_size_margins.h" @@ -116,8 +117,8 @@ void PrintPreviewMessageHandler::PrintToPDF( options.GetInteger(printing::kPreviewRequestID, &request_id); print_to_pdf_callback_map_[request_id] = callback; - content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); - rvh->Send(new PrintMsg_PrintPreview(rvh->GetRoutingID(), options)); + content::RenderFrameHost* rfh = web_contents()->GetMainFrame(); + rfh->Send(new PrintMsg_PrintPreview(rfh->GetRoutingID(), options)); } void PrintPreviewMessageHandler::RunPrintToPDFCallback( diff --git a/chromium_src/chrome/browser/printing/printer_query.cc b/chromium_src/chrome/browser/printing/printer_query.cc index 72e2b85f635c..bfaeb574db32 100644 --- a/chromium_src/chrome/browser/printing/printer_query.cc +++ b/chromium_src/chrome/browser/printing/printer_query.cc @@ -4,6 +4,9 @@ #include "chrome/browser/printing/printer_query.h" +#include +#include + #include "base/bind.h" #include "base/bind_helpers.h" #include "base/message_loop/message_loop.h" @@ -13,8 +16,8 @@ namespace printing { -PrinterQuery::PrinterQuery(int render_process_id, int render_view_id) - : worker_(new PrintJobWorker(render_process_id, render_view_id, this)), +PrinterQuery::PrinterQuery(int render_process_id, int render_frame_id) + : worker_(new PrintJobWorker(render_process_id, render_frame_id, this)), is_print_dialog_box_shown_(false), cookie_(PrintSettings::NewCookie()), last_status_(PrintingContext::FAILED) { @@ -25,7 +28,7 @@ PrinterQuery::~PrinterQuery() { // The job should be finished (or at least canceled) when it is destroyed. DCHECK(!is_print_dialog_box_shown_); // If this fires, it is that this pending printer context has leaked. - DCHECK(!worker_.get()); + DCHECK(!worker_); } void PrinterQuery::GetSettingsDone(const PrintSettings& new_settings, @@ -47,12 +50,13 @@ void PrinterQuery::GetSettingsDone(const PrintSettings& new_settings, } } -PrintJobWorker* PrinterQuery::DetachWorker(PrintJobWorkerOwner* new_owner) { +std::unique_ptr PrinterQuery::DetachWorker( + PrintJobWorkerOwner* new_owner) { DCHECK(callback_.is_null()); - DCHECK(worker_.get()); + DCHECK(worker_); worker_->SetNewOwner(new_owner); - return worker_.release(); + return std::move(worker_); } const PrintSettings& PrinterQuery::settings() const { @@ -63,30 +67,31 @@ int PrinterQuery::cookie() const { return cookie_; } -void PrinterQuery::GetSettings( - GetSettingsAskParam ask_user_for_settings, - int expected_page_count, - bool has_selection, - MarginType margin_type, - const base::Closure& callback) { +void PrinterQuery::GetSettings(GetSettingsAskParam ask_user_for_settings, + int expected_page_count, + bool has_selection, + MarginType margin_type, + bool is_scripted, + bool is_modifiable, + const base::Closure& callback) { DCHECK(RunsTasksOnCurrentThread()); - DCHECK(!is_print_dialog_box_shown_); + DCHECK(!is_print_dialog_box_shown_ || !is_scripted); StartWorker(callback); // Real work is done in PrintJobWorker::GetSettings(). - is_print_dialog_box_shown_ = ask_user_for_settings == ASK_USER; - worker_->PostTask(FROM_HERE, - base::Bind(&PrintJobWorker::GetSettings, - base::Unretained(worker_.get()), - is_print_dialog_box_shown_, - expected_page_count, - has_selection, - margin_type)); + is_print_dialog_box_shown_ = + ask_user_for_settings == GetSettingsAskParam::ASK_USER; + worker_->PostTask( + FROM_HERE, + base::Bind(&PrintJobWorker::GetSettings, base::Unretained(worker_.get()), + is_print_dialog_box_shown_, expected_page_count, has_selection, + margin_type, is_scripted, is_modifiable)); } -void PrinterQuery::SetSettings(std::unique_ptr new_settings, - const base::Closure& callback) { +void PrinterQuery::SetSettings( + std::unique_ptr new_settings, + const base::Closure& callback) { StartWorker(callback); worker_->PostTask(FROM_HERE, @@ -97,7 +102,7 @@ void PrinterQuery::SetSettings(std::unique_ptr new_settin void PrinterQuery::StartWorker(const base::Closure& callback) { DCHECK(callback_.is_null()); - DCHECK(worker_.get()); + DCHECK(worker_); // Lazily create the worker thread. There is one worker thread per print job. if (!worker_->IsRunning()) @@ -107,7 +112,7 @@ void PrinterQuery::StartWorker(const base::Closure& callback) { } void PrinterQuery::StopWorker() { - if (worker_.get()) { + if (worker_) { // http://crbug.com/66082: We're blocking on the PrinterQuery's worker // thread. It's not clear to me if this may result in blocking the current // thread for an unacceptable time. We should probably fix it. @@ -122,7 +127,7 @@ bool PrinterQuery::is_callback_pending() const { } bool PrinterQuery::is_valid() const { - return worker_.get() != NULL; + return !!worker_; } } // namespace printing diff --git a/chromium_src/chrome/browser/printing/printer_query.h b/chromium_src/chrome/browser/printing/printer_query.h index d2f017d1895c..9008e19de815 100644 --- a/chromium_src/chrome/browser/printing/printer_query.h +++ b/chromium_src/chrome/browser/printing/printer_query.h @@ -9,6 +9,7 @@ #include "base/callback.h" #include "base/compiler_specific.h" +#include "base/macros.h" #include "chrome/browser/printing/print_job_worker_owner.h" #include "printing/print_job_constants.h" @@ -25,30 +26,32 @@ class PrintJobWorker; class PrinterQuery : public PrintJobWorkerOwner { public: // GetSettings() UI parameter. - enum GetSettingsAskParam { + enum class GetSettingsAskParam { DEFAULTS, ASK_USER, }; - PrinterQuery(int render_process_id, int render_view_id); + PrinterQuery(int render_process_id, int render_frame_id); // PrintJobWorkerOwner implementation. - virtual void GetSettingsDone(const PrintSettings& new_settings, - PrintingContext::Result result) override; - virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner) override; - virtual const PrintSettings& settings() const override; - virtual int cookie() const override; + void GetSettingsDone(const PrintSettings& new_settings, + PrintingContext::Result result) override; + std::unique_ptr DetachWorker( + PrintJobWorkerOwner* new_owner) override; + const PrintSettings& settings() const override; + int cookie() const override; // Initializes the printing context. It is fine to call this function multiple // times to reinitialize the settings. |web_contents_observer| can be queried // to find the owner of the print setting dialog box. It is unused when // |ask_for_user_settings| is DEFAULTS. - void GetSettings( - GetSettingsAskParam ask_user_for_settings, - int expected_page_count, - bool has_selection, - MarginType margin_type, - const base::Closure& callback); + void GetSettings(GetSettingsAskParam ask_user_for_settings, + int expected_page_count, + bool has_selection, + MarginType margin_type, + bool is_scripted, + bool is_modifiable, + const base::Closure& callback); // Updates the current settings with |new_settings| dictionary values. void SetSettings(std::unique_ptr new_settings, @@ -66,7 +69,7 @@ class PrinterQuery : public PrintJobWorkerOwner { bool is_valid() const; private: - virtual ~PrinterQuery(); + ~PrinterQuery() override; // Lazy create the worker thread. There is one worker thread per print job. void StartWorker(const base::Closure& callback); diff --git a/chromium_src/chrome/browser/printing/printing_message_filter.cc b/chromium_src/chrome/browser/printing/printing_message_filter.cc index 819c6af5b020..b0d3824fc876 100644 --- a/chromium_src/chrome/browser/printing/printing_message_filter.cc +++ b/chromium_src/chrome/browser/printing/printing_message_filter.cc @@ -14,23 +14,12 @@ #include "chrome/browser/profiles/profile_io_data.h" #include "chrome/common/print_messages.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/render_view_host.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/common/child_process_host.h" +#include "printing/features/features.h" -#if defined(ENABLE_FULL_PRINTING) -#include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" -#endif - -#if defined(OS_CHROMEOS) -#include - -#include - -#include "base/files/file_util.h" -#include "base/lazy_instance.h" -#include "chrome/browser/printing/print_dialog_cloud.h" -#endif #if defined(OS_ANDROID) #include "base/strings/string_number_conversions.h" @@ -44,19 +33,6 @@ namespace printing { namespace { -#if defined(OS_CHROMEOS) -typedef std::map SequenceToPathMap; - -struct PrintingSequencePathMap { - SequenceToPathMap map; - int sequence; -}; - -// No locking, only access on the FILE thread. -static base::LazyInstance - g_printing_file_descriptor_map = LAZY_INSTANCE_INITIALIZER; -#endif - void RenderParamsFromPrintSettings(const PrintSettings& settings, PrintMsg_Print_Params* params) { params->page_size = settings.page_setup_device_units().physical_size(); @@ -71,6 +47,7 @@ void RenderParamsFromPrintSettings(const PrintSettings& settings, params->margin_top = settings.page_setup_device_units().content_area().y(); params->margin_left = settings.page_setup_device_units().content_area().x(); params->dpi = settings.dpi(); + params->scale_factor = settings.scale_factor(); // Currently hardcoded at 72dpi. See PrintSettings' constructor. params->desired_dpi = settings.desired_dpi(); // Always use an invalid cookie. @@ -78,10 +55,30 @@ void RenderParamsFromPrintSettings(const PrintSettings& settings, params->selection_only = settings.selection_only(); params->supports_alpha_blend = settings.supports_alpha_blend(); params->should_print_backgrounds = settings.should_print_backgrounds(); + params->display_header_footer = settings.display_header_footer(); params->title = settings.title(); params->url = settings.url(); } +#if defined(OS_ANDROID) +content::WebContents* GetWebContentsForRenderFrame(int render_process_id, + int render_frame_id) { + DCHECK_CURRENTLY_ON(BrowserThread::UI); + content::RenderFrameHost* frame = + content::RenderFrameHost::FromID(render_process_id, render_frame_id); + return frame ? content::WebContents::FromRenderFrameHost(frame) : nullptr; +} + +PrintViewManagerBasic* GetPrintManager(int render_process_id, + int render_frame_id) { + DCHECK_CURRENTLY_ON(BrowserThread::UI); + content::WebContents* web_contents = + GetWebContentsForRenderFrame(render_process_id, render_frame_id); + return web_contents ? PrintViewManagerBasic::FromWebContents(web_contents) + : nullptr; +} +#endif + } // namespace PrintingMessageFilter::PrintingMessageFilter(int render_process_id) @@ -94,14 +91,13 @@ PrintingMessageFilter::PrintingMessageFilter(int render_process_id) PrintingMessageFilter::~PrintingMessageFilter() { } +void PrintingMessageFilter::OnDestruct() const { + BrowserThread::DeleteOnUIThread::Destruct(this); +} + void PrintingMessageFilter::OverrideThreadForMessage( const IPC::Message& message, BrowserThread::ID* thread) { -#if defined(OS_CHROMEOS) - if (message.type() == PrintHostMsg_AllocateTempFileForPrinting::ID || - message.type() == PrintHostMsg_TempFileForPrintingWritten::ID) { - *thread = BrowserThread::FILE; - } -#elif defined(OS_ANDROID) +#if defined(OS_ANDROID) if (message.type() == PrintHostMsg_AllocateTempFileForPrinting::ID || message.type() == PrintHostMsg_TempFileForPrintingWritten::ID) { *thread = BrowserThread::UI; @@ -112,10 +108,7 @@ void PrintingMessageFilter::OverrideThreadForMessage( bool PrintingMessageFilter::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PrintingMessageFilter, message) -#if defined(OS_WIN) - IPC_MESSAGE_HANDLER(PrintHostMsg_DuplicateSection, OnDuplicateSection) -#endif -#if defined(OS_CHROMEOS) || defined(OS_ANDROID) +#if defined(OS_ANDROID) IPC_MESSAGE_HANDLER(PrintHostMsg_AllocateTempFileForPrinting, OnAllocateTempFileForPrinting) IPC_MESSAGE_HANDLER(PrintHostMsg_TempFileForPrintingWritten, @@ -126,139 +119,46 @@ bool PrintingMessageFilter::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_ScriptedPrint, OnScriptedPrint) IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_UpdatePrintSettings, OnUpdatePrintSettings) -#if defined(ENABLE_FULL_PRINTING) - IPC_MESSAGE_HANDLER(PrintHostMsg_CheckForCancel, OnCheckForCancel) -#endif IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; } -#if defined(OS_WIN) -void PrintingMessageFilter::OnDuplicateSection( - base::SharedMemoryHandle renderer_handle, - base::SharedMemoryHandle* browser_handle) { - // Duplicate the handle in this process right now so the memory is kept alive - // (even if it is not mapped) - base::SharedMemory shared_buf(renderer_handle, true); - shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), browser_handle); -} -#endif - -#if defined(OS_CHROMEOS) || defined(OS_ANDROID) +#if defined(OS_ANDROID) void PrintingMessageFilter::OnAllocateTempFileForPrinting( - int render_view_id, + int render_frame_id, base::FileDescriptor* temp_file_fd, int* sequence_number) { -#if defined(OS_CHROMEOS) - // TODO(thestig): Use |render_view_id| for Chrome OS. - DCHECK_CURRENTLY_ON(BrowserThread::FILE); - temp_file_fd->fd = *sequence_number = -1; - temp_file_fd->auto_close = false; - - SequenceToPathMap* map = &g_printing_file_descriptor_map.Get().map; - *sequence_number = g_printing_file_descriptor_map.Get().sequence++; - - base::FilePath path; - if (base::CreateTemporaryFile(&path)) { - int fd = open(path.value().c_str(), O_WRONLY); - if (fd >= 0) { - SequenceToPathMap::iterator it = map->find(*sequence_number); - if (it != map->end()) { - NOTREACHED() << "Sequence number already in use. seq=" << - *sequence_number; - } else { - (*map)[*sequence_number] = path; - temp_file_fd->fd = fd; - temp_file_fd->auto_close = true; - } - } - } -#elif defined(OS_ANDROID) DCHECK_CURRENTLY_ON(BrowserThread::UI); - content::WebContents* wc = GetWebContentsForRenderView(render_view_id); - if (!wc) - return; PrintViewManagerBasic* print_view_manager = - PrintViewManagerBasic::FromWebContents(wc); + GetPrintManager(render_process_id_, render_frame_id); + if (!print_view_manager) + return; + // The file descriptor is originally created in & passed from the Android // side, and it will handle the closing. - const base::FileDescriptor& file_descriptor = - print_view_manager->file_descriptor(); - temp_file_fd->fd = file_descriptor.fd; + temp_file_fd->fd = print_view_manager->file_descriptor().fd; temp_file_fd->auto_close = false; -#endif } -void PrintingMessageFilter::OnTempFileForPrintingWritten(int render_view_id, +void PrintingMessageFilter::OnTempFileForPrintingWritten(int render_frame_id, int sequence_number) { -#if defined(OS_CHROMEOS) - DCHECK_CURRENTLY_ON(BrowserThread::FILE); - SequenceToPathMap* map = &g_printing_file_descriptor_map.Get().map; - SequenceToPathMap::iterator it = map->find(sequence_number); - if (it == map->end()) { - NOTREACHED() << "Got a sequence that we didn't pass to the " - "renderer: " << sequence_number; - return; - } - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind(&PrintingMessageFilter::CreatePrintDialogForFile, - this, render_view_id, it->second)); - - // Erase the entry in the map. - map->erase(it); -#elif defined(OS_ANDROID) DCHECK_CURRENTLY_ON(BrowserThread::UI); - content::WebContents* wc = GetWebContentsForRenderView(render_view_id); - if (!wc) - return; PrintViewManagerBasic* print_view_manager = - PrintViewManagerBasic::FromWebContents(wc); - const base::FileDescriptor& file_descriptor = - print_view_manager->file_descriptor(); - PrintingContextAndroid::PdfWritingDone(file_descriptor.fd, true); - // Invalidate the file descriptor so it doesn't accidentally get reused. - print_view_manager->set_file_descriptor(base::FileDescriptor(-1, false)); -#endif -} -#endif // defined(OS_CHROMEOS) || defined(OS_ANDROID) - -#if defined(OS_CHROMEOS) -void PrintingMessageFilter::CreatePrintDialogForFile( - int render_view_id, - const base::FilePath& path) { - content::WebContents* wc = GetWebContentsForRenderView(render_view_id); - if (!wc) - return; - print_dialog_cloud::CreatePrintDialogForFile( - wc->GetBrowserContext(), - wc->GetTopLevelNativeWindow(), - path, - wc->GetTitle(), - base::string16(), - std::string("application/pdf")); -} -#endif // defined(OS_CHROMEOS) - -content::WebContents* PrintingMessageFilter::GetWebContentsForRenderView( - int render_view_id) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - content::RenderViewHost* view = content::RenderViewHost::FromID( - render_process_id_, render_view_id); - return view ? content::WebContents::FromRenderViewHost(view) : NULL; + GetPrintManager(render_process_id_, render_frame_id); + if (print_view_manager) + print_view_manager->PdfWritingDone(true); } +#endif // defined(OS_ANDROID) void PrintingMessageFilter::OnGetDefaultPrintSettings(IPC::Message* reply_msg) { DCHECK_CURRENTLY_ON(BrowserThread::IO); scoped_refptr printer_query; -#if 0 - if (!profile_io_data_->printing_enabled()->GetValue()) { + if (false) { // Reply with NULL query. OnGetDefaultPrintSettingsReply(printer_query, reply_msg); return; } -#endif printer_query = queue_->PopPrinterQuery(0); if (!printer_query.get()) { printer_query = @@ -268,14 +168,10 @@ void PrintingMessageFilter::OnGetDefaultPrintSettings(IPC::Message* reply_msg) { // Loads default settings. This is asynchronous, only the IPC message sender // will hang until the settings are retrieved. printer_query->GetSettings( - PrinterQuery::DEFAULTS, - 0, - false, - DEFAULT_MARGINS, - base::Bind(&PrintingMessageFilter::OnGetDefaultPrintSettingsReply, - this, - printer_query, - reply_msg)); + PrinterQuery::GetSettingsAskParam::DEFAULTS, 0, false, DEFAULT_MARGINS, + false, false, + base::Bind(&PrintingMessageFilter::OnGetDefaultPrintSettingsReply, this, + printer_query, reply_msg)); } void PrintingMessageFilter::OnGetDefaultPrintSettingsReply( @@ -312,14 +208,10 @@ void PrintingMessageFilter::OnScriptedPrint( queue_->CreatePrinterQuery(render_process_id_, reply_msg->routing_id()); } printer_query->GetSettings( - PrinterQuery::ASK_USER, - params.expected_pages_count, - params.has_selection, - params.margin_type, - base::Bind(&PrintingMessageFilter::OnScriptedPrintReply, - this, - printer_query, - reply_msg)); + PrinterQuery::GetSettingsAskParam::ASK_USER, params.expected_pages_count, + params.has_selection, params.margin_type, true, true, + base::Bind(&PrintingMessageFilter::OnScriptedPrintReply, this, + printer_query, reply_msg)); } void PrintingMessageFilter::OnScriptedPrintReply( @@ -407,11 +299,10 @@ void PrintingMessageFilter::OnUpdatePrintSettingsReply( params.params.document_cookie = printer_query->cookie(); params.pages = PageRange::GetPages(printer_query->settings().ranges()); } - PrintHostMsg_UpdatePrintSettings::WriteReplyParams( - reply_msg, - params, - printer_query.get() && - (printer_query->last_status() == printing::PrintingContext::CANCEL)); + bool canceled = printer_query.get() && + (printer_query->last_status() == PrintingContext::CANCEL); + PrintHostMsg_UpdatePrintSettings::WriteReplyParams(reply_msg, params, + canceled); Send(reply_msg); // If user hasn't cancelled. if (printer_query.get()) { diff --git a/chromium_src/chrome/browser/printing/printing_message_filter.h b/chromium_src/chrome/browser/printing/printing_message_filter.h index e8536a69c5a3..d023af1b34f7 100644 --- a/chromium_src/chrome/browser/printing/printing_message_filter.h +++ b/chromium_src/chrome/browser/printing/printing_message_filter.h @@ -10,13 +10,7 @@ #include "base/compiler_specific.h" #include "content/public/browser/browser_message_filter.h" -#if defined(OS_WIN) -#include "base/memory/shared_memory.h" -#endif - struct PrintHostMsg_ScriptedPrint_Params; -class Profile; -class ProfileIOData; namespace base { class DictionaryValue; @@ -29,7 +23,6 @@ class WebContents; namespace printing { -class PrintJobManager; class PrintQueriesQueue; class PrinterQuery; @@ -46,43 +39,26 @@ class PrintingMessageFilter : public content::BrowserMessageFilter { bool OnMessageReceived(const IPC::Message& message) override; private: + friend class base::DeleteHelper; + friend class content::BrowserThread; + virtual ~PrintingMessageFilter(); -#if defined(OS_WIN) - // Used to pass resulting EMF from renderer to browser in printing. - void OnDuplicateSection(base::SharedMemoryHandle renderer_handle, - base::SharedMemoryHandle* browser_handle); -#endif - -#if defined(OS_CHROMEOS) || defined(OS_ANDROID) - // Used to ask the browser allocate a temporary file for the renderer - // to fill in resulting PDF in renderer. - void OnAllocateTempFileForPrinting(int render_view_id, - base::FileDescriptor* temp_file_fd, - int* sequence_number); - void OnTempFileForPrintingWritten(int render_view_id, int sequence_number); -#endif - -#if defined(OS_CHROMEOS) - void CreatePrintDialogForFile(int render_view_id, const base::FilePath& path); -#endif + void OnDestruct() const override; #if defined(OS_ANDROID) + // Used to ask the browser allocate a temporary file for the renderer + // to fill in resulting PDF in renderer. + void OnAllocateTempFileForPrinting(int render_frame_id, + base::FileDescriptor* temp_file_fd, + int* sequence_number); + void OnTempFileForPrintingWritten(int render_frame_id, int sequence_number); + // Updates the file descriptor for the PrintViewManagerBasic of a given - // render_view_id. - void UpdateFileDescriptor(int render_view_id, int fd); + // render_frame_id. + void UpdateFileDescriptor(int render_frame_id, int fd); #endif - // Given a render_view_id get the corresponding WebContents. - // Must be called on the UI thread. - content::WebContents* GetWebContentsForRenderView(int render_view_id); - - // GetPrintSettingsForRenderView must be called via PostTask and - // base::Bind. Collapse the settings-specific params into a - // struct to avoid running into issues with too many params - // to base::Bind. - struct GetPrintSettingsForRenderViewParams; - // Get the default print setting. void OnGetDefaultPrintSettings(IPC::Message* reply_msg); void OnGetDefaultPrintSettingsReply(scoped_refptr printer_query, @@ -105,13 +81,6 @@ class PrintingMessageFilter : public content::BrowserMessageFilter { void OnUpdatePrintSettingsReply(scoped_refptr printer_query, IPC::Message* reply_msg); -#if defined(ENABLE_FULL_PRINTING) - // Check to see if print preview has been cancelled. - void OnCheckForCancel(int32_t preview_ui_id, - int preview_request_id, - bool* cancel); -#endif - const int render_process_id_; scoped_refptr queue_; diff --git a/chromium_src/chrome/common/print_messages.cc b/chromium_src/chrome/common/print_messages.cc index b0ec282382d6..8c68e432bba2 100644 --- a/chromium_src/chrome/common/print_messages.cc +++ b/chromium_src/chrome/common/print_messages.cc @@ -8,23 +8,26 @@ #include "ui/gfx/geometry/size.h" PrintMsg_Print_Params::PrintMsg_Print_Params() - : page_size(), - content_size(), - printable_area(), - margin_top(0), - margin_left(0), - dpi(0), - min_shrink(0), - max_shrink(0), - desired_dpi(0), - document_cookie(0), - selection_only(false), - supports_alpha_blend(false), - print_scaling_option(blink::WebPrintScalingOptionSourceSize), - title(), - url(), - should_print_backgrounds(false) { -} + : page_size(), + content_size(), + printable_area(), + margin_top(0), + margin_left(0), + dpi(0), + scale_factor(1.0f), + desired_dpi(0), + document_cookie(0), + selection_only(false), + supports_alpha_blend(false), + preview_ui_id(-1), + preview_request_id(0), + is_first_request(false), + print_scaling_option(blink::WebPrintScalingOptionSourceSize), + print_to_pdf(false), + display_header_footer(false), + title(), + url(), + should_print_backgrounds(false) {} PrintMsg_Print_Params::~PrintMsg_Print_Params() {} @@ -35,15 +38,19 @@ void PrintMsg_Print_Params::Reset() { margin_top = 0; margin_left = 0; dpi = 0; - min_shrink = 0; - max_shrink = 0; + scale_factor = 1.0f; desired_dpi = 0; document_cookie = 0; selection_only = false; supports_alpha_blend = false; + preview_ui_id = -1; + preview_request_id = 0; + is_first_request = false; print_scaling_option = blink::WebPrintScalingOptionSourceSize; - title.clear(); - url.clear(); + print_to_pdf = false; + display_header_footer = false; + title = base::string16(); + url = base::string16(); should_print_backgrounds = false; } diff --git a/chromium_src/chrome/common/print_messages.h b/chromium_src/chrome/common/print_messages.h index 034691b5b958..dce74cbe9f24 100644 --- a/chromium_src/chrome/common/print_messages.h +++ b/chromium_src/chrome/common/print_messages.h @@ -40,15 +40,18 @@ struct PrintMsg_Print_Params { int margin_top; int margin_left; double dpi; - double min_shrink; - double max_shrink; + double scale_factor; int desired_dpi; + bool rasterize_pdf; int document_cookie; bool selection_only; bool supports_alpha_blend; + int32_t preview_ui_id; int preview_request_id; + bool is_first_request; blink::WebPrintScalingOption print_scaling_option; bool print_to_pdf; + bool display_header_footer; base::string16 title; base::string16 url; bool should_print_backgrounds; @@ -95,11 +98,8 @@ IPC_STRUCT_TRAITS_BEGIN(PrintMsg_Print_Params) // Specifies dots per inch. IPC_STRUCT_TRAITS_MEMBER(dpi) - // Minimum shrink factor. See PrintSettings::min_shrink for more information. - IPC_STRUCT_TRAITS_MEMBER(min_shrink) - - // Maximum shrink factor. See PrintSettings::max_shrink for more information. - IPC_STRUCT_TRAITS_MEMBER(max_shrink) + // Specifies the scale factor in percent + IPC_STRUCT_TRAITS_MEMBER(scale_factor) // Desired apparent dpi on paper. IPC_STRUCT_TRAITS_MEMBER(desired_dpi) @@ -113,9 +113,26 @@ IPC_STRUCT_TRAITS_BEGIN(PrintMsg_Print_Params) // Does the printer support alpha blending? IPC_STRUCT_TRAITS_MEMBER(supports_alpha_blend) + // *** Parameters below are used only for print preview. *** + + // The print preview ui associated with this request. + IPC_STRUCT_TRAITS_MEMBER(preview_ui_id) + + // The id of the preview request. + IPC_STRUCT_TRAITS_MEMBER(preview_request_id) + + // True if this is the first preview request. + IPC_STRUCT_TRAITS_MEMBER(is_first_request) + // Specifies the page scaling option for preview printing. IPC_STRUCT_TRAITS_MEMBER(print_scaling_option) + // True if print to pdf is requested. + IPC_STRUCT_TRAITS_MEMBER(print_to_pdf) + + // Specifies if the header and footer should be rendered. + IPC_STRUCT_TRAITS_MEMBER(display_header_footer) + // Title string to be printed as header if requested by the user. IPC_STRUCT_TRAITS_MEMBER(title) diff --git a/chromium_src/chrome/renderer/printing/print_web_view_helper.cc b/chromium_src/chrome/renderer/printing/print_web_view_helper.cc index d78d9975783a..d93cdea83129 100644 --- a/chromium_src/chrome/renderer/printing/print_web_view_helper.cc +++ b/chromium_src/chrome/renderer/printing/print_web_view_helper.cc @@ -1087,16 +1087,16 @@ bool PrintWebViewHelper::UpdatePrintSettings( SetPrintPagesParams(settings); - if (!PrintMsg_Print_Params_IsValid(settings.params)) { - if (!print_for_preview_) - print_preview_context_.set_error(PREVIEW_ERROR_INVALID_PRINTER_SETTINGS); - return false; - } + if (PrintMsg_Print_Params_IsValid(settings.params)) + return true; - return true; + if (print_for_preview_) + Send(new PrintHostMsg_ShowInvalidPrinterSettingsError(routing_id())); + else + print_preview_context_.set_error(PREVIEW_ERROR_INVALID_PRINTER_SETTINGS); + return false; } - bool PrintWebViewHelper::GetPrintSettingsFromUser(blink::WebLocalFrame* frame, const blink::WebNode& node, int expected_pages_count) { @@ -1170,6 +1170,8 @@ bool PrintWebViewHelper::CopyMetafileDataToSharedMem( void PrintWebViewHelper::SetPrintPagesParams( const PrintMsg_PrintPages_Params& settings) { print_pages_params_.reset(new PrintMsg_PrintPages_Params(settings)); + Send(new PrintHostMsg_DidGetDocumentCookie(routing_id(), + settings.params.document_cookie)); } bool PrintWebViewHelper::PreviewPageRendered(int page_number, From 3024d0563fefdefff8b6d64303426e28f31a6504 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 31 Jan 2017 17:41:05 +0900 Subject: [PATCH 55/63] There were new defaultPrintingSetting fields added --- lib/browser/api/web-contents.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index de31eeb70576..a92ef7603b25 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -72,6 +72,8 @@ const defaultPrintingSetting = { deviceName: 'Save as PDF', generateDraftData: true, fitToPageEnabled: false, + scaleFactor: 1, + rasterizePDF: false, duplex: 0, copies: 1, collate: true, From d483352f789a70983fe8f5b62d68cae1796fdb38 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 31 Jan 2017 17:59:39 +0900 Subject: [PATCH 56/63] Fix PrintToPDF not receiving results --- .../chrome/browser/printing/print_preview_message_handler.cc | 3 ++- .../chrome/browser/printing/print_preview_message_handler.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/chromium_src/chrome/browser/printing/print_preview_message_handler.cc b/chromium_src/chrome/browser/printing/print_preview_message_handler.cc index 05f4ca9ed98c..7e44f64c7c63 100644 --- a/chromium_src/chrome/browser/printing/print_preview_message_handler.cc +++ b/chromium_src/chrome/browser/printing/print_preview_message_handler.cc @@ -98,7 +98,8 @@ void PrintPreviewMessageHandler::OnPrintPreviewFailed(int document_cookie, } bool PrintPreviewMessageHandler::OnMessageReceived( - const IPC::Message& message) { + const IPC::Message& message, + content::RenderFrameHost* render_frame_host) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PrintPreviewMessageHandler, message) IPC_MESSAGE_HANDLER(PrintHostMsg_MetafileReadyForPrinting, diff --git a/chromium_src/chrome/browser/printing/print_preview_message_handler.h b/chromium_src/chrome/browser/printing/print_preview_message_handler.h index 1aac74baa229..465bbf598319 100644 --- a/chromium_src/chrome/browser/printing/print_preview_message_handler.h +++ b/chromium_src/chrome/browser/printing/print_preview_message_handler.h @@ -30,7 +30,8 @@ class PrintPreviewMessageHandler ~PrintPreviewMessageHandler() override; // content::WebContentsObserver implementation. - bool OnMessageReceived(const IPC::Message& message) override; + bool OnMessageReceived(const IPC::Message& message, + content::RenderFrameHost* render_frame_host) override; void PrintToPDF(const base::DictionaryValue& options, const atom::api::WebContents::PrintToPDFCallback& callback); From 1ed8743da8f9d0d5241f6487557b34181a41eaa6 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 31 Jan 2017 19:18:51 +0900 Subject: [PATCH 57/63] Update Windows printing code to latest --- atom/utility/atom_content_utility_client.cc | 54 +------ atom/utility/atom_content_utility_client.h | 24 --- .../browser/printing/pdf_to_emf_converter.cc | 143 ++++++++++++------ .../browser/printing/pdf_to_emf_converter.h | 10 +- .../printing/print_view_manager_base.cc | 7 +- .../chrome/common/chrome_utility_messages.h | 6 - chromium_src/chrome/common/print_messages.h | 15 +- .../chrome/utility/printing_handler_win.cc | 15 +- .../chrome/utility/printing_handler_win.h | 3 +- 9 files changed, 133 insertions(+), 144 deletions(-) diff --git a/atom/utility/atom_content_utility_client.cc b/atom/utility/atom_content_utility_client.cc index 4be5a5f3fd7d..37fa7558712f 100644 --- a/atom/utility/atom_content_utility_client.cc +++ b/atom/utility/atom_content_utility_client.cc @@ -4,38 +4,13 @@ #include "atom/utility/atom_content_utility_client.h" -#include "base/command_line.h" -#include "base/files/file_path.h" -#include "base/memory/ref_counted.h" -#include "base/time/time.h" -#include "chrome/common/chrome_utility_messages.h" -#include "chrome/utility/utility_message_handler.h" -#include "content/public/common/content_switches.h" -#include "content/public/utility/utility_thread.h" -#include "ipc/ipc_channel.h" -#include "ipc/ipc_message_macros.h" - - #if defined(OS_WIN) #include "chrome/utility/printing_handler_win.h" #endif - -namespace { - -bool Send(IPC::Message* message) { - return content::UtilityThread::Get()->Send(message); -} - -} // namespace - namespace atom { -int64_t AtomContentUtilityClient::max_ipc_message_size_ = - IPC::Channel::kMaximumMessageSize; - -AtomContentUtilityClient::AtomContentUtilityClient() - : filter_messages_(false) { +AtomContentUtilityClient::AtomContentUtilityClient() { #if defined(OS_WIN) handlers_.push_back(new printing::PrintingHandlerWin()); #endif @@ -44,31 +19,4 @@ AtomContentUtilityClient::AtomContentUtilityClient() AtomContentUtilityClient::~AtomContentUtilityClient() { } -void AtomContentUtilityClient::UtilityThreadStarted() { -} - -bool AtomContentUtilityClient::OnMessageReceived( - const IPC::Message& message) { - if (filter_messages_ && - !base::ContainsKey(message_id_whitelist_, message.type())) - return false; - - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(AtomContentUtilityClient, message) - IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - - for (auto it = handlers_.begin(); !handled && it != handlers_.end(); ++it) { - handled = (*it)->OnMessageReceived(message); - } - - return handled; -} - -void AtomContentUtilityClient::OnStartupPing() { - Send(new ChromeUtilityHostMsg_ProcessStarted); - // Don't release the process, we assume further messages are on the way. -} - } // namespace atom diff --git a/atom/utility/atom_content_utility_client.h b/atom/utility/atom_content_utility_client.h index ba0fef471a11..d59b3812ff87 100644 --- a/atom/utility/atom_content_utility_client.h +++ b/atom/utility/atom_content_utility_client.h @@ -5,19 +5,11 @@ #ifndef ATOM_UTILITY_ATOM_CONTENT_UTILITY_CLIENT_H_ #define ATOM_UTILITY_ATOM_CONTENT_UTILITY_CLIENT_H_ -#include -#include #include #include "base/compiler_specific.h" #include "base/memory/scoped_vector.h" #include "content/public/utility/content_utility_client.h" -#include "ipc/ipc_platform_file.h" - -namespace base { -class FilePath; -struct FileDescriptor; -} class UtilityMessageHandler; @@ -28,26 +20,10 @@ class AtomContentUtilityClient : public content::ContentUtilityClient { AtomContentUtilityClient(); ~AtomContentUtilityClient() override; - void UtilityThreadStarted() override; - bool OnMessageReceived(const IPC::Message& message) override; - - static void set_max_ipc_message_size_for_test(int64_t max_message_size) { - max_ipc_message_size_ = max_message_size; - } - private: - void OnStartupPing(); - typedef ScopedVector Handlers; Handlers handlers_; - // Flag to enable whitelisting. - bool filter_messages_; - // A list of message_ids to filter. - std::set message_id_whitelist_; - // Maximum IPC msg size (default to kMaximumMessageSize; override for testing) - static int64_t max_ipc_message_size_; - DISALLOW_COPY_AND_ASSIGN(AtomContentUtilityClient); }; diff --git a/chromium_src/chrome/browser/printing/pdf_to_emf_converter.cc b/chromium_src/chrome/browser/printing/pdf_to_emf_converter.cc index 503d192feec5..b06c3a06409d 100644 --- a/chromium_src/chrome/browser/printing/pdf_to_emf_converter.cc +++ b/chromium_src/chrome/browser/printing/pdf_to_emf_converter.cc @@ -4,13 +4,22 @@ #include "chrome/browser/printing/pdf_to_emf_converter.h" +#include +#include + +#include #include +#include +#include #include "base/files/file.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/logging.h" +#include "base/macros.h" #include "base/memory/ptr_util.h" +#include "base/strings/utf_string_conversions.h" +#include "base/threading/thread_task_runner_handle.h" #include "chrome/common/chrome_utility_messages.h" #include "chrome/common/print_messages.h" #include "content/public/browser/browser_thread.h" @@ -19,6 +28,7 @@ #include "content/public/browser/utility_process_host_client.h" #include "printing/emf_win.h" #include "printing/pdf_render_settings.h" +#include "ui/base/l10n/l10n_util.h" namespace printing { @@ -59,7 +69,9 @@ typedef std::unique_ptr class LazyEmf : public MetafilePlayer { public: LazyEmf(const scoped_refptr& temp_dir, ScopedTempFile file) - : temp_dir_(temp_dir), file_(std::move(file)) {} + : temp_dir_(temp_dir), file_(std::move(file)) { + CHECK(file_); + } ~LazyEmf() override { Close(); } bool SafePlayback(HDC hdc) const override; @@ -97,6 +109,7 @@ class PdfToEmfUtilityProcessHostClient const PdfRenderSettings& settings); void Start(const scoped_refptr& data, + bool print_text_with_gdi, const PdfToEmfConverter::StartCallback& start_callback); void GetPage(int page_number, @@ -104,10 +117,14 @@ class PdfToEmfUtilityProcessHostClient void Stop(); + // Needs to be public to handle ChromeUtilityHostMsg_PreCacheFontCharacters + // sync message replies. + bool Send(IPC::Message* msg); + // UtilityProcessHostClient implementation. - virtual void OnProcessCrashed(int exit_code) override; - virtual void OnProcessLaunchFailed(int exit_code) override; - virtual bool OnMessageReceived(const IPC::Message& message) override; + void OnProcessCrashed(int exit_code) override; + void OnProcessLaunchFailed(int exit_code) override; + bool OnMessageReceived(const IPC::Message& message) override; private: class GetPageCallbackData { @@ -138,19 +155,20 @@ class PdfToEmfUtilityProcessHostClient int page_number_; PdfToEmfConverter::GetPageCallback callback_; ScopedTempFile emf_; + + DISALLOW_COPY_AND_ASSIGN(GetPageCallbackData); }; - virtual ~PdfToEmfUtilityProcessHostClient(); - - bool Send(IPC::Message* msg); + ~PdfToEmfUtilityProcessHostClient() override; // Message handlers. - void OnProcessStarted(); void OnPageCount(int page_count); void OnPageDone(bool success, float scale_factor); + void OnPreCacheFontCharacters(const LOGFONT& log_font, + const base::string16& characters); void OnFailed(); - void OnTempPdfReady(ScopedTempFile pdf); + void OnTempPdfReady(bool print_text_with_gdi, ScopedTempFile pdf); void OnTempEmfReady(GetPageCallbackData* callback_data, ScopedTempFile emf); scoped_refptr temp_dir_; @@ -158,7 +176,6 @@ class PdfToEmfUtilityProcessHostClient // Used to suppress callbacks after PdfToEmfConverterImpl is deleted. base::WeakPtr converter_; PdfRenderSettings settings_; - scoped_refptr data_; // Document loaded callback. PdfToEmfConverter::StartCallback start_callback_; @@ -179,14 +196,15 @@ class PdfToEmfConverterImpl : public PdfToEmfConverter { public: PdfToEmfConverterImpl(); - virtual ~PdfToEmfConverterImpl(); + ~PdfToEmfConverterImpl() override; - virtual void Start(const scoped_refptr& data, - const PdfRenderSettings& conversion_settings, - const StartCallback& start_callback) override; + void Start(const scoped_refptr& data, + const PdfRenderSettings& conversion_settings, + bool print_text_with_gdi, + const StartCallback& start_callback) override; - virtual void GetPage(int page_number, - const GetPageCallback& get_page_callback) override; + void GetPage(int page_number, + const GetPageCallback& get_page_callback) override; // Helps to cancel callbacks if this object is destroyed. void RunCallback(const base::Closure& callback); @@ -205,16 +223,21 @@ ScopedTempFile CreateTempFile(scoped_refptr* temp_dir) { if (!(*temp_dir)->IsValid()) return file; base::FilePath path; - if (!base::CreateTemporaryFileInDir((*temp_dir)->GetPath(), &path)) + if (!base::CreateTemporaryFileInDir((*temp_dir)->GetPath(), &path)) { + PLOG(ERROR) << "Failed to create file in " + << (*temp_dir)->GetPath().value(); return file; + } file.reset(new base::File(path, base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE | base::File::FLAG_READ | base::File::FLAG_DELETE_ON_CLOSE | base::File::FLAG_TEMPORARY)); - if (!file->IsValid()) + if (!file->IsValid()) { + PLOG(ERROR) << "Failed to create " << path.value(); file.reset(); + } return file; } @@ -228,6 +251,7 @@ ScopedTempFile CreateTempPdfFile( static_cast(data->size()) != pdf_file->WriteAtCurrentPos(data->front_as(), data->size())) { pdf_file.reset(); + return pdf_file; } pdf_file->Seek(base::File::FROM_BEGIN, 0); return pdf_file; @@ -281,17 +305,15 @@ PdfToEmfUtilityProcessHostClient::~PdfToEmfUtilityProcessHostClient() { void PdfToEmfUtilityProcessHostClient::Start( const scoped_refptr& data, + bool print_text_with_gdi, const PdfToEmfConverter::StartCallback& start_callback) { if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { - BrowserThread::PostTask(BrowserThread::IO, - FROM_HERE, - base::Bind(&PdfToEmfUtilityProcessHostClient::Start, - this, - data, - start_callback)); + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, + base::Bind(&PdfToEmfUtilityProcessHostClient::Start, this, data, + print_text_with_gdi, start_callback)); return; } - data_ = data; // Store callback before any OnFailed() call to make it called on failure. start_callback_ = start_callback; @@ -299,37 +321,28 @@ void PdfToEmfUtilityProcessHostClient::Start( // NOTE: This process _must_ be sandboxed, otherwise the pdf dll will load // gdiplus.dll, change how rendering happens, and not be able to correctly // generate when sent to a metafile DC. - utility_process_host_ = - content::UtilityProcessHost::Create( - this, base::MessageLoop::current()->task_runner())->AsWeakPtr(); - if (!utility_process_host_) - return OnFailed(); - // Should reply with OnProcessStarted(). - Send(new ChromeUtilityMsg_StartupPing); -} + utility_process_host_ = content::UtilityProcessHost::Create( + this, base::ThreadTaskRunnerHandle::Get()) + ->AsWeakPtr(); + utility_process_host_->SetName(base::ASCIIToUTF16( + "IDS_UTILITY_PROCESS_EMF_CONVERTOR_NAME")); -void PdfToEmfUtilityProcessHostClient::OnProcessStarted() { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - if (!utility_process_host_) - return OnFailed(); - - scoped_refptr data = data_; - data_ = NULL; BrowserThread::PostTaskAndReplyWithResult( - BrowserThread::FILE, - FROM_HERE, + BrowserThread::FILE, FROM_HERE, base::Bind(&CreateTempPdfFile, data, &temp_dir_), - base::Bind(&PdfToEmfUtilityProcessHostClient::OnTempPdfReady, this)); + base::Bind(&PdfToEmfUtilityProcessHostClient::OnTempPdfReady, this, + print_text_with_gdi)); } -void PdfToEmfUtilityProcessHostClient::OnTempPdfReady(ScopedTempFile pdf) { +void PdfToEmfUtilityProcessHostClient::OnTempPdfReady(bool print_text_with_gdi, + ScopedTempFile pdf) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (!utility_process_host_ || !pdf) return OnFailed(); // Should reply with OnPageCount(). Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles( - IPC::GetPlatformFileForTransit(pdf->GetPlatformFile(), false), - settings_)); + IPC::GetPlatformFileForTransit(pdf->GetPlatformFile(), false), settings_, + print_text_with_gdi)); } void PdfToEmfUtilityProcessHostClient::OnPageCount(int page_count) { @@ -413,6 +426,38 @@ void PdfToEmfUtilityProcessHostClient::OnPageDone(bool success, get_page_callbacks_.pop(); } +void PdfToEmfUtilityProcessHostClient::OnPreCacheFontCharacters( + const LOGFONT& font, + const base::string16& str) { + // TODO(scottmg): pdf/ppapi still require the renderer to be able to precache + // GDI fonts (http://crbug.com/383227), even when using DirectWrite. + // Eventually this shouldn't be added and should be moved to + // FontCacheDispatcher too. http://crbug.com/356346. + + // First, comments from FontCacheDispatcher::OnPreCacheFont do apply here too. + // Except that for True Type fonts, + // GetTextMetrics will not load the font in memory. + // The only way windows seem to load properly, it is to create a similar + // device (like the one in which we print), then do an ExtTextOut, + // as we do in the printing thread, which is sandboxed. + HDC hdc = CreateEnhMetaFile(nullptr, nullptr, nullptr, nullptr); + HFONT font_handle = CreateFontIndirect(&font); + DCHECK(font_handle != nullptr); + + HGDIOBJ old_font = SelectObject(hdc, font_handle); + DCHECK(old_font != nullptr); + + ExtTextOut(hdc, 0, 0, ETO_GLYPH_INDEX, 0, str.c_str(), str.length(), nullptr); + + SelectObject(hdc, old_font); + DeleteObject(font_handle); + + HENHMETAFILE metafile = CloseEnhMetaFile(hdc); + + if (metafile) + DeleteEnhMetaFile(metafile); +} + void PdfToEmfUtilityProcessHostClient::Stop() { if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { BrowserThread::PostTask( @@ -436,11 +481,12 @@ bool PdfToEmfUtilityProcessHostClient::OnMessageReceived( const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PdfToEmfUtilityProcessHostClient, message) - IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ProcessStarted, OnProcessStarted) IPC_MESSAGE_HANDLER( ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageCount, OnPageCount) IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageDone, OnPageDone) + IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_PreCacheFontCharacters, + OnPreCacheFontCharacters) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -473,11 +519,12 @@ PdfToEmfConverterImpl::~PdfToEmfConverterImpl() { void PdfToEmfConverterImpl::Start( const scoped_refptr& data, const PdfRenderSettings& conversion_settings, + bool print_text_with_gdi, const StartCallback& start_callback) { DCHECK(!utility_client_.get()); utility_client_ = new PdfToEmfUtilityProcessHostClient( weak_ptr_factory_.GetWeakPtr(), conversion_settings); - utility_client_->Start(data, start_callback); + utility_client_->Start(data, print_text_with_gdi, start_callback); } void PdfToEmfConverterImpl::GetPage(int page_number, diff --git a/chromium_src/chrome/browser/printing/pdf_to_emf_converter.h b/chromium_src/chrome/browser/printing/pdf_to_emf_converter.h index bd292dd476a1..1f5271527406 100644 --- a/chromium_src/chrome/browser/printing/pdf_to_emf_converter.h +++ b/chromium_src/chrome/browser/printing/pdf_to_emf_converter.h @@ -10,21 +10,18 @@ #include "base/callback.h" #include "base/memory/ref_counted_memory.h" -namespace base { -class FilePath; -} - namespace printing { class MetafilePlayer; -class PdfRenderSettings; +struct PdfRenderSettings; class PdfToEmfConverter { public: typedef base::Callback StartCallback; typedef base::Callback emf)> GetPageCallback; + std::unique_ptr emf)> + GetPageCallback; virtual ~PdfToEmfConverter(); @@ -34,6 +31,7 @@ class PdfToEmfConverter { // with positive |page_count|. |page_count| is 0 if initialization failed. virtual void Start(const scoped_refptr& data, const PdfRenderSettings& conversion_settings, + bool print_text_with_gdi, const StartCallback& start_callback) = 0; // Requests conversion of the page. |page_number| is 0-base page number in diff --git a/chromium_src/chrome/browser/printing/print_view_manager_base.cc b/chromium_src/chrome/browser/printing/print_view_manager_base.cc index 67caebb63ecf..fb54bda2c778 100644 --- a/chromium_src/chrome/browser/printing/print_view_manager_base.cc +++ b/chromium_src/chrome/browser/printing/print_view_manager_base.cc @@ -160,13 +160,18 @@ void PrintViewManagerBase::OnDidPrintPage( ShouldQuitFromInnerMessageLoop(); #else if (metafile_must_be_valid) { + bool print_text_with_gdi = + document->settings().print_text_with_gdi() && + !document->settings().printer_is_xps(); + scoped_refptr bytes = new base::RefCountedBytes( reinterpret_cast(shared_buf.memory()), params.data_size); document->DebugDumpData(bytes.get(), FILE_PATH_LITERAL(".pdf")); print_job_->StartPdfToEmfConversion( - bytes, params.page_size, params.content_area); + bytes, params.page_size, params.content_area, + print_text_with_gdi); } #endif // !OS_WIN } diff --git a/chromium_src/chrome/common/chrome_utility_messages.h b/chromium_src/chrome/common/chrome_utility_messages.h index efcd468c5138..012c9f67509b 100644 --- a/chromium_src/chrome/common/chrome_utility_messages.h +++ b/chromium_src/chrome/common/chrome_utility_messages.h @@ -83,12 +83,6 @@ IPC_MESSAGE_CONTROL3(ChromeUtilityMsg_PatchFileCourgette, base::FilePath /* output_file */) -// Requests the utility process to respond with a -// ChromeUtilityHostMsg_ProcessStarted message once it has started. This may -// be used if the host process needs a handle to the running utility process. -IPC_MESSAGE_CONTROL0(ChromeUtilityMsg_StartupPing) - - #if defined(OS_WIN) // Invokes ui::base::win::OpenFileViaShell from the utility process. IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_OpenFileViaShell, diff --git a/chromium_src/chrome/common/print_messages.h b/chromium_src/chrome/common/print_messages.h index dce74cbe9f24..e74dfafa71aa 100644 --- a/chromium_src/chrome/common/print_messages.h +++ b/chromium_src/chrome/common/print_messages.h @@ -315,9 +315,10 @@ IPC_MESSAGE_ROUTED2(PrintHostMsg_PrintPreviewFailed, // Tell the utility process to start rendering the given PDF into a metafile. // Utility process would be alive until // ChromeUtilityMsg_RenderPDFPagesToMetafiles_Stop message. -IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_RenderPDFPagesToMetafiles, - IPC::PlatformFileForTransit, /* input_file */ - printing::PdfRenderSettings /* settings */) +IPC_MESSAGE_CONTROL3(ChromeUtilityMsg_RenderPDFPagesToMetafiles, + IPC::PlatformFileForTransit /* input_file */, + printing::PdfRenderSettings /* settings */, + bool /* print_text_with_gdi */) // Requests conversion of the next page. IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_RenderPDFPagesToMetafiles_GetPage, @@ -336,4 +337,12 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageCount, IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageDone, bool /* success */, float /* scale_factor */) + +// Request that the given font characters be loaded by the browser so it's +// cached by the OS. Please see +// PdfToEmfUtilityProcessHostClient::OnPreCacheFontCharacters for details. +IPC_SYNC_MESSAGE_CONTROL2_0(ChromeUtilityHostMsg_PreCacheFontCharacters, + LOGFONT /* font_data */, + base::string16 /* characters */) + #endif diff --git a/chromium_src/chrome/utility/printing_handler_win.cc b/chromium_src/chrome/utility/printing_handler_win.cc index c29dd5f9f694..4265991272af 100644 --- a/chromium_src/chrome/utility/printing_handler_win.cc +++ b/chromium_src/chrome/utility/printing_handler_win.cc @@ -28,9 +28,18 @@ void ReleaseProcessIfNeeded() { content::UtilityThread::Get()->ReleaseProcessIfNeeded(); } +void PreCacheFontCharacters(const LOGFONT* logfont, + const wchar_t* text, + size_t text_length) { + Send(new ChromeUtilityHostMsg_PreCacheFontCharacters( + *logfont, base::string16(text, text_length))); +} + } // namespace -PrintingHandlerWin::PrintingHandlerWin() {} +PrintingHandlerWin::PrintingHandlerWin() { + chrome_pdf::SetPDFEnsureTypefaceCharactersAccessible(PreCacheFontCharacters); +} PrintingHandlerWin::~PrintingHandlerWin() {} @@ -50,8 +59,10 @@ bool PrintingHandlerWin::OnMessageReceived(const IPC::Message& message) { void PrintingHandlerWin::OnRenderPDFPagesToMetafile( IPC::PlatformFileForTransit pdf_transit, - const PdfRenderSettings& settings) { + const PdfRenderSettings& settings, + bool print_text_with_gdi) { pdf_rendering_settings_ = settings; + chrome_pdf::SetPDFUseGDIPrinting(print_text_with_gdi); base::File pdf_file = IPC::PlatformFileForTransitToFile(pdf_transit); int page_count = LoadPDF(std::move(pdf_file)); //int page_count = 1; diff --git a/chromium_src/chrome/utility/printing_handler_win.h b/chromium_src/chrome/utility/printing_handler_win.h index e7fcc5bed158..b4a1902dc714 100644 --- a/chromium_src/chrome/utility/printing_handler_win.h +++ b/chromium_src/chrome/utility/printing_handler_win.h @@ -29,7 +29,8 @@ class PrintingHandlerWin : public UtilityMessageHandler { private: // IPC message handlers. void OnRenderPDFPagesToMetafile(IPC::PlatformFileForTransit pdf_transit, - const PdfRenderSettings& settings); + const PdfRenderSettings& settings, + bool print_text_with_gdi); void OnRenderPDFPagesToMetafileGetPage( int page_number, IPC::PlatformFileForTransit output_file); From e0c021bfef7292524964b4ab61db5db65c49f6aa Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 1 Feb 2017 13:56:34 +0900 Subject: [PATCH 58/63] Fix compilation waring on Mac --- atom/utility/atom_content_utility_client.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/atom/utility/atom_content_utility_client.h b/atom/utility/atom_content_utility_client.h index d59b3812ff87..0edc4d5d80c9 100644 --- a/atom/utility/atom_content_utility_client.h +++ b/atom/utility/atom_content_utility_client.h @@ -21,8 +21,10 @@ class AtomContentUtilityClient : public content::ContentUtilityClient { ~AtomContentUtilityClient() override; private: +#if defined(OS_WIN) typedef ScopedVector Handlers; Handlers handlers_; +#endif DISALLOW_COPY_AND_ASSIGN(AtomContentUtilityClient); }; From 86215d4300aa04bab4412b6e4dbc58023481c31e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 1 Feb 2017 15:06:40 +0900 Subject: [PATCH 59/63] Allow filter to use any scheme --- atom/browser/api/atom_api_web_request.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/atom/browser/api/atom_api_web_request.cc b/atom/browser/api/atom_api_web_request.cc index ff1e2254b89b..d8526e03ad8f 100644 --- a/atom/browser/api/atom_api_web_request.cc +++ b/atom/browser/api/atom_api_web_request.cc @@ -26,6 +26,7 @@ struct Converter { std::string pattern; if (!ConvertFromV8(isolate, val, &pattern)) return false; + *out = URLPattern(URLPattern::SCHEME_ALL); return out->Parse(pattern) == URLPattern::PARSE_SUCCESS; } }; From 864a23f72bdbd48d5d65397f5ffcb8d6771c6a2d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 2 Feb 2017 17:13:47 +0900 Subject: [PATCH 60/63] Fix print() not working --- .../chrome/browser/printing/print_view_manager_base.cc | 4 +++- .../chrome/browser/printing/print_view_manager_base.h | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/chromium_src/chrome/browser/printing/print_view_manager_base.cc b/chromium_src/chrome/browser/printing/print_view_manager_base.cc index fb54bda2c778..bc5d3f31f01d 100644 --- a/chromium_src/chrome/browser/printing/print_view_manager_base.cc +++ b/chromium_src/chrome/browser/printing/print_view_manager_base.cc @@ -194,7 +194,9 @@ void PrintViewManagerBase::OnShowInvalidPrinterSettingsError() { LOG(ERROR) << "Invalid printer settings"; } -bool PrintViewManagerBase::OnMessageReceived(const IPC::Message& message) { +bool PrintViewManagerBase::OnMessageReceived( + const IPC::Message& message, + content::RenderFrameHost* render_frame_host) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PrintViewManagerBase, message) IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPrintedPagesCount, diff --git a/chromium_src/chrome/browser/printing/print_view_manager_base.h b/chromium_src/chrome/browser/printing/print_view_manager_base.h index fbf2e2ffd022..46765d091004 100644 --- a/chromium_src/chrome/browser/printing/print_view_manager_base.h +++ b/chromium_src/chrome/browser/printing/print_view_manager_base.h @@ -54,10 +54,11 @@ class PrintViewManagerBase : public content::NotificationObserver, std::unique_ptr message); // Terminates or cancels the print job if one was pending. - virtual void RenderProcessGone(base::TerminationStatus status) override; + void RenderProcessGone(base::TerminationStatus status) override; // content::WebContentsObserver implementation. - virtual bool OnMessageReceived(const IPC::Message& message) override; + bool OnMessageReceived(const IPC::Message& message, + content::RenderFrameHost* render_frame_host) override; // IPC Message handlers. virtual void OnPrintingFailed(int cookie); From ec650b37736d52f7e96acf87b13069816dbadeb1 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 6 Feb 2017 10:12:33 +0900 Subject: [PATCH 61/63] Update to Chrome 56.0.2924.87 --- atom/common/chrome_version.h | 2 +- vendor/brightray | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/atom/common/chrome_version.h b/atom/common/chrome_version.h index 782973f792a2..4838875354ab 100644 --- a/atom/common/chrome_version.h +++ b/atom/common/chrome_version.h @@ -8,7 +8,7 @@ #ifndef ATOM_COMMON_CHROME_VERSION_H_ #define ATOM_COMMON_CHROME_VERSION_H_ -#define CHROME_VERSION_STRING "56.0.2924.67" +#define CHROME_VERSION_STRING "56.0.2924.87" #define CHROME_VERSION "v" CHROME_VERSION_STRING #endif // ATOM_COMMON_CHROME_VERSION_H_ diff --git a/vendor/brightray b/vendor/brightray index d5ac0caf9995..509fd37d890c 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit d5ac0caf9995d7736391d9d34158d1d2f7af9de7 +Subproject commit 509fd37d890ce24d4b1ef0790e7d5e1382d27d0c From 997799ad68f0ac36d2895cff123a6659c23404f7 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 6 Feb 2017 10:32:10 -0800 Subject: [PATCH 62/63] Update libcc to e0da1e9 --- script/lib/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/lib/config.py b/script/lib/config.py index 5637571e3c93..e6d149353c62 100644 --- a/script/lib/config.py +++ b/script/lib/config.py @@ -9,7 +9,7 @@ import sys BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \ 'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent' LIBCHROMIUMCONTENT_COMMIT = os.getenv('LIBCHROMIUMCONTENT_COMMIT') or \ - 'd8397c07461e726caad74dfe0cfe6ec284951667' + 'e0da1e9caa7c8f3da3519963a9ea32abba43c7c8' PLATFORM = { 'cygwin': 'win32', From dbb81e34e82b61c121e4630c1e816e0c70aa3077 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 6 Feb 2017 10:34:14 -0800 Subject: [PATCH 63/63] Upgrade node for modules version bump --- vendor/node | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/node b/vendor/node index 0bf9958c91e7..be4f9967b2c5 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit 0bf9958c91e7aed26d5d474b4ca59d3dce3e5e05 +Subproject commit be4f9967b2c5e8ce78647f37d44928e028e9f750