Merge remote-tracking branch 'upstream/master'

# Conflicts:
#	atom/browser/api/atom_api_web_contents.cc
#	chromium_src/chrome/browser/printing/print_job_worker.cc
#	chromium_src/chrome/browser/printing/print_job_worker.h
#	chromium_src/chrome/browser/printing/print_view_manager_base.cc
#	chromium_src/chrome/browser/printing/print_view_manager_base.h
#	chromium_src/chrome/browser/printing/printer_query.cc
#	chromium_src/chrome/common/print_messages.cc
#	chromium_src/chrome/renderer/printing/print_web_view_helper.cc
This commit is contained in:
renaesop 2017-02-07 09:30:36 +08:00
commit 26135b412b
168 changed files with 1632 additions and 1755 deletions

View file

@ -23,7 +23,7 @@
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "url/url_constants.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" #include "chrome/common/widevine_cdm_constants.h"
#endif #endif
@ -71,7 +71,7 @@ content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
return plugin; 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, content::PepperPluginInfo CreateWidevineCdmInfo(const base::FilePath& path,
const std::string& version) { const std::string& version) {
content::PepperPluginInfo widevine_cdm; content::PepperPluginInfo widevine_cdm;
@ -135,7 +135,7 @@ void AddPepperFlashFromCommandLine(
plugins->push_back(CreatePepperFlashInfo(flash_path, flash_version)); 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( void AddWidevineCdmFromCommandLine(
std::vector<content::PepperPluginInfo>* plugins) { std::vector<content::PepperPluginInfo>* plugins) {
auto command_line = base::CommandLine::ForCurrentProcess(); auto command_line = base::CommandLine::ForCurrentProcess();
@ -187,7 +187,7 @@ void AtomContentClient::AddAdditionalSchemes(
void AtomContentClient::AddPepperPlugins( void AtomContentClient::AddPepperPlugins(
std::vector<content::PepperPluginInfo>* plugins) { std::vector<content::PepperPluginInfo>* plugins) {
AddPepperFlashFromCommandLine(plugins); AddPepperFlashFromCommandLine(plugins);
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) #if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS)
AddWidevineCdmFromCommandLine(plugins); AddWidevineCdmFromCommandLine(plugins);
#endif #endif
} }

View file

@ -12,7 +12,6 @@
#include "atom/browser/api/atom_api_web_contents.h" #include "atom/browser/api/atom_api_web_contents.h"
#include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_browser_context.h"
#include "atom/browser/atom_browser_main_parts.h" #include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/browser.h"
#include "atom/browser/login_handler.h" #include "atom/browser/login_handler.h"
#include "atom/browser/relauncher.h" #include "atom/browser/relauncher.h"
#include "atom/common/atom_command_line.h" #include "atom/common/atom_command_line.h"
@ -298,6 +297,8 @@ struct Converter<Browser::LoginItemSettings> {
dict.Get("openAtLogin", &(out->open_at_login)); dict.Get("openAtLogin", &(out->open_at_login));
dict.Get("openAsHidden", &(out->open_as_hidden)); dict.Get("openAsHidden", &(out->open_as_hidden));
dict.Get("path", &(out->path));
dict.Get("args", &(out->args));
return true; return true;
} }
@ -557,7 +558,7 @@ void App::OnCreateWindow(
const GURL& target_url, const GURL& target_url,
const std::string& frame_name, const std::string& frame_name,
WindowOpenDisposition disposition, WindowOpenDisposition disposition,
const std::vector<base::string16>& features, const std::vector<std::string>& features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body, const scoped_refptr<content::ResourceRequestBodyImpl>& body,
int render_process_id, int render_process_id,
int render_frame_id) { int render_frame_id) {
@ -746,6 +747,12 @@ bool App::IsAccessibilitySupportEnabled() {
return ax_state->IsAccessibleBrowser(); return ax_state->IsAccessibleBrowser();
} }
Browser::LoginItemSettings App::GetLoginItemSettings(mate::Arguments* args) {
Browser::LoginItemSettings options;
args->GetNext(&options);
return Browser::Get()->GetLoginItemSettings(options);
}
#if defined(USE_NSS_CERTS) #if defined(USE_NSS_CERTS)
void App::ImportCertificate( void App::ImportCertificate(
const base::DictionaryValue& options, const base::DictionaryValue& options,
@ -867,8 +874,7 @@ void App::BuildPrototype(
base::Bind(&Browser::RemoveAsDefaultProtocolClient, browser)) base::Bind(&Browser::RemoveAsDefaultProtocolClient, browser))
.SetMethod("setBadgeCount", base::Bind(&Browser::SetBadgeCount, browser)) .SetMethod("setBadgeCount", base::Bind(&Browser::SetBadgeCount, browser))
.SetMethod("getBadgeCount", base::Bind(&Browser::GetBadgeCount, browser)) .SetMethod("getBadgeCount", base::Bind(&Browser::GetBadgeCount, browser))
.SetMethod("getLoginItemSettings", .SetMethod("getLoginItemSettings", &App::GetLoginItemSettings)
base::Bind(&Browser::GetLoginItemSettings, browser))
.SetMethod("setLoginItemSettings", .SetMethod("setLoginItemSettings",
base::Bind(&Browser::SetLoginItemSettings, browser)) base::Bind(&Browser::SetLoginItemSettings, browser))
#if defined(OS_MACOSX) #if defined(OS_MACOSX)

View file

@ -10,6 +10,7 @@
#include "atom/browser/api/event_emitter.h" #include "atom/browser/api/event_emitter.h"
#include "atom/browser/atom_browser_client.h" #include "atom/browser/atom_browser_client.h"
#include "atom/browser/browser.h"
#include "atom/browser/browser_observer.h" #include "atom/browser/browser_observer.h"
#include "atom/common/native_mate_converters/callback.h" #include "atom/common/native_mate_converters/callback.h"
#include "chrome/browser/process_singleton.h" #include "chrome/browser/process_singleton.h"
@ -52,7 +53,7 @@ class App : public AtomBrowserClient::Delegate,
const GURL& target_url, const GURL& target_url,
const std::string& frame_name, const std::string& frame_name,
WindowOpenDisposition disposition, WindowOpenDisposition disposition,
const std::vector<base::string16>& features, const std::vector<std::string>& features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body, const scoped_refptr<content::ResourceRequestBodyImpl>& body,
int render_process_id, int render_process_id,
int render_frame_id); int render_frame_id);
@ -123,6 +124,7 @@ class App : public AtomBrowserClient::Delegate,
bool Relaunch(mate::Arguments* args); bool Relaunch(mate::Arguments* args);
void DisableHardwareAcceleration(mate::Arguments* args); void DisableHardwareAcceleration(mate::Arguments* args);
bool IsAccessibilitySupportEnabled(); bool IsAccessibilitySupportEnabled();
Browser::LoginItemSettings GetLoginItemSettings(mate::Arguments* args);
#if defined(USE_NSS_CERTS) #if defined(USE_NSS_CERTS)
void ImportCertificate(const base::DictionaryValue& options, void ImportCertificate(const base::DictionaryValue& options,
const net::CompletionCallback& callback); const net::CompletionCallback& callback);

View file

@ -69,10 +69,6 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
dict.SetMethod("stopRecording", &StopRecording); dict.SetMethod("stopRecording", &StopRecording);
dict.SetMethod("getTraceBufferUsage", base::Bind( dict.SetMethod("getTraceBufferUsage", base::Bind(
&TracingController::GetTraceBufferUsage, controller)); &TracingController::GetTraceBufferUsage, controller));
dict.SetMethod("setWatchEvent", base::Bind(
&TracingController::SetWatchEvent, controller));
dict.SetMethod("cancelWatchEvent", base::Bind(
&TracingController::CancelWatchEvent, controller));
} }
} // namespace } // namespace

View file

