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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -20,13 +20,14 @@ using content::BrowserThread;
namespace mate {
template<>
struct Converter<extensions::URLPattern> {
struct Converter<URLPattern> {
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
extensions::URLPattern* out) {
URLPattern* out) {
std::string pattern;
if (!ConvertFromV8(isolate, val, &pattern))
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_file_access_from_file_urls = true;
prefs->experimental_webgl_enabled = true;
prefs->allow_displaying_insecure_content = false;
prefs->allow_running_insecure_content = false;
// Custom preferences of guest page.
@ -300,7 +299,7 @@ bool AtomBrowserClient::CanCreateWindow(
const std::string& frame_name,
WindowOpenDisposition disposition,
const blink::WebWindowFeatures& features,
const std::vector<base::string16>& additional_features,
const std::vector<std::string>& additional_features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
bool user_gesture,
bool opener_suppressed,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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

View file

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

View file

@ -10,7 +10,7 @@
#include "atom/browser/window_list.h"
#include "atom/common/atom_version.h"
#include "brightray/common/application_info.h"
#include "chrome/browser/ui/libgtk2ui/unity_service.h"
#include "chrome/browser/ui/libgtkui/unity_service.h"
namespace atom {
@ -63,7 +63,8 @@ bool Browser::SetBadgeCount(int count) {
void Browser::SetLoginItemSettings(LoginItemSettings settings) {
}
Browser::LoginItemSettings Browser::GetLoginItemSettings() {
Browser::LoginItemSettings Browser::GetLoginItemSettings(
LoginItemSettings options) {
return LoginItemSettings();
}

View file

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

View file

@ -43,15 +43,19 @@ BOOL CALLBACK WindowsEnumerationHandler(HWND hwnd, LPARAM param) {
return TRUE;
}
bool GetProtocolLaunchPath(mate::Arguments* args, base::string16* exe) {
// Executable Path
if (!args->GetNext(exe)) {
bool GetProcessExecPath(base::string16* exe) {
base::FilePath path;
if (!PathService::Get(base::FILE_EXE, &path)) {
LOG(ERROR) << "Error getting app exe path";
return false;
}
*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
@ -65,6 +69,22 @@ bool GetProtocolLaunchPath(mate::Arguments* args, base::string16* exe) {
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
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);
if (settings.open_at_login) {
base::FilePath path;
if (PathService::Get(base::FILE_EXE, &path)) {
base::string16 exePath(path.value());
key.WriteValue(GetAppUserModelID(), exePath.c_str());
base::string16 exe = settings.path;
if (FormatCommandLineString(&exe, settings.args)) {
key.WriteValue(GetAppUserModelID(), exe.c_str());
}
} else {
key.DeleteValue(GetAppUserModelID());
}
}
Browser::LoginItemSettings Browser::GetLoginItemSettings() {
Browser::LoginItemSettings Browser::GetLoginItemSettings(
LoginItemSettings options) {
LoginItemSettings settings;
base::string16 keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS);
base::string16 keyVal;
if (!FAILED(key.ReadValue(GetAppUserModelID(), &keyVal))) {
base::FilePath path;
if (PathService::Get(base::FILE_EXE, &path)) {
base::string16 exePath(path.value());
settings.open_at_login = keyVal == exePath;
base::string16 exe = options.path;
if (FormatCommandLineString(&exe, options.args)) {
settings.open_at_login = keyVal == exe;
}
}
return settings;
}
PCWSTR Browser::GetAppUserModelID() {
if (app_user_model_id_.empty()) {
SetAppUserModelID(base::ReplaceStringPlaceholders(

View file

@ -10,7 +10,6 @@
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/atom_javascript_dialog_manager.h"
#include "atom/browser/atom_security_state_model_client.h"
#include "atom/browser/native_window.h"
#include "atom/browser/ui/file_dialog.h"
#include "atom/browser/web_dialog_helper.h"
@ -18,10 +17,13 @@
#include "base/files/file_util.h"
#include "chrome/browser/printing/print_preview_message_handler.h"
#include "chrome/browser/printing/print_view_manager_basic.h"
#include "chrome/browser/ssl/security_state_tab_helper.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "components/security_state/content/content_utils.h"
#include "components/security_state/core/security_state.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/render_process_host.h"
@ -32,7 +34,6 @@
#include "storage/browser/fileapi/isolated_context.h"
using content::BrowserThread;
using security_state::SecurityStateModel;
namespace atom {
@ -93,8 +94,10 @@ FileSystem CreateFileSystemStruct(
return FileSystem(file_system_name, root_url, file_system_path);
}
base::DictionaryValue* CreateFileSystemValue(const FileSystem& file_system) {
auto* file_system_value = new base::DictionaryValue();
std::unique_ptr<base::DictionaryValue> CreateFileSystemValue(
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("rootURL", file_system.root_url);
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();
}
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
CommonWebContentsDelegate::CommonWebContentsDelegate()
@ -290,81 +275,16 @@ bool CommonWebContentsDelegate::IsFullscreenForTabOrPending(
return html_fullscreen_;
}
content::SecurityStyle CommonWebContentsDelegate::GetSecurityStyle(
blink::WebSecurityStyle CommonWebContentsDelegate::GetSecurityStyle(
content::WebContents* web_contents,
content::SecurityStyleExplanations* explanations) {
auto model_client =
AtomSecurityStateModelClient::FromWebContents(web_contents);
const SecurityStateModel::SecurityInfo& security_info =
model_client->GetSecurityInfo();
const content::SecurityStyle security_style =
SecurityLevelToSecurityStyle(security_info.security_level);
explanations->ran_insecure_content_style =
SecurityLevelToSecurityStyle(
SecurityStateModel::kRanInsecureContentLevel);
explanations->displayed_insecure_content_style =
SecurityLevelToSecurityStyle(
SecurityStateModel::kDisplayedInsecureContentLevel);
explanations->scheme_is_cryptographic = security_info.scheme_is_cryptographic;
if (!security_info.scheme_is_cryptographic)
return security_style;
if (security_info.sha1_deprecation_status ==
SecurityStateModel::DEPRECATED_SHA1_MAJOR) {
explanations->broken_explanations.push_back(
content::SecurityStyleExplanation(
kSHA1Certificate,
kSHA1MajorDescription,
security_info.cert_id));
} else if (security_info.sha1_deprecation_status ==
SecurityStateModel::DEPRECATED_SHA1_MINOR) {
explanations->unauthenticated_explanations.push_back(
content::SecurityStyleExplanation(
kSHA1Certificate,
kSHA1MinorDescription,
security_info.cert_id));
}
explanations->ran_insecure_content =
security_info.mixed_content_status ==
security_state::SecurityStateModel::CONTENT_STATUS_RAN ||
security_info.mixed_content_status ==
security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN;
explanations->displayed_insecure_content =
security_info.mixed_content_status ==
security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED ||
security_info.mixed_content_status ==
security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN;
if (net::IsCertStatusError(security_info.cert_status)) {
std::string error_string = net::ErrorToString(
net::MapCertStatusToNetError(security_info.cert_status));
content::SecurityStyleExplanation explanation(
kCertificateError,
"There are issues with the site's certificate chain " + error_string,
security_info.cert_id);
if (net::IsCertStatusMinorError(security_info.cert_status))
explanations->unauthenticated_explanations.push_back(explanation);
else
explanations->broken_explanations.push_back(explanation);
} else {
if (security_info.sha1_deprecation_status ==
SecurityStateModel::NO_DEPRECATED_SHA1) {
explanations->secure_explanations.push_back(
content::SecurityStyleExplanation(
kValidCertificate,
kValidCertificateDescription,
security_info.cert_id));
}
}
return security_style;
content::SecurityStyleExplanations* security_style_explanations) {
SecurityStateTabHelper* helper =
SecurityStateTabHelper::FromWebContents(web_contents);
DCHECK(helper);
security_state::SecurityInfo security_info;
helper->GetSecurityInfo(&security_info);
return security_state::GetSecurityStyle(security_info,
security_style_explanations);
}
void CommonWebContentsDelegate::DevToolsSaveToFile(

View file

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

View file

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

View file

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

View file

@ -41,7 +41,7 @@
#include "atom/browser/ui/x/window_state_watcher.h"
#include "atom/browser/ui/x/x_window_utils.h"
#include "base/strings/string_util.h"
#include "chrome/browser/ui/libgtk2ui/unity_service.h"
#include "chrome/browser/ui/libgtkui/unity_service.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"

View file

@ -21,7 +21,7 @@
#include "net/base/load_flags.h"
#include "net/base/mime_util.h"
#include "net/base/net_errors.h"
#include "net/filter/filter.h"
#include "net/filter/gzip_source_stream.h"
#include "net/http/http_util.h"
#include "net/url_request/url_request_status.h"
@ -179,10 +179,14 @@ bool URLRequestAsarJob::IsRedirectResponse(GURL* location,
#endif
}
std::unique_ptr<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.
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 {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -19,13 +19,11 @@
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
namespace extensions {
class URLPattern;
}
namespace atom {
using URLPatterns = std::set<extensions::URLPattern>;
using URLPatterns = std::set<URLPattern>;
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);
}
int Finish(const net::CompletionCallback& callback) override {
int Finish(int net_error, const net::CompletionCallback& callback) override {
return net::OK;
}
@ -97,8 +97,8 @@ void URLRequestFetchJob::BeforeStartInUI(
// We have to create the URLRequestContextGetter on UI thread.
url_request_context_getter_ = new brightray::URLRequestContextGetter(
this, nullptr, nullptr, base::FilePath(), true,
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO),
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE),
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE),
nullptr, content::URLRequestInterceptorScopedVector());
} else {
mate::Handle<api::Session> session;

View file

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

View file

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

View file

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

View file

@ -47,16 +47,6 @@ class MacHelper :
is_swap_ack, resources));
}
void BrowserCompositorMacOnLostCompositorResources() override {
view_->render_widget_host()->ScheduleComposite();
}
void BrowserCompositorMacUpdateVSyncParameters(
const base::TimeTicks& timebase,
const base::TimeDelta& interval) override {
view_->render_widget_host()->UpdateVSyncParameters(timebase, interval);
}
void BrowserCompositorMacSendBeginFrame(
const cc::BeginFrameArgs& args) override {
view_->render_widget_host()->Send(

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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

View file

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

View file

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

View file

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

View file

@ -8,7 +8,7 @@
#ifndef ATOM_COMMON_CHROME_VERSION_H_
#define ATOM_COMMON_CHROME_VERSION_H_
#define CHROME_VERSION_STRING "54.0.2840.101"
#define CHROME_VERSION_STRING "56.0.2924.87"
#define CHROME_VERSION "v" CHROME_VERSION_STRING
#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");
crashpad::CrashpadClient crashpad_client;
if (crashpad_client.StartHandler(handler_path, crashes_dir,
crashpad_client.StartHandler(handler_path, crashes_dir, crashes_dir,
submit_url,
StringMap(),
std::vector<std::string>(),
true)) {
crashpad_client.UseHandler();
}
true,
false);
} // @autoreleasepool
}

View file

@ -7,7 +7,7 @@
#include "atom/common/keyboard_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "third_party/WebKit/public/platform/WebInputEvent.h"
#include "ui/events/event_constants.h"
namespace atom {

View file

@ -13,10 +13,10 @@
#include "base/strings/utf_string_conversions.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "native_mate/dictionary.h"
#include "third_party/WebKit/public/platform/WebInputEvent.h"
#include "third_party/WebKit/public/web/WebCache.h"
#include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
#include "third_party/WebKit/public/web/WebFindOptions.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/events/keycodes/dom/keycode_converter.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("size", static_cast<double>(stat.size));
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();
}

View file

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

View file

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

View file

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

View file

@ -150,13 +150,6 @@ const char kRegisterServiceWorkerSchemes[] = "register-service-worker-schemes";
// Register schemes as secure.
const char kSecureSchemes[] = "secure-schemes";
// The minimum SSL/TLS version ("tls1", "tls1.1", or "tls1.2") that
// TLS fallback will accept.
const char kSSLVersionFallbackMin[] = "ssl-version-fallback-min";
// Comma-separated list of SSL cipher suites to disable.
const char kCipherSuiteBlacklist[] = "cipher-suite-blacklist";
// The browser process app 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 kRegisterServiceWorkerSchemes[];
extern const char kSecureSchemes[];
extern const char kSSLVersionFallbackMin[];
extern const char kCipherSuiteBlacklist[];
extern const char kAppUserModelId[];
extern const char kBackgroundColor[];

View file

@ -6,6 +6,9 @@
#include <io.h>
#include "v8-profiler.h"
#include "v8-inspector.h"
namespace node {
int open_osfhandle(intptr_t osfhandle, int flags) {
@ -16,4 +19,14 @@ int close(int fd) {
return _close(fd);
}
void ReferenceSymbols() {
// Following symbols are used by electron.exe but got stripped by compiler,
// for some reason, adding them to ForceSymbolReferences does not work,
// probably because of VC++ bugs.
v8::TracingCpuProfiler::Create(nullptr);
reinterpret_cast<v8_inspector::V8InspectorSession*>(nullptr)->
canDispatchMethod(v8_inspector::StringView());
reinterpret_cast<v8_inspector::V8InspectorClient*>(nullptr)->unmuteMetrics(0);
}
} // namespace node

View file

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

View file

@ -17,6 +17,8 @@
#include "native_mate/object_template_builder.h"
#include "third_party/WebKit/public/web/WebCache.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebFrameWidget.h"
#include "third_party/WebKit/public/web/WebInputMethodController.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebScriptExecutionCallback.h"
#include "third_party/WebKit/public/web/WebScriptSource.h"
@ -187,7 +189,9 @@ void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& scheme,
}
void WebFrame::InsertText(const std::string& text) {
web_frame_->insertText(blink::WebString::fromUTF8(text));
web_frame_->frameWidget()
->getActiveWebInputMethodController()
->commitText(blink::WebString::fromUTF8(text), 0);
}
void WebFrame::InsertCSS(const std::string& css) {

View file

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

View file

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

View file

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

View file

@ -4,38 +4,13 @@
#include "atom/utility/atom_content_utility_client.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/time/time.h"
#include "chrome/common/chrome_utility_messages.h"
#include "chrome/utility/utility_message_handler.h"
#include "content/public/common/content_switches.h"
#include "content/public/utility/utility_thread.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_message_macros.h"
#if defined(OS_WIN)
#include "chrome/utility/printing_handler_win.h"
#endif
namespace {
bool Send(IPC::Message* message) {
return content::UtilityThread::Get()->Send(message);
}
} // namespace
namespace atom {
int64_t AtomContentUtilityClient::max_ipc_message_size_ =
IPC::Channel::kMaximumMessageSize;
AtomContentUtilityClient::AtomContentUtilityClient()
: filter_messages_(false) {
AtomContentUtilityClient::AtomContentUtilityClient() {
#if defined(OS_WIN)
handlers_.push_back(new printing::PrintingHandlerWin());
#endif
@ -44,31 +19,4 @@ AtomContentUtilityClient::AtomContentUtilityClient()
AtomContentUtilityClient::~AtomContentUtilityClient() {
}
void AtomContentUtilityClient::UtilityThreadStarted() {
}
bool AtomContentUtilityClient::OnMessageReceived(
const IPC::Message& message) {
if (filter_messages_ &&
!base::ContainsKey(message_id_whitelist_, message.type()))
return false;
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(AtomContentUtilityClient, message)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
for (auto it = handlers_.begin(); !handled && it != handlers_.end(); ++it) {
handled = (*it)->OnMessageReceived(message);
}
return handled;
}
void AtomContentUtilityClient::OnStartupPing() {
Send(new ChromeUtilityHostMsg_ProcessStarted);
// Don't release the process, we assume further messages are on the way.
}
} // namespace atom

View file

@ -5,19 +5,11 @@
#ifndef ATOM_UTILITY_ATOM_CONTENT_UTILITY_CLIENT_H_
#define ATOM_UTILITY_ATOM_CONTENT_UTILITY_CLIENT_H_
#include <set>
#include <string>
#include <vector>
#include "base/compiler_specific.h"
#include "base/memory/scoped_vector.h"
#include "content/public/utility/content_utility_client.h"
#include "ipc/ipc_platform_file.h"
namespace base {
class FilePath;
struct FileDescriptor;
}
class UtilityMessageHandler;
@ -28,25 +20,11 @@ class AtomContentUtilityClient : public content::ContentUtilityClient {
AtomContentUtilityClient();
~AtomContentUtilityClient() override;
void UtilityThreadStarted() override;
bool OnMessageReceived(const IPC::Message& message) override;
static void set_max_ipc_message_size_for_test(int64_t max_message_size) {
max_ipc_message_size_ = max_message_size;
}
private:
void OnStartupPing();
#if defined(OS_WIN)
typedef ScopedVector<UtilityMessageHandler> Handlers;
Handlers handlers_;
// 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_;
#endif
DISALLOW_COPY_AND_ASSIGN(AtomContentUtilityClient);
};

View file

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

View file

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

View file

@ -4,13 +4,22 @@
#include "chrome/browser/printing/pdf_to_emf_converter.h"
#include <stdint.h>
#include <windows.h>
#include <memory>
#include <queue>
#include <utility>
#include <vector>
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/common/chrome_utility_messages.h"
#include "chrome/common/print_messages.h"
#include "content/public/browser/browser_thread.h"
@ -19,6 +28,7 @@
#include "content/public/browser/utility_process_host_client.h"
#include "printing/emf_win.h"
#include "printing/pdf_render_settings.h"
#include "ui/base/l10n/l10n_util.h"
namespace printing {
@ -38,7 +48,7 @@ class RefCountedTempDir
public:
RefCountedTempDir() { ignore_result(temp_dir_.CreateUniqueTempDir()); }
bool IsValid() const { return temp_dir_.IsValid(); }
const base::FilePath& GetPath() const { return temp_dir_.path(); }
const base::FilePath& GetPath() const { return temp_dir_.GetPath(); }
private:
friend struct BrowserThread::DeleteOnThread<BrowserThread::FILE>;
@ -59,7 +69,9 @@ typedef std::unique_ptr<base::File, BrowserThread::DeleteOnFileThread>
class LazyEmf : public MetafilePlayer {
public:
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(); }
bool SafePlayback(HDC hdc) const override;
@ -97,6 +109,7 @@ class PdfToEmfUtilityProcessHostClient
const PdfRenderSettings& settings);
void Start(const scoped_refptr<base::RefCountedMemory>& data,
bool print_text_with_gdi,
const PdfToEmfConverter::StartCallback& start_callback);
void GetPage(int page_number,
@ -104,10 +117,14 @@ class PdfToEmfUtilityProcessHostClient
void Stop();
// Needs to be public to handle ChromeUtilityHostMsg_PreCacheFontCharacters
// sync message replies.
bool Send(IPC::Message* msg);
// UtilityProcessHostClient implementation.
virtual void OnProcessCrashed(int exit_code) override;
virtual void OnProcessLaunchFailed(int exit_code) override;
virtual bool OnMessageReceived(const IPC::Message& message) override;
void OnProcessCrashed(int exit_code) override;
void OnProcessLaunchFailed(int exit_code) override;
bool OnMessageReceived(const IPC::Message& message) override;
private:
class GetPageCallbackData {
@ -138,19 +155,20 @@ class PdfToEmfUtilityProcessHostClient
int page_number_;
PdfToEmfConverter::GetPageCallback callback_;
ScopedTempFile emf_;
DISALLOW_COPY_AND_ASSIGN(GetPageCallbackData);
};
virtual ~PdfToEmfUtilityProcessHostClient();
bool Send(IPC::Message* msg);
~PdfToEmfUtilityProcessHostClient() override;
// Message handlers.
void OnProcessStarted();
void OnPageCount(int page_count);
void OnPageDone(bool success, float scale_factor);
void OnPreCacheFontCharacters(const LOGFONT& log_font,
const base::string16& characters);
void OnFailed();
void OnTempPdfReady(ScopedTempFile pdf);
void OnTempPdfReady(bool print_text_with_gdi, ScopedTempFile pdf);
void OnTempEmfReady(GetPageCallbackData* callback_data, ScopedTempFile emf);
scoped_refptr<RefCountedTempDir> temp_dir_;
@ -158,7 +176,6 @@ class PdfToEmfUtilityProcessHostClient
// Used to suppress callbacks after PdfToEmfConverterImpl is deleted.
base::WeakPtr<PdfToEmfConverterImpl> converter_;
PdfRenderSettings settings_;
scoped_refptr<base::RefCountedMemory> data_;
// Document loaded callback.
PdfToEmfConverter::StartCallback start_callback_;
@ -179,13 +196,14 @@ class PdfToEmfConverterImpl : public PdfToEmfConverter {
public:
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,
bool print_text_with_gdi,
const StartCallback& start_callback) override;
virtual void GetPage(int page_number,
void GetPage(int page_number,
const GetPageCallback& get_page_callback) override;
// Helps to cancel callbacks if this object is destroyed.
@ -205,16 +223,21 @@ ScopedTempFile CreateTempFile(scoped_refptr<RefCountedTempDir>* temp_dir) {
if (!(*temp_dir)->IsValid())
return file;
base::FilePath path;
if (!base::CreateTemporaryFileInDir((*temp_dir)->GetPath(), &path))
if (!base::CreateTemporaryFileInDir((*temp_dir)->GetPath(), &path)) {
PLOG(ERROR) << "Failed to create file in "
<< (*temp_dir)->GetPath().value();
return file;
}
file.reset(new base::File(path,
base::File::FLAG_CREATE_ALWAYS |
base::File::FLAG_WRITE |
base::File::FLAG_READ |
base::File::FLAG_DELETE_ON_CLOSE |
base::File::FLAG_TEMPORARY));
if (!file->IsValid())
if (!file->IsValid()) {
PLOG(ERROR) << "Failed to create " << path.value();
file.reset();
}
return file;
}
@ -228,6 +251,7 @@ ScopedTempFile CreateTempPdfFile(
static_cast<int>(data->size()) !=
pdf_file->WriteAtCurrentPos(data->front_as<char>(), data->size())) {
pdf_file.reset();
return pdf_file;
}
pdf_file->Seek(base::File::FROM_BEGIN, 0);
return pdf_file;
@ -281,17 +305,15 @@ PdfToEmfUtilityProcessHostClient::~PdfToEmfUtilityProcessHostClient() {
void PdfToEmfUtilityProcessHostClient::Start(
const scoped_refptr<base::RefCountedMemory>& data,
bool print_text_with_gdi,
const PdfToEmfConverter::StartCallback& start_callback) {
if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
BrowserThread::PostTask(BrowserThread::IO,
FROM_HERE,
base::Bind(&PdfToEmfUtilityProcessHostClient::Start,
this,
data,
start_callback));
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&PdfToEmfUtilityProcessHostClient::Start, this, data,
print_text_with_gdi, start_callback));
return;
}
data_ = data;
// Store callback before any OnFailed() call to make it called on failure.
start_callback_ = start_callback;
@ -299,37 +321,28 @@ void PdfToEmfUtilityProcessHostClient::Start(
// NOTE: This process _must_ be sandboxed, otherwise the pdf dll will load
// gdiplus.dll, change how rendering happens, and not be able to correctly
// generate when sent to a metafile DC.
utility_process_host_ =
content::UtilityProcessHost::Create(
this, base::MessageLoop::current()->task_runner())->AsWeakPtr();
if (!utility_process_host_)
return OnFailed();
// Should reply with OnProcessStarted().
Send(new ChromeUtilityMsg_StartupPing);
}
utility_process_host_ = content::UtilityProcessHost::Create(
this, base::ThreadTaskRunnerHandle::Get())
->AsWeakPtr();
utility_process_host_->SetName(base::ASCIIToUTF16(
"IDS_UTILITY_PROCESS_EMF_CONVERTOR_NAME"));
void PdfToEmfUtilityProcessHostClient::OnProcessStarted() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!utility_process_host_)
return OnFailed();
scoped_refptr<base::RefCountedMemory> data = data_;
data_ = NULL;
BrowserThread::PostTaskAndReplyWithResult(
BrowserThread::FILE,
FROM_HERE,
BrowserThread::FILE, FROM_HERE,
base::Bind(&CreateTempPdfFile, data, &temp_dir_),
base::Bind(&PdfToEmfUtilityProcessHostClient::OnTempPdfReady, this));
base::Bind(&PdfToEmfUtilityProcessHostClient::OnTempPdfReady, this,
print_text_with_gdi));
}
void PdfToEmfUtilityProcessHostClient::OnTempPdfReady(ScopedTempFile pdf) {
void PdfToEmfUtilityProcessHostClient::OnTempPdfReady(bool print_text_with_gdi,
ScopedTempFile pdf) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!utility_process_host_ || !pdf)
return OnFailed();
// Should reply with OnPageCount().
Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles(
IPC::GetPlatformFileForTransit(pdf->GetPlatformFile(), false),
settings_));
IPC::GetPlatformFileForTransit(pdf->GetPlatformFile(), false), settings_,
print_text_with_gdi));
}
void PdfToEmfUtilityProcessHostClient::OnPageCount(int page_count) {
@ -413,6 +426,38 @@ void PdfToEmfUtilityProcessHostClient::OnPageDone(bool success,
get_page_callbacks_.pop();
}
void PdfToEmfUtilityProcessHostClient::OnPreCacheFontCharacters(
const LOGFONT& font,
const base::string16& str) {
// TODO(scottmg): pdf/ppapi still require the renderer to be able to precache
// GDI fonts (http://crbug.com/383227), even when using DirectWrite.
// Eventually this shouldn't be added and should be moved to
// FontCacheDispatcher too. http://crbug.com/356346.
// First, comments from FontCacheDispatcher::OnPreCacheFont do apply here too.
// Except that for True Type fonts,
// GetTextMetrics will not load the font in memory.
// The only way windows seem to load properly, it is to create a similar
// device (like the one in which we print), then do an ExtTextOut,
// as we do in the printing thread, which is sandboxed.
HDC hdc = CreateEnhMetaFile(nullptr, nullptr, nullptr, nullptr);
HFONT font_handle = CreateFontIndirect(&font);
DCHECK(font_handle != nullptr);
HGDIOBJ old_font = SelectObject(hdc, font_handle);
DCHECK(old_font != nullptr);
ExtTextOut(hdc, 0, 0, ETO_GLYPH_INDEX, 0, str.c_str(), str.length(), nullptr);
SelectObject(hdc, old_font);
DeleteObject(font_handle);
HENHMETAFILE metafile = CloseEnhMetaFile(hdc);
if (metafile)
DeleteEnhMetaFile(metafile);
}
void PdfToEmfUtilityProcessHostClient::Stop() {
if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
BrowserThread::PostTask(
@ -436,11 +481,12 @@ bool PdfToEmfUtilityProcessHostClient::OnMessageReceived(
const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PdfToEmfUtilityProcessHostClient, message)
IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ProcessStarted, OnProcessStarted)
IPC_MESSAGE_HANDLER(
ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageCount, OnPageCount)
IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageDone,
OnPageDone)
IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_PreCacheFontCharacters,
OnPreCacheFontCharacters)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@ -473,11 +519,12 @@ PdfToEmfConverterImpl::~PdfToEmfConverterImpl() {
void PdfToEmfConverterImpl::Start(
const scoped_refptr<base::RefCountedMemory>& data,
const PdfRenderSettings& conversion_settings,
bool print_text_with_gdi,
const StartCallback& start_callback) {
DCHECK(!utility_client_.get());
utility_client_ = new PdfToEmfUtilityProcessHostClient(
weak_ptr_factory_.GetWeakPtr(), conversion_settings);
utility_client_->Start(data, start_callback);
utility_client_->Start(data, print_text_with_gdi, start_callback);
}
void PdfToEmfConverterImpl::GetPage(int page_number,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,13 +4,14 @@
#include "chrome/browser/printing/print_job_worker_owner.h"
#include "base/message_loop/message_loop.h"
#include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
namespace printing {
PrintJobWorkerOwner::PrintJobWorkerOwner()
: task_runner_(base::MessageLoop::current()->task_runner()) {
}
: task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
PrintJobWorkerOwner::~PrintJobWorkerOwner() {
}

View file

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

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