@ -56,19 +56,20 @@ struct Converter<net::CanonicalCookie> {
}; };
template<> template<>
struct Converter<AtomCookieDelegate::ChangeCause> { struct Converter<net::CookieStore::ChangeCause> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const AtomCookieDelegate::ChangeCause& val) { const net::CookieStore::ChangeCause& val) {
switch (val) { switch (val) {
case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_EXPLICIT: case net::CookieStore::ChangeCause::INSERTED:
case net::CookieStore::ChangeCause::EXPLICIT:
return mate::StringToV8(isolate, "explicit"); return mate::StringToV8(isolate, "explicit");
case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_OVERWRITE: case net::CookieStore::ChangeCause::OVERWRITE:
return mate::StringToV8(isolate, "overwrite"); return mate::StringToV8(isolate, "overwrite");
case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_EXPIRED: case net::CookieStore::ChangeCause::EXPIRED:
return mate::StringToV8(isolate, "expired"); return mate::StringToV8(isolate, "expired");
case AtomCookieDelegate::ChangeCause::CHANGE_COOKIE_EVICTED: case net::CookieStore::ChangeCause::EVICTED:
return mate::StringToV8(isolate, "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"); return mate::StringToV8(isolate, "expired-overwrite");
default: default:
return mate::StringToV8(isolate, "unknown"); return mate::StringToV8(isolate, "unknown");
@ -266,7 +267,7 @@ void Cookies::Set(const base::DictionaryValue& details,
void Cookies::OnCookieChanged(const net::CanonicalCookie& cookie, void Cookies::OnCookieChanged(const net::CanonicalCookie& cookie,
bool removed, bool removed,
AtomCookieDelegate::ChangeCause cause) { net::CookieStore::ChangeCause cause) {
Emit("changed", cookie, cause, removed); Emit("changed", cookie, cause, removed);
} }

View file

@ -57,7 +57,7 @@ class Cookies : public mate::TrackableObject<Cookies>,
// AtomCookieDelegate::Observer: // AtomCookieDelegate::Observer:
void OnCookieChanged(const net::CanonicalCookie& cookie, void OnCookieChanged(const net::CanonicalCookie& cookie,
bool removed, bool removed,
AtomCookieDelegate::ChangeCause cause) override; net::CookieStore::ChangeCause cause) override;
private: private:
net::URLRequestContextGetter* request_context_getter_; net::URLRequestContextGetter* request_context_getter_;

View file

@ -10,8 +10,7 @@
#include "chrome/browser/media/desktop_media_list.h" #include "chrome/browser/media/desktop_media_list.h"
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.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/desktop_capturer.h"
#include "third_party/webrtc/modules/desktop_capture/window_capturer.h"
#include "atom/common/node_includes.h" #include "atom/common/node_includes.h"
@ -61,10 +60,12 @@ void DesktopCapturer::StartHandling(bool capture_window,
options.set_disable_effects(false); options.set_disable_effects(false);
#endif #endif
std::unique_ptr<webrtc::ScreenCapturer> screen_capturer( std::unique_ptr<webrtc::DesktopCapturer> screen_capturer(
capture_screen ? webrtc::ScreenCapturer::Create(options) : nullptr); capture_screen ? webrtc::DesktopCapturer::CreateScreenCapturer(options)
std::unique_ptr<webrtc::WindowCapturer> window_capturer( : nullptr);
capture_window ? webrtc::WindowCapturer::Create(options) : nullptr); std::unique_ptr<webrtc::DesktopCapturer> window_capturer(
capture_window ? webrtc::DesktopCapturer::CreateWindowCapturer(options)
: nullptr);
media_list_.reset(new NativeDesktopMediaList( media_list_.reset(new NativeDesktopMediaList(
std::move(screen_capturer), std::move(window_capturer))); std::move(screen_capturer), std::move(window_capturer)));

View file

@ -255,7 +255,7 @@ class ResolveProxyHelper {
// Start the request. // Start the request.
int result = proxy_service->ResolveProxy( int result = proxy_service->ResolveProxy(
url, "GET", &proxy_info_, completion_callback, &pac_req_, nullptr, url, "GET", &proxy_info_, completion_callback, &pac_req_, nullptr,
net::BoundNetLog()); net::NetLogWithSource());
// Completed synchronously. // Completed synchronously.
if (result != net::ERR_IO_PENDING) if (result != net::ERR_IO_PENDING)
@ -271,6 +271,9 @@ class ResolveProxyHelper {
}; };
// Runs the callback in UI thread. // Runs the callback in UI thread.
void RunCallbackInUI(const base::Callback<void()>& callback) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback);
}
template<typename ...T> template<typename ...T>
void RunCallbackInUI(const base::Callback<void(T...)>& callback, T... result) { void RunCallbackInUI(const base::Callback<void(T...)>& callback, T... result) {
BrowserThread::PostTask( BrowserThread::PostTask(
@ -371,7 +374,7 @@ void ClearAuthCacheInIO(
options.origin, options.realm, options.auth_scheme, options.origin, options.realm, options.auth_scheme,
net::AuthCredentials(options.username, options.password)); net::AuthCredentials(options.username, options.password));
} else { } else {
auth_cache->Clear(); auth_cache->ClearEntriesAddedWithin(base::TimeDelta::Max());
} }
} else if (options.type == "clientCertificate") { } else if (options.type == "clientCertificate") {
auto client_auth_cache = network_session->ssl_client_auth_cache(); auto client_auth_cache = network_session->ssl_client_auth_cache();

View file

@ -13,7 +13,6 @@
#include "atom/browser/atom_browser_client.h" #include "atom/browser/atom_browser_client.h"
#include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_browser_context.h"
#include "atom/browser/atom_browser_main_parts.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/lib/bluetooth_chooser.h"
#include "atom/browser/native_window.h" #include "atom/browser/native_window.h"
#include "atom/browser/net/atom_network_delegate.h" #include "atom/browser/net/atom_network_delegate.h"
@ -46,6 +45,7 @@
#include "brightray/browser/inspectable_web_contents_view.h" #include "brightray/browser/inspectable_web_contents_view.h"
#include "chrome/browser/printing/print_preview_message_handler.h" #include "chrome/browser/printing/print_preview_message_handler.h"
#include "chrome/browser/printing/print_view_manager_basic.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/renderer_host/render_widget_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/view_messages.h" #include "content/common/view_messages.h"
@ -70,8 +70,8 @@
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h" #include "native_mate/object_template_builder.h"
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
#include "third_party/WebKit/public/platform/WebInputEvent.h"
#include "third_party/WebKit/public/web/WebFindOptions.h" #include "third_party/WebKit/public/web/WebFindOptions.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
#if !defined(OS_MACOSX) #if !defined(OS_MACOSX)
@ -148,12 +148,24 @@ struct Converter<WindowOpenDisposition> {
WindowOpenDisposition val) { WindowOpenDisposition val) {
std::string disposition = "other"; std::string disposition = "other";
switch (val) { switch (val) {
case CURRENT_TAB: disposition = "default"; break; case WindowOpenDisposition::CURRENT_TAB:
case NEW_FOREGROUND_TAB: disposition = "foreground-tab"; break; disposition = "default";
case NEW_BACKGROUND_TAB: disposition = "background-tab"; break; break;
case NEW_POPUP: case NEW_WINDOW: disposition = "new-window"; break; case WindowOpenDisposition::NEW_FOREGROUND_TAB:
case SAVE_TO_DISK: disposition = "save-to-disk"; break; disposition = "foreground-tab";
default: break; 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); return mate::ConvertToV8(isolate, disposition);
} }
@ -354,7 +366,7 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
// Intialize permission helper. // Intialize permission helper.
WebContentsPermissionHelper::CreateForWebContents(web_contents); WebContentsPermissionHelper::CreateForWebContents(web_contents);
// Intialize security state client. // Intialize security state client.
AtomSecurityStateModelClient::CreateForWebContents(web_contents); SecurityStateTabHelper::CreateForWebContents(web_contents);
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent()); web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
@ -393,7 +405,7 @@ WebContents::~WebContents() {
} }
} }
bool WebContents::AddMessageToConsole(content::WebContents* source, bool WebContents::DidAddMessageToConsole(content::WebContents* source,
int32_t level, int32_t level,
const base::string16& message, const base::string16& message,
int32_t line_no, int32_t line_no,
@ -410,7 +422,7 @@ void WebContents::OnCreateWindow(
const GURL& target_url, const GURL& target_url,
const std::string& frame_name, const std::string& frame_name,
WindowOpenDisposition disposition, WindowOpenDisposition disposition,
const std::vector<base::string16>& features, const std::vector<std::string>& features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body) { const scoped_refptr<content::ResourceRequestBodyImpl>& body) {
if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN)
Emit("-new-window", target_url, frame_name, disposition, features, body); Emit("-new-window", target_url, frame_name, disposition, features, body);
@ -419,6 +431,7 @@ void WebContents::OnCreateWindow(
} }
void WebContents::WebContentsCreated(content::WebContents* source_contents, void WebContents::WebContentsCreated(content::WebContents* source_contents,
int opener_render_process_id,
int opener_render_frame_id, int opener_render_frame_id,
const std::string& frame_name, const std::string& frame_name,
const GURL& target_url, const GURL& target_url,
@ -448,7 +461,7 @@ void WebContents::AddNewContents(content::WebContents* source,
content::WebContents* WebContents::OpenURLFromTab( content::WebContents* WebContents::OpenURLFromTab(
content::WebContents* source, content::WebContents* source,
const content::OpenURLParams& params) { const content::OpenURLParams& params) {
if (params.disposition != CURRENT_TAB) { if (params.disposition != WindowOpenDisposition::CURRENT_TAB) {
if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN)
Emit("-new-window", params.url, "", params.disposition); Emit("-new-window", params.url, "", params.disposition);
else else
@ -548,7 +561,9 @@ void WebContents::ExitFullscreenModeForTab(content::WebContents* source) {
Emit("leave-html-full-screen"); Emit("leave-html-full-screen");
} }
void WebContents::RendererUnresponsive(content::WebContents* source) { void WebContents::RendererUnresponsive(
content::WebContents* source,
const content::WebContentsUnresponsiveState& unresponsive_state) {
Emit("unresponsive"); Emit("unresponsive");
if ((type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) && owner_window()) if ((type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) && owner_window())
owner_window()->RendererUnresponsive(source); owner_window()->RendererUnresponsive(source);
@ -658,11 +673,13 @@ void WebContents::PluginCrashed(const base::FilePath& plugin_path,
Emit("plugin-crashed", info.name, info.version); 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"); Emit("media-started-playing");
} }
void WebContents::MediaStoppedPlaying(const MediaPlayerId& id) { void WebContents::MediaStoppedPlaying(const MediaPlayerInfo& video_type,
const MediaPlayerId& id) {
Emit("media-paused"); Emit("media-paused");
} }
@ -716,7 +733,6 @@ void WebContents::DidGetResourceResponseStart(
} }
void WebContents::DidGetRedirectForResourceRequest( void WebContents::DidGetRedirectForResourceRequest(
content::RenderFrameHost* render_frame_host,
const content::ResourceRedirectDetails& details) { const content::ResourceRedirectDetails& details) {
Emit("did-get-redirect-request", Emit("did-get-redirect-request",
details.url, details.url,
@ -1094,7 +1110,7 @@ void WebContents::InspectServiceWorker() {
for (const auto& agent_host : content::DevToolsAgentHost::GetOrCreateAll()) { for (const auto& agent_host : content::DevToolsAgentHost::GetOrCreateAll()) {
if (agent_host->GetType() == if (agent_host->GetType() ==
content::DevToolsAgentHost::TYPE_SERVICE_WORKER) { content::DevToolsAgentHost::kTypeServiceWorker) {
OpenDevTools(nullptr); OpenDevTools(nullptr);
managed_web_contents()->AttachTo(agent_host); managed_web_contents()->AttachTo(agent_host);
break; break;
@ -1139,8 +1155,10 @@ void WebContents::Print(mate::Arguments* args) {
} }
printing::PrintViewManagerBasic::FromWebContents(web_contents())-> printing::PrintViewManagerBasic::FromWebContents(web_contents())->
PrintNow(settings.silent, PrintNow(web_contents()->GetMainFrame(),
settings.print_background, settings.device_name); settings.silent,
settings.print_background,
settings.device_name);
} }

View file

@ -186,7 +186,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
const GURL& target_url, const GURL& target_url,
const std::string& frame_name, const std::string& frame_name,
WindowOpenDisposition disposition, WindowOpenDisposition disposition,
const std::vector<base::string16>& features, const std::vector<std::string>& features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body); const scoped_refptr<content::ResourceRequestBodyImpl>& body);
// Returns the web preferences of current WebContents. // Returns the web preferences of current WebContents.
@ -215,12 +215,13 @@ class WebContents : public mate::TrackableObject<WebContents>,
const mate::Dictionary& options); const mate::Dictionary& options);
// content::WebContentsDelegate: // content::WebContentsDelegate:
bool AddMessageToConsole(content::WebContents* source, bool DidAddMessageToConsole(content::WebContents* source,
int32_t level, int32_t level,
const base::string16& message, const base::string16& message,
int32_t line_no, int32_t line_no,
const base::string16& source_id) override; const base::string16& source_id) override;
void WebContentsCreated(content::WebContents* source_contents, void WebContentsCreated(content::WebContents* source_contents,
int opener_render_process_id,
int opener_render_frame_id, int opener_render_frame_id,
const std::string& frame_name, const std::string& frame_name,
const GURL& target_url, const GURL& target_url,
@ -252,7 +253,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
void EnterFullscreenModeForTab(content::WebContents* source, void EnterFullscreenModeForTab(content::WebContents* source,
const GURL& origin) override; const GURL& origin) override;
void ExitFullscreenModeForTab(content::WebContents* source) 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; void RendererResponsive(content::WebContents* source) override;
bool HandleContextMenu(const content::ContextMenuParams& params) override; bool HandleContextMenu(const content::ContextMenuParams& params) override;
bool OnGoToEntryOffset(int offset) override; bool OnGoToEntryOffset(int offset) override;
@ -297,7 +300,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
void DidGetResourceResponseStart( void DidGetResourceResponseStart(
const content::ResourceRequestDetails& details) override; const content::ResourceRequestDetails& details) override;
void DidGetRedirectForResourceRequest( void DidGetRedirectForResourceRequest(
content::RenderFrameHost* render_frame_host,
const content::ResourceRedirectDetails& details) override; const content::ResourceRedirectDetails& details) override;
void DidFinishNavigation( void DidFinishNavigation(
content::NavigationHandle* navigation_handle) override; content::NavigationHandle* navigation_handle) override;
@ -310,8 +312,10 @@ class WebContents : public mate::TrackableObject<WebContents>,
const std::vector<content::FaviconURL>& urls) override; const std::vector<content::FaviconURL>& urls) override;
void PluginCrashed(const base::FilePath& plugin_path, void PluginCrashed(const base::FilePath& plugin_path,
base::ProcessId plugin_pid) override; base::ProcessId plugin_pid) override;
void MediaStartedPlaying(const MediaPlayerId& id) override; void MediaStartedPlaying(const MediaPlayerInfo& video_type,
void MediaStoppedPlaying(const MediaPlayerId& id) override; const MediaPlayerId& id) override;
void MediaStoppedPlaying(const MediaPlayerInfo& video_type,
const MediaPlayerId& id) override;
void DidChangeThemeColor(SkColor theme_color) override; void DidChangeThemeColor(SkColor theme_color) override;
// brightray::InspectableWebContentsDelegate: // brightray::InspectableWebContentsDelegate:

View file

@ -20,13 +20,14 @@ using content::BrowserThread;
namespace mate { namespace mate {
template<> template<>
struct Converter<extensions::URLPattern> { struct Converter<URLPattern> {
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val, static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
extensions::URLPattern* out) { URLPattern* out) {
std::string pattern; std::string pattern;
if (!ConvertFromV8(isolate, val, &pattern)) if (!ConvertFromV8(isolate, val, &pattern))
return false; return false;
return out->Parse(pattern) == extensions::URLPattern::PARSE_SUCCESS; *out = URLPattern(URLPattern::SCHEME_ALL);
return out->Parse(pattern) == URLPattern::PARSE_SUCCESS;
} }
}; };

View file

@ -160,7 +160,6 @@ void AtomBrowserClient::OverrideWebkitPrefs(
prefs->allow_universal_access_from_file_urls = true; prefs->allow_universal_access_from_file_urls = true;
prefs->allow_file_access_from_file_urls = true; prefs->allow_file_access_from_file_urls = true;
prefs->experimental_webgl_enabled = true; prefs->experimental_webgl_enabled = true;
prefs->allow_displaying_insecure_content = false;
prefs->allow_running_insecure_content = false; prefs->allow_running_insecure_content = false;
// Custom preferences of guest page. // Custom preferences of guest page.
@ -300,7 +299,7 @@ bool AtomBrowserClient::CanCreateWindow(
const std::string& frame_name, const std::string& frame_name,
WindowOpenDisposition disposition, WindowOpenDisposition disposition,
const blink::WebWindowFeatures& features, const blink::WebWindowFeatures& features,
const std::vector<base::string16>& additional_features, const std::vector<std::string>& additional_features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body, const scoped_refptr<content::ResourceRequestBodyImpl>& body,
bool user_gesture, bool user_gesture,
bool opener_suppressed, bool opener_suppressed,

View file

@ -88,7 +88,7 @@ class AtomBrowserClient : public brightray::BrowserClient,
const std::string& frame_name, const std::string& frame_name,
WindowOpenDisposition disposition, WindowOpenDisposition disposition,
const blink::WebWindowFeatures& features, const blink::WebWindowFeatures& features,
const std::vector<base::string16>& additional_features, const std::vector<std::string>& additional_features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body, const scoped_refptr<content::ResourceRequestBodyImpl>& body,
bool user_gesture, bool user_gesture,
bool opener_suppressed, bool opener_suppressed,

View file

@ -15,7 +15,6 @@
#include "atom/browser/net/atom_cert_verifier.h" #include "atom/browser/net/atom_cert_verifier.h"
#include "atom/browser/net/atom_ct_delegate.h" #include "atom/browser/net/atom_ct_delegate.h"
#include "atom/browser/net/atom_network_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/atom_url_request_job_factory.h"
#include "atom/browser/net/http_protocol_handler.h" #include "atom/browser/net/http_protocol_handler.h"
#include "atom/browser/web_view_manager.h" #include "atom/browser/web_view_manager.h"
@ -156,8 +155,7 @@ AtomBrowserContext::CreateURLRequestJobFactory(
url_request_context_getter()->GetURLRequestContext()->host_resolver(); url_request_context_getter()->GetURLRequestContext()->host_resolver();
job_factory->SetProtocolHandler( job_factory->SetProtocolHandler(
url::kFtpScheme, url::kFtpScheme,
base::WrapUnique(new net::FtpProtocolHandler( net::FtpProtocolHandler::Create(host_resolver));
new net::FtpNetworkLayer(host_resolver))));
return std::move(job_factory); return std::move(job_factory);
} }
@ -198,10 +196,6 @@ std::unique_ptr<net::CertVerifier> AtomBrowserContext::CreateCertVerifier() {
return base::WrapUnique(new AtomCertVerifier(ct_delegate_.get())); return base::WrapUnique(new AtomCertVerifier(ct_delegate_.get()));
} }
net::SSLConfigService* AtomBrowserContext::CreateSSLConfigService() {
return new AtomSSLConfigService;
}
std::vector<std::string> AtomBrowserContext::GetCookieableSchemes() { std::vector<std::string> AtomBrowserContext::GetCookieableSchemes() {
auto default_schemes = brightray::BrowserContext::GetCookieableSchemes(); auto default_schemes = brightray::BrowserContext::GetCookieableSchemes();
const auto& standard_schemes = atom::api::GetStandardSchemes(); const auto& standard_schemes = atom::api::GetStandardSchemes();

View file

@ -41,7 +41,6 @@ class AtomBrowserContext : public brightray::BrowserContext {
net::HttpCache::BackendFactory* CreateHttpCacheBackendFactory( net::HttpCache::BackendFactory* CreateHttpCacheBackendFactory(
const base::FilePath& base_path) override; const base::FilePath& base_path) override;
std::unique_ptr<net::CertVerifier> CreateCertVerifier() override; std::unique_ptr<net::CertVerifier> CreateCertVerifier() override;
net::SSLConfigService* CreateSSLConfigService() override;
std::vector<std::string> GetCookieableSchemes() override; std::vector<std::string> GetCookieableSchemes() override;
net::TransportSecurityState::RequireCTDelegate* GetRequireCTDelegate() net::TransportSecurityState::RequireCTDelegate* GetRequireCTDelegate()
override; override;

View file

@ -24,7 +24,7 @@
#include "v8/include/v8-debug.h" #include "v8/include/v8-debug.h"
#if defined(USE_X11) #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" #include "ui/events/devices/x11/touch_factory_x11.h"
#endif #endif
@ -170,7 +170,7 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
bridge_task_runner_ = nullptr; bridge_task_runner_ = nullptr;
#if defined(USE_X11) #if defined(USE_X11)
libgtk2ui::GtkInitFromCommandLine(*base::CommandLine::ForCurrentProcess()); libgtkui::GtkInitFromCommandLine(*base::CommandLine::ForCurrentProcess());
#endif #endif
#if !defined(OS_MACOSX) #if !defined(OS_MACOSX)

View file

@ -58,6 +58,12 @@ void AtomJavaScriptDialogManager::RunBeforeUnloadDialog(
callback.Run(false, base::ASCIIToUTF16("This should not be displayed")); callback.Run(false, base::ASCIIToUTF16("This should not be displayed"));
} }
void AtomJavaScriptDialogManager::CancelDialogs(
content::WebContents* web_contents,
bool suppress_callbacks,
bool reset_state) {
}
// static // static
void AtomJavaScriptDialogManager::OnMessageBoxCallback( void AtomJavaScriptDialogManager::OnMessageBoxCallback(
const DialogClosedCallback& callback, int code) { const DialogClosedCallback& callback, int code) {

View file

@ -26,9 +26,9 @@ class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
content::WebContents* web_contents, content::WebContents* web_contents,
bool is_reload, bool is_reload,
const DialogClosedCallback& callback) override; const DialogClosedCallback& callback) override;
void CancelActiveAndPendingDialogs( void CancelDialogs(content::WebContents* web_contents,
content::WebContents* web_contents) override {} bool suppress_callbacks,
void ResetDialogState(content::WebContents* web_contents) override {}; bool reset_state) override;
private: private:
static void OnMessageBoxCallback(const DialogClosedCallback& callback, static void OnMessageBoxCallback(const DialogClosedCallback& callback,

View file

@ -64,17 +64,12 @@ AtomResourceDispatcherHostDelegate::AtomResourceDispatcherHostDelegate() {
bool AtomResourceDispatcherHostDelegate::HandleExternalProtocol( bool AtomResourceDispatcherHostDelegate::HandleExternalProtocol(
const GURL& url, const GURL& url,
int child_id, content::ResourceRequestInfo* info) {
const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
bool is_main_frame,
ui::PageTransition transition,
bool has_user_gesture,
content::ResourceContext* resource_context) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&HandleExternalProtocolInUI, base::Bind(&HandleExternalProtocolInUI,
url, url,
web_contents_getter, info->GetWebContentsGetterForRequest(),
has_user_gesture)); info->HasUserGesture()));
return true; return true;
} }

View file

@ -15,14 +15,8 @@ class AtomResourceDispatcherHostDelegate
AtomResourceDispatcherHostDelegate(); AtomResourceDispatcherHostDelegate();
// content::ResourceDispatcherHostDelegate: // content::ResourceDispatcherHostDelegate:
bool HandleExternalProtocol( bool HandleExternalProtocol(const GURL& url,
const GURL& url, content::ResourceRequestInfo* info) override;
int child_id,
const content::ResourceRequestInfo::WebContentsGetter&,
bool is_main_frame,
ui::PageTransition transition,
bool has_user_gesture,
content::ResourceContext* resource_context) override;
content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate( content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
net::AuthChallengeInfo* auth_info, net::AuthChallengeInfo* auth_info,
net::URLRequest* request) override; net::URLRequest* request) override;

View file

@ -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<net::X509Certificate>* 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

View file

@ -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<AtomSecurityStateModelClient> {
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<net::X509Certificate>* cert) override;
bool UsedPolicyInstalledCertificate() override;
bool IsOriginSecure(const GURL& url) override;
private:
explicit AtomSecurityStateModelClient(content::WebContents* web_contents);
friend class content::WebContentsUserData<AtomSecurityStateModelClient>;
content::WebContents* web_contents_;
std::unique_ptr<security_state::SecurityStateModel> security_state_model_;
DISALLOW_COPY_AND_ASSIGN(AtomSecurityStateModelClient);
};
} // namespace atom
#endif // ATOM_BROWSER_ATOM_SECURITY_STATE_MODEL_CLIENT_H_

View file

@ -7,10 +7,12 @@
#include <string> #include <string>
#include "atom/browser/atom_browser_main_parts.h" #include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/browser_observer.h"
#include "atom/browser/native_window.h" #include "atom/browser/native_window.h"
#include "atom/browser/window_list.h" #include "atom/browser/window_list.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/run_loop.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "brightray/browser/brightray_paths.h" #include "brightray/browser/brightray_paths.h"
@ -82,9 +84,10 @@ void Browser::Shutdown() {
is_shutdown_ = true; is_shutdown_ = true;
is_quiting_ = true; is_quiting_ = true;
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnQuit()); for (BrowserObserver& observer : observers_)
observer.OnQuit();
if (base::MessageLoop::current()) { if (base::ThreadTaskRunnerHandle::IsSet()) {
base::ThreadTaskRunnerHandle::Get()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
} else { } else {
@ -127,25 +130,25 @@ int Browser::GetBadgeCount() {
bool Browser::OpenFile(const std::string& file_path) { bool Browser::OpenFile(const std::string& file_path) {
bool prevent_default = false; bool prevent_default = false;
FOR_EACH_OBSERVER(BrowserObserver, for (BrowserObserver& observer : observers_)
observers_, observer.OnOpenFile(&prevent_default, file_path);
OnOpenFile(&prevent_default, file_path));
return prevent_default; return prevent_default;
} }
void Browser::OpenURL(const std::string& url) { 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) { void Browser::Activate(bool has_visible_windows) {
FOR_EACH_OBSERVER(BrowserObserver, for (BrowserObserver& observer : observers_)
observers_, observer.OnActivate(has_visible_windows);
OnActivate(has_visible_windows));
} }
void Browser::WillFinishLaunching() { void Browser::WillFinishLaunching() {
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillFinishLaunching()); for (BrowserObserver& observer : observers_)
observer.OnWillFinishLaunching();
} }
void Browser::DidFinishLaunching(const base::DictionaryValue& launch_info) { void Browser::DidFinishLaunching(const base::DictionaryValue& launch_info) {
@ -155,22 +158,20 @@ void Browser::DidFinishLaunching(const base::DictionaryValue& launch_info) {
base::CreateDirectoryAndGetError(user_data, nullptr); base::CreateDirectoryAndGetError(user_data, nullptr);
is_ready_ = true; is_ready_ = true;
FOR_EACH_OBSERVER(BrowserObserver, observers_, for (BrowserObserver& observer : observers_)
OnFinishLaunching(launch_info)); observer.OnFinishLaunching(launch_info);
} }
void Browser::OnAccessibilitySupportChanged() { void Browser::OnAccessibilitySupportChanged() {
FOR_EACH_OBSERVER(BrowserObserver, for (BrowserObserver& observer : observers_)
observers_, observer.OnAccessibilitySupportChanged();
OnAccessibilitySupportChanged());
} }
void Browser::RequestLogin( void Browser::RequestLogin(
LoginHandler* login_handler, LoginHandler* login_handler,
std::unique_ptr<base::DictionaryValue> request_details) { std::unique_ptr<base::DictionaryValue> request_details) {
FOR_EACH_OBSERVER(BrowserObserver, for (BrowserObserver& observer : observers_)
observers_, observer.OnLogin(login_handler, *(request_details.get()));
OnLogin(login_handler, *(request_details.get())));
} }
void Browser::NotifyAndShutdown() { void Browser::NotifyAndShutdown() {
@ -178,7 +179,8 @@ void Browser::NotifyAndShutdown() {
return; return;
bool prevent_default = false; bool prevent_default = false;
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillQuit(&prevent_default)); for (BrowserObserver& observer : observers_)
observer.OnWillQuit(&prevent_default);
if (prevent_default) { if (prevent_default) {
is_quiting_ = false; is_quiting_ = false;
@ -190,9 +192,8 @@ void Browser::NotifyAndShutdown() {
bool Browser::HandleBeforeQuit() { bool Browser::HandleBeforeQuit() {
bool prevent_default = false; bool prevent_default = false;
FOR_EACH_OBSERVER(BrowserObserver, for (BrowserObserver& observer : observers_)
observers_, observer.OnBeforeQuit(&prevent_default);
OnBeforeQuit(&prevent_default));
return !prevent_default; return !prevent_default;
} }
@ -205,12 +206,14 @@ void Browser::OnWindowCloseCancelled(NativeWindow* window) {
} }
void Browser::OnWindowAllClosed() { void Browser::OnWindowAllClosed() {
if (is_exiting_) if (is_exiting_) {
Shutdown(); Shutdown();
else if (is_quiting_) } else if (is_quiting_) {
NotifyAndShutdown(); NotifyAndShutdown();
else } else {
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWindowAllClosed()); for (BrowserObserver& observer : observers_)
observer.OnWindowAllClosed();
}
} }
} // namespace atom } // namespace atom

View file

@ -98,9 +98,11 @@ class Browser : public WindowListObserver {
bool restore_state = false; bool restore_state = false;
bool opened_at_login = false; bool opened_at_login = false;
bool opened_as_hidden = false; bool opened_as_hidden = false;
base::string16 path;
std::vector<base::string16> args;
}; };
void SetLoginItemSettings(LoginItemSettings settings); void SetLoginItemSettings(LoginItemSettings settings);
LoginItemSettings GetLoginItemSettings(); LoginItemSettings GetLoginItemSettings(LoginItemSettings options);
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// Hide the application. // Hide the application.

View file

@ -10,7 +10,7 @@
#include "atom/browser/window_list.h" #include "atom/browser/window_list.h"
#include "atom/common/atom_version.h" #include "atom/common/atom_version.h"
#include "brightray/common/application_info.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 { namespace atom {
@ -63,7 +63,8 @@ bool Browser::SetBadgeCount(int count) {
void Browser::SetLoginItemSettings(LoginItemSettings settings) { void Browser::SetLoginItemSettings(LoginItemSettings settings) {
} }
Browser::LoginItemSettings Browser::GetLoginItemSettings() { Browser::LoginItemSettings Browser::GetLoginItemSettings(
LoginItemSettings options) {
return LoginItemSettings(); return LoginItemSettings();
} }

View file

@ -146,13 +146,13 @@ std::string Browser::GetCurrentActivityType() {
bool Browser::ContinueUserActivity(const std::string& type, bool Browser::ContinueUserActivity(const std::string& type,
const base::DictionaryValue& user_info) { const base::DictionaryValue& user_info) {
bool prevent_default = false; bool prevent_default = false;
FOR_EACH_OBSERVER(BrowserObserver, for (BrowserObserver& observer : observers_)
observers_, observer.OnContinueUserActivity(&prevent_default, type, user_info);
OnContinueUserActivity(&prevent_default, type, user_info));
return prevent_default; return prevent_default;
} }
Browser::LoginItemSettings Browser::GetLoginItemSettings() { Browser::LoginItemSettings Browser::GetLoginItemSettings(
LoginItemSettings options) {
LoginItemSettings settings; LoginItemSettings settings;
settings.open_at_login = base::mac::CheckLoginItemStatus( settings.open_at_login = base::mac::CheckLoginItemStatus(
&settings.open_as_hidden); &settings.open_as_hidden);

View file

@ -43,15 +43,19 @@ BOOL CALLBACK WindowsEnumerationHandler(HWND hwnd, LPARAM param) {
return TRUE; return TRUE;
} }
bool GetProtocolLaunchPath(mate::Arguments* args, base::string16* exe) { bool GetProcessExecPath(base::string16* exe) {
// Executable Path
if (!args->GetNext(exe)) {
base::FilePath path; base::FilePath path;
if (!PathService::Get(base::FILE_EXE, &path)) { if (!PathService::Get(base::FILE_EXE, &path)) {
LOG(ERROR) << "Error getting app exe path"; LOG(ERROR) << "Error getting app exe path";
return false; return false;
} }
*exe = path.value(); *exe = path.value();
return true;
}
bool GetProtocolLaunchPath(mate::Arguments* args, base::string16* exe) {
if (!args->GetNext(exe) && !GetProcessExecPath(exe)) {
return false;
} }
// Read in optional args arg // Read in optional args arg
@ -65,6 +69,22 @@ bool GetProtocolLaunchPath(mate::Arguments* args, base::string16* exe) {
return true; return true;
} }
bool FormatCommandLineString(base::string16* exe,
const std::vector<base::string16>& launch_args) {
if (exe->empty() && !GetProcessExecPath(exe)) {
return false;
}
if (!launch_args.empty()) {
base::string16 formatString = L"%s %s";
*exe = base::StringPrintf(formatString.c_str(),
exe->c_str(),
base::JoinString(launch_args, L" ").c_str());
}
return true;
}
} // namespace } // namespace
void Browser::Focus() { void Browser::Focus() {
@ -257,34 +277,32 @@ void Browser::SetLoginItemSettings(LoginItemSettings settings) {
base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS); base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS);
if (settings.open_at_login) { if (settings.open_at_login) {
base::FilePath path; base::string16 exe = settings.path;
if (PathService::Get(base::FILE_EXE, &path)) { if (FormatCommandLineString(&exe, settings.args)) {
base::string16 exePath(path.value()); key.WriteValue(GetAppUserModelID(), exe.c_str());
key.WriteValue(GetAppUserModelID(), exePath.c_str());
} }
} else { } else {
key.DeleteValue(GetAppUserModelID()); key.DeleteValue(GetAppUserModelID());
} }
} }
Browser::LoginItemSettings Browser::GetLoginItemSettings() { Browser::LoginItemSettings Browser::GetLoginItemSettings(
LoginItemSettings options) {
LoginItemSettings settings; LoginItemSettings settings;
base::string16 keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run"; base::string16 keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS); base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS);
base::string16 keyVal; base::string16 keyVal;
if (!FAILED(key.ReadValue(GetAppUserModelID(), &keyVal))) { if (!FAILED(key.ReadValue(GetAppUserModelID(), &keyVal))) {
base::FilePath path; base::string16 exe = options.path;
if (PathService::Get(base::FILE_EXE, &path)) { if (FormatCommandLineString(&exe, options.args)) {
base::string16 exePath(path.value()); settings.open_at_login = keyVal == exe;
settings.open_at_login = keyVal == exePath;
} }
} }
return settings; return settings;
} }
PCWSTR Browser::GetAppUserModelID() { PCWSTR Browser::GetAppUserModelID() {
if (app_user_model_id_.empty()) { if (app_user_model_id_.empty()) {
SetAppUserModelID(base::ReplaceStringPlaceholders( SetAppUserModelID(base::ReplaceStringPlaceholders(

View file

@ -10,7 +10,6 @@
#include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_browser_context.h"
#include "atom/browser/atom_javascript_dialog_manager.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/native_window.h"
#include "atom/browser/ui/file_dialog.h" #include "atom/browser/ui/file_dialog.h"
#include "atom/browser/web_dialog_helper.h" #include "atom/browser/web_dialog_helper.h"
@ -18,10 +17,13 @@
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "chrome/browser/printing/print_preview_message_handler.h" #include "chrome/browser/printing/print_preview_message_handler.h"
#include "chrome/browser/printing/print_view_manager_basic.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/browser/ui/browser_dialogs.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.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/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
@ -32,7 +34,6 @@
#include "storage/browser/fileapi/isolated_context.h" #include "storage/browser/fileapi/isolated_context.h"
using content::BrowserThread; using content::BrowserThread;
using security_state::SecurityStateModel;
namespace atom { namespace atom {
@ -93,8 +94,10 @@ FileSystem CreateFileSystemStruct(
return FileSystem(file_system_name, root_url, file_system_path); return FileSystem(file_system_name, root_url, file_system_path);
} }
base::DictionaryValue* CreateFileSystemValue(const FileSystem& file_system) { std::unique_ptr<base::DictionaryValue> CreateFileSystemValue(
auto* file_system_value = new base::DictionaryValue(); const FileSystem& file_system) {
std::unique_ptr<base::DictionaryValue> file_system_value(
new base::DictionaryValue());
file_system_value->SetString("fileSystemName", file_system.file_system_name); file_system_value->SetString("fileSystemName", file_system.file_system_name);
file_system_value->SetString("rootURL", file_system.root_url); file_system_value->SetString("rootURL", file_system.root_url);
file_system_value->SetString("fileSystemPath", file_system.file_system_path); file_system_value->SetString("fileSystemPath", file_system.file_system_path);
@ -144,24 +147,6 @@ bool IsDevToolsFileSystemAdded(
return file_system_paths.find(file_system_path) != file_system_paths.end(); return file_system_paths.find(file_system_path) != file_system_paths.end();
} }
content::SecurityStyle SecurityLevelToSecurityStyle(
SecurityStateModel::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;
}
return content::SECURITY_STYLE_UNKNOWN;
}
} // namespace } // namespace
CommonWebContentsDelegate::CommonWebContentsDelegate() CommonWebContentsDelegate::CommonWebContentsDelegate()
@ -290,81 +275,16 @@ bool CommonWebContentsDelegate::IsFullscreenForTabOrPending(
return html_fullscreen_; return html_fullscreen_;
} }
content::SecurityStyle CommonWebContentsDelegate::GetSecurityStyle( blink::WebSecurityStyle CommonWebContentsDelegate::GetSecurityStyle(
content::WebContents* web_contents, content::WebContents* web_contents,
content::SecurityStyleExplanations* explanations) { content::SecurityStyleExplanations* security_style_explanations) {
auto model_client = SecurityStateTabHelper* helper =
AtomSecurityStateModelClient::FromWebContents(web_contents); SecurityStateTabHelper::FromWebContents(web_contents);
DCHECK(helper);
const SecurityStateModel::SecurityInfo& security_info = security_state::SecurityInfo security_info;
model_client->GetSecurityInfo(); helper->GetSecurityInfo(&security_info);
return security_state::GetSecurityStyle(security_info,
const content::SecurityStyle security_style = security_style_explanations);
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;
} }
void CommonWebContentsDelegate::DevToolsSaveToFile( void CommonWebContentsDelegate::DevToolsSaveToFile(

View file

@ -81,7 +81,7 @@ class CommonWebContentsDelegate
void ExitFullscreenModeForTab(content::WebContents* source) override; void ExitFullscreenModeForTab(content::WebContents* source) override;
bool IsFullscreenForTabOrPending( bool IsFullscreenForTabOrPending(
const content::WebContents* source) const override; const content::WebContents* source) const override;
content::SecurityStyle GetSecurityStyle( blink::WebSecurityStyle GetSecurityStyle(
content::WebContents* web_contents, content::WebContents* web_contents,
content::SecurityStyleExplanations* explanations) override; content::SecurityStyleExplanations* explanations) override;
void HandleKeyboardEvent( void HandleKeyboardEvent(

View file

@ -390,9 +390,8 @@ void NativeWindow::CloseFilePreview() {
void NativeWindow::RequestToClosePage() { void NativeWindow::RequestToClosePage() {
bool prevent_default = false; bool prevent_default = false;
FOR_EACH_OBSERVER(NativeWindowObserver, for (NativeWindowObserver& observer : observers_)
observers_, observer.WillCloseWindow(&prevent_default);
WillCloseWindow(&prevent_default));
if (prevent_default) { if (prevent_default) {
WindowList::WindowCloseCancelled(this); WindowList::WindowCloseCancelled(this);
return; return;
@ -423,8 +422,8 @@ void NativeWindow::CloseContents(content::WebContents* source) {
inspectable_web_contents_ = nullptr; inspectable_web_contents_ = nullptr;
Observe(nullptr); Observe(nullptr);
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, for (NativeWindowObserver& observer : observers_)
WillDestroyNativeObject()); observer.WillDestroyNativeObject();
// When the web contents is gone, close the window immediately, but the // When the web contents is gone, close the window immediately, but the
// memory will not be freed until you call delete. // 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) { void NativeWindow::RendererResponsive(content::WebContents* source) {
window_unresposive_closure_.Cancel(); window_unresposive_closure_.Cancel();
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererResponsive()); for (NativeWindowObserver& observer : observers_)
observer.OnRendererResponsive();
} }
void NativeWindow::NotifyWindowClosed() { void NativeWindow::NotifyWindowClosed() {
@ -460,104 +460,116 @@ void NativeWindow::NotifyWindowClosed() {
WindowList::RemoveWindow(this); WindowList::RemoveWindow(this);
is_closed_ = true; is_closed_ = true;
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowClosed()); for (NativeWindowObserver& observer : observers_)
observer.OnWindowClosed();
} }
void NativeWindow::NotifyWindowBlur() { void NativeWindow::NotifyWindowBlur() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowBlur()); for (NativeWindowObserver& observer : observers_)
observer.OnWindowBlur();
} }
void NativeWindow::NotifyWindowFocus() { void NativeWindow::NotifyWindowFocus() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowFocus()); for (NativeWindowObserver& observer : observers_)
observer.OnWindowFocus();
} }
void NativeWindow::NotifyWindowShow() { void NativeWindow::NotifyWindowShow() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowShow()); for (NativeWindowObserver& observer : observers_)
observer.OnWindowShow();
} }
void NativeWindow::NotifyWindowHide() { void NativeWindow::NotifyWindowHide() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowHide()); for (NativeWindowObserver& observer : observers_)
observer.OnWindowHide();
} }
void NativeWindow::NotifyWindowMaximize() { void NativeWindow::NotifyWindowMaximize() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowMaximize()); for (NativeWindowObserver& observer : observers_)
observer.OnWindowMaximize();
} }
void NativeWindow::NotifyWindowUnmaximize() { void NativeWindow::NotifyWindowUnmaximize() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowUnmaximize()); for (NativeWindowObserver& observer : observers_)
observer.OnWindowUnmaximize();
} }
void NativeWindow::NotifyWindowMinimize() { void NativeWindow::NotifyWindowMinimize() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowMinimize()); for (NativeWindowObserver& observer : observers_)
observer.OnWindowMinimize();
} }
void NativeWindow::NotifyWindowRestore() { void NativeWindow::NotifyWindowRestore() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowRestore()); for (NativeWindowObserver& observer : observers_)
observer.OnWindowRestore();
} }
void NativeWindow::NotifyWindowResize() { void NativeWindow::NotifyWindowResize() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowResize()); for (NativeWindowObserver& observer : observers_)
observer.OnWindowResize();
} }
void NativeWindow::NotifyWindowMove() { void NativeWindow::NotifyWindowMove() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowMove()); for (NativeWindowObserver& observer : observers_)
observer.OnWindowMove();
} }
void NativeWindow::NotifyWindowMoved() { void NativeWindow::NotifyWindowMoved() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowMoved()); for (NativeWindowObserver& observer : observers_)
observer.OnWindowMoved();
} }
void NativeWindow::NotifyWindowEnterFullScreen() { void NativeWindow::NotifyWindowEnterFullScreen() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, for (NativeWindowObserver& observer : observers_)
OnWindowEnterFullScreen()); observer.OnWindowEnterFullScreen();
} }
void NativeWindow::NotifyWindowScrollTouchBegin() { void NativeWindow::NotifyWindowScrollTouchBegin() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, for (NativeWindowObserver& observer : observers_)
OnWindowScrollTouchBegin()); observer.OnWindowScrollTouchBegin();
} }
void NativeWindow::NotifyWindowScrollTouchEnd() { void NativeWindow::NotifyWindowScrollTouchEnd() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, for (NativeWindowObserver& observer : observers_)
OnWindowScrollTouchEnd()); observer.OnWindowScrollTouchEdge();
} }
void NativeWindow::NotifyWindowScrollTouchEdge() { void NativeWindow::NotifyWindowScrollTouchEdge() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, for (NativeWindowObserver& observer : observers_)
OnWindowScrollTouchEdge()); observer.OnWindowScrollTouchEdge();
} }
void NativeWindow::NotifyWindowSwipe(const std::string& direction) { void NativeWindow::NotifyWindowSwipe(const std::string& direction) {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, for (NativeWindowObserver& observer : observers_)
OnWindowSwipe(direction)); observer.OnWindowSwipe(direction);
} }
void NativeWindow::NotifyWindowLeaveFullScreen() { void NativeWindow::NotifyWindowLeaveFullScreen() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, for (NativeWindowObserver& observer : observers_)
OnWindowLeaveFullScreen()); observer.OnWindowLeaveFullScreen();
} }
void NativeWindow::NotifyWindowEnterHtmlFullScreen() { void NativeWindow::NotifyWindowEnterHtmlFullScreen() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, for (NativeWindowObserver& observer : observers_)
OnWindowEnterHtmlFullScreen()); observer.OnWindowEnterHtmlFullScreen();
} }
void NativeWindow::NotifyWindowLeaveHtmlFullScreen() { void NativeWindow::NotifyWindowLeaveHtmlFullScreen() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, for (NativeWindowObserver& observer : observers_)
OnWindowLeaveHtmlFullScreen()); observer.OnWindowLeaveHtmlFullScreen();
} }
void NativeWindow::NotifyWindowExecuteWindowsCommand( void NativeWindow::NotifyWindowExecuteWindowsCommand(
const std::string& command) { const std::string& command) {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, for (NativeWindowObserver& observer : observers_)
OnExecuteWindowsCommand(command)); observer.OnExecuteWindowsCommand(command);
} }
#if defined(OS_WIN) #if defined(OS_WIN)
void NativeWindow::NotifyWindowMessage( void NativeWindow::NotifyWindowMessage(
UINT message, WPARAM w_param, LPARAM l_param) { UINT message, WPARAM w_param, LPARAM l_param) {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, for (NativeWindowObserver& observer : observers_)
OnWindowMessage(message, w_param, l_param)); observer.OnWindowMessage(message, w_param, l_param);
} }
#endif #endif
@ -645,14 +657,15 @@ void NativeWindow::ScheduleUnresponsiveEvent(int ms) {
void NativeWindow::NotifyWindowUnresponsive() { void NativeWindow::NotifyWindowUnresponsive() {
window_unresposive_closure_.Cancel(); window_unresposive_closure_.Cancel();
if (!is_closed_ && !IsUnresponsiveEventSuppressed() && IsEnabled()) if (!is_closed_ && !IsUnresponsiveEventSuppressed() && IsEnabled()) {
FOR_EACH_OBSERVER(NativeWindowObserver, for (NativeWindowObserver& observer : observers_)
observers_, observer.OnRendererUnresponsive();
OnRendererUnresponsive()); }
} }
void NativeWindow::NotifyReadyToShow() { void NativeWindow::NotifyReadyToShow() {
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnReadyToShow()); for (NativeWindowObserver& observer : observers_)
observer.OnReadyToShow();
} }
} // namespace atom } // namespace atom

View file

@ -228,7 +228,7 @@ bool ScopedDisableResize::disable_resize_ = false;
- (void)windowWillEnterFullScreen:(NSNotification*)notification { - (void)windowWillEnterFullScreen:(NSNotification*)notification {
// Hide the native toolbar before entering fullscreen, so there is no visual // Hide the native toolbar before entering fullscreen, so there is no visual
// artifacts. // artifacts.
if (base::mac::IsOSYosemiteOrLater() && if (base::mac::IsOS10_10() &&
shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) { shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
NSWindow* window = shell_->GetNativeWindow(); NSWindow* window = shell_->GetNativeWindow();
[window setToolbar:nil]; [window setToolbar:nil];
@ -243,7 +243,7 @@ bool ScopedDisableResize::disable_resize_ = false;
// have to set one, because title bar is visible here. // have to set one, because title bar is visible here.
NSWindow* window = shell_->GetNativeWindow(); NSWindow* window = shell_->GetNativeWindow();
if ((shell_->transparent() || !shell_->has_frame()) && if ((shell_->transparent() || !shell_->has_frame()) &&
base::mac::IsOSYosemiteOrLater() && base::mac::IsOS10_10() &&
// FIXME(zcbenz): Showing titlebar for hiddenInset window is weird under // FIXME(zcbenz): Showing titlebar for hiddenInset window is weird under
// fullscreen mode. // fullscreen mode.
shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET) { 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 // Restore the native toolbar immediately after entering fullscreen, if we do
// this before leaving fullscreen, traffic light buttons will be jumping. // 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) { shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
base::scoped_nsobject<NSToolbar> toolbar( base::scoped_nsobject<NSToolbar> toolbar(
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]); [[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
@ -269,13 +269,13 @@ bool ScopedDisableResize::disable_resize_ = false;
// Restore the titlebar visibility. // Restore the titlebar visibility.
NSWindow* window = shell_->GetNativeWindow(); NSWindow* window = shell_->GetNativeWindow();
if ((shell_->transparent() || !shell_->has_frame()) && if ((shell_->transparent() || !shell_->has_frame()) &&
base::mac::IsOSYosemiteOrLater() && base::mac::IsOS10_10() &&
shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET) { shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET) {
[window setTitleVisibility:NSWindowTitleHidden]; [window setTitleVisibility:NSWindowTitleHidden];
} }
// Turn off the style for toolbar. // Turn off the style for toolbar.
if (base::mac::IsOSYosemiteOrLater() && if (base::mac::IsOS10_10() &&
shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) { shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) {
shell_->SetStyleMask(false, NSFullSizeContentViewWindowMask); shell_->SetStyleMask(false, NSFullSizeContentViewWindowMask);
} }
@ -712,7 +712,7 @@ NativeWindowMac::NativeWindowMac(
[window_ setDisableKeyOrMainWindow:YES]; [window_ setDisableKeyOrMainWindow:YES];
if (transparent() || !has_frame()) { if (transparent() || !has_frame()) {
if (base::mac::IsOSYosemiteOrLater()) { if (base::mac::IsOS10_10()) {
// Don't show title bar. // Don't show title bar.
[window_ setTitleVisibility:NSWindowTitleHidden]; [window_ setTitleVisibility:NSWindowTitleHidden];
} }
@ -725,7 +725,7 @@ NativeWindowMac::NativeWindowMac(
// Hide the title bar. // Hide the title bar.
if (title_bar_style_ == HIDDEN_INSET) { if (title_bar_style_ == HIDDEN_INSET) {
if (base::mac::IsOSYosemiteOrLater()) { if (base::mac::IsOS10_10()) {
[window_ setTitlebarAppearsTransparent:YES]; [window_ setTitlebarAppearsTransparent:YES];
base::scoped_nsobject<NSToolbar> toolbar( base::scoped_nsobject<NSToolbar> toolbar(
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]); [[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
@ -1104,7 +1104,7 @@ void NativeWindowMac::Center() {
void NativeWindowMac::SetTitle(const std::string& title) { void NativeWindowMac::SetTitle(const std::string& title) {
// For macOS <= 10.9, the setTitleVisibility API is not available, we have // For macOS <= 10.9, the setTitleVisibility API is not available, we have
// to avoid calling setTitle for frameless window. // to avoid calling setTitle for frameless window.
if (!base::mac::IsOSYosemiteOrLater() && (transparent() || !has_frame())) if (!base::mac::IsOS10_10() && (transparent() || !has_frame()))
return; return;
[window_ setTitle:base::SysUTF8ToNSString(title)]; [window_ setTitle:base::SysUTF8ToNSString(title)];
@ -1275,7 +1275,7 @@ void NativeWindowMac::SetAutoHideCursor(bool auto_hide) {
} }
void NativeWindowMac::SetVibrancy(const std::string& type) { void NativeWindowMac::SetVibrancy(const std::string& type) {
if (!base::mac::IsOSYosemiteOrLater()) return; if (!base::mac::IsOS10_10()) return;
NSView* vibrant_view = [window_ vibrantView]; NSView* vibrant_view = [window_ vibrantView];
@ -1314,7 +1314,7 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
vibrancyType = NSVisualEffectMaterialTitlebar; vibrancyType = NSVisualEffectMaterialTitlebar;
} }
if (base::mac::IsOSElCapitanOrLater()) { if (base::mac::IsOS10_11()) {
// TODO(kevinsawicki): Use NSVisualEffectMaterial* constants directly once // TODO(kevinsawicki): Use NSVisualEffectMaterial* constants directly once
// they are available in the minimum SDK version // they are available in the minimum SDK version
if (type == "selection") { 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. // 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 // But do not enable it on OS X 10.9 for transparent window, otherwise a
// semi-transparent frame would show. // semi-transparent frame would show.
if (!(transparent() && base::mac::IsOSMavericks()) && !is_modal()) if (!(transparent() && base::mac::IsOS10_9()) && !is_modal())
[[window_ contentView] setWantsLayer:YES]; [[window_ contentView] setWantsLayer:YES];
NSView* view = inspectable_web_contents()->GetView()->GetNativeView(); NSView* view = inspectable_web_contents()->GetView()->GetNativeView();
@ -1444,7 +1444,7 @@ void NativeWindowMac::InstallView() {
[[window_ standardWindowButton:NSWindowFullScreenButton] setHidden:YES]; [[window_ standardWindowButton:NSWindowFullScreenButton] setHidden:YES];
if (title_bar_style_ != NORMAL) { if (title_bar_style_ != NORMAL) {
if (base::mac::IsOSMavericks()) { if (base::mac::IsOS10_9()) {
ShowWindowButton(NSWindowZoomButton); ShowWindowButton(NSWindowZoomButton);
ShowWindowButton(NSWindowMiniaturizeButton); ShowWindowButton(NSWindowMiniaturizeButton);
ShowWindowButton(NSWindowCloseButton); ShowWindowButton(NSWindowCloseButton);

View file

@ -41,7 +41,7 @@
#include "atom/browser/ui/x/window_state_watcher.h" #include "atom/browser/ui/x/window_state_watcher.h"
#include "atom/browser/ui/x/x_window_utils.h" #include "atom/browser/ui/x/x_window_utils.h"
#include "base/strings/string_util.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/base/x/x11_util.h"
#include "ui/gfx/x/x11_types.h" #include "ui/gfx/x/x11_types.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"

View file

@ -21,7 +21,7 @@
#include "net/base/load_flags.h" #include "net/base/load_flags.h"
#include "net/base/mime_util.h" #include "net/base/mime_util.h"
#include "net/base/net_errors.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/http/http_util.h"
#include "net/url_request/url_request_status.h" #include "net/url_request/url_request_status.h"
@ -179,10 +179,14 @@ bool URLRequestAsarJob::IsRedirectResponse(GURL* location,
#endif #endif
} }
std::unique_ptr<net::Filter> URLRequestAsarJob::SetupFilter() const { std::unique_ptr<net::SourceStream> URLRequestAsarJob::SetUpSourceStream() {
std::unique_ptr<net::SourceStream> source =
net::URLRequestJob::SetUpSourceStream();
// Bug 9936 - .svgz files needs to be decompressed. // Bug 9936 - .svgz files needs to be decompressed.
return base::LowerCaseEqualsASCII(file_path_.Extension(), ".svgz") 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 { bool URLRequestAsarJob::GetMimeType(std::string* mime_type) const {

View file

@ -56,7 +56,7 @@ class URLRequestAsarJob : public net::URLRequestJob {
void Kill() override; void Kill() override;
int ReadRawData(net::IOBuffer* buf, int buf_size) override; int ReadRawData(net::IOBuffer* buf, int buf_size) override;
bool IsRedirectResponse(GURL* location, int* http_status_code) override; bool IsRedirectResponse(GURL* location, int* http_status_code) override;
std::unique_ptr<net::Filter> SetupFilter() const override; std::unique_ptr<net::SourceStream> SetUpSourceStream() override;
bool GetMimeType(std::string* mime_type) const override; bool GetMimeType(std::string* mime_type) const override;
void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) override; void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) override;
int GetResponseCode() const override; int GetResponseCode() const override;

View file

@ -46,7 +46,7 @@ int AtomCertVerifier::Verify(
net::CertVerifyResult* verify_result, net::CertVerifyResult* verify_result,
const net::CompletionCallback& callback, const net::CompletionCallback& callback,
std::unique_ptr<Request>* out_req, std::unique_ptr<Request>* out_req,
const net::BoundNetLog& net_log) { const net::NetLogWithSource& net_log) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (verify_proc_.is_null()) { if (verify_proc_.is_null()) {

View file

@ -33,7 +33,7 @@ class AtomCertVerifier : public net::CertVerifier {
net::CertVerifyResult* verify_result, net::CertVerifyResult* verify_result,
const net::CompletionCallback& callback, const net::CompletionCallback& callback,
std::unique_ptr<Request>* out_req, std::unique_ptr<Request>* out_req,
const net::BoundNetLog& net_log) override; const net::NetLogWithSource& net_log) override;
bool SupportsOCSPStapling() override; bool SupportsOCSPStapling() override;
private: private:

View file

@ -23,14 +23,17 @@ void AtomCookieDelegate::RemoveObserver(Observer* observer) {
} }
void AtomCookieDelegate::NotifyObservers( void AtomCookieDelegate::NotifyObservers(
const net::CanonicalCookie& cookie, bool removed, ChangeCause cause) { const net::CanonicalCookie& cookie,
FOR_EACH_OBSERVER(Observer, bool removed,
observers_, net::CookieStore::ChangeCause cause) {
OnCookieChanged(cookie, removed, cause)); for (Observer& observer : observers_)
observer.OnCookieChanged(cookie, removed, cause);
} }
void AtomCookieDelegate::OnCookieChanged( 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::PostTask(
content::BrowserThread::UI, content::BrowserThread::UI,
FROM_HERE, FROM_HERE,

View file

@ -19,7 +19,7 @@ class AtomCookieDelegate : public net::CookieMonsterDelegate {
public: public:
virtual void OnCookieChanged(const net::CanonicalCookie& cookie, virtual void OnCookieChanged(const net::CanonicalCookie& cookie,
bool removed, bool removed,
ChangeCause cause) {} net::CookieStore::ChangeCause cause) {}
protected: protected:
virtual ~Observer() {} virtual ~Observer() {}
}; };
@ -30,7 +30,7 @@ class AtomCookieDelegate : public net::CookieMonsterDelegate {
// net::CookieMonsterDelegate: // net::CookieMonsterDelegate:
void OnCookieChanged(const net::CanonicalCookie& cookie, void OnCookieChanged(const net::CanonicalCookie& cookie,
bool removed, bool removed,
ChangeCause cause) override; net::CookieStore::ChangeCause cause) override;
private: private:
@ -38,7 +38,7 @@ class AtomCookieDelegate : public net::CookieMonsterDelegate {
void NotifyObservers(const net::CanonicalCookie& cookie, void NotifyObservers(const net::CanonicalCookie& cookie,
bool removed, bool removed,
ChangeCause cause); net::CookieStore::ChangeCause cause);
DISALLOW_COPY_AND_ASSIGN(AtomCookieDelegate); DISALLOW_COPY_AND_ASSIGN(AtomCookieDelegate);
}; };

View file

@ -19,13 +19,11 @@
#include "net/http/http_request_headers.h" #include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h" #include "net/http/http_response_headers.h"
namespace extensions {
class URLPattern; class URLPattern;
}
namespace atom { namespace atom {
using URLPatterns = std::set<extensions::URLPattern>; using URLPatterns = std::set<URLPattern>;
const char* ResourceTypeToString(content::ResourceType type); const char* ResourceTypeToString(content::ResourceType type);

View file

@ -1,74 +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 <string>
#include <vector>
#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<uint16_t> ParseCipherSuites(
const std::vector<std::string>& cipher_strings) {
std::vector<uint16_t> 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::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),
",", 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

View file

@ -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_

View file

@ -64,7 +64,7 @@ class ResponsePiper : public net::URLFetcherResponseWriter {
} }
return job_->DataAvailable(buffer, num_bytes, callback); 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; return net::OK;
} }
@ -97,8 +97,8 @@ void URLRequestFetchJob::BeforeStartInUI(
// We have to create the URLRequestContextGetter on UI thread. // We have to create the URLRequestContextGetter on UI thread.
url_request_context_getter_ = new brightray::URLRequestContextGetter( url_request_context_getter_ = new brightray::URLRequestContextGetter(
this, nullptr, nullptr, base::FilePath(), true, this, nullptr, nullptr, base::FilePath(), true,
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO), BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE), BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE),
nullptr, content::URLRequestInterceptorScopedVector()); nullptr, content::URLRequestInterceptorScopedVector());
} else { } else {
mate::Handle<api::Session> session; mate::Handle<api::Session> session;

View file

@ -22,8 +22,6 @@ OffScreenOutputDevice::~OffScreenOutputDevice() {
void OffScreenOutputDevice::Resize( void OffScreenOutputDevice::Resize(
const gfx::Size& pixel_size, float scale_factor) { const gfx::Size& pixel_size, float scale_factor) {
scale_factor_ = scale_factor;
if (viewport_pixel_size_ == pixel_size) return; if (viewport_pixel_size_ == pixel_size) return;
viewport_pixel_size_ = pixel_size; viewport_pixel_size_ = pixel_size;

View file

@ -20,6 +20,7 @@
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/context_factory.h" #include "content/public/browser/context_factory.h"
#include "content/public/browser/render_widget_host_view_frame_subscriber.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.h"
#include "ui/compositor/layer_type.h" #include "ui/compositor/layer_type.h"
#include "ui/events/latency_info.h" #include "ui/events/latency_info.h"
@ -349,14 +350,16 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
is_showing_(!render_widget_host_->is_hidden()), is_showing_(!render_widget_host_->is_hidden()),
size_(native_window->GetSize()), size_(native_window->GetSize()),
painting_(true), painting_(true),
#if !defined(OS_MACOSX)
delegated_frame_host_(new content::DelegatedFrameHost(this)),
#endif
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
DCHECK(render_widget_host_); DCHECK(render_widget_host_);
render_widget_host_->SetView(this); render_widget_host_->SetView(this);
#if !defined(OS_MACOSX) #if !defined(OS_MACOSX)
content::ImageTransportFactory* factory =
content::ImageTransportFactory::GetInstance();
delegated_frame_host_ = base::MakeUnique<content::DelegatedFrameHost>(
factory->GetContextFactory()->AllocateFrameSinkId(), this);
root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
#endif #endif
@ -743,16 +746,6 @@ OffScreenRenderWidgetHostView::DelegatedFrameHostSendReclaimCompositorResources(
resources)); 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( void OffScreenRenderWidgetHostView::SetBeginFrameSource(
cc::BeginFrameSource* source) { cc::BeginFrameSource* source) {
} }

View file

@ -163,9 +163,6 @@ class OffScreenRenderWidgetHostView
int output_surface_id, int output_surface_id,
bool is_swap_ack, bool is_swap_ack,
const cc::ReturnedResourceArray& resources) override; const cc::ReturnedResourceArray& resources) override;
void DelegatedFrameHostOnLostCompositorResources(void) override;
void DelegatedFrameHostUpdateVSyncParameters(
const base::TimeTicks &, const base::TimeDelta &) override;
void SetBeginFrameSource(cc::BeginFrameSource* source) override; void SetBeginFrameSource(cc::BeginFrameSource* source) override;
#endif // !defined(OS_MACOSX) #endif // !defined(OS_MACOSX)

View file

@ -47,16 +47,6 @@ class MacHelper :
is_swap_ack, resources)); 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( void BrowserCompositorMacSendBeginFrame(
const cc::BeginFrameArgs& args) override { const cc::BeginFrameArgs& args) override {
view_->render_widget_host()->Send( view_->render_widget_host()->Send(

View file

@ -109,15 +109,15 @@ void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled) {
} }
void OffScreenWebContentsView::GetScreenInfo( void OffScreenWebContentsView::GetScreenInfo(
blink::WebScreenInfo* web_screen_info) const { content::ScreenInfo* screen_info) const {
web_screen_info->rect = gfx::Rect(view_->size()); screen_info->rect = gfx::Rect(view_->size());
web_screen_info->availableRect = gfx::Rect(view_->size()); screen_info->available_rect = gfx::Rect(view_->size());
web_screen_info->depth = 24; screen_info->depth = 24;
web_screen_info->depthPerComponent = 8; screen_info->depth_per_component = 8;
web_screen_info->deviceScaleFactor = view_->scale_factor(); screen_info->device_scale_factor = view_->scale_factor();
web_screen_info->orientationAngle = 0; screen_info->orientation_angle = 0;
web_screen_info->orientationType = screen_info->orientation_type =
blink::WebScreenOrientationLandscapePrimary; content::SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY;
} }
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
@ -141,9 +141,10 @@ void OffScreenWebContentsView::StartDragging(
blink::WebDragOperationsMask allowed_ops, blink::WebDragOperationsMask allowed_ops,
const gfx::ImageSkia& image, const gfx::ImageSkia& image,
const gfx::Vector2d& image_offset, const gfx::Vector2d& image_offset,
const content::DragEventSourceInfo& event_info) { const content::DragEventSourceInfo& event_info,
content::RenderWidgetHostImpl* source_rwh) {
if (web_contents_) if (web_contents_)
web_contents_->SystemDragEnded(); web_contents_->SystemDragEnded(source_rwh);
} }
void OffScreenWebContentsView::UpdateDragCursor( void OffScreenWebContentsView::UpdateDragCursor(

View file

@ -51,7 +51,7 @@ class OffScreenWebContentsView : public content::WebContentsView,
void RenderViewCreated(content::RenderViewHost* host) override; void RenderViewCreated(content::RenderViewHost* host) override;
void RenderViewSwappedIn(content::RenderViewHost* host) override; void RenderViewSwappedIn(content::RenderViewHost* host) override;
void SetOverscrollControllerEnabled(bool enabled) 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) #if defined(OS_MACOSX)
void SetAllowOtherViews(bool allow) override; void SetAllowOtherViews(bool allow) override;
@ -61,12 +61,12 @@ class OffScreenWebContentsView : public content::WebContentsView,
#endif #endif
// content::RenderViewHostDelegateView // content::RenderViewHostDelegateView
void StartDragging( void StartDragging(const content::DropData& drop_data,
const content::DropData& drop_data,
blink::WebDragOperationsMask allowed_ops, blink::WebDragOperationsMask allowed_ops,
const gfx::ImageSkia& image, const gfx::ImageSkia& image,
const gfx::Vector2d& image_offset, const gfx::Vector2d& image_offset,
const content::DragEventSourceInfo& event_info) override; const content::DragEventSourceInfo& event_info,
content::RenderWidgetHostImpl* source_rwh) override;
void UpdateDragCursor(blink::WebDragOperation operation) override; void UpdateDragCursor(blink::WebDragOperation operation) override;
private: private:

View file

@ -17,9 +17,9 @@
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>electron.icns</string> <string>electron.icns</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.5.0</string> <string>1.5.1</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.5.0</string> <string>1.5.1</string>
<key>LSApplicationCategoryType</key> <key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string> <string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>

View file

@ -56,8 +56,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,5,0,0 FILEVERSION 1,5,1,0
PRODUCTVERSION 1,5,0,0 PRODUCTVERSION 1,5,1,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -74,12 +74,12 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "GitHub, Inc." VALUE "CompanyName", "GitHub, Inc."
VALUE "FileDescription", "Electron" VALUE "FileDescription", "Electron"
VALUE "FileVersion", "1.5.0" VALUE "FileVersion", "1.5.1"
VALUE "InternalName", "electron.exe" VALUE "InternalName", "electron.exe"
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved." VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
VALUE "OriginalFilename", "electron.exe" VALUE "OriginalFilename", "electron.exe"
VALUE "ProductName", "Electron" VALUE "ProductName", "Electron"
VALUE "ProductVersion", "1.5.0" VALUE "ProductVersion", "1.5.1"
VALUE "SquirrelAwareVersion", "1" VALUE "SquirrelAwareVersion", "1"
END END
END END

View file

@ -40,9 +40,10 @@ bool AtomMenuModel::GetAcceleratorAtWithParams(
return false; return false;
} }
void AtomMenuModel::MenuClosed() { void AtomMenuModel::MenuWillClose() {
ui::SimpleMenuModel::MenuClosed(); ui::SimpleMenuModel::MenuWillClose();
FOR_EACH_OBSERVER(Observer, observers_, MenuClosed()); for (Observer& observer : observers_)
observer.MenuWillClose();
} }
AtomMenuModel* AtomMenuModel::GetSubmenuModelAt(int index) { AtomMenuModel* AtomMenuModel::GetSubmenuModelAt(int index) {

View file

@ -37,7 +37,7 @@ class AtomMenuModel : public ui::SimpleMenuModel {
virtual ~Observer() {} virtual ~Observer() {}
// Notifies the menu has been closed. // Notifies the menu has been closed.
virtual void MenuClosed() {} virtual void MenuWillClose() {}
}; };
explicit AtomMenuModel(Delegate* delegate); explicit AtomMenuModel(Delegate* delegate);
@ -53,7 +53,7 @@ class AtomMenuModel : public ui::SimpleMenuModel {
ui::Accelerator* accelerator) const; ui::Accelerator* accelerator) const;
// ui::SimpleMenuModel: // ui::SimpleMenuModel:
void MenuClosed() override; void MenuWillClose() override;
using SimpleMenuModel::GetSubmenuModelAt; using SimpleMenuModel::GetSubmenuModelAt;
AtomMenuModel* GetSubmenuModelAt(int index); AtomMenuModel* GetSubmenuModelAt(int index);

View file

@ -90,7 +90,7 @@ Role kRolesMap[] = {
- (void)cancel { - (void)cancel {
if (isMenuOpen_) { if (isMenuOpen_) {
[menu_ cancelTracking]; [menu_ cancelTracking];
model_->MenuClosed(); model_->MenuWillClose();
isMenuOpen_ = NO; isMenuOpen_ = NO;
} }
} }
@ -265,7 +265,7 @@ Role kRolesMap[] = {
- (void)menuDidClose:(NSMenu*)menu { - (void)menuDidClose:(NSMenu*)menu {
if (isMenuOpen_) { if (isMenuOpen_) {
model_->MenuClosed(); model_->MenuWillClose();
isMenuOpen_ = NO; isMenuOpen_ = NO;
} }
} }

View file

@ -4,6 +4,7 @@
#include "atom/browser/ui/drag_util.h" #include "atom/browser/ui/drag_util.h"
#include "ui/aura/client/drag_drop_client.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/base/dragdrop/drag_drop_types.h" #include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/dragdrop/drag_utils.h" #include "ui/base/dragdrop/drag_utils.h"
@ -12,7 +13,6 @@
#include "ui/display/screen.h" #include "ui/display/screen.h"
#include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/point.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#include "ui/wm/public/drag_drop_client.h"
namespace atom { namespace atom {

View file

@ -9,8 +9,8 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" #include "chrome/browser/ui/libgtkui/gtk_signal.h"
#include "chrome/browser/ui/libgtk2ui/gtk2_util.h" #include "chrome/browser/ui/libgtkui/gtk_util.h"
#include "ui/views/widget/desktop_aura/x11_desktop_handler.h" #include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
namespace file_dialog { namespace file_dialog {
@ -61,7 +61,7 @@ class FileChooserDialog {
NULL); NULL);
if (parent_) { if (parent_) {
parent_->SetEnabled(false); parent_->SetEnabled(false);
libgtk2ui::SetGtkTransientForAura(dialog_, parent_->GetNativeWindow()); libgtkui::SetGtkTransientForAura(dialog_, parent_->GetNativeWindow());
gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE); 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 // We need to call gtk_window_present after making the widgets visible to
// make sure window gets correctly raised and gets focus. // 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); gtk_window_present_with_time(GTK_WINDOW(dialog_), time);
} }

View file

@ -18,6 +18,7 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/win/registry.h" #include "base/win/registry.h"
#include "third_party/wtl/include/atlapp.h" #include "third_party/wtl/include/atlapp.h"
#include "third_party/wtl/include/atldlgs.h" #include "third_party/wtl/include/atldlgs.h"
@ -143,7 +144,7 @@ class FileDialog {
struct RunState { struct RunState {
base::Thread* dialog_thread; base::Thread* dialog_thread;
base::MessageLoop* ui_message_loop; scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner;
}; };
bool CreateDialogThread(RunState* run_state) { bool CreateDialogThread(RunState* run_state) {
@ -154,7 +155,7 @@ bool CreateDialogThread(RunState* run_state) {
return false; return false;
run_state->dialog_thread = thread.release(); run_state->dialog_thread = thread.release();
run_state->ui_message_loop = base::MessageLoop::current(); run_state->ui_task_runner = base::ThreadTaskRunnerHandle::Get();
return true; return true;
} }
@ -169,9 +170,9 @@ void RunOpenDialogInNewThread(const RunState& run_state,
std::vector<base::FilePath> paths; std::vector<base::FilePath> paths;
bool result = ShowOpenDialog(parent, title, button_label, default_path, bool result = ShowOpenDialog(parent, title, button_label, default_path,
filters, properties, &paths); filters, properties, &paths);
run_state.ui_message_loop->PostTask(FROM_HERE, run_state.ui_task_runner->PostTask(FROM_HERE,
base::Bind(callback, result, paths)); 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, void RunSaveDialogInNewThread(const RunState& run_state,
@ -184,9 +185,9 @@ void RunSaveDialogInNewThread(const RunState& run_state,
base::FilePath path; base::FilePath path;
bool result = ShowSaveDialog(parent, title, button_label, default_path, bool result = ShowSaveDialog(parent, title, button_label, default_path,
filters, &path); filters, &path);
run_state.ui_message_loop->PostTask(FROM_HERE, run_state.ui_task_runner->PostTask(FROM_HERE,
base::Bind(callback, result, path)); base::Bind(callback, result, path));
run_state.ui_message_loop->DeleteSoon(FROM_HERE, run_state.dialog_thread); run_state.ui_task_runner->DeleteSoon(FROM_HERE, run_state.dialog_thread);
} }
} // namespace } // namespace
@ -256,7 +257,7 @@ void ShowOpenDialog(atom::NativeWindow* parent,
return; return;
} }
run_state.dialog_thread->message_loop()->PostTask( run_state.dialog_thread->task_runner()->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&RunOpenDialogInNewThread, run_state, parent, title, base::Bind(&RunOpenDialogInNewThread, run_state, parent, title,
button_label, default_path, filters, properties, callback)); button_label, default_path, filters, properties, callback));
@ -295,7 +296,7 @@ void ShowSaveDialog(atom::NativeWindow* parent,
return; return;
} }
run_state.dialog_thread->message_loop()->PostTask( run_state.dialog_thread->task_runner()->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&RunSaveDialogInNewThread, run_state, parent, title, base::Bind(&RunSaveDialogInNewThread, run_state, parent, title,
button_label, default_path, filters, callback)); button_label, default_path, filters, callback));

View file

@ -11,9 +11,9 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/libgtk2ui/gtk2_signal.h" #include "chrome/browser/ui/libgtkui/gtk_signal.h"
#include "chrome/browser/ui/libgtk2ui/gtk2_util.h" #include "chrome/browser/ui/libgtkui/gtk_util.h"
#include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h" #include "chrome/browser/ui/libgtkui/skia_utils_gtk.h"
#include "ui/views/widget/desktop_aura/x11_desktop_handler.h" #include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
#define ANSI_FOREGROUND_RED "\x1b[31m" #define ANSI_FOREGROUND_RED "\x1b[31m"
@ -54,7 +54,7 @@ class GtkMessageBox : public NativeWindowObserver {
// Set dialog's icon. // Set dialog's icon.
if (!icon.isNull()) { if (!icon.isNull()) {
GdkPixbuf* pixbuf = libgtk2ui::GdkPixbufFromSkBitmap(*icon.bitmap()); GdkPixbuf* pixbuf = libgtkui::GdkPixbufFromSkBitmap(*icon.bitmap());
GtkIconSource* iconsource = gtk_icon_source_new(); GtkIconSource* iconsource = gtk_icon_source_new();
GtkIconSet* iconset = gtk_icon_set_new(); GtkIconSet* iconset = gtk_icon_set_new();
gtk_icon_source_set_pixbuf(iconsource, pixbuf); gtk_icon_source_set_pixbuf(iconsource, pixbuf);
@ -80,7 +80,7 @@ class GtkMessageBox : public NativeWindowObserver {
if (parent_) { if (parent_) {
parent_->AddObserver(this); parent_->AddObserver(this);
parent_->SetEnabled(false); parent_->SetEnabled(false);
libgtk2ui::SetGtkTransientForAura(dialog_, parent_->GetNativeWindow()); libgtkui::SetGtkTransientForAura(dialog_, parent_->GetNativeWindow());
gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE); gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE);
} }
} }
@ -126,7 +126,7 @@ class GtkMessageBox : public NativeWindowObserver {
gtk_widget_show_all(dialog_); gtk_widget_show_all(dialog_);
// We need to call gtk_window_present after making the widgets visible to // We need to call gtk_window_present after making the widgets visible to
// make sure window gets correctly raised and gets focus. // 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); gtk_window_present_with_time(GTK_WINDOW(dialog_), time);
} }

View file

@ -233,7 +233,7 @@ void ShowMessageBox(NativeWindow* parent,
} }
base::Thread* unretained = thread.release(); base::Thread* unretained = thread.release();
unretained->message_loop()->PostTask( unretained->task_runner()->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&RunMessageBoxInNewThread, base::Unretained(unretained), base::Bind(&RunMessageBoxInNewThread, base::Unretained(unretained),
parent, type, buttons, default_id, cancel_id, options, title, parent, type, buttons, default_id, cancel_id, options, title,

View file

@ -35,53 +35,63 @@ gfx::Rect TrayIcon::GetBounds() {
} }
void TrayIcon::NotifyClicked(const gfx::Rect& bounds, int modifiers) { 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) { void TrayIcon::NotifyDoubleClicked(const gfx::Rect& bounds, int modifiers) {
FOR_EACH_OBSERVER(TrayIconObserver, observers_, for (TrayIconObserver& observer : observers_)
OnDoubleClicked(bounds, modifiers)); observer.OnDoubleClicked(bounds, modifiers);
} }
void TrayIcon::NotifyBalloonShow() { void TrayIcon::NotifyBalloonShow() {
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnBalloonShow()); for (TrayIconObserver& observer : observers_)
observer.OnBalloonShow();
} }
void TrayIcon::NotifyBalloonClicked() { void TrayIcon::NotifyBalloonClicked() {
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnBalloonClicked()); for (TrayIconObserver& observer : observers_)
observer.OnBalloonClicked();
} }
void TrayIcon::NotifyBalloonClosed() { void TrayIcon::NotifyBalloonClosed() {
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnBalloonClosed()); for (TrayIconObserver& observer : observers_)
observer.OnBalloonClosed();
} }
void TrayIcon::NotifyRightClicked(const gfx::Rect& bounds, int modifiers) { void TrayIcon::NotifyRightClicked(const gfx::Rect& bounds, int modifiers) {
FOR_EACH_OBSERVER(TrayIconObserver, observers_, for (TrayIconObserver& observer : observers_)
OnRightClicked(bounds, modifiers)); observer.OnRightClicked(bounds, modifiers);
} }
void TrayIcon::NotifyDrop() { void TrayIcon::NotifyDrop() {
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDrop()); for (TrayIconObserver& observer : observers_)
observer.OnDrop();
} }
void TrayIcon::NotifyDropFiles(const std::vector<std::string>& files) { void TrayIcon::NotifyDropFiles(const std::vector<std::string>& files) {
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDropFiles(files)); for (TrayIconObserver& observer : observers_)
observer.OnDropFiles(files);
} }
void TrayIcon::NotifyDropText(const std::string& text) { void TrayIcon::NotifyDropText(const std::string& text) {
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDropText(text)); for (TrayIconObserver& observer : observers_)
observer.OnDropText(text);
} }
void TrayIcon::NotifyDragEntered() { void TrayIcon::NotifyDragEntered() {
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDragEntered()); for (TrayIconObserver& observer : observers_)
observer.OnDragEntered();
} }
void TrayIcon::NotifyDragExited() { void TrayIcon::NotifyDragExited() {
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDragExited()); for (TrayIconObserver& observer : observers_)
observer.OnDragExited();
} }
void TrayIcon::NotifyDragEnded() { void TrayIcon::NotifyDragEnded() {
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDragEnded()); for (TrayIconObserver& observer : observers_)
observer.OnDragEnded();
} }
} // namespace atom } // namespace atom

View file

@ -35,7 +35,7 @@ class TrayIconCocoa : public TrayIcon,
protected: protected:
// AtomMenuModel::Observer: // AtomMenuModel::Observer:
void MenuClosed() override; void MenuWillClose() override;
private: private:
// Atom custom view for NSStatusItem. // Atom custom view for NSStatusItem.

View file

@ -405,7 +405,7 @@ gfx::Rect TrayIconCocoa::GetBounds() {
return bounds; return bounds;
} }
void TrayIconCocoa::MenuClosed() { void TrayIconCocoa::MenuWillClose() {
[status_item_view_ setNeedsDisplay:YES]; [status_item_view_ setNeedsDisplay:YES];
} }

View file

@ -7,8 +7,8 @@
#include "atom/browser/browser.h" #include "atom/browser/browser.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/libgtk2ui/app_indicator_icon.h" #include "chrome/browser/ui/libgtkui/app_indicator_icon.h"
#include "chrome/browser/ui/libgtk2ui/gtk2_status_icon.h" #include "chrome/browser/ui/libgtkui/gtk_status_icon.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
namespace atom { namespace atom {
@ -33,15 +33,15 @@ void TrayIconGtk::SetImage(const gfx::Image& image) {
} }
base::string16 empty; base::string16 empty;
if (libgtk2ui::AppIndicatorIcon::CouldOpen()) { if (libgtkui::AppIndicatorIcon::CouldOpen()) {
++indicators_count; ++indicators_count;
icon_.reset(new libgtk2ui::AppIndicatorIcon( icon_.reset(new libgtkui::AppIndicatorIcon(
base::StringPrintf( base::StringPrintf(
"%s%d", Browser::Get()->GetName().c_str(), indicators_count), "%s%d", Browser::Get()->GetName().c_str(), indicators_count),
image.AsImageSkia(), image.AsImageSkia(),
empty)); empty));
} else { } else {
icon_.reset(new libgtk2ui::Gtk2StatusIcon(image.AsImageSkia(), empty)); icon_.reset(new libgtkui::Gtk2StatusIcon(image.AsImageSkia(), empty));
} }
icon_->set_delegate(this); icon_->set_delegate(this);
} }

View file

@ -17,7 +17,7 @@
#if defined(OS_WIN) #if defined(OS_WIN)
#include "ui/gfx/color_utils.h" #include "ui/gfx/color_utils.h"
#elif defined(USE_X11) #elif defined(USE_X11)
#include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h" #include "chrome/browser/ui/libgtkui/skia_utils_gtk.h"
#endif #endif
namespace atom { namespace atom {
@ -35,11 +35,11 @@ void GetMenuBarColor(SkColor* enabled, SkColor* disabled, SkColor* highlight,
GtkWidget* menu_bar = gtk_menu_bar_new(); GtkWidget* menu_bar = gtk_menu_bar_new();
GtkStyle* style = gtk_rc_get_style(menu_bar); GtkStyle* style = gtk_rc_get_style(menu_bar);
*enabled = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_NORMAL]); *enabled = libgtkui::GdkColorToSkColor(style->fg[GTK_STATE_NORMAL]);
*disabled = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_INSENSITIVE]); *disabled = libgtkui::GdkColorToSkColor(style->fg[GTK_STATE_INSENSITIVE]);
*highlight = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_SELECTED]); *highlight = libgtkui::GdkColorToSkColor(style->fg[GTK_STATE_SELECTED]);
*hover = libgtk2ui::GdkColorToSkColor(style->fg[GTK_STATE_PRELIGHT]); *hover = libgtkui::GdkColorToSkColor(style->fg[GTK_STATE_PRELIGHT]);
*background = libgtk2ui::GdkColorToSkColor(style->bg[GTK_STATE_NORMAL]); *background = libgtkui::GdkColorToSkColor(style->bg[GTK_STATE_NORMAL]);
gtk_widget_destroy(menu_bar); gtk_widget_destroy(menu_bar);
} }

View file

@ -11,6 +11,7 @@
#include "ui/gfx/text_utils.h" #include "ui/gfx/text_utils.h"
#include "ui/views/animation/flood_fill_ink_drop_ripple.h" #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
#include "ui/views/animation/ink_drop_host_view.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" #include "ui/views/controls/button/label_button_border.h"
namespace atom { namespace atom {
@ -59,28 +60,20 @@ SubmenuButton::~SubmenuButton() {
std::unique_ptr<views::InkDropRipple> SubmenuButton::CreateInkDropRipple() std::unique_ptr<views::InkDropRipple> SubmenuButton::CreateInkDropRipple()
const { const {
return base::MakeUnique<views::FloodFillInkDropRipple>( std::unique_ptr<views::InkDropRipple> ripple(
GetLocalBounds(), new views::FloodFillInkDropRipple(
size(),
GetInkDropCenterBasedOnLastEvent(), GetInkDropCenterBasedOnLastEvent(),
GetInkDropBaseColor(), GetInkDropBaseColor(),
ink_drop_visible_opacity()); ink_drop_visible_opacity()));
return ripple;
} }
std::unique_ptr<views::InkDropHighlight> std::unique_ptr<views::InkDrop> SubmenuButton::CreateInkDrop() {
SubmenuButton::CreateInkDropHighlight() const { std::unique_ptr<views::InkDropImpl> ink_drop =
if (!ShouldShowInkDropHighlight()) CustomButton::CreateDefaultInkDropImpl();
return nullptr; ink_drop->SetShowHighlightOnHover(false);
return std::move(ink_drop);
gfx::Size size = GetLocalBounds().size();
return base::MakeUnique<views::InkDropHighlight>(
size,
kInkDropSmallCornerRadius,
gfx::RectF(gfx::SizeF(size)).CenterPoint(),
GetInkDropBaseColor());
}
bool SubmenuButton::ShouldShowInkDropForFocus() const {
return false;
} }
void SubmenuButton::SetAcceleratorVisibility(bool visible) { void SubmenuButton::SetAcceleratorVisibility(bool visible) {

View file

@ -31,9 +31,7 @@ class SubmenuButton : public views::MenuButton {
// views::InkDropHostView: // views::InkDropHostView:
std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() std::unique_ptr<views::InkDrop> CreateInkDrop() override;
const override;
bool ShouldShowInkDropForFocus() const override;
private: private:
bool GetUnderlinePosition(const base::string16& text, bool GetUnderlinePosition(const base::string16& text,

View file

@ -86,9 +86,8 @@ NotifyIconHost::~NotifyIconHost() {
if (atom_) if (atom_)
UnregisterClass(MAKEINTATOM(atom_), instance_); UnregisterClass(MAKEINTATOM(atom_), instance_);
NotifyIcons copied_container(notify_icons_); for (NotifyIcon* ptr : notify_icons_)
base::STLDeleteContainerPointers( delete ptr;
copied_container.begin(), copied_container.end());
} }
NotifyIcon* NotifyIconHost::CreateNotifyIcon() { NotifyIcon* NotifyIconHost::CreateNotifyIcon() {

View file

@ -233,11 +233,8 @@ void WebContentsPreferences::OverrideWebkitPrefs(
prefs->experimental_webgl_enabled = b; prefs->experimental_webgl_enabled = b;
if (self->web_preferences_.GetBoolean("webSecurity", &b)) { if (self->web_preferences_.GetBoolean("webSecurity", &b)) {
prefs->web_security_enabled = b; prefs->web_security_enabled = b;
prefs->allow_displaying_insecure_content = !b;
prefs->allow_running_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)) if (self->web_preferences_.GetBoolean("allowRunningInsecureContent", &b))
prefs->allow_running_insecure_content = b; prefs->allow_running_insecure_content = b;
const base::DictionaryValue* fonts = nullptr; const base::DictionaryValue* fonts = nullptr;

View file

@ -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 } // namespace atom

View file

@ -59,6 +59,9 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
int element_instance_id, int element_instance_id,
bool is_full_page_plugin, bool is_full_page_plugin,
const base::Closure& completion_callback) final; const base::Closure& completion_callback) final;
bool CanBeEmbeddedInsideCrossProcessFrames() override;
content::RenderWidgetHost* GetOwnerRenderWidgetHost() override;
content::SiteInstance* GetOwnerSiteInstance() override;
private: private:
// This method is invoked when the contents auto-resized to give the container // This method is invoked when the contents auto-resized to give the container

View file

@ -33,8 +33,8 @@ void WindowList::AddWindow(NativeWindow* window) {
WindowVector& windows = GetInstance()->windows_; WindowVector& windows = GetInstance()->windows_;
windows.push_back(window); windows.push_back(window);
FOR_EACH_OBSERVER(WindowListObserver, observers_.Get(), for (WindowListObserver& observer : observers_.Get())
OnWindowAdded(window)); observer.OnWindowAdded(window);
} }
// static // static
@ -43,18 +43,19 @@ void WindowList::RemoveWindow(NativeWindow* window) {
windows.erase(std::remove(windows.begin(), windows.end(), window), windows.erase(std::remove(windows.begin(), windows.end(), window),
windows.end()); windows.end());
FOR_EACH_OBSERVER(WindowListObserver, observers_.Get(), for (WindowListObserver& observer : observers_.Get())
OnWindowRemoved(window)); observer.OnWindowRemoved(window);
if (windows.size() == 0) if (windows.size() == 0) {
FOR_EACH_OBSERVER(WindowListObserver, observers_.Get(), for (WindowListObserver& observer : observers_.Get())
OnWindowAllClosed()); observer.OnWindowAllClosed();
}
} }
// static // static
void WindowList::WindowCloseCancelled(NativeWindow* window) { void WindowList::WindowCloseCancelled(NativeWindow* window) {
FOR_EACH_OBSERVER(WindowListObserver, observers_.Get(), for (WindowListObserver& observer : observers_.Get())
OnWindowCloseCancelled(window)); observer.OnWindowCloseCancelled(window);
} }
// static // static

View file

@ -7,7 +7,7 @@
#define ATOM_MAJOR_VERSION 1 #define ATOM_MAJOR_VERSION 1
#define ATOM_MINOR_VERSION 5 #define ATOM_MINOR_VERSION 5
#define ATOM_PATCH_VERSION 0 #define ATOM_PATCH_VERSION 1
#define ATOM_VERSION_IS_RELEASE 1 #define ATOM_VERSION_IS_RELEASE 1

View file

@ -8,7 +8,7 @@
#ifndef ATOM_COMMON_CHROME_VERSION_H_ #ifndef ATOM_COMMON_CHROME_VERSION_H_
#define 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.87"
#define CHROME_VERSION "v" CHROME_VERSION_STRING #define CHROME_VERSION "v" CHROME_VERSION_STRING
#endif // ATOM_COMMON_CHROME_VERSION_H_ #endif // ATOM_COMMON_CHROME_VERSION_H_

View file

@ -44,13 +44,12 @@ void CrashReporterMac::InitBreakpad(const std::string& product_name,
framework_bundle_path.Append("Resources").Append("crashpad_handler"); framework_bundle_path.Append("Resources").Append("crashpad_handler");
crashpad::CrashpadClient crashpad_client; crashpad::CrashpadClient crashpad_client;
if (crashpad_client.StartHandler(handler_path, crashes_dir, crashpad_client.StartHandler(handler_path, crashes_dir, crashes_dir,
submit_url, submit_url,
StringMap(), StringMap(),
std::vector<std::string>(), std::vector<std::string>(),
true)) { true,
crashpad_client.UseHandler(); false);
}
} // @autoreleasepool } // @autoreleasepool
} }

View file

@ -7,7 +7,7 @@
#include "atom/common/keyboard_util.h" #include "atom/common/keyboard_util.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.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" #include "ui/events/event_constants.h"
namespace atom { namespace atom {

View file

@ -13,10 +13,10 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/native_web_keyboard_event.h"
#include "native_mate/dictionary.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/WebCache.h"
#include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
#include "third_party/WebKit/public/web/WebFindOptions.h" #include "third_party/WebKit/public/web/WebFindOptions.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/clipboard.h"
#include "ui/events/keycodes/dom/keycode_converter.h" #include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/events/keycodes/keyboard_code_conversion.h" #include "ui/events/keycodes/keyboard_code_conversion.h"
@ -445,9 +445,6 @@ v8::Local<v8::Value> Converter<blink::WebCache::ResourceTypeStat>::ToV8(
dict.Set("count", static_cast<uint32_t>(stat.count)); dict.Set("count", static_cast<uint32_t>(stat.count));
dict.Set("size", static_cast<double>(stat.size)); dict.Set("size", static_cast<double>(stat.size));
dict.Set("liveSize", static_cast<double>(stat.liveSize)); dict.Set("liveSize", static_cast<double>(stat.liveSize));
dict.Set("decodedSize", static_cast<double>(stat.decodedSize));
dict.Set("purgedSize", static_cast<double>(stat.purgedSize));
dict.Set("purgeableSize", static_cast<double>(stat.purgeableSize));
return dict.GetHandle(); return dict.GetHandle();
} }

View file

@ -361,7 +361,7 @@ base::Value* V8ValueConverter::FromV8Array(
base::Value* child = FromV8ValueImpl(state, child_v8, isolate); base::Value* child = FromV8ValueImpl(state, child_v8, isolate);
if (child) if (child)
result->Append(child); result->Append(std::unique_ptr<base::Value>(child));
else else
// JSON.stringify puts null in places where values don't serialize, for // JSON.stringify puts null in places where values don't serialize, for
// example undefined and functions. Emulate that behavior. // example undefined and functions. Emulate that behavior.

View file

@ -7,6 +7,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/single_thread_task_runner.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
#include "vendor/node/deps/uv/include/uv.h" #include "vendor/node/deps/uv/include/uv.h"

View file

@ -22,6 +22,7 @@
#undef UNLIKELY #undef UNLIKELY
#undef DISALLOW_COPY_AND_ASSIGN #undef DISALLOW_COPY_AND_ASSIGN
#undef NO_RETURN #undef NO_RETURN
#undef LIKELY
#undef arraysize #undef arraysize
#undef debug_string // This is defined in macOS 10.9 SDK in AssertMacros.h. #undef debug_string // This is defined in macOS 10.9 SDK in AssertMacros.h.
#include "vendor/node/src/env.h" #include "vendor/node/src/env.h"

View file

@ -150,13 +150,6 @@ const char kRegisterServiceWorkerSchemes[] = "register-service-worker-schemes";
// Register schemes as secure. // Register schemes as secure.
const char kSecureSchemes[] = "secure-schemes"; 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";
// The browser process app model ID // The browser process app model ID
const char kAppUserModelId[] = "app-user-model-id"; const char kAppUserModelId[] = "app-user-model-id";

View file

@ -78,8 +78,6 @@ extern const char kDisableHttpCache[];
extern const char kStandardSchemes[]; extern const char kStandardSchemes[];
extern const char kRegisterServiceWorkerSchemes[]; extern const char kRegisterServiceWorkerSchemes[];
extern const char kSecureSchemes[]; extern const char kSecureSchemes[];
extern const char kSSLVersionFallbackMin[];
extern const char kCipherSuiteBlacklist[];
extern const char kAppUserModelId[]; extern const char kAppUserModelId[];
extern const char kBackgroundColor[]; extern const char kBackgroundColor[];

View file

@ -6,6 +6,9 @@
#include <io.h> #include <io.h>
#include "v8-profiler.h"
#include "v8-inspector.h"
namespace node { namespace node {
int open_osfhandle(intptr_t osfhandle, int flags) { int open_osfhandle(intptr_t osfhandle, int flags) {
@ -16,4 +19,14 @@ int close(int fd) {
return _close(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<v8_inspector::V8InspectorSession*>(nullptr)->
canDispatchMethod(v8_inspector::StringView());
reinterpret_cast<v8_inspector::V8InspectorClient*>(nullptr)->unmuteMetrics(0);
}
} // namespace node } // namespace node

View file

@ -21,6 +21,9 @@ namespace node {
__declspec(dllexport) int open_osfhandle(intptr_t osfhandle, int flags); __declspec(dllexport) int open_osfhandle(intptr_t osfhandle, int flags);
__declspec(dllexport) int close(int fd); __declspec(dllexport) int close(int fd);
// A trick to force referencing symbols.
__declspec(dllexport) void ReferenceSymbols();
} // namespace node } // namespace node
#endif // ATOM_NODE_OSFHANDLE_H_ #endif // ATOM_NODE_OSFHANDLE_H_

View file

@ -17,6 +17,8 @@
#include "native_mate/object_template_builder.h" #include "native_mate/object_template_builder.h"
#include "third_party/WebKit/public/web/WebCache.h" #include "third_party/WebKit/public/web/WebCache.h"
#include "third_party/WebKit/public/web/WebDocument.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/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebScriptExecutionCallback.h" #include "third_party/WebKit/public/web/WebScriptExecutionCallback.h"
#include "third_party/WebKit/public/web/WebScriptSource.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) { 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) { void WebFrame::InsertCSS(const std::string& css) {

View file

@ -257,6 +257,7 @@ void AtomRendererClient::RenderFrameCreated(
new PepperHelper(render_frame); new PepperHelper(render_frame);
new AtomRenderFrameObserver(render_frame, this); new AtomRenderFrameObserver(render_frame, this);
new ContentSettingsObserver(render_frame); new ContentSettingsObserver(render_frame);
new printing::PrintWebViewHelper(render_frame);
// Allow file scheme to handle service worker by default. // Allow file scheme to handle service worker by default.
// FIXME(zcbenz): Can this be moved elsewhere? // FIXME(zcbenz): Can this be moved elsewhere?
@ -271,7 +272,6 @@ void AtomRendererClient::RenderFrameCreated(
} }
void AtomRendererClient::RenderViewCreated(content::RenderView* render_view) { void AtomRendererClient::RenderViewCreated(content::RenderView* render_view) {
new printing::PrintWebViewHelper(render_view);
new AtomRenderViewObserver(render_view, this); new AtomRenderViewObserver(render_view, this);
blink::WebFrameWidget* web_frame_widget = render_view->GetWebFrameWidget(); blink::WebFrameWidget* web_frame_widget = render_view->GetWebFrameWidget();

View file

@ -123,11 +123,11 @@ AtomSandboxedRendererClient::~AtomSandboxedRendererClient() {
void AtomSandboxedRendererClient::RenderFrameCreated( void AtomSandboxedRendererClient::RenderFrameCreated(
content::RenderFrame* render_frame) { content::RenderFrame* render_frame) {
new AtomSandboxedRenderFrameObserver(render_frame, this); new AtomSandboxedRenderFrameObserver(render_frame, this);
new printing::PrintWebViewHelper(render_frame);
} }
void AtomSandboxedRendererClient::RenderViewCreated( void AtomSandboxedRendererClient::RenderViewCreated(
content::RenderView* render_view) { content::RenderView* render_view) {
new printing::PrintWebViewHelper(render_view);
new AtomSandboxedRenderViewObserver(render_view, this); new AtomSandboxedRenderViewObserver(render_view, this);
} }

View file

@ -7,6 +7,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "content/public/renderer/browser_plugin_delegate.h" #include "content/public/renderer/browser_plugin_delegate.h"
#include "content/public/renderer/render_frame.h"
namespace gfx { namespace gfx {
class Size; class Size;

View file

@ -4,38 +4,13 @@
#include "atom/utility/atom_content_utility_client.h" #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) #if defined(OS_WIN)
#include "chrome/utility/printing_handler_win.h" #include "chrome/utility/printing_handler_win.h"
#endif #endif
namespace {
bool Send(IPC::Message* message) {
return content::UtilityThread::Get()->Send(message);
}
} // namespace
namespace atom { namespace atom {
int64_t AtomContentUtilityClient::max_ipc_message_size_ = AtomContentUtilityClient::AtomContentUtilityClient() {
IPC::Channel::kMaximumMessageSize;
AtomContentUtilityClient::AtomContentUtilityClient()
: filter_messages_(false) {
#if defined(OS_WIN) #if defined(OS_WIN)
handlers_.push_back(new printing::PrintingHandlerWin()); handlers_.push_back(new printing::PrintingHandlerWin());
#endif #endif
@ -44,31 +19,4 @@ AtomContentUtilityClient::AtomContentUtilityClient()
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 } // namespace atom

View file

@ -5,19 +5,11 @@
#ifndef ATOM_UTILITY_ATOM_CONTENT_UTILITY_CLIENT_H_ #ifndef ATOM_UTILITY_ATOM_CONTENT_UTILITY_CLIENT_H_
#define ATOM_UTILITY_ATOM_CONTENT_UTILITY_CLIENT_H_ #define ATOM_UTILITY_ATOM_CONTENT_UTILITY_CLIENT_H_
#include <set>
#include <string>
#include <vector> #include <vector>
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/memory/scoped_vector.h" #include "base/memory/scoped_vector.h"
#include "content/public/utility/content_utility_client.h" #include "content/public/utility/content_utility_client.h"
#include "ipc/ipc_platform_file.h"
namespace base {
class FilePath;
struct FileDescriptor;
}
class UtilityMessageHandler; class UtilityMessageHandler;
@ -28,25 +20,11 @@ class AtomContentUtilityClient : public content::ContentUtilityClient {
AtomContentUtilityClient(); AtomContentUtilityClient();
~AtomContentUtilityClient() override; ~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: private:
void OnStartupPing(); #if defined(OS_WIN)
typedef ScopedVector<UtilityMessageHandler> Handlers; typedef ScopedVector<UtilityMessageHandler> Handlers;
Handlers handlers_; Handlers handlers_;
#endif
// Flag to enable whitelisting.
bool filter_messages_;
// A list of message_ids to filter.
std::set<int> 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); DISALLOW_COPY_AND_ASSIGN(AtomContentUtilityClient);
}; };

View file

@ -19,8 +19,7 @@
#include "third_party/libyuv/include/libyuv/scale_argb.h" #include "third_party/libyuv/include/libyuv/scale_argb.h"
#include "third_party/skia/include/core/SkBitmap.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/desktop_frame.h"
#include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
#include "third_party/webrtc/modules/desktop_capture/window_capturer.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/skia_util.h" #include "ui/gfx/skia_util.h"
@ -86,8 +85,8 @@ class NativeDesktopMediaList::Worker
: public webrtc::DesktopCapturer::Callback { : public webrtc::DesktopCapturer::Callback {
public: public:
Worker(base::WeakPtr<NativeDesktopMediaList> media_list, Worker(base::WeakPtr<NativeDesktopMediaList> media_list,
std::unique_ptr<webrtc::ScreenCapturer> screen_capturer, std::unique_ptr<webrtc::DesktopCapturer> screen_capturer,
std::unique_ptr<webrtc::WindowCapturer> window_capturer); std::unique_ptr<webrtc::DesktopCapturer> window_capturer);
~Worker() override; ~Worker() override;
void Refresh(const gfx::Size& thumbnail_size, void Refresh(const gfx::Size& thumbnail_size,
@ -102,8 +101,8 @@ class NativeDesktopMediaList::Worker
base::WeakPtr<NativeDesktopMediaList> media_list_; base::WeakPtr<NativeDesktopMediaList> media_list_;
std::unique_ptr<webrtc::ScreenCapturer> screen_capturer_; std::unique_ptr<webrtc::DesktopCapturer> screen_capturer_;
std::unique_ptr<webrtc::WindowCapturer> window_capturer_; std::unique_ptr<webrtc::DesktopCapturer> window_capturer_;
std::unique_ptr<webrtc::DesktopFrame> current_frame_; std::unique_ptr<webrtc::DesktopFrame> current_frame_;
@ -114,8 +113,8 @@ class NativeDesktopMediaList::Worker
NativeDesktopMediaList::Worker::Worker( NativeDesktopMediaList::Worker::Worker(
base::WeakPtr<NativeDesktopMediaList> media_list, base::WeakPtr<NativeDesktopMediaList> media_list,
std::unique_ptr<webrtc::ScreenCapturer> screen_capturer, std::unique_ptr<webrtc::DesktopCapturer> screen_capturer,
std::unique_ptr<webrtc::WindowCapturer> window_capturer) std::unique_ptr<webrtc::DesktopCapturer> window_capturer)
: media_list_(media_list), : media_list_(media_list),
screen_capturer_(std::move(screen_capturer)), screen_capturer_(std::move(screen_capturer)),
window_capturer_(std::move(window_capturer)) { window_capturer_(std::move(window_capturer)) {
@ -133,8 +132,8 @@ void NativeDesktopMediaList::Worker::Refresh(
std::vector<SourceDescription> sources; std::vector<SourceDescription> sources;
if (screen_capturer_) { if (screen_capturer_) {
webrtc::ScreenCapturer::ScreenList screens; webrtc::DesktopCapturer::SourceList screens;
if (screen_capturer_->GetScreenList(&screens)) { if (screen_capturer_->GetSourceList(&screens)) {
bool mutiple_screens = screens.size() > 1; bool mutiple_screens = screens.size() > 1;
base::string16 title; base::string16 title;
for (size_t i = 0; i < screens.size(); ++i) { for (size_t i = 0; i < screens.size(); ++i) {
@ -150,10 +149,9 @@ void NativeDesktopMediaList::Worker::Refresh(
} }
if (window_capturer_) { if (window_capturer_) {
webrtc::WindowCapturer::WindowList windows; webrtc::DesktopCapturer::SourceList windows;
if (window_capturer_->GetWindowList(&windows)) { if (window_capturer_->GetSourceList(&windows)) {
for (webrtc::WindowCapturer::WindowList::iterator it = windows.begin(); for (auto it = windows.begin(); it != windows.end(); ++it) {
it != windows.end(); ++it) {
// Skip the picker dialog window. // Skip the picker dialog window.
if (it->id != view_dialog_id) { if (it->id != view_dialog_id) {
sources.push_back(SourceDescription( sources.push_back(SourceDescription(
@ -176,15 +174,15 @@ void NativeDesktopMediaList::Worker::Refresh(
SourceDescription& source = sources[i]; SourceDescription& source = sources[i];
switch (source.id.type) { switch (source.id.type) {
case DesktopMediaID::TYPE_SCREEN: case DesktopMediaID::TYPE_SCREEN:
if (!screen_capturer_->SelectScreen(source.id.id)) if (!screen_capturer_->SelectSource(source.id.id))
continue; continue;
screen_capturer_->Capture(webrtc::DesktopRegion()); screen_capturer_->CaptureFrame();
break; break;
case DesktopMediaID::TYPE_WINDOW: case DesktopMediaID::TYPE_WINDOW:
if (!window_capturer_->SelectWindow(source.id.id)) if (!window_capturer_->SelectSource(source.id.id))
continue; continue;
window_capturer_->Capture(webrtc::DesktopRegion()); window_capturer_->CaptureFrame();
break; break;
default: default:
@ -225,8 +223,8 @@ void NativeDesktopMediaList::Worker::OnCaptureResult(
} }
NativeDesktopMediaList::NativeDesktopMediaList( NativeDesktopMediaList::NativeDesktopMediaList(
std::unique_ptr<webrtc::ScreenCapturer> screen_capturer, std::unique_ptr<webrtc::DesktopCapturer> screen_capturer,
std::unique_ptr<webrtc::WindowCapturer> window_capturer) std::unique_ptr<webrtc::DesktopCapturer> window_capturer)
: screen_capturer_(std::move(screen_capturer)), : screen_capturer_(std::move(screen_capturer)),
window_capturer_(std::move(window_capturer)), window_capturer_(std::move(window_capturer)),
update_period_(base::TimeDelta::FromMilliseconds(kDefaultUpdatePeriod)), update_period_(base::TimeDelta::FromMilliseconds(kDefaultUpdatePeriod)),

View file

@ -12,8 +12,7 @@
#include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia.h"
namespace webrtc { namespace webrtc {
class ScreenCapturer; class DesktopCapturer;
class WindowCapturer;
} }
// Implementation of DesktopMediaList that shows native screens and // 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 // types of sources the model should be populated with (e.g. it will only
// contain windows, if |screen_capturer| is NULL). // contain windows, if |screen_capturer| is NULL).
NativeDesktopMediaList( NativeDesktopMediaList(
std::unique_ptr<webrtc::ScreenCapturer> screen_capturer, std::unique_ptr<webrtc::DesktopCapturer> screen_capturer,
std::unique_ptr<webrtc::WindowCapturer> window_capturer); std::unique_ptr<webrtc::DesktopCapturer> window_capturer);
~NativeDesktopMediaList() override; ~NativeDesktopMediaList() override;
// DesktopMediaList interface. // DesktopMediaList interface.
@ -65,8 +64,8 @@ class NativeDesktopMediaList : public DesktopMediaList {
void OnRefreshFinished(); void OnRefreshFinished();
// Capturers specified in SetCapturers() and passed to the |worker_| later. // Capturers specified in SetCapturers() and passed to the |worker_| later.
std::unique_ptr<webrtc::ScreenCapturer> screen_capturer_; std::unique_ptr<webrtc::DesktopCapturer> screen_capturer_;
std::unique_ptr<webrtc::WindowCapturer> window_capturer_; std::unique_ptr<webrtc::DesktopCapturer> window_capturer_;
// Time interval between mode updates. // Time interval between mode updates.
base::TimeDelta update_period_; base::TimeDelta update_period_;

View file

@ -4,13 +4,22 @@
#include "chrome/browser/printing/pdf_to_emf_converter.h" #include "chrome/browser/printing/pdf_to_emf_converter.h"
#include <stdint.h>
#include <windows.h>
#include <memory>
#include <queue> #include <queue>
#include <utility>
#include <vector>
#include "base/files/file.h" #include "base/files/file.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h" #include "base/files/scoped_temp_dir.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.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/chrome_utility_messages.h"
#include "chrome/common/print_messages.h" #include "chrome/common/print_messages.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
@ -19,6 +28,7 @@
#include "content/public/browser/utility_process_host_client.h" #include "content/public/browser/utility_process_host_client.h"
#include "printing/emf_win.h" #include "printing/emf_win.h"
#include "printing/pdf_render_settings.h" #include "printing/pdf_render_settings.h"
#include "ui/base/l10n/l10n_util.h"
namespace printing { namespace printing {
@ -38,7 +48,7 @@ class RefCountedTempDir
public: public:
RefCountedTempDir() { ignore_result(temp_dir_.CreateUniqueTempDir()); } RefCountedTempDir() { ignore_result(temp_dir_.CreateUniqueTempDir()); }
bool IsValid() const { return temp_dir_.IsValid(); } 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: private:
friend struct BrowserThread::DeleteOnThread<BrowserThread::FILE>; friend struct BrowserThread::DeleteOnThread<BrowserThread::FILE>;
@ -59,7 +69,9 @@ typedef std::unique_ptr<base::File, BrowserThread::DeleteOnFileThread>
class LazyEmf : public MetafilePlayer { class LazyEmf : public MetafilePlayer {
public: public:
LazyEmf(const scoped_refptr<RefCountedTempDir>& temp_dir, ScopedTempFile file) LazyEmf(const scoped_refptr<RefCountedTempDir>& 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(); } ~LazyEmf() override { Close(); }
bool SafePlayback(HDC hdc) const override; bool SafePlayback(HDC hdc) const override;
@ -97,6 +109,7 @@ class PdfToEmfUtilityProcessHostClient
const PdfRenderSettings& settings); const PdfRenderSettings& settings);
void Start(const scoped_refptr<base::RefCountedMemory>& data, void Start(const scoped_refptr<base::RefCountedMemory>& data,
bool print_text_with_gdi,
const PdfToEmfConverter::StartCallback& start_callback); const PdfToEmfConverter::StartCallback& start_callback);
void GetPage(int page_number, void GetPage(int page_number,
@ -104,10 +117,14 @@ class PdfToEmfUtilityProcessHostClient
void Stop(); void Stop();
// Needs to be public to handle ChromeUtilityHostMsg_PreCacheFontCharacters
// sync message replies.
bool Send(IPC::Message* msg);
// UtilityProcessHostClient implementation. // UtilityProcessHostClient implementation.
virtual void OnProcessCrashed(int exit_code) override; void OnProcessCrashed(int exit_code) override;
virtual void OnProcessLaunchFailed(int exit_code) override; void OnProcessLaunchFailed(int exit_code) override;
virtual bool OnMessageReceived(const IPC::Message& message) override; bool OnMessageReceived(const IPC::Message& message) override;
private: private:
class GetPageCallbackData { class GetPageCallbackData {
@ -138,19 +155,20 @@ class PdfToEmfUtilityProcessHostClient
int page_number_; int page_number_;
PdfToEmfConverter::GetPageCallback callback_; PdfToEmfConverter::GetPageCallback callback_;
ScopedTempFile emf_; ScopedTempFile emf_;
DISALLOW_COPY_AND_ASSIGN(GetPageCallbackData);
}; };
virtual ~PdfToEmfUtilityProcessHostClient(); ~PdfToEmfUtilityProcessHostClient() override;
bool Send(IPC::Message* msg);
// Message handlers. // Message handlers.
void OnProcessStarted();
void OnPageCount(int page_count); void OnPageCount(int page_count);
void OnPageDone(bool success, float scale_factor); void OnPageDone(bool success, float scale_factor);
void OnPreCacheFontCharacters(const LOGFONT& log_font,
const base::string16& characters);
void OnFailed(); void OnFailed();
void OnTempPdfReady(ScopedTempFile pdf); void OnTempPdfReady(bool print_text_with_gdi, ScopedTempFile pdf);
void OnTempEmfReady(GetPageCallbackData* callback_data, ScopedTempFile emf); void OnTempEmfReady(GetPageCallbackData* callback_data, ScopedTempFile emf);
scoped_refptr<RefCountedTempDir> temp_dir_; scoped_refptr<RefCountedTempDir> temp_dir_;
@ -158,7 +176,6 @@ class PdfToEmfUtilityProcessHostClient
// Used to suppress callbacks after PdfToEmfConverterImpl is deleted. // Used to suppress callbacks after PdfToEmfConverterImpl is deleted.
base::WeakPtr<PdfToEmfConverterImpl> converter_; base::WeakPtr<PdfToEmfConverterImpl> converter_;
PdfRenderSettings settings_; PdfRenderSettings settings_;
scoped_refptr<base::RefCountedMemory> data_;
// Document loaded callback. // Document loaded callback.
PdfToEmfConverter::StartCallback start_callback_; PdfToEmfConverter::StartCallback start_callback_;
@ -179,13 +196,14 @@ class PdfToEmfConverterImpl : public PdfToEmfConverter {
public: public:
PdfToEmfConverterImpl(); PdfToEmfConverterImpl();
virtual ~PdfToEmfConverterImpl(); ~PdfToEmfConverterImpl() override;
virtual void Start(const scoped_refptr<base::RefCountedMemory>& data, void Start(const scoped_refptr<base::RefCountedMemory>& data,
const PdfRenderSettings& conversion_settings, const PdfRenderSettings& conversion_settings,
bool print_text_with_gdi,
const StartCallback& start_callback) override; const StartCallback& start_callback) override;
virtual void GetPage(int page_number, void GetPage(int page_number,
const GetPageCallback& get_page_callback) override; const GetPageCallback& get_page_callback) override;
// Helps to cancel callbacks if this object is destroyed. // Helps to cancel callbacks if this object is destroyed.
@ -205,16 +223,21 @@ ScopedTempFile CreateTempFile(scoped_refptr<RefCountedTempDir>* temp_dir) {
if (!(*temp_dir)->IsValid()) if (!(*temp_dir)->IsValid())
return file; return file;
base::FilePath path; 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; return file;
}
file.reset(new base::File(path, file.reset(new base::File(path,
base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_CREATE_ALWAYS |
base::File::FLAG_WRITE | base::File::FLAG_WRITE |
base::File::FLAG_READ | base::File::FLAG_READ |
base::File::FLAG_DELETE_ON_CLOSE | base::File::FLAG_DELETE_ON_CLOSE |
base::File::FLAG_TEMPORARY)); base::File::FLAG_TEMPORARY));
if (!file->IsValid()) if (!file->IsValid()) {
PLOG(ERROR) << "Failed to create " << path.value();
file.reset(); file.reset();
}
return file; return file;
} }
@ -228,6 +251,7 @@ ScopedTempFile CreateTempPdfFile(
static_cast<int>(data->size()) != static_cast<int>(data->size()) !=
pdf_file->WriteAtCurrentPos(data->front_as<char>(), data->size())) { pdf_file->WriteAtCurrentPos(data->front_as<char>(), data->size())) {
pdf_file.reset(); pdf_file.reset();
return pdf_file;
} }
pdf_file->Seek(base::File::FROM_BEGIN, 0); pdf_file->Seek(base::File::FROM_BEGIN, 0);
return pdf_file; return pdf_file;
@ -281,17 +305,15 @@ PdfToEmfUtilityProcessHostClient::~PdfToEmfUtilityProcessHostClient() {
void PdfToEmfUtilityProcessHostClient::Start( void PdfToEmfUtilityProcessHostClient::Start(
const scoped_refptr<base::RefCountedMemory>& data, const scoped_refptr<base::RefCountedMemory>& data,
bool print_text_with_gdi,
const PdfToEmfConverter::StartCallback& start_callback) { const PdfToEmfConverter::StartCallback& start_callback) {
if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
BrowserThread::PostTask(BrowserThread::IO, BrowserThread::PostTask(
FROM_HERE, BrowserThread::IO, FROM_HERE,
base::Bind(&PdfToEmfUtilityProcessHostClient::Start, base::Bind(&PdfToEmfUtilityProcessHostClient::Start, this, data,
this, print_text_with_gdi, start_callback));
data,
start_callback));
return; return;
} }
data_ = data;
// Store callback before any OnFailed() call to make it called on failure. // Store callback before any OnFailed() call to make it called on failure.
start_callback_ = start_callback; start_callback_ = start_callback;
@ -299,37 +321,28 @@ void PdfToEmfUtilityProcessHostClient::Start(
// NOTE: This process _must_ be sandboxed, otherwise the pdf dll will load // NOTE: This process _must_ be sandboxed, otherwise the pdf dll will load
// gdiplus.dll, change how rendering happens, and not be able to correctly // gdiplus.dll, change how rendering happens, and not be able to correctly
// generate when sent to a metafile DC. // generate when sent to a metafile DC.
utility_process_host_ = utility_process_host_ = content::UtilityProcessHost::Create(
content::UtilityProcessHost::Create( this, base::ThreadTaskRunnerHandle::Get())
this, base::MessageLoop::current()->task_runner())->AsWeakPtr(); ->AsWeakPtr();
if (!utility_process_host_) utility_process_host_->SetName(base::ASCIIToUTF16(
return OnFailed(); "IDS_UTILITY_PROCESS_EMF_CONVERTOR_NAME"));
// Should reply with OnProcessStarted().
Send(new ChromeUtilityMsg_StartupPing);
}
void PdfToEmfUtilityProcessHostClient::OnProcessStarted() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!utility_process_host_)
return OnFailed();
scoped_refptr<base::RefCountedMemory> data = data_;
data_ = NULL;
BrowserThread::PostTaskAndReplyWithResult( BrowserThread::PostTaskAndReplyWithResult(
BrowserThread::FILE, BrowserThread::FILE, FROM_HERE,
FROM_HERE,
base::Bind(&CreateTempPdfFile, data, &temp_dir_), 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); DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!utility_process_host_ || !pdf) if (!utility_process_host_ || !pdf)
return OnFailed(); return OnFailed();
// Should reply with OnPageCount(). // Should reply with OnPageCount().
Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles( Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles(
IPC::GetPlatformFileForTransit(pdf->GetPlatformFile(), false), IPC::GetPlatformFileForTransit(pdf->GetPlatformFile(), false), settings_,
settings_)); print_text_with_gdi));
} }
void PdfToEmfUtilityProcessHostClient::OnPageCount(int page_count) { void PdfToEmfUtilityProcessHostClient::OnPageCount(int page_count) {
@ -413,6 +426,38 @@ void PdfToEmfUtilityProcessHostClient::OnPageDone(bool success,
get_page_callbacks_.pop(); 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() { void PdfToEmfUtilityProcessHostClient::Stop() {
if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
BrowserThread::PostTask( BrowserThread::PostTask(
@ -436,11 +481,12 @@ bool PdfToEmfUtilityProcessHostClient::OnMessageReceived(
const IPC::Message& message) { const IPC::Message& message) {
bool handled = true; bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PdfToEmfUtilityProcessHostClient, message) IPC_BEGIN_MESSAGE_MAP(PdfToEmfUtilityProcessHostClient, message)
IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ProcessStarted, OnProcessStarted)
IPC_MESSAGE_HANDLER( IPC_MESSAGE_HANDLER(
ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageCount, OnPageCount) ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageCount, OnPageCount)
IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageDone, IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageDone,
OnPageDone) OnPageDone)
IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_PreCacheFontCharacters,
OnPreCacheFontCharacters)
IPC_MESSAGE_UNHANDLED(handled = false) IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP() IPC_END_MESSAGE_MAP()
return handled; return handled;
@ -473,11 +519,12 @@ PdfToEmfConverterImpl::~PdfToEmfConverterImpl() {
void PdfToEmfConverterImpl::Start( void PdfToEmfConverterImpl::Start(
const scoped_refptr<base::RefCountedMemory>& data, const scoped_refptr<base::RefCountedMemory>& data,
const PdfRenderSettings& conversion_settings, const PdfRenderSettings& conversion_settings,
bool print_text_with_gdi,
const StartCallback& start_callback) { const StartCallback& start_callback) {
DCHECK(!utility_client_.get()); DCHECK(!utility_client_.get());
utility_client_ = new PdfToEmfUtilityProcessHostClient( utility_client_ = new PdfToEmfUtilityProcessHostClient(
weak_ptr_factory_.GetWeakPtr(), conversion_settings); 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, void PdfToEmfConverterImpl::GetPage(int page_number,

View file

@ -10,21 +10,18 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/memory/ref_counted_memory.h" #include "base/memory/ref_counted_memory.h"
namespace base {
class FilePath;
}
namespace printing { namespace printing {
class MetafilePlayer; class MetafilePlayer;
class PdfRenderSettings; struct PdfRenderSettings;
class PdfToEmfConverter { class PdfToEmfConverter {
public: public:
typedef base::Callback<void(int page_count)> StartCallback; typedef base::Callback<void(int page_count)> StartCallback;
typedef base::Callback<void(int page_number, typedef base::Callback<void(int page_number,
float scale_factor, float scale_factor,
std::unique_ptr<MetafilePlayer> emf)> GetPageCallback; std::unique_ptr<MetafilePlayer> emf)>
GetPageCallback;
virtual ~PdfToEmfConverter(); virtual ~PdfToEmfConverter();
@ -34,6 +31,7 @@ class PdfToEmfConverter {
// with positive |page_count|. |page_count| is 0 if initialization failed. // with positive |page_count|. |page_count| is 0 if initialization failed.
virtual void Start(const scoped_refptr<base::RefCountedMemory>& data, virtual void Start(const scoped_refptr<base::RefCountedMemory>& data,
const PdfRenderSettings& conversion_settings, const PdfRenderSettings& conversion_settings,
bool print_text_with_gdi,
const StartCallback& start_callback) = 0; const StartCallback& start_callback) = 0;
// Requests conversion of the page. |page_number| is 0-base page number in // Requests conversion of the page. |page_number| is 0-base page number in

View file

@ -4,14 +4,20 @@
#include "chrome/browser/printing/print_job.h" #include "chrome/browser/printing/print_job.h"
#include <memory>
#include <utility>
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.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/message_loop/message_loop.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/threading/worker_pool.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/chrome_notification_types.h"
#include "chrome/browser/printing/print_job_worker.h" #include "chrome/browser/printing/print_job_worker.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
@ -24,25 +30,22 @@
#include "printing/pdf_render_settings.h" #include "printing/pdf_render_settings.h"
#endif #endif
using base::TimeDelta; using base::TimeDelta;
namespace printing {
namespace { namespace {
// Helper function to ensure |owner| is valid until at least |callback| returns. // Helper function to ensure |owner| is valid until at least |callback| returns.
void HoldRefCallback(const scoped_refptr<printing::PrintJobWorkerOwner>& owner, void HoldRefCallback(const scoped_refptr<PrintJobWorkerOwner>& owner,
const base::Closure& callback) { const base::Closure& callback) {
callback.Run(); callback.Run();
} }
} // namespace } // namespace
namespace printing {
PrintJob::PrintJob() PrintJob::PrintJob()
: source_(NULL), : source_(nullptr),
worker_(),
settings_(),
is_job_pending_(false), is_job_pending_(false),
is_canceling_(false), is_canceling_(false),
quit_factory_(this) { quit_factory_(this) {
@ -65,12 +68,12 @@ void PrintJob::Initialize(PrintJobWorkerOwner* job,
PrintedPagesSource* source, PrintedPagesSource* source,
int page_count) { int page_count) {
DCHECK(!source_); DCHECK(!source_);
DCHECK(!worker_.get()); DCHECK(!worker_);
DCHECK(!is_job_pending_); DCHECK(!is_job_pending_);
DCHECK(!is_canceling_); DCHECK(!is_canceling_);
DCHECK(!document_.get()); DCHECK(!document_.get());
source_ = source; source_ = source;
worker_.reset(job->DetachWorker(this)); worker_ = job->DetachWorker(this);
settings_ = job->settings(); settings_ = job->settings();
PrintedDocument* new_doc = PrintedDocument* new_doc =
@ -90,15 +93,9 @@ void PrintJob::Observe(int type,
const content::NotificationSource& source, const content::NotificationSource& source,
const content::NotificationDetails& details) { const content::NotificationDetails& details) {
DCHECK(RunsTasksOnCurrentThread()); DCHECK(RunsTasksOnCurrentThread());
switch (type) { DCHECK_EQ(chrome::NOTIFICATION_PRINT_JOB_EVENT, type);
case chrome::NOTIFICATION_PRINT_JOB_EVENT: {
OnNotifyPrintJobEvent(*content::Details<JobEventDetails>(details).ptr()); OnNotifyPrintJobEvent(*content::Details<JobEventDetails>(details).ptr());
break;
}
default: {
break;
}
}
} }
void PrintJob::GetSettingsDone(const PrintSettings& new_settings, void PrintJob::GetSettingsDone(const PrintSettings& new_settings,
@ -106,9 +103,10 @@ void PrintJob::GetSettingsDone(const PrintSettings& new_settings,
NOTREACHED(); NOTREACHED();
} }
PrintJobWorker* PrintJob::DetachWorker(PrintJobWorkerOwner* new_owner) { std::unique_ptr<PrintJobWorker> PrintJob::DetachWorker(
PrintJobWorkerOwner* new_owner) {
NOTREACHED(); NOTREACHED();
return NULL; return nullptr;
} }
const PrintSettings& PrintJob::settings() const { const PrintSettings& PrintJob::settings() const {
@ -116,23 +114,22 @@ const PrintSettings& PrintJob::settings() const {
} }
int PrintJob::cookie() const { int PrintJob::cookie() const {
if (!document_.get())
// Always use an invalid cookie in this case. // Always use an invalid cookie in this case.
if (!document_.get())
return 0; return 0;
return document_->cookie(); return document_->cookie();
} }
void PrintJob::StartPrinting() { void PrintJob::StartPrinting() {
DCHECK(RunsTasksOnCurrentThread()); DCHECK(RunsTasksOnCurrentThread());
DCHECK(worker_->IsRunning()); if (!worker_->IsRunning() || is_job_pending_) {
DCHECK(!is_job_pending_); NOTREACHED();
if (!worker_->IsRunning() || is_job_pending_)
return; return;
}
// Real work is done in PrintJobWorker::StartPrinting(). // Real work is done in PrintJobWorker::StartPrinting().
worker_->PostTask(FROM_HERE, worker_->PostTask(FROM_HERE,
base::Bind(&HoldRefCallback, base::Bind(&HoldRefCallback, make_scoped_refptr(this),
make_scoped_refptr(this),
base::Bind(&PrintJobWorker::StartPrinting, base::Bind(&PrintJobWorker::StartPrinting,
base::Unretained(worker_.get()), base::Unretained(worker_.get()),
base::RetainedRef(document_)))); base::RetainedRef(document_))));
@ -141,7 +138,7 @@ void PrintJob::StartPrinting() {
// Tell everyone! // Tell everyone!
scoped_refptr<JobEventDetails> details( scoped_refptr<JobEventDetails> details(
new JobEventDetails(JobEventDetails::NEW_DOC, document_.get(), NULL)); new JobEventDetails(JobEventDetails::NEW_DOC, document_.get(), nullptr));
content::NotificationService::current()->Notify( content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PRINT_JOB_EVENT, chrome::NOTIFICATION_PRINT_JOB_EVENT,
content::Source<PrintJob>(this), content::Source<PrintJob>(this),
@ -165,7 +162,8 @@ void PrintJob::Stop() {
ControlledWorkerShutdown(); ControlledWorkerShutdown();
} else { } else {
// Flush the cached document. // 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. // Make sure a Cancel() is broadcast.
scoped_refptr<JobEventDetails> details( scoped_refptr<JobEventDetails> details(
new JobEventDetails(JobEventDetails::FAILED, NULL, NULL)); new JobEventDetails(JobEventDetails::FAILED, nullptr, nullptr));
content::NotificationService::current()->Notify( content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PRINT_JOB_EVENT, chrome::NOTIFICATION_PRINT_JOB_EVENT,
content::Source<PrintJob>(this), content::Source<PrintJob>(this),
@ -210,7 +208,7 @@ bool PrintJob::FlushJob(base::TimeDelta timeout) {
} }
void PrintJob::DisconnectSource() { void PrintJob::DisconnectSource() {
source_ = NULL; source_ = nullptr;
if (document_.get()) if (document_.get())
document_->DisconnectSource(); document_->DisconnectSource();
} }
@ -237,8 +235,10 @@ class PrintJob::PdfToEmfState {
void Start(const scoped_refptr<base::RefCountedMemory>& data, void Start(const scoped_refptr<base::RefCountedMemory>& data,
const PdfRenderSettings& conversion_settings, const PdfRenderSettings& conversion_settings,
bool print_text_with_gdi,
const PdfToEmfConverter::StartCallback& start_callback) { 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( void GetMorePages(
@ -273,48 +273,51 @@ class PrintJob::PdfToEmfState {
std::unique_ptr<PdfToEmfConverter> converter_; std::unique_ptr<PdfToEmfConverter> converter_;
}; };
void PrintJob::AppendPrintedPage(int page_number) {
pdf_page_mapping_.push_back(page_number);
}
void PrintJob::StartPdfToEmfConversion( void PrintJob::StartPdfToEmfConversion(
const scoped_refptr<base::RefCountedMemory>& bytes, const scoped_refptr<base::RefCountedMemory>& bytes,
const gfx::Size& page_size, const gfx::Size& page_size,
const gfx::Rect& content_area) { const gfx::Rect& content_area,
DCHECK(!ptd_to_emf_state_.get()); bool print_text_with_gdi) {
ptd_to_emf_state_.reset(new PdfToEmfState(page_size, content_area)); DCHECK(!pdf_to_emf_state_);
pdf_to_emf_state_ = base::MakeUnique<PdfToEmfState>(page_size, content_area);
const int kPrinterDpi = settings().dpi(); const int kPrinterDpi = settings().dpi();
ptd_to_emf_state_->Start( pdf_to_emf_state_->Start(
bytes, bytes, PdfRenderSettings(content_area, kPrinterDpi, true),
printing::PdfRenderSettings(content_area, kPrinterDpi, true), print_text_with_gdi, base::Bind(&PrintJob::OnPdfToEmfStarted, this));
base::Bind(&PrintJob::OnPdfToEmfStarted, this));
} }
void PrintJob::OnPdfToEmfStarted(int page_count) { void PrintJob::OnPdfToEmfStarted(int page_count) {
if (page_count <= 0) { if (page_count <= 0) {
ptd_to_emf_state_.reset(); pdf_to_emf_state_.reset();
Cancel(); Cancel();
return; return;
} }
ptd_to_emf_state_->set_page_count(page_count); pdf_to_emf_state_->set_page_count(page_count);
ptd_to_emf_state_->GetMorePages( pdf_to_emf_state_->GetMorePages(
base::Bind(&PrintJob::OnPdfToEmfPageConverted, this)); base::Bind(&PrintJob::OnPdfToEmfPageConverted, this));
} }
void PrintJob::OnPdfToEmfPageConverted(int page_number, void PrintJob::OnPdfToEmfPageConverted(int page_number,
float scale_factor, float scale_factor,
std::unique_ptr<MetafilePlayer> emf) { std::unique_ptr<MetafilePlayer> emf) {
DCHECK(ptd_to_emf_state_); DCHECK(pdf_to_emf_state_);
if (!document_.get() || !emf) { if (!document_.get() || !emf || page_number < 0 ||
ptd_to_emf_state_.reset(); static_cast<size_t>(page_number) >= pdf_page_mapping_.size()) {
pdf_to_emf_state_.reset();
Cancel(); Cancel();
return; return;
} }
// Update the rendered document. It will send notifications to the listener. // Update the rendered document. It will send notifications to the listener.
document_->SetPage(page_number, document_->SetPage(pdf_page_mapping_[page_number], std::move(emf),
std::move(emf), scale_factor, pdf_to_emf_state_->page_size(),
scale_factor, pdf_to_emf_state_->content_area());
ptd_to_emf_state_->page_size(),
ptd_to_emf_state_->content_area());
ptd_to_emf_state_->GetMorePages( pdf_to_emf_state_->GetMorePages(
base::Bind(&PrintJob::OnPdfToEmfPageConverted, this)); base::Bind(&PrintJob::OnPdfToEmfPageConverted, this));
} }
@ -326,16 +329,14 @@ void PrintJob::UpdatePrintedDocument(PrintedDocument* new_document) {
document_ = new_document; document_ = new_document;
if (document_.get()) { if (document_.get())
settings_ = document_->settings(); settings_ = document_->settings();
}
if (worker_) { if (worker_) {
DCHECK(!is_job_pending_); DCHECK(!is_job_pending_);
// Sync the document with the worker. // Sync the document with the worker.
worker_->PostTask(FROM_HERE, worker_->PostTask(FROM_HERE,
base::Bind(&HoldRefCallback, base::Bind(&HoldRefCallback, make_scoped_refptr(this),
make_scoped_refptr(this),
base::Bind(&PrintJobWorker::OnDocumentChanged, base::Bind(&PrintJobWorker::OnDocumentChanged,
base::Unretained(worker_.get()), base::Unretained(worker_.get()),
base::RetainedRef(document_)))); base::RetainedRef(document_))));
@ -371,9 +372,9 @@ void PrintJob::OnNotifyPrintJobEvent(const JobEventDetails& event_details) {
} }
case JobEventDetails::PAGE_DONE: case JobEventDetails::PAGE_DONE:
#if defined(OS_WIN) #if defined(OS_WIN)
ptd_to_emf_state_->OnPageProcessed( pdf_to_emf_state_->OnPageProcessed(
base::Bind(&PrintJob::OnPdfToEmfPageConverted, this)); base::Bind(&PrintJob::OnPdfToEmfPageConverted, this));
#endif // OS_WIN #endif // defined(OS_WIN)
break; break;
default: { default: {
NOTREACHED(); NOTREACHED();
@ -391,7 +392,7 @@ void PrintJob::OnDocumentDone() {
Stop(); Stop();
scoped_refptr<JobEventDetails> details( scoped_refptr<JobEventDetails> details(
new JobEventDetails(JobEventDetails::JOB_DONE, document_.get(), NULL)); new JobEventDetails(JobEventDetails::JOB_DONE, document_.get(), nullptr));
content::NotificationService::current()->Notify( content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PRINT_JOB_EVENT, chrome::NOTIFICATION_PRINT_JOB_EVENT,
content::Source<PrintJob>(this), content::Source<PrintJob>(this),
@ -418,9 +419,8 @@ void PrintJob::ControlledWorkerShutdown() {
// Delay shutdown until the worker terminates. We want this code path // Delay shutdown until the worker terminates. We want this code path
// to wait on the thread to quit before continuing. // to wait on the thread to quit before continuing.
if (worker_->IsRunning()) { if (worker_->IsRunning()) {
base::MessageLoop::current()->PostDelayedTask( base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, FROM_HERE, base::Bind(&PrintJob::ControlledWorkerShutdown, this),
base::Bind(&PrintJob::ControlledWorkerShutdown, this),
base::TimeDelta::FromMilliseconds(100)); base::TimeDelta::FromMilliseconds(100));
return; return;
} }
@ -437,7 +437,7 @@ void PrintJob::ControlledWorkerShutdown() {
is_job_pending_ = false; is_job_pending_ = false;
registrar_.RemoveAll(); registrar_.RemoveAll();
UpdatePrintedDocument(NULL); UpdatePrintedDocument(nullptr);
} }
void PrintJob::HoldUntilStopIsCalled() { void PrintJob::HoldUntilStopIsCalled() {

View file

@ -6,15 +6,15 @@
#define CHROME_BROWSER_PRINTING_PRINT_JOB_H_ #define CHROME_BROWSER_PRINTING_PRINT_JOB_H_
#include <memory> #include <memory>
#include <vector>
#include "base/macros.h"
#include "base/memory/weak_ptr.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 "chrome/browser/printing/print_job_worker_owner.h"
#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
class Thread;
namespace base { namespace base {
class RefCountedMemory; class RefCountedMemory;
} }
@ -49,16 +49,17 @@ class PrintJob : public PrintJobWorkerOwner,
int page_count); int page_count);
// content::NotificationObserver implementation. // content::NotificationObserver implementation.
virtual void Observe(int type, void Observe(int type,
const content::NotificationSource& source, const content::NotificationSource& source,
const content::NotificationDetails& details) override; const content::NotificationDetails& details) override;
// PrintJobWorkerOwner implementation. // PrintJobWorkerOwner implementation.
virtual void GetSettingsDone(const PrintSettings& new_settings, void GetSettingsDone(const PrintSettings& new_settings,
PrintingContext::Result result) override; PrintingContext::Result result) override;
virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner) override; std::unique_ptr<PrintJobWorker> DetachWorker(
virtual const PrintSettings& settings() const override; PrintJobWorkerOwner* new_owner) override;
virtual int cookie() const override; const PrintSettings& settings() const override;
int cookie() const override;
// Starts the actual printing. Signals the worker that it should begin to // Starts the actual printing. Signals the worker that it should begin to
// spool as soon as data is available. // spool as soon as data is available.
@ -91,23 +92,21 @@ class PrintJob : public PrintJobWorkerOwner,
PrintedDocument* document() const; PrintedDocument* document() const;
#if defined(OS_WIN) #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( void StartPdfToEmfConversion(
const scoped_refptr<base::RefCountedMemory>& bytes, const scoped_refptr<base::RefCountedMemory>& bytes,
const gfx::Size& page_size, const gfx::Size& page_size,
const gfx::Rect& content_area); const gfx::Rect& content_area,
bool print_text_with_gdi);
void OnPdfToEmfStarted(int page_count); #endif // defined(OS_WIN)
void OnPdfToEmfPageConverted(int page_number,
float scale_factor,
std::unique_ptr<MetafilePlayer> emf);
#endif // OS_WIN
protected: protected:
virtual ~PrintJob(); ~PrintJob() override;
private: private:
// Updates document_ to a new instance. // Updates |document_| to a new instance.
void UpdatePrintedDocument(PrintedDocument* new_document); void UpdatePrintedDocument(PrintedDocument* new_document);
// Processes a NOTIFY_PRINT_JOB_EVENT notification. // Processes a NOTIFY_PRINT_JOB_EVENT notification.
@ -126,6 +125,13 @@ class PrintJob : public PrintJobWorkerOwner,
void HoldUntilStopIsCalled(); void HoldUntilStopIsCalled();
#if defined(OS_WIN)
void OnPdfToEmfStarted(int page_count);
void OnPdfToEmfPageConverted(int page_number,
float scale_factor,
std::unique_ptr<MetafilePlayer> emf);
#endif // defined(OS_WIN)
content::NotificationRegistrar registrar_; content::NotificationRegistrar registrar_;
// Source that generates the PrintedPage's (i.e. a WebContents). It will be // 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) #if defined(OS_WIN)
class PdfToEmfState; class PdfToEmfState;
std::unique_ptr<PdfToEmfState> ptd_to_emf_state_; std::unique_ptr<PdfToEmfState> pdf_to_emf_state_;
#endif // OS_WIN std::vector<int> pdf_page_mapping_;
#endif // defined(OS_WIN)
// Used at shutdown so that we can quit a nested message loop. // Used at shutdown so that we can quit a nested message loop.
base::WeakPtrFactory<PrintJob> quit_factory_; base::WeakPtrFactory<PrintJob> quit_factory_;

View file

@ -35,7 +35,7 @@ scoped_refptr<PrinterQuery> PrintQueriesQueue::PopPrinterQuery(
for (PrinterQueries::iterator itr = queued_queries_.begin(); for (PrinterQueries::iterator itr = queued_queries_.begin();
itr != queued_queries_.end(); ++itr) { itr != queued_queries_.end(); ++itr) {
if ((*itr)->cookie() == document_cookie && !(*itr)->is_callback_pending()) { if ((*itr)->cookie() == document_cookie && !(*itr)->is_callback_pending()) {
scoped_refptr<printing::PrinterQuery> current_query(*itr); scoped_refptr<PrinterQuery> current_query(*itr);
queued_queries_.erase(itr); queued_queries_.erase(itr);
DCHECK(current_query->is_valid()); DCHECK(current_query->is_valid());
return current_query; return current_query;
@ -46,10 +46,9 @@ scoped_refptr<PrinterQuery> PrintQueriesQueue::PopPrinterQuery(
scoped_refptr<PrinterQuery> PrintQueriesQueue::CreatePrinterQuery( scoped_refptr<PrinterQuery> PrintQueriesQueue::CreatePrinterQuery(
int render_process_id, int render_process_id,
int render_view_id) { int render_frame_id) {
scoped_refptr<PrinterQuery> job = return make_scoped_refptr(
new printing::PrinterQuery(render_process_id, render_view_id); new PrinterQuery(render_process_id, render_frame_id));
return job;
} }
void PrintQueriesQueue::Shutdown() { void PrintQueriesQueue::Shutdown() {
@ -76,14 +75,14 @@ PrintJobManager::~PrintJobManager() {
} }
scoped_refptr<PrintQueriesQueue> PrintJobManager::queue() { scoped_refptr<PrintQueriesQueue> PrintJobManager::queue() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (!queue_.get()) if (!queue_.get())
queue_ = new PrintQueriesQueue(); queue_ = new PrintQueriesQueue();
return queue_; return queue_;
} }
void PrintJobManager::Shutdown() { void PrintJobManager::Shutdown() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(!is_shutdown_); DCHECK(!is_shutdown_);
is_shutdown_ = true; is_shutdown_ = true;
registrar_.RemoveAll(); registrar_.RemoveAll();
@ -94,7 +93,7 @@ void PrintJobManager::Shutdown() {
} }
void PrintJobManager::StopJobs(bool wait_for_finish) { 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. // Copy the array since it can be modified in transit.
PrintJobs to_stop; PrintJobs to_stop;
to_stop.swap(current_jobs_); to_stop.swap(current_jobs_);
@ -111,18 +110,11 @@ void PrintJobManager::StopJobs(bool wait_for_finish) {
void PrintJobManager::Observe(int type, void PrintJobManager::Observe(int type,
const content::NotificationSource& source, const content::NotificationSource& source,
const content::NotificationDetails& details) { const content::NotificationDetails& details) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
switch (type) { DCHECK_EQ(chrome::NOTIFICATION_PRINT_JOB_EVENT, type);
case chrome::NOTIFICATION_PRINT_JOB_EVENT: {
OnPrintJobEvent(content::Source<PrintJob>(source).ptr(), OnPrintJobEvent(content::Source<PrintJob>(source).ptr(),
*content::Details<JobEventDetails>(details).ptr()); *content::Details<JobEventDetails>(details).ptr());
break;
}
default: {
NOTREACHED();
break;
}
}
} }
void PrintJobManager::OnPrintJobEvent( void PrintJobManager::OnPrintJobEvent(

View file

@ -10,6 +10,7 @@
#include <vector> #include <vector>
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "base/threading/non_thread_safe.h" #include "base/threading/non_thread_safe.h"
@ -37,7 +38,7 @@ class PrintQueriesQueue : public base::RefCountedThreadSafe<PrintQueriesQueue> {
// Creates new query. // Creates new query.
scoped_refptr<PrinterQuery> CreatePrinterQuery(int render_process_id, scoped_refptr<PrinterQuery> CreatePrinterQuery(int render_process_id,
int render_view_id); int render_frame_id);
void Shutdown(); void Shutdown();
@ -58,13 +59,13 @@ class PrintQueriesQueue : public base::RefCountedThreadSafe<PrintQueriesQueue> {
class PrintJobManager : public content::NotificationObserver { class PrintJobManager : public content::NotificationObserver {
public: public:
PrintJobManager(); PrintJobManager();
virtual ~PrintJobManager(); ~PrintJobManager() override;
// On browser quit, we should wait to have the print job finished. // On browser quit, we should wait to have the print job finished.
void Shutdown(); void Shutdown();
// content::NotificationObserver // content::NotificationObserver
virtual void Observe(int type, void Observe(int type,
const content::NotificationSource& source, const content::NotificationSource& source,
const content::NotificationDetails& details) override; const content::NotificationDetails& details) override;

View file

@ -4,19 +4,25 @@
#include "chrome/browser/printing/print_job_worker.h" #include "chrome/browser/printing/print_job_worker.h"
#include <memory>
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/compiler_specific.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/message_loop/message_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/values.h" #include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/printing/print_job.h" #include "chrome/browser/printing/print_job.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.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 "content/public/browser/web_contents.h"
#include "printing/print_job_constants.h" #include "printing/print_job_constants.h"
#include "printing/printed_document.h" #include "printing/printed_document.h"
@ -27,7 +33,6 @@
#include <stddef.h> #include <stddef.h>
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
#include <memory>
#include <string> #include <string>
#include <utility> #include <utility>
@ -46,7 +51,7 @@ namespace printing {
namespace { namespace {
// Helper function to ensure |owner| is valid until at least |callback| returns. // Helper function to ensure |owner| is valid until at least |callback| returns.
void HoldRefCallback(const scoped_refptr<printing::PrintJobWorkerOwner>& owner, void HoldRefCallback(const scoped_refptr<PrintJobWorkerOwner>& owner,
const base::Closure& callback) { const base::Closure& callback) {
callback.Run(); callback.Run();
} }
@ -128,34 +133,38 @@ void PrintSettingsToJobSettings(const PrintSettings& settings,
class PrintingContextDelegate : public PrintingContext::Delegate { class PrintingContextDelegate : public PrintingContext::Delegate {
public: public:
PrintingContextDelegate(int render_process_id, int render_view_id); PrintingContextDelegate(int render_process_id, int render_frame_id);
virtual ~PrintingContextDelegate(); ~PrintingContextDelegate() override;
virtual gfx::NativeView GetParentView() override; gfx::NativeView GetParentView() override;
virtual std::string GetAppLocale() override; std::string GetAppLocale() override;
// Not exposed to PrintingContext::Delegate because of dependency issues.
content::WebContents* GetWebContents();
private: private:
int render_process_id_; const int render_process_id_;
int render_view_id_; const int render_frame_id_;
}; };
PrintingContextDelegate::PrintingContextDelegate(int render_process_id, PrintingContextDelegate::PrintingContextDelegate(int render_process_id,
int render_view_id) int render_frame_id)
: render_process_id_(render_process_id), : render_process_id_(render_process_id),
render_view_id_(render_view_id) { render_frame_id_(render_frame_id) {}
}
PrintingContextDelegate::~PrintingContextDelegate() { PrintingContextDelegate::~PrintingContextDelegate() {
} }
gfx::NativeView PrintingContextDelegate::GetParentView() { gfx::NativeView PrintingContextDelegate::GetParentView() {
content::WebContents* wc = GetWebContents();
return wc ? wc->GetNativeView() : nullptr;
}
content::WebContents* PrintingContextDelegate::GetWebContents() {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
content::RenderViewHost* view = auto* rfh =
content::RenderViewHost::FromID(render_process_id_, render_view_id_); content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
if (!view) return rfh ? content::WebContents::FromRenderFrameHost(rfh) : nullptr;
return NULL;
content::WebContents* wc = content::WebContents::FromRenderViewHost(view);
return wc ? wc->GetNativeView() : NULL;
} }
std::string PrintingContextDelegate::GetAppLocale() { std::string PrintingContextDelegate::GetAppLocale() {
@ -174,17 +183,24 @@ void NotificationCallback(PrintJobWorkerOwner* print_job,
content::Details<JobEventDetails>(details)); content::Details<JobEventDetails>(details));
} }
void PostOnOwnerThread(const scoped_refptr<PrintJobWorkerOwner>& owner,
const PrintingContext::PrintSettingsCallback& callback,
PrintingContext::Result result) {
owner->PostTask(FROM_HERE, base::Bind(&HoldRefCallback, owner,
base::Bind(callback, result)));
}
} // namespace } // namespace
PrintJobWorker::PrintJobWorker(int render_process_id, PrintJobWorker::PrintJobWorker(int render_process_id,
int render_view_id, int render_frame_id,
PrintJobWorkerOwner* owner) PrintJobWorkerOwner* owner)
: owner_(owner), thread_("Printing_Worker"), weak_factory_(this) { : owner_(owner), thread_("Printing_Worker"), weak_factory_(this) {
// The object is created in the IO thread. // The object is created in the IO thread.
DCHECK(owner_->RunsTasksOnCurrentThread()); DCHECK(owner_->RunsTasksOnCurrentThread());
printing_context_delegate_.reset( printing_context_delegate_ = base::MakeUnique<PrintingContextDelegate>(
new PrintingContextDelegate(render_process_id, render_view_id)); render_process_id, render_frame_id);
printing_context_ = PrintingContext::Create(printing_context_delegate_.get()); printing_context_ = PrintingContext::Create(printing_context_delegate_.get());
} }
@ -201,11 +217,12 @@ void PrintJobWorker::SetNewOwner(PrintJobWorkerOwner* new_owner) {
owner_ = new_owner; owner_ = new_owner;
} }
void PrintJobWorker::GetSettings( void PrintJobWorker::GetSettings(bool ask_user_for_settings,
bool ask_user_for_settings,
int document_page_count, int document_page_count,
bool has_selection, bool has_selection,
MarginType margin_type, MarginType margin_type,
bool is_scripted,
bool is_modifiable,
const base::string16& device_name) { const base::string16& device_name) {
DCHECK(task_runner_->RunsTasksOnCurrentThread()); DCHECK(task_runner_->RunsTasksOnCurrentThread());
DCHECK_EQ(page_number_, PageNumber::npos()); DCHECK_EQ(page_number_, PageNumber::npos());
@ -217,6 +234,7 @@ void PrintJobWorker::GetSettings(
// should happen on the same thread. See http://crbug.com/73466 // should happen on the same thread. See http://crbug.com/73466
// MessageLoop::current()->SetNestableTasksAllowed(true); // MessageLoop::current()->SetNestableTasksAllowed(true);
printing_context_->set_margin_type(margin_type); 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. // When we delegate to a destination, we don't ask the user for settings.
// TODO(mad): Ask the destination for settings. // TODO(mad): Ask the destination for settings.
@ -227,7 +245,8 @@ void PrintJobWorker::GetSettings(
base::Bind(&PrintJobWorker::GetSettingsWithUI, base::Bind(&PrintJobWorker::GetSettingsWithUI,
base::Unretained(this), base::Unretained(this),
document_page_count, document_page_count,
has_selection))); has_selection,
is_scripted)));
} else if (!device_name.empty()) { } else if (!device_name.empty()) {
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, BrowserThread::UI, FROM_HERE,
@ -286,23 +305,16 @@ void PrintJobWorker::GetSettingsDone(PrintingContext::Result result) {
void PrintJobWorker::GetSettingsWithUI( void PrintJobWorker::GetSettingsWithUI(
int document_page_count, int document_page_count,
bool has_selection) { bool has_selection,
bool is_scripted) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); 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) { // weak_factory_ creates pointers valid only on owner_ thread.
PostTask(FROM_HERE, printing_context_->AskUserForSettings(
base::Bind(&HoldRefCallback, document_page_count, has_selection, is_scripted,
make_scoped_refptr(owner_), base::Bind(&PostOnOwnerThread, make_scoped_refptr(owner_),
base::Bind(&PrintJobWorker::GetSettingsDone, base::Bind(&PrintJobWorker::GetSettingsDone,
base::Unretained(this), weak_factory_.GetWeakPtr())));
result)));
} }
void PrintJobWorker::UseDefaultSettings() { void PrintJobWorker::UseDefaultSettings() {
@ -331,8 +343,6 @@ void PrintJobWorker::StartPrinting(PrintedDocument* new_document) {
base::string16 document_name = base::string16 document_name =
printing::SimplifyDocumentTitle(document_->name()); printing::SimplifyDocumentTitle(document_->name());
if (document_name.empty()) {
}
PrintingContext::Result result = PrintingContext::Result result =
printing_context_->NewDocument(document_name); printing_context_->NewDocument(document_name);
if (result != PrintingContext::OK) { if (result != PrintingContext::OK) {
@ -458,7 +468,8 @@ void PrintJobWorker::SpoolPage(PrintedPage* page) {
DCHECK_NE(page_number_, PageNumber::npos()); DCHECK_NE(page_number_, PageNumber::npos());
// Signal everyone that the page is about to be printed. // Signal everyone that the page is about to be printed.
owner_->PostTask(FROM_HERE, owner_->PostTask(
FROM_HERE,
base::Bind(&NotificationCallback, base::RetainedRef(owner_), base::Bind(&NotificationCallback, base::RetainedRef(owner_),
JobEventDetails::NEW_PAGE, base::RetainedRef(document_), JobEventDetails::NEW_PAGE, base::RetainedRef(document_),
base::RetainedRef(page))); base::RetainedRef(page)));
@ -496,8 +507,7 @@ void PrintJobWorker::OnFailure() {
// We may loose our last reference by broadcasting the FAILED event. // We may loose our last reference by broadcasting the FAILED event.
scoped_refptr<PrintJobWorkerOwner> handle(owner_); scoped_refptr<PrintJobWorkerOwner> handle(owner_);
owner_->PostTask( owner_->PostTask(FROM_HERE,
FROM_HERE,
base::Bind(&NotificationCallback, base::RetainedRef(owner_), base::Bind(&NotificationCallback, base::RetainedRef(owner_),
JobEventDetails::FAILED, JobEventDetails::FAILED,
base::RetainedRef(document_), nullptr)); base::RetainedRef(document_), nullptr));

View file

@ -7,9 +7,11 @@
#include <memory> #include <memory>
#include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "chrome/browser/printing/printer_query.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "printing/page_number.h" #include "printing/page_number.h"
#include "printing/print_job_constants.h" #include "printing/print_job_constants.h"
@ -34,19 +36,22 @@ class PrintedPage;
class PrintJobWorker { class PrintJobWorker {
public: public:
PrintJobWorker(int render_process_id, PrintJobWorker(int render_process_id,
int render_view_id, int render_frame_id,
PrintJobWorkerOwner* owner); PrintJobWorkerOwner* owner);
virtual ~PrintJobWorker(); virtual ~PrintJobWorker();
void SetNewOwner(PrintJobWorkerOwner* new_owner); void SetNewOwner(PrintJobWorkerOwner* new_owner);
// Initializes the print settings. If |ask_user_for_settings| is true, a // Initializes the print settings. If |ask_user_for_settings| is true, a
// Print... dialog box will be shown to ask the user his preference. // Print... dialog box will be shown to ask the user their preference.
void GetSettings( // |is_scripted| should be true for calls coming straight from window.print().
bool ask_user_for_settings, // |is_modifiable| implies HTML and not other formats like PDF.
void GetSettings(bool ask_user_for_settings,
int document_page_count, int document_page_count,
bool has_selection, bool has_selection,
MarginType margin_type, MarginType margin_type,
bool is_scripted,
bool is_modifiable,
const base::string16& device_name); const base::string16& device_name);
// Set the new print settings. // Set the new print settings.
@ -110,12 +115,8 @@ class PrintJobWorker {
// but sticks with this for consistency. // but sticks with this for consistency.
void GetSettingsWithUI( void GetSettingsWithUI(
int document_page_count, int document_page_count,
bool has_selection); bool has_selection,
bool is_scripted);
// 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);
// Called on the UI thread to update the print settings. // Called on the UI thread to update the print settings.
void UpdatePrintSettings(std::unique_ptr<base::DictionaryValue> new_settings); void UpdatePrintSettings(std::unique_ptr<base::DictionaryValue> new_settings);

View file

@ -4,13 +4,14 @@
#include "chrome/browser/printing/print_job_worker_owner.h" #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 { namespace printing {
PrintJobWorkerOwner::PrintJobWorkerOwner() PrintJobWorkerOwner::PrintJobWorkerOwner()
: task_runner_(base::MessageLoop::current()->task_runner()) { : task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
}
PrintJobWorkerOwner::~PrintJobWorkerOwner() { PrintJobWorkerOwner::~PrintJobWorkerOwner() {
} }

View file

@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__ #ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__
#define CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__ #define CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__
#include <memory>
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "printing/printing_context.h" #include "printing/printing_context.h"
@ -34,7 +36,8 @@ class PrintJobWorkerOwner
PrintingContext::Result result) = 0; PrintingContext::Result result) = 0;
// Detach the PrintJobWorker associated to this object. // Detach the PrintJobWorker associated to this object.
virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner) = 0; virtual std::unique_ptr<PrintJobWorker> DetachWorker(
PrintJobWorkerOwner* new_owner) = 0;
// Access the current settings. // Access the current settings.
virtual const PrintSettings& settings() const = 0; virtual const PrintSettings& settings() const = 0;

Some files were not shown because too many files have changed in this diff Show more