Merge pull request #16494 from electron/chromium-upgrade/73

feat: upgrade to Chromium 73.0.3683.27
This commit is contained in:
Samuel Attard 2019-02-14 12:28:41 -08:00 committed by GitHub
commit 5904544235
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
174 changed files with 1288 additions and 2572 deletions

View file

@ -2,7 +2,6 @@ import("//build/config/locales.gni")
import("//build/config/ui.gni") import("//build/config/ui.gni")
import("//build/config/win/manifest.gni") import("//build/config/win/manifest.gni")
import("//pdf/features.gni") import("//pdf/features.gni")
import("//services/service_manager/public/service_manifest.gni")
import("//third_party/ffmpeg/ffmpeg_options.gni") import("//third_party/ffmpeg/ffmpeg_options.gni")
import("//tools/generate_library_loader/generate_library_loader.gni") import("//tools/generate_library_loader/generate_library_loader.gni")
import("//tools/grit/grit_rule.gni") import("//tools/grit/grit_rule.gni")
@ -281,7 +280,6 @@ grit("resources") {
deps = [ deps = [
":copy_shell_devtools_discovery_page", ":copy_shell_devtools_discovery_page",
":electron_content_manifest_overlays",
] ]
output_dir = "$target_gen_dir" output_dir = "$target_gen_dir"
@ -330,6 +328,7 @@ static_library("electron_lib") {
":atom_js2c", ":atom_js2c",
"buildflags", "buildflags",
"chromium_src:chrome", "chromium_src:chrome",
"manifests",
"native_mate", "native_mate",
"//base", "//base",
"//base:base_static", "//base:base_static",
@ -1055,26 +1054,3 @@ group("electron") {
":electron_app", ":electron_app",
] ]
} }
group("electron_content_manifest_overlays") {
deps = [
":electron_content_browser_manifest_overlay",
":electron_content_packaged_services_manifest_overlay",
]
}
service_manifest("electron_content_packaged_services_manifest_overlay") {
source = "//electron/manifests/electron_content_packaged_services_manifest_overlay.json"
packaged_services = [ "//services/proxy_resolver:proxy_resolver_manifest" ]
if (enable_basic_printing) {
packaged_services += [
"//chrome/services/printing:manifest",
"//components/services/pdf_compositor:pdf_compositor_manifest",
]
}
}
service_manifest("electron_content_browser_manifest_overlay") {
source = "//electron/manifests/electron_content_browser_manifest_overlay.json"
}

4
DEPS
View file

@ -10,9 +10,9 @@ gclient_gn_args = [
vars = { vars = {
'chromium_version': 'chromium_version':
'72.0.3626.110', '73.0.3683.27',
'node_version': 'node_version':
'ad2c89ec3be0f5db3ea02b0f591d36a5d84c51ad', 'fac6d766c143db8db05bb3b0c0871df8f032363c',
'boto_version': 'f7574aa6cc2c819430c1f05e9a1a1a666ef8169b', 'boto_version': 'f7574aa6cc2c819430c1f05e9a1a1a666ef8169b',
'pyyaml_version': '3.12', 'pyyaml_version': '3.12',

View file

@ -7,17 +7,14 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "atom/common/atom_version.h"
#include "atom/common/options_switches.h" #include "atom/common/options_switches.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/common/chrome_version.h"
#include "content/public/common/content_constants.h" #include "content/public/common/content_constants.h"
#include "content/public/common/pepper_plugin_info.h" #include "content/public/common/pepper_plugin_info.h"
#include "content/public/common/user_agent.h"
#include "electron/buildflags/buildflags.h" #include "electron/buildflags/buildflags.h"
#include "ppapi/shared_impl/ppapi_permissions.h" #include "ppapi/shared_impl/ppapi_permissions.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
@ -180,16 +177,6 @@ AtomContentClient::AtomContentClient() {}
AtomContentClient::~AtomContentClient() {} AtomContentClient::~AtomContentClient() {}
std::string AtomContentClient::GetProduct() const {
return "Chrome/" CHROME_VERSION_STRING;
}
std::string AtomContentClient::GetUserAgent() const {
return content::BuildUserAgentFromProduct("Chrome/" CHROME_VERSION_STRING
" " ATOM_PRODUCT_NAME
"/" ATOM_VERSION_STRING);
}
base::string16 AtomContentClient::GetLocalizedString(int message_id) const { base::string16 AtomContentClient::GetLocalizedString(int message_id) const {
return l10n_util::GetStringUTF16(message_id); return l10n_util::GetStringUTF16(message_id);
} }

View file

@ -20,8 +20,6 @@ class AtomContentClient : public content::ContentClient {
protected: protected:
// content::ContentClient: // content::ContentClient:
std::string GetProduct() const override;
std::string GetUserAgent() const override;
base::string16 GetLocalizedString(int message_id) const override; base::string16 GetLocalizedString(int message_id) const override;
base::StringPiece GetDataResource(int resource_id, base::StringPiece GetDataResource(int resource_id,
ui::ScaleFactor) const override; ui::ScaleFactor) const override;

44
atom/app/manifests.cc Normal file
View file

@ -0,0 +1,44 @@
// Copyright (c) 2019 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/app/manifests.h"
#include "base/no_destructor.h"
#include "printing/buildflags/buildflags.h"
#include "services/proxy_resolver/proxy_resolver_manifest.h"
#include "services/service_manager/public/cpp/manifest_builder.h"
#if BUILDFLAG(ENABLE_PRINTING)
#include "components/services/pdf_compositor/pdf_compositor_manifest.h"
#endif
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/services/printing/manifest.h"
#endif
const service_manager::Manifest& GetElectronContentBrowserOverlayManifest() {
static base::NoDestructor<service_manager::Manifest> manifest{
service_manager::ManifestBuilder()
.WithDisplayName("Electron (browser process)")
.RequireCapability("device", "device:geolocation_control")
.RequireCapability("proxy_resolver", "factory")
.RequireCapability("chrome_printing", "converter")
.RequireCapability("pdf_compositor", "compositor")
.Build()};
return *manifest;
}
const std::vector<service_manager::Manifest>&
GetElectronPackagedServicesOverlayManifest() {
static base::NoDestructor<std::vector<service_manager::Manifest>> manifests{{
proxy_resolver::GetManifest(),
#if BUILDFLAG(ENABLE_PRINTING)
pdf_compositor::GetManifest(),
#endif
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
chrome_printing::GetManifest(),
#endif
}};
return *manifests;
}

16
atom/app/manifests.h Normal file
View file

@ -0,0 +1,16 @@
// Copyright (c) 2019 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_APP_MANIFESTS_H_
#define ATOM_APP_MANIFESTS_H_
#include <vector>
#include "services/service_manager/public/cpp/manifest.h"
const service_manager::Manifest& GetElectronContentBrowserOverlayManifest();
const std::vector<service_manager::Manifest>&
GetElectronPackagedServicesOverlayManifest();
#endif // ATOM_APP_MANIFESTS_H_

View file

@ -690,7 +690,7 @@ bool App::CanCreateWindow(
content::RenderFrameHost* opener, content::RenderFrameHost* opener,
const GURL& opener_url, const GURL& opener_url,
const GURL& opener_top_level_frame_url, const GURL& opener_top_level_frame_url,
const GURL& source_origin, const url::Origin& source_origin,
content::mojom::WindowContainerType container_type, content::mojom::WindowContainerType container_type,
const GURL& target_url, const GURL& target_url,
const content::Referrer& referrer, const content::Referrer& referrer,

View file

@ -141,7 +141,7 @@ class App : public AtomBrowserClient::Delegate,
bool CanCreateWindow(content::RenderFrameHost* opener, bool CanCreateWindow(content::RenderFrameHost* opener,
const GURL& opener_url, const GURL& opener_url,
const GURL& opener_top_level_frame_url, const GURL& opener_top_level_frame_url,
const GURL& source_origin, const url::Origin& source_origin,
content::mojom::WindowContainerType container_type, content::mojom::WindowContainerType container_type,
const GURL& target_url, const GURL& target_url,
const content::Referrer& referrer, const content::Referrer& referrer,

View file

@ -18,6 +18,7 @@
#include "atom/common/options_switches.h" #include "atom/common/options_switches.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_owner_delegate.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "gin/converter.h" #include "gin/converter.h"
@ -130,7 +131,7 @@ void BrowserWindow::RenderViewCreated(
render_view_host->GetProcess()->GetID(), render_view_host->GetProcess()->GetID(),
render_view_host->GetRoutingID()); render_view_host->GetRoutingID());
if (impl) if (impl)
impl->SetBackgroundOpaque(false); impl->owner_delegate()->SetBackgroundOpaque(false);
} }
void BrowserWindow::DidFirstVisuallyNonEmptyPaint() { void BrowserWindow::DidFirstVisuallyNonEmptyPaint() {
@ -349,7 +350,8 @@ void BrowserWindow::SetVibrancy(v8::Isolate* isolate,
render_view_host->GetProcess()->GetID(), render_view_host->GetProcess()->GetID(),
render_view_host->GetRoutingID()); render_view_host->GetRoutingID());
if (impl) if (impl)
impl->SetBackgroundOpaque(type.empty() ? !window_->transparent() : false); impl->owner_delegate()->SetBackgroundOpaque(
type.empty() ? !window_->transparent() : false);
} }
TopLevelWindow::SetVibrancy(isolate, value); TopLevelWindow::SetVibrancy(isolate, value);

View file

@ -103,7 +103,7 @@ bool DownloadItem::IsPaused() const {
} }
void DownloadItem::Resume() { void DownloadItem::Resume() {
download_item_->Resume(); download_item_->Resume(true /* user_gesture */);
} }
bool DownloadItem::CanResume() const { bool DownloadItem::CanResume() const {

View file

@ -84,19 +84,19 @@ void PowerMonitor::OnResume() {
Emit("resume"); Emit("resume");
} }
void PowerMonitor::QuerySystemIdleState(v8::Isolate* isolate, ui::IdleState PowerMonitor::QuerySystemIdleState(v8::Isolate* isolate,
int idle_threshold, int idle_threshold) {
const ui::IdleCallback& callback) {
if (idle_threshold > 0) { if (idle_threshold > 0) {
ui::CalculateIdleState(idle_threshold, callback); return ui::CalculateIdleState(idle_threshold);
} else { } else {
isolate->ThrowException(v8::Exception::TypeError(mate::StringToV8( isolate->ThrowException(v8::Exception::TypeError(mate::StringToV8(
isolate, "Invalid idle threshold, must be greater than 0"))); isolate, "Invalid idle threshold, must be greater than 0")));
return ui::IDLE_STATE_UNKNOWN;
} }
} }
void PowerMonitor::QuerySystemIdleTime(const ui::IdleTimeCallback& callback) { int PowerMonitor::QuerySystemIdleTime() {
ui::CalculateIdleTime(callback); return ui::CalculateIdleTime();
} }
// static // static
@ -122,8 +122,8 @@ void PowerMonitor::BuildPrototype(v8::Isolate* isolate,
.SetMethod("blockShutdown", &PowerMonitor::BlockShutdown) .SetMethod("blockShutdown", &PowerMonitor::BlockShutdown)
.SetMethod("unblockShutdown", &PowerMonitor::UnblockShutdown) .SetMethod("unblockShutdown", &PowerMonitor::UnblockShutdown)
#endif #endif
.SetMethod("querySystemIdleState", &PowerMonitor::QuerySystemIdleState) .SetMethod("_querySystemIdleState", &PowerMonitor::QuerySystemIdleState)
.SetMethod("querySystemIdleTime", &PowerMonitor::QuerySystemIdleTime); .SetMethod("_querySystemIdleTime", &PowerMonitor::QuerySystemIdleTime);
} }
} // namespace api } // namespace api

View file

@ -46,10 +46,8 @@ class PowerMonitor : public mate::TrackableObject<PowerMonitor>,
void OnResume() override; void OnResume() override;
private: private:
void QuerySystemIdleState(v8::Isolate* isolate, ui::IdleState QuerySystemIdleState(v8::Isolate* isolate, int idle_threshold);
int idle_threshold, int QuerySystemIdleTime();
const ui::IdleCallback& callback);
void QuerySystemIdleTime(const ui::IdleTimeCallback& callback);
#if defined(OS_WIN) #if defined(OS_WIN)
// Static callback invoked when a message comes in to our messaging window. // Static callback invoked when a message comes in to our messaging window.

View file

@ -712,7 +712,7 @@ void WebContents::FindReply(content::WebContents* web_contents,
bool WebContents::CheckMediaAccessPermission( bool WebContents::CheckMediaAccessPermission(
content::RenderFrameHost* render_frame_host, content::RenderFrameHost* render_frame_host,
const GURL& security_origin, const GURL& security_origin,
content::MediaStreamType type) { blink::MediaStreamType type) {
auto* web_contents = auto* web_contents =
content::WebContents::FromRenderFrameHost(render_frame_host); content::WebContents::FromRenderFrameHost(render_frame_host);
auto* permission_helper = auto* permission_helper =
@ -999,8 +999,7 @@ void WebContents::DevToolsOpened() {
// Inherit owner window in devtools when it doesn't have one. // Inherit owner window in devtools when it doesn't have one.
auto* devtools = managed_web_contents()->GetDevToolsWebContents(); auto* devtools = managed_web_contents()->GetDevToolsWebContents();
bool has_window = bool has_window = devtools->GetUserData(NativeWindowRelay::UserDataKey());
devtools->GetUserData(NativeWindowRelay::kNativeWindowRelayUserDataKey);
if (owner_window() && !has_window) if (owner_window() && !has_window)
handle->SetOwnerWindow(devtools, owner_window()); handle->SetOwnerWindow(devtools, owner_window());
@ -1127,7 +1126,7 @@ void WebContents::SetBackgroundThrottling(bool allowed) {
return; return;
} }
const auto* render_process_host = render_view_host->GetProcess(); auto* render_process_host = render_view_host->GetProcess();
if (!render_process_host) { if (!render_process_host) {
return; return;
} }

View file

@ -387,7 +387,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
bool final_update) override; bool final_update) override;
bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host, bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
const GURL& security_origin, const GURL& security_origin,
content::MediaStreamType type) override; blink::MediaStreamType type) override;
void RequestMediaAccessPermission( void RequestMediaAccessPermission(
content::WebContents* web_contents, content::WebContents* web_contents,
const content::MediaStreamRequest& request, const content::MediaStreamRequest& request,

View file

@ -31,9 +31,13 @@ class WebContentsViewRelay
atom::api::WebContentsView* view_ = nullptr; atom::api::WebContentsView* view_ = nullptr;
WEB_CONTENTS_USER_DATA_KEY_DECL();
DISALLOW_COPY_AND_ASSIGN(WebContentsViewRelay); DISALLOW_COPY_AND_ASSIGN(WebContentsViewRelay);
}; };
WEB_CONTENTS_USER_DATA_KEY_IMPL(WebContentsViewRelay)
} // namespace } // namespace
namespace atom { namespace atom {

View file

@ -11,6 +11,7 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "atom/app/manifests.h"
#include "atom/browser/api/atom_api_app.h" #include "atom/browser/api/atom_api_app.h"
#include "atom/browser/api/atom_api_protocol.h" #include "atom/browser/api/atom_api_protocol.h"
#include "atom/browser/api/atom_api_web_contents.h" #include "atom/browser/api/atom_api_web_contents.h"
@ -32,6 +33,7 @@
#include "atom/browser/web_contents_permission_helper.h" #include "atom/browser/web_contents_permission_helper.h"
#include "atom/browser/web_contents_preferences.h" #include "atom/browser/web_contents_preferences.h"
#include "atom/browser/window_list.h" #include "atom/browser/window_list.h"
#include "atom/common/application_info.h"
#include "atom/common/options_switches.h" #include "atom/common/options_switches.h"
#include "atom/common/platform_util.h" #include "atom/common/platform_util.h"
#include "base/command_line.h" #include "base/command_line.h"
@ -47,6 +49,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/common/chrome_version.h"
#include "components/net_log/chrome_net_log.h" #include "components/net_log/chrome_net_log.h"
#include "content/public/browser/browser_ppapi_host.h" #include "content/public/browser/browser_ppapi_host.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
@ -117,15 +120,14 @@ namespace {
bool g_suppress_renderer_process_restart = false; bool g_suppress_renderer_process_restart = false;
bool IsSameWebSite(content::BrowserContext* browser_context, bool IsSameWebSite(content::BrowserContext* browser_context,
const GURL& src_url, content::SiteInstance* site_instance,
const GURL& dest_url) { const GURL& dest_url) {
return content::SiteInstance::IsSameWebSite(browser_context, src_url, return site_instance->IsSameSiteWithURL(dest_url) ||
dest_url) || // `IsSameSiteWithURL` doesn't seem to work for some URIs such as
// `IsSameWebSite` doesn't seem to work for some URIs such as `file:`, // `file:`, handle these scenarios by comparing only the site as
// handle these scenarios by comparing only the site as defined by // defined by `GetSiteForURL`.
// `GetSiteForURL`. (content::SiteInstance::GetSiteForURL(browser_context, dest_url) ==
content::SiteInstance::GetSiteForURL(browser_context, dest_url) == site_instance->GetSiteURL());
src_url;
} }
AtomBrowserClient* g_browser_client = nullptr; AtomBrowserClient* g_browser_client = nullptr;
@ -224,8 +226,7 @@ bool AtomBrowserClient::ShouldForceNewSiteInstance(
} }
// Create new a SiteInstance if navigating to a different site. // Create new a SiteInstance if navigating to a different site.
auto src_url = current_instance->GetSiteURL(); return !IsSameWebSite(browser_context, current_instance, url);
return !IsSameWebSite(browser_context, src_url, url);
} }
bool AtomBrowserClient::NavigationWasRedirectedCrossSite( bool AtomBrowserClient::NavigationWasRedirectedCrossSite(
@ -236,13 +237,12 @@ bool AtomBrowserClient::NavigationWasRedirectedCrossSite(
bool has_response_started) const { bool has_response_started) const {
bool navigation_was_redirected = false; bool navigation_was_redirected = false;
if (has_response_started) { if (has_response_started) {
navigation_was_redirected = !IsSameWebSite( navigation_was_redirected =
browser_context, current_instance->GetSiteURL(), dest_url); !IsSameWebSite(browser_context, current_instance, dest_url);
} else { } else {
navigation_was_redirected = navigation_was_redirected =
speculative_instance && speculative_instance &&
!IsSameWebSite(browser_context, speculative_instance->GetSiteURL(), !IsSameWebSite(browser_context, speculative_instance, dest_url);
dest_url);
} }
return navigation_was_redirected; return navigation_was_redirected;
@ -306,7 +306,7 @@ content::SiteInstance* AtomBrowserClient::GetSiteInstanceFromAffinity(
auto iter = site_per_affinities_.find(affinity); auto iter = site_per_affinities_.find(affinity);
GURL dest_site = content::SiteInstance::GetSiteForURL(browser_context, url); GURL dest_site = content::SiteInstance::GetSiteForURL(browser_context, url);
if (iter != site_per_affinities_.end() && if (iter != site_per_affinities_.end() &&
IsSameWebSite(browser_context, iter->second->GetSiteURL(), dest_site)) { IsSameWebSite(browser_context, iter->second, dest_site)) {
return iter->second; return iter->second;
} }
} }
@ -478,7 +478,7 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
switches::kServiceWorkerSchemes}; switches::kServiceWorkerSchemes};
command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(), command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
kCommonSwitchNames, kCommonSwitchNames,
arraysize(kCommonSwitchNames)); base::size(kCommonSwitchNames));
#if defined(OS_WIN) #if defined(OS_WIN)
// Append --app-user-model-id. // Append --app-user-model-id.
@ -596,7 +596,7 @@ bool AtomBrowserClient::CanCreateWindow(
content::RenderFrameHost* opener, content::RenderFrameHost* opener,
const GURL& opener_url, const GURL& opener_url,
const GURL& opener_top_level_frame_url, const GURL& opener_top_level_frame_url,
const GURL& source_origin, const url::Origin& source_origin,
content::mojom::WindowContainerType container_type, content::mojom::WindowContainerType container_type,
const GURL& target_url, const GURL& target_url,
const content::Referrer& referrer, const content::Referrer& referrer,
@ -715,20 +715,17 @@ void AtomBrowserClient::RegisterOutOfProcessServices(
#endif #endif
} }
std::unique_ptr<base::Value> AtomBrowserClient::GetServiceManifestOverlay( base::Optional<service_manager::Manifest>
base::StringPiece name) { AtomBrowserClient::GetServiceManifestOverlay(base::StringPiece name) {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); if (name == content::mojom::kBrowserServiceName) {
int id = -1; return GetElectronContentBrowserOverlayManifest();
if (name == content::mojom::kBrowserServiceName) } else if (name == content::mojom::kPackagedServicesServiceName) {
id = IDR_ELECTRON_CONTENT_BROWSER_MANIFEST_OVERLAY; service_manager::Manifest overlay;
else if (name == content::mojom::kPackagedServicesServiceName) overlay.packaged_services = GetElectronPackagedServicesOverlayManifest();
id = IDR_ELECTRON_CONTENT_PACKAGED_SERVICES_MANIFEST_OVERLAY; return overlay;
}
if (id == -1) return base::nullopt;
return nullptr;
base::StringPiece manifest_contents = rb.GetRawDataResource(id);
return base::JSONReader::Read(manifest_contents);
} }
net::NetLog* AtomBrowserClient::GetNetLog() { net::NetLog* AtomBrowserClient::GetNetLog() {
@ -897,6 +894,14 @@ bool AtomBrowserClient::ShouldBypassCORB(int render_process_id) const {
return it != process_preferences_.end() && !it->second.web_security; return it != process_preferences_.end() && !it->second.web_security;
} }
std::string AtomBrowserClient::GetProduct() const {
return "Chrome/" CHROME_VERSION_STRING;
}
std::string AtomBrowserClient::GetUserAgent() const {
return GetApplicationUserAgent();
}
std::string AtomBrowserClient::GetApplicationLocale() { std::string AtomBrowserClient::GetApplicationLocale() {
if (BrowserThread::CurrentlyOn(BrowserThread::IO)) if (BrowserThread::CurrentlyOn(BrowserThread::IO))
return g_io_thread_application_locale.Get(); return g_io_thread_application_locale.Get();

View file

@ -112,7 +112,7 @@ class AtomBrowserClient : public content::ContentBrowserClient,
bool CanCreateWindow(content::RenderFrameHost* opener, bool CanCreateWindow(content::RenderFrameHost* opener,
const GURL& opener_url, const GURL& opener_url,
const GURL& opener_top_level_frame_url, const GURL& opener_top_level_frame_url,
const GURL& source_origin, const url::Origin& source_origin,
content::mojom::WindowContainerType container_type, content::mojom::WindowContainerType container_type,
const GURL& target_url, const GURL& target_url,
const content::Referrer& referrer, const content::Referrer& referrer,
@ -138,7 +138,7 @@ class AtomBrowserClient : public content::ContentBrowserClient,
bool in_memory, bool in_memory,
const base::FilePath& relative_partition_path) override; const base::FilePath& relative_partition_path) override;
void RegisterOutOfProcessServices(OutOfProcessServiceMap* services) override; void RegisterOutOfProcessServices(OutOfProcessServiceMap* services) override;
std::unique_ptr<base::Value> GetServiceManifestOverlay( base::Optional<service_manager::Manifest> GetServiceManifestOverlay(
base::StringPiece name) override; base::StringPiece name) override;
net::NetLog* GetNetLog() override; net::NetLog* GetNetLog() override;
content::MediaObserver* GetMediaObserver() override; content::MediaObserver* GetMediaObserver() override;
@ -153,6 +153,8 @@ class AtomBrowserClient : public content::ContentBrowserClient,
void OnNetworkServiceCreated( void OnNetworkServiceCreated(
network::mojom::NetworkService* network_service) override; network::mojom::NetworkService* network_service) override;
bool ShouldBypassCORB(int render_process_id) const override; bool ShouldBypassCORB(int render_process_id) const override;
std::string GetProduct() const override;
std::string GetUserAgent() const override;
// content::RenderProcessHostObserver: // content::RenderProcessHostObserver:
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override; void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;

View file

@ -11,7 +11,6 @@
#include "atom/browser/atom_download_manager_delegate.h" #include "atom/browser/atom_download_manager_delegate.h"
#include "atom/browser/atom_paths.h" #include "atom/browser/atom_paths.h"
#include "atom/browser/atom_permission_manager.h" #include "atom/browser/atom_permission_manager.h"
#include "atom/browser/browser.h"
#include "atom/browser/cookie_change_notifier.h" #include "atom/browser/cookie_change_notifier.h"
#include "atom/browser/net/resolve_proxy_helper.h" #include "atom/browser/net/resolve_proxy_helper.h"
#include "atom/browser/pref_store_delegate.h" #include "atom/browser/pref_store_delegate.h"
@ -20,17 +19,14 @@
#include "atom/browser/web_view_manager.h" #include "atom/browser/web_view_manager.h"
#include "atom/browser/zoom_level_delegate.h" #include "atom/browser/zoom_level_delegate.h"
#include "atom/common/application_info.h" #include "atom/common/application_info.h"
#include "atom/common/atom_version.h"
#include "atom/common/options_switches.h" #include "atom/common/options_switches.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/sequenced_task_runner_handle.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_version.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/prefs/json_pref_store.h" #include "components/prefs/json_pref_store.h"
@ -41,8 +37,8 @@
#include "components/proxy_config/pref_proxy_config_tracker_impl.h" #include "components/proxy_config/pref_proxy_config_tracker_impl.h"
#include "components/proxy_config/proxy_config_pref_names.h" #include "components/proxy_config/proxy_config_pref_names.h"
#include "content/browser/blob_storage/chrome_blob_storage_context.h" #include "content/browser/blob_storage/chrome_blob_storage_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "content/public/common/user_agent.h"
#include "net/base/escape.h" #include "net/base/escape.h"
using content::BrowserThread; using content::BrowserThread;
@ -51,14 +47,6 @@ namespace atom {
namespace { namespace {
std::string RemoveWhitespace(const std::string& str) {
std::string trimmed;
if (base::RemoveChars(str, " ", &trimmed))
return trimmed;
else
return str;
}
// Convert string to lower case and escape it. // Convert string to lower case and escape it.
std::string MakePartitionName(const std::string& input) { std::string MakePartitionName(const std::string& input) {
return net::EscapePath(base::ToLowerASCII(input)); return net::EscapePath(base::ToLowerASCII(input));
@ -78,19 +66,7 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition,
storage_policy_(new SpecialStoragePolicy), storage_policy_(new SpecialStoragePolicy),
in_memory_(in_memory), in_memory_(in_memory),
weak_factory_(this) { weak_factory_(this) {
// Construct user agent string. user_agent_ = GetApplicationUserAgent();
Browser* browser = Browser::Get();
std::string name = RemoveWhitespace(browser->GetName());
std::string user_agent;
if (name == ATOM_PRODUCT_NAME) {
user_agent = "Chrome/" CHROME_VERSION_STRING " " ATOM_PRODUCT_NAME
"/" ATOM_VERSION_STRING;
} else {
user_agent = base::StringPrintf(
"%s/%s Chrome/%s " ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING,
name.c_str(), browser->GetVersion().c_str(), CHROME_VERSION_STRING);
}
user_agent_ = content::BuildUserAgentFromProduct(user_agent);
// Read options. // Read options.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
@ -285,6 +261,11 @@ AtomBrowserContext::GetBrowsingDataRemoverDelegate() {
return nullptr; return nullptr;
} }
content::ClientHintsControllerDelegate*
AtomBrowserContext::GetClientHintsControllerDelegate() {
return nullptr;
}
net::URLRequestContextGetter* net::URLRequestContextGetter*
AtomBrowserContext::CreateRequestContextForStoragePartition( AtomBrowserContext::CreateRequestContextForStoragePartition(
const base::FilePath& partition_path, const base::FilePath& partition_path,

View file

@ -88,6 +88,8 @@ class AtomBrowserContext
content::ProtocolHandlerMap* protocol_handlers, content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) override; content::URLRequestInterceptorScopedVector request_interceptors) override;
net::URLRequestContextGetter* CreateMediaRequestContext() override; net::URLRequestContextGetter* CreateMediaRequestContext() override;
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
override;
CookieChangeNotifier* cookie_change_notifier() const { CookieChangeNotifier* cookie_change_notifier() const {
return cookie_change_notifier_.get(); return cookie_change_notifier_.get();

View file

@ -232,9 +232,10 @@ LSSharedFileListItemRef GetLoginItemForApp() {
for (NSUInteger i = 0; i < [login_items_array count]; ++i) { for (NSUInteger i = 0; i < [login_items_array count]; ++i) {
LSSharedFileListItemRef item = LSSharedFileListItemRef item =
reinterpret_cast<LSSharedFileListItemRef>(login_items_array[i]); reinterpret_cast<LSSharedFileListItemRef>(login_items_array[i]);
CFURLRef item_url_ref = NULL; base::ScopedCFTypeRef<CFErrorRef> error;
if (LSSharedFileListItemResolve(item, 0, &item_url_ref, NULL) == noErr && CFURLRef item_url_ref =
item_url_ref) { LSSharedFileListItemCopyResolvedURL(item, 0, error.InitializeInto());
if (!error && item_url_ref) {
base::ScopedCFTypeRef<CFURLRef> item_url(item_url_ref); base::ScopedCFTypeRef<CFURLRef> item_url(item_url_ref);
if (CFEqual(item_url, url)) { if (CFEqual(item_url, url)) {
CFRetain(item); CFRetain(item);
@ -265,9 +266,10 @@ void RemoveFromLoginItems() {
for (NSUInteger i = 0; i < [login_items_array count]; ++i) { for (NSUInteger i = 0; i < [login_items_array count]; ++i) {
LSSharedFileListItemRef item = LSSharedFileListItemRef item =
reinterpret_cast<LSSharedFileListItemRef>(login_items_array[i]); reinterpret_cast<LSSharedFileListItemRef>(login_items_array[i]);
CFURLRef url_ref = NULL; base::ScopedCFTypeRef<CFErrorRef> error;
if (LSSharedFileListItemResolve(item, 0, &url_ref, NULL) == noErr && CFURLRef url_ref =
item) { LSSharedFileListItemCopyResolvedURL(item, 0, error.InitializeInto());
if (!error && url_ref) {
base::ScopedCFTypeRef<CFURLRef> url(url_ref); base::ScopedCFTypeRef<CFURLRef> url(url_ref);
if ([[base::mac::CFToNSCast(url.get()) path] if ([[base::mac::CFToNSCast(url.get()) path]
hasPrefix:[[NSBundle mainBundle] bundlePath]]) hasPrefix:[[NSBundle mainBundle] bundlePath]])

View file

@ -0,0 +1,14 @@
// Copyright (c) 2019 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/child_web_contents_tracker.h"
namespace atom {
ChildWebContentsTracker::ChildWebContentsTracker(
content::WebContents* web_contents) {}
WEB_CONTENTS_USER_DATA_KEY_IMPL(ChildWebContentsTracker)
} // namespace atom

View file

@ -18,11 +18,12 @@ struct ChildWebContentsTracker
GURL url; GURL url;
std::string frame_name; std::string frame_name;
explicit ChildWebContentsTracker(content::WebContents* web_contents) {}
private: private:
explicit ChildWebContentsTracker(content::WebContents* web_contents);
friend class content::WebContentsUserData<ChildWebContentsTracker>; friend class content::WebContentsUserData<ChildWebContentsTracker>;
WEB_CONTENTS_USER_DATA_KEY_DECL();
DISALLOW_COPY_AND_ASSIGN(ChildWebContentsTracker); DISALLOW_COPY_AND_ASSIGN(ChildWebContentsTracker);
}; };

View file

@ -10,6 +10,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "atom/browser/atom_browser_client.h"
#include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_browser_context.h"
#include "atom/browser/native_window.h" #include "atom/browser/native_window.h"
#include "atom/browser/ui/file_dialog.h" #include "atom/browser/ui/file_dialog.h"
@ -23,7 +24,7 @@
#include "base/threading/scoped_blocking_call.h" #include "base/threading/scoped_blocking_call.h"
#include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/sequenced_task_runner_handle.h"
#include "chrome/browser/ssl/security_state_tab_helper.h" #include "chrome/browser/ssl/security_state_tab_helper.h"
#include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/color_chooser.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h" #include "components/prefs/scoped_user_pref_update.h"
@ -183,7 +184,8 @@ void CommonWebContentsDelegate::InitWithWebContents(
#if BUILDFLAG(ENABLE_PRINTING) #if BUILDFLAG(ENABLE_PRINTING)
PrintPreviewMessageHandler::CreateForWebContents(web_contents); PrintPreviewMessageHandler::CreateForWebContents(web_contents);
printing::PrintViewManagerBasic::CreateForWebContents(web_contents); printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
printing::CreateCompositeClientIfNeeded(web_contents); printing::CreateCompositeClientIfNeeded(web_contents,
browser_context->GetUserAgent());
#endif #endif
// Determien whether the WebContents is offscreen. // Determien whether the WebContents is offscreen.
@ -213,8 +215,7 @@ void CommonWebContentsDelegate::SetOwnerWindow(
owner_window->GetWeakPtr()); owner_window->GetWeakPtr());
} else { } else {
owner_window_ = nullptr; owner_window_ = nullptr;
web_contents->RemoveUserData( web_contents->RemoveUserData(NativeWindowRelay::UserDataKey());
NativeWindowRelay::kNativeWindowRelayUserDataKey);
} }
#if BUILDFLAG(ENABLE_OSR) #if BUILDFLAG(ENABLE_OSR)
auto* osr_wcv = GetOffScreenWebContentsView(); auto* osr_wcv = GetOffScreenWebContentsView();
@ -274,6 +275,7 @@ content::WebContents* CommonWebContentsDelegate::OpenURLFromTab(
load_url_params.should_replace_current_entry = load_url_params.should_replace_current_entry =
params.should_replace_current_entry; params.should_replace_current_entry;
load_url_params.is_renderer_initiated = params.is_renderer_initiated; load_url_params.is_renderer_initiated = params.is_renderer_initiated;
load_url_params.initiator_origin = params.initiator_origin;
load_url_params.should_clear_history_list = true; load_url_params.should_clear_history_list = true;
source->GetController().LoadURLWithParams(load_url_params); source->GetController().LoadURLWithParams(load_url_params);

View file

@ -7,6 +7,7 @@
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include "base/stl_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
@ -103,7 +104,7 @@ const FontDefault kFontDefaults[] = {
IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN}, IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN},
#endif #endif
}; };
const size_t kFontDefaultsLength = arraysize(kFontDefaults); const size_t kFontDefaultsLength = base::size(kFontDefaults);
// ^^^^^ DO NOT EDIT ^^^^^ // ^^^^^ DO NOT EDIT ^^^^^

View file

@ -54,10 +54,10 @@ v8::Isolate* JavascriptEnvironment::Initialize(uv_loop_t* event_loop) {
tracing_controller); tracing_controller);
v8::V8::InitializePlatform(platform_); v8::V8::InitializePlatform(platform_);
gin::IsolateHolder::Initialize( gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
gin::IsolateHolder::kNonStrictMode, gin::IsolateHolder::kStableV8Extras,
gin::ArrayBufferAllocator::SharedInstance(), gin::ArrayBufferAllocator::SharedInstance(),
nullptr /* external_reference_table */, false /* create_v8_platform */); nullptr /* external_reference_table */,
false /* create_v8_platform */);
v8::Isolate* isolate = v8::Isolate::Allocate(); v8::Isolate* isolate = v8::Isolate::Allocate();
platform_->RegisterIsolate(isolate, event_loop); platform_->RegisterIsolate(isolate, event_loop);

View file

@ -7,18 +7,16 @@
#include "base/logging.h" #include "base/logging.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/media_capture_devices.h" #include "content/public/browser/media_capture_devices.h"
#include "content/public/common/media_stream_request.h"
namespace atom {
using content::BrowserThread; using content::BrowserThread;
using content::MediaStreamDevices;
namespace atom {
namespace { namespace {
// Finds a device in |devices| that has |device_id|, or NULL if not found. // Finds a device in |devices| that has |device_id|, or NULL if not found.
const content::MediaStreamDevice* FindDeviceWithId( const blink::MediaStreamDevice* FindDeviceWithId(
const content::MediaStreamDevices& devices, const blink::MediaStreamDevices& devices,
const std::string& device_id) { const std::string& device_id) {
auto iter = devices.begin(); auto iter = devices.begin();
for (; iter != devices.end(); ++iter) { for (; iter != devices.end(); ++iter) {
@ -29,11 +27,6 @@ const content::MediaStreamDevice* FindDeviceWithId(
return nullptr; return nullptr;
} }
const MediaStreamDevices& EmptyDevices() {
static MediaStreamDevices* devices = new MediaStreamDevices;
return *devices;
}
} // namespace } // namespace
MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() { MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() {
@ -49,75 +42,75 @@ MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher()
MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {} MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {}
const MediaStreamDevices& const blink::MediaStreamDevices&
MediaCaptureDevicesDispatcher::GetAudioCaptureDevices() { MediaCaptureDevicesDispatcher::GetAudioCaptureDevices() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (is_device_enumeration_disabled_) if (is_device_enumeration_disabled_)
return EmptyDevices(); return test_audio_devices_;
return content::MediaCaptureDevices::GetInstance()->GetAudioCaptureDevices(); return content::MediaCaptureDevices::GetInstance()->GetAudioCaptureDevices();
} }
const MediaStreamDevices& const blink::MediaStreamDevices&
MediaCaptureDevicesDispatcher::GetVideoCaptureDevices() { MediaCaptureDevicesDispatcher::GetVideoCaptureDevices() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (is_device_enumeration_disabled_) if (is_device_enumeration_disabled_)
return EmptyDevices(); return test_video_devices_;
return content::MediaCaptureDevices::GetInstance()->GetVideoCaptureDevices(); return content::MediaCaptureDevices::GetInstance()->GetVideoCaptureDevices();
} }
void MediaCaptureDevicesDispatcher::GetDefaultDevices( void MediaCaptureDevicesDispatcher::GetDefaultDevices(
bool audio, bool audio,
bool video, bool video,
content::MediaStreamDevices* devices) { blink::MediaStreamDevices* devices) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(audio || video); DCHECK(audio || video);
if (audio) { if (audio) {
const content::MediaStreamDevice* device = GetFirstAvailableAudioDevice(); const blink::MediaStreamDevice* device = GetFirstAvailableAudioDevice();
if (device) if (device)
devices->push_back(*device); devices->push_back(*device);
} }
if (video) { if (video) {
const content::MediaStreamDevice* device = GetFirstAvailableVideoDevice(); const blink::MediaStreamDevice* device = GetFirstAvailableVideoDevice();
if (device) if (device)
devices->push_back(*device); devices->push_back(*device);
} }
} }
const content::MediaStreamDevice* const blink::MediaStreamDevice*
MediaCaptureDevicesDispatcher::GetRequestedAudioDevice( MediaCaptureDevicesDispatcher::GetRequestedAudioDevice(
const std::string& requested_audio_device_id) { const std::string& requested_audio_device_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
const content::MediaStreamDevices& audio_devices = GetAudioCaptureDevices(); const blink::MediaStreamDevices& audio_devices = GetAudioCaptureDevices();
const content::MediaStreamDevice* const device = const blink::MediaStreamDevice* const device =
FindDeviceWithId(audio_devices, requested_audio_device_id); FindDeviceWithId(audio_devices, requested_audio_device_id);
return device; return device;
} }
const content::MediaStreamDevice* const blink::MediaStreamDevice*
MediaCaptureDevicesDispatcher::GetFirstAvailableAudioDevice() { MediaCaptureDevicesDispatcher::GetFirstAvailableAudioDevice() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
const content::MediaStreamDevices& audio_devices = GetAudioCaptureDevices(); const blink::MediaStreamDevices& audio_devices = GetAudioCaptureDevices();
if (audio_devices.empty()) if (audio_devices.empty())
return nullptr; return nullptr;
return &(*audio_devices.begin()); return &(*audio_devices.begin());
} }
const content::MediaStreamDevice* const blink::MediaStreamDevice*
MediaCaptureDevicesDispatcher::GetRequestedVideoDevice( MediaCaptureDevicesDispatcher::GetRequestedVideoDevice(
const std::string& requested_video_device_id) { const std::string& requested_video_device_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
const content::MediaStreamDevices& video_devices = GetVideoCaptureDevices(); const blink::MediaStreamDevices& video_devices = GetVideoCaptureDevices();
const content::MediaStreamDevice* const device = const blink::MediaStreamDevice* const device =
FindDeviceWithId(video_devices, requested_video_device_id); FindDeviceWithId(video_devices, requested_video_device_id);
return device; return device;
} }
const content::MediaStreamDevice* const blink::MediaStreamDevice*
MediaCaptureDevicesDispatcher::GetFirstAvailableVideoDevice() { MediaCaptureDevicesDispatcher::GetFirstAvailableVideoDevice() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
const content::MediaStreamDevices& video_devices = GetVideoCaptureDevices(); const blink::MediaStreamDevices& video_devices = GetVideoCaptureDevices();
if (video_devices.empty()) if (video_devices.empty())
return nullptr; return nullptr;
return &(*video_devices.begin()); return &(*video_devices.begin());
@ -136,7 +129,7 @@ void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(
int render_view_id, int render_view_id,
int page_request_id, int page_request_id,
const GURL& security_origin, const GURL& security_origin,
content::MediaStreamType stream_type, blink::MediaStreamType stream_type,
content::MediaRequestState state) {} content::MediaRequestState state) {}
void MediaCaptureDevicesDispatcher::OnCreatingAudioStream(int render_process_id, void MediaCaptureDevicesDispatcher::OnCreatingAudioStream(int render_process_id,
@ -146,7 +139,7 @@ void MediaCaptureDevicesDispatcher::OnSetCapturingLinkSecured(
int render_process_id, int render_process_id,
int render_frame_id, int render_frame_id,
int page_request_id, int page_request_id,
content::MediaStreamType stream_type, blink::MediaStreamType stream_type,
bool is_secure) {} bool is_secure) {}
} // namespace atom } // namespace atom

View file

@ -9,7 +9,8 @@
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "content/public/browser/media_observer.h" #include "content/public/browser/media_observer.h"
#include "content/public/common/media_stream_request.h" #include "content/public/browser/media_stream_request.h"
#include "third_party/blink/public/common/mediastream/media_stream_request.h"
namespace atom { namespace atom {
@ -20,8 +21,8 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
static MediaCaptureDevicesDispatcher* GetInstance(); static MediaCaptureDevicesDispatcher* GetInstance();
// Methods for observers. Called on UI thread. // Methods for observers. Called on UI thread.
const content::MediaStreamDevices& GetAudioCaptureDevices(); const blink::MediaStreamDevices& GetAudioCaptureDevices();
const content::MediaStreamDevices& GetVideoCaptureDevices(); const blink::MediaStreamDevices& GetVideoCaptureDevices();
// Helper to get the default devices which can be used by the media request. // Helper to get the default devices which can be used by the media request.
// Uses the first available devices if the default devices are not available. // Uses the first available devices if the default devices are not available.
@ -30,19 +31,19 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
// Called on the UI thread. // Called on the UI thread.
void GetDefaultDevices(bool audio, void GetDefaultDevices(bool audio,
bool video, bool video,
content::MediaStreamDevices* devices); blink::MediaStreamDevices* devices);
// Helpers for picking particular requested devices, identified by raw id. // Helpers for picking particular requested devices, identified by raw id.
// If the device requested is not available it will return NULL. // If the device requested is not available it will return NULL.
const content::MediaStreamDevice* GetRequestedAudioDevice( const blink::MediaStreamDevice* GetRequestedAudioDevice(
const std::string& requested_audio_device_id); const std::string& requested_audio_device_id);
const content::MediaStreamDevice* GetRequestedVideoDevice( const blink::MediaStreamDevice* GetRequestedVideoDevice(
const std::string& requested_video_device_id); const std::string& requested_video_device_id);
// Returns the first available audio or video device, or NULL if no devices // Returns the first available audio or video device, or NULL if no devices
// are available. // are available.
const content::MediaStreamDevice* GetFirstAvailableAudioDevice(); const blink::MediaStreamDevice* GetFirstAvailableAudioDevice();
const content::MediaStreamDevice* GetFirstAvailableVideoDevice(); const blink::MediaStreamDevice* GetFirstAvailableVideoDevice();
// Unittests that do not require actual device enumeration should call this // Unittests that do not require actual device enumeration should call this
// API on the singleton. It is safe to call this multiple times on the // API on the singleton. It is safe to call this multiple times on the
@ -56,14 +57,14 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
int render_view_id, int render_view_id,
int page_request_id, int page_request_id,
const GURL& security_origin, const GURL& security_origin,
content::MediaStreamType stream_type, blink::MediaStreamType stream_type,
content::MediaRequestState state) override; content::MediaRequestState state) override;
void OnCreatingAudioStream(int render_process_id, void OnCreatingAudioStream(int render_process_id,
int render_view_id) override; int render_view_id) override;
void OnSetCapturingLinkSecured(int render_process_id, void OnSetCapturingLinkSecured(int render_process_id,
int render_frame_id, int render_frame_id,
int page_request_id, int page_request_id,
content::MediaStreamType stream_type, blink::MediaStreamType stream_type,
bool is_secure) override; bool is_secure) override;
private: private:
@ -72,6 +73,12 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
MediaCaptureDevicesDispatcher(); MediaCaptureDevicesDispatcher();
~MediaCaptureDevicesDispatcher() override; ~MediaCaptureDevicesDispatcher() override;
// Only for testing, a list of cached audio capture devices.
blink::MediaStreamDevices test_audio_devices_;
// Only for testing, a list of cached video capture devices.
blink::MediaStreamDevices test_video_devices_;
// Flag used by unittests to disable device enumeration. // Flag used by unittests to disable device enumeration.
bool is_device_enumeration_disabled_; bool is_device_enumeration_disabled_;

View file

@ -9,16 +9,16 @@
#include "atom/browser/media/media_capture_devices_dispatcher.h" #include "atom/browser/media/media_capture_devices_dispatcher.h"
#include "content/public/browser/desktop_media_id.h" #include "content/public/browser/desktop_media_id.h"
#include "content/public/common/media_stream_request.h" #include "content/public/browser/media_stream_request.h"
namespace atom { namespace atom {
namespace { namespace {
bool HasAnyAvailableDevice() { bool HasAnyAvailableDevice() {
const content::MediaStreamDevices& audio_devices = const blink::MediaStreamDevices& audio_devices =
MediaCaptureDevicesDispatcher::GetInstance()->GetAudioCaptureDevices(); MediaCaptureDevicesDispatcher::GetInstance()->GetAudioCaptureDevices();
const content::MediaStreamDevices& video_devices = const blink::MediaStreamDevices& video_devices =
MediaCaptureDevicesDispatcher::GetInstance()->GetVideoCaptureDevices(); MediaCaptureDevicesDispatcher::GetInstance()->GetVideoCaptureDevices();
return !audio_devices.empty() || !video_devices.empty(); return !audio_devices.empty() || !video_devices.empty();
@ -34,33 +34,33 @@ MediaStreamDevicesController::MediaStreamDevicesController(
// For MEDIA_OPEN_DEVICE requests (Pepper) we always request both webcam // For MEDIA_OPEN_DEVICE requests (Pepper) we always request both webcam
// and microphone to avoid popping two infobars. // and microphone to avoid popping two infobars.
microphone_requested_( microphone_requested_(
request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE || request.audio_type == blink::MEDIA_DEVICE_AUDIO_CAPTURE ||
request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY), request.request_type == blink::MEDIA_OPEN_DEVICE_PEPPER_ONLY),
webcam_requested_( webcam_requested_(
request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE || request.video_type == blink::MEDIA_DEVICE_VIDEO_CAPTURE ||
request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY) {} request.request_type == blink::MEDIA_OPEN_DEVICE_PEPPER_ONLY) {}
MediaStreamDevicesController::~MediaStreamDevicesController() { MediaStreamDevicesController::~MediaStreamDevicesController() {
if (!callback_.is_null()) { if (!callback_.is_null()) {
std::move(callback_).Run(content::MediaStreamDevices(), std::move(callback_).Run(blink::MediaStreamDevices(),
content::MEDIA_DEVICE_INVALID_STATE, blink::MEDIA_DEVICE_FAILED_DUE_TO_SHUTDOWN,
std::unique_ptr<content::MediaStreamUI>()); std::unique_ptr<content::MediaStreamUI>());
} }
} }
bool MediaStreamDevicesController::TakeAction() { bool MediaStreamDevicesController::TakeAction() {
// Do special handling of desktop screen cast. // Do special handling of desktop screen cast.
if (request_.audio_type == content::MEDIA_GUM_TAB_AUDIO_CAPTURE || if (request_.audio_type == blink::MEDIA_GUM_TAB_AUDIO_CAPTURE ||
request_.video_type == content::MEDIA_GUM_TAB_VIDEO_CAPTURE || request_.video_type == blink::MEDIA_GUM_TAB_VIDEO_CAPTURE ||
request_.audio_type == content::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE || request_.audio_type == blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE ||
request_.video_type == content::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE) { request_.video_type == blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE) {
HandleUserMediaRequest(); HandleUserMediaRequest();
return true; return true;
} }
// Deny the request if there is no device attached to the OS. // Deny the request if there is no device attached to the OS.
if (!HasAnyAvailableDevice()) { if (!HasAnyAvailableDevice()) {
Deny(content::MEDIA_DEVICE_NO_HARDWARE); Deny(blink::MEDIA_DEVICE_NO_HARDWARE);
return true; return true;
} }
@ -70,14 +70,14 @@ bool MediaStreamDevicesController::TakeAction() {
void MediaStreamDevicesController::Accept() { void MediaStreamDevicesController::Accept() {
// Get the default devices for the request. // Get the default devices for the request.
content::MediaStreamDevices devices; blink::MediaStreamDevices devices;
if (microphone_requested_ || webcam_requested_) { if (microphone_requested_ || webcam_requested_) {
switch (request_.request_type) { switch (request_.request_type) {
case content::MEDIA_OPEN_DEVICE_PEPPER_ONLY: { case blink::MEDIA_OPEN_DEVICE_PEPPER_ONLY: {
const content::MediaStreamDevice* device = nullptr; const blink::MediaStreamDevice* device = nullptr;
// For open device request pick the desired device or fall back to the // For open device request pick the desired device or fall back to the
// first available of the given type. // first available of the given type.
if (request_.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE) { if (request_.audio_type == blink::MEDIA_DEVICE_AUDIO_CAPTURE) {
device = device =
MediaCaptureDevicesDispatcher::GetInstance() MediaCaptureDevicesDispatcher::GetInstance()
->GetRequestedAudioDevice(request_.requested_audio_device_id); ->GetRequestedAudioDevice(request_.requested_audio_device_id);
@ -86,7 +86,7 @@ void MediaStreamDevicesController::Accept() {
device = MediaCaptureDevicesDispatcher::GetInstance() device = MediaCaptureDevicesDispatcher::GetInstance()
->GetFirstAvailableAudioDevice(); ->GetFirstAvailableAudioDevice();
} }
} else if (request_.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE) { } else if (request_.video_type == blink::MEDIA_DEVICE_VIDEO_CAPTURE) {
// Pepper API opens only one device at a time. // Pepper API opens only one device at a time.
device = device =
MediaCaptureDevicesDispatcher::GetInstance() MediaCaptureDevicesDispatcher::GetInstance()
@ -101,13 +101,13 @@ void MediaStreamDevicesController::Accept() {
devices.push_back(*device); devices.push_back(*device);
break; break;
} }
case content::MEDIA_GENERATE_STREAM: { case blink::MEDIA_GENERATE_STREAM: {
bool needs_audio_device = microphone_requested_; bool needs_audio_device = microphone_requested_;
bool needs_video_device = webcam_requested_; bool needs_video_device = webcam_requested_;
// Get the exact audio or video device if an id is specified. // Get the exact audio or video device if an id is specified.
if (!request_.requested_audio_device_id.empty()) { if (!request_.requested_audio_device_id.empty()) {
const content::MediaStreamDevice* audio_device = const blink::MediaStreamDevice* audio_device =
MediaCaptureDevicesDispatcher::GetInstance() MediaCaptureDevicesDispatcher::GetInstance()
->GetRequestedAudioDevice(request_.requested_audio_device_id); ->GetRequestedAudioDevice(request_.requested_audio_device_id);
if (audio_device) { if (audio_device) {
@ -116,7 +116,7 @@ void MediaStreamDevicesController::Accept() {
} }
} }
if (!request_.requested_video_device_id.empty()) { if (!request_.requested_video_device_id.empty()) {
const content::MediaStreamDevice* video_device = const blink::MediaStreamDevice* video_device =
MediaCaptureDevicesDispatcher::GetInstance() MediaCaptureDevicesDispatcher::GetInstance()
->GetRequestedVideoDevice(request_.requested_video_device_id); ->GetRequestedVideoDevice(request_.requested_video_device_id);
if (video_device) { if (video_device) {
@ -133,40 +133,45 @@ void MediaStreamDevicesController::Accept() {
} }
break; break;
} }
case content::MEDIA_DEVICE_ACCESS: case blink::MEDIA_DEVICE_ACCESS: {
// Get the default devices for the request. // Get the default devices for the request.
MediaCaptureDevicesDispatcher::GetInstance()->GetDefaultDevices( MediaCaptureDevicesDispatcher::GetInstance()->GetDefaultDevices(
microphone_requested_, webcam_requested_, &devices); microphone_requested_, webcam_requested_, &devices);
break; break;
} }
case blink::MEDIA_DEVICE_UPDATE: {
NOTREACHED();
break;
}
}
} }
std::move(callback_).Run(devices, content::MEDIA_DEVICE_OK, std::move(callback_).Run(devices, blink::MEDIA_DEVICE_OK,
std::unique_ptr<content::MediaStreamUI>()); std::unique_ptr<content::MediaStreamUI>());
} }
void MediaStreamDevicesController::Deny( void MediaStreamDevicesController::Deny(
content::MediaStreamRequestResult result) { blink::MediaStreamRequestResult result) {
std::move(callback_).Run(content::MediaStreamDevices(), result, std::move(callback_).Run(blink::MediaStreamDevices(), result,
std::unique_ptr<content::MediaStreamUI>()); std::unique_ptr<content::MediaStreamUI>());
} }
void MediaStreamDevicesController::HandleUserMediaRequest() { void MediaStreamDevicesController::HandleUserMediaRequest() {
content::MediaStreamDevices devices; blink::MediaStreamDevices devices;
if (request_.audio_type == content::MEDIA_GUM_TAB_AUDIO_CAPTURE) { if (request_.audio_type == blink::MEDIA_GUM_TAB_AUDIO_CAPTURE) {
devices.push_back(content::MediaStreamDevice( devices.push_back(
content::MEDIA_GUM_TAB_AUDIO_CAPTURE, "", "")); blink::MediaStreamDevice(blink::MEDIA_GUM_TAB_AUDIO_CAPTURE, "", ""));
} }
if (request_.video_type == content::MEDIA_GUM_TAB_VIDEO_CAPTURE) { if (request_.video_type == blink::MEDIA_GUM_TAB_VIDEO_CAPTURE) {
devices.push_back(content::MediaStreamDevice( devices.push_back(
content::MEDIA_GUM_TAB_VIDEO_CAPTURE, "", "")); blink::MediaStreamDevice(blink::MEDIA_GUM_TAB_VIDEO_CAPTURE, "", ""));
} }
if (request_.audio_type == content::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE) { if (request_.audio_type == blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE) {
devices.push_back(content::MediaStreamDevice( devices.push_back(blink::MediaStreamDevice(
content::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE, "loopback", "System Audio")); blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE, "loopback", "System Audio"));
} }
if (request_.video_type == content::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE) { if (request_.video_type == blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE) {
content::DesktopMediaID screen_id; content::DesktopMediaID screen_id;
// If the device id wasn't specified then this is a screen capture request // If the device id wasn't specified then this is a screen capture request
// (i.e. chooseDesktopMedia() API wasn't used to generate device id). // (i.e. chooseDesktopMedia() API wasn't used to generate device id).
@ -179,13 +184,13 @@ void MediaStreamDevicesController::HandleUserMediaRequest() {
} }
devices.push_back( devices.push_back(
content::MediaStreamDevice(content::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE, blink::MediaStreamDevice(blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE,
screen_id.ToString(), "Screen")); screen_id.ToString(), "Screen"));
} }
std::move(callback_).Run(devices, std::move(callback_).Run(devices,
devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE devices.empty() ? blink::MEDIA_DEVICE_NO_HARDWARE
: content::MEDIA_DEVICE_OK, : blink::MEDIA_DEVICE_OK,
std::unique_ptr<content::MediaStreamUI>()); std::unique_ptr<content::MediaStreamUI>());
} }

View file

@ -6,6 +6,7 @@
#define ATOM_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ #define ATOM_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
#include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/web_contents_delegate.h"
#include "third_party/blink/public/common/mediastream/media_stream_request.h"
namespace atom { namespace atom {
@ -21,7 +22,7 @@ class MediaStreamDevicesController {
// Explicitly accept or deny the request. // Explicitly accept or deny the request.
void Accept(); void Accept();
void Deny(content::MediaStreamRequestResult result); void Deny(blink::MediaStreamRequestResult result);
private: private:
// Handle the request of desktop or tab screen cast. // Handle the request of desktop or tab screen cast.

View file

@ -577,23 +577,22 @@ const views::Widget* NativeWindow::GetWidget() const {
return widget(); return widget();
} }
// static
const void* const NativeWindowRelay::kNativeWindowRelayUserDataKey =
&NativeWindowRelay::kNativeWindowRelayUserDataKey;
// static // static
void NativeWindowRelay::CreateForWebContents( void NativeWindowRelay::CreateForWebContents(
content::WebContents* web_contents, content::WebContents* web_contents,
base::WeakPtr<NativeWindow> window) { base::WeakPtr<NativeWindow> window) {
DCHECK(web_contents); DCHECK(web_contents);
DCHECK(!web_contents->GetUserData(kNativeWindowRelayUserDataKey)); if (!web_contents->GetUserData(UserDataKey())) {
web_contents->SetUserData(kNativeWindowRelayUserDataKey, web_contents->SetUserData(UserDataKey(),
base::WrapUnique(new NativeWindowRelay(window))); base::WrapUnique(new NativeWindowRelay(window)));
} }
}
NativeWindowRelay::NativeWindowRelay(base::WeakPtr<NativeWindow> window) NativeWindowRelay::NativeWindowRelay(base::WeakPtr<NativeWindow> window)
: native_window_(window) {} : native_window_(window) {}
NativeWindowRelay::~NativeWindowRelay() = default; NativeWindowRelay::~NativeWindowRelay() = default;
WEB_CONTENTS_USER_DATA_KEY_IMPL(NativeWindowRelay)
} // namespace atom } // namespace atom

View file

@ -360,8 +360,6 @@ class NativeWindow : public base::SupportsUserData,
class NativeWindowRelay class NativeWindowRelay
: public content::WebContentsUserData<NativeWindowRelay> { : public content::WebContentsUserData<NativeWindowRelay> {
public: public:
static const void* const kNativeWindowRelayUserDataKey;
static void CreateForWebContents(content::WebContents*, static void CreateForWebContents(content::WebContents*,
base::WeakPtr<NativeWindow>); base::WeakPtr<NativeWindow>);
@ -369,6 +367,8 @@ class NativeWindowRelay
NativeWindow* GetNativeWindow() const { return native_window_.get(); } NativeWindow* GetNativeWindow() const { return native_window_.get(); }
WEB_CONTENTS_USER_DATA_KEY_DECL();
private: private:
friend class content::WebContentsUserData<NativeWindow>; friend class content::WebContentsUserData<NativeWindow>;
explicit NativeWindowRelay(base::WeakPtr<NativeWindow> window); explicit NativeWindowRelay(base::WeakPtr<NativeWindow> window);

View file

@ -267,8 +267,8 @@ void AtomURLRequest::DoCancel() {
void AtomURLRequest::DoFollowRedirect() { void AtomURLRequest::DoFollowRedirect() {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO); DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
if (request_ && request_->is_redirecting() && redirect_policy_ == "manual") { if (request_ && request_->is_redirecting() && redirect_policy_ == "manual") {
request_->FollowDeferredRedirect( request_->FollowDeferredRedirect(base::nullopt /* removed_headers */,
base::nullopt /* modified_request_headers */); base::nullopt /* modified_headers */);
} }
} }

View file

@ -52,7 +52,7 @@ void ResolveProxyHelper::StartPendingRequest() {
binding_.Bind(mojo::MakeRequest(&proxy_lookup_client)); binding_.Bind(mojo::MakeRequest(&proxy_lookup_client));
binding_.set_connection_error_handler( binding_.set_connection_error_handler(
base::BindOnce(&ResolveProxyHelper::OnProxyLookupComplete, base::BindOnce(&ResolveProxyHelper::OnProxyLookupComplete,
base::Unretained(this), base::nullopt)); base::Unretained(this), net::ERR_ABORTED, base::nullopt));
content::BrowserContext::GetDefaultStoragePartition(browser_context_) content::BrowserContext::GetDefaultStoragePartition(browser_context_)
->GetNetworkContext() ->GetNetworkContext()
->LookUpProxyForURL(pending_requests_.front().url, ->LookUpProxyForURL(pending_requests_.front().url,
@ -60,6 +60,7 @@ void ResolveProxyHelper::StartPendingRequest() {
} }
void ResolveProxyHelper::OnProxyLookupComplete( void ResolveProxyHelper::OnProxyLookupComplete(
int32_t net_error,
const base::Optional<net::ProxyInfo>& proxy_info) { const base::Optional<net::ProxyInfo>& proxy_info) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(!pending_requests_.empty()); DCHECK(!pending_requests_.empty());

View file

@ -54,6 +54,7 @@ class ResolveProxyHelper
// network::mojom::ProxyLookupClient implementation. // network::mojom::ProxyLookupClient implementation.
void OnProxyLookupComplete( void OnProxyLookupComplete(
int32_t net_error,
const base::Optional<net::ProxyInfo>& proxy_info) override; const base::Optional<net::ProxyInfo>& proxy_info) override;
// Self-reference. Owned as long as there's an outstanding proxy lookup. // Self-reference. Owned as long as there's an outstanding proxy lookup.

View file

@ -8,6 +8,7 @@
#include <utility> #include <utility>
#include "atom/browser/io_thread.h" #include "atom/browser/io_thread.h"
#include "atom/common/application_info.h"
#include "atom/common/options_switches.h" #include "atom/common/options_switches.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
@ -222,6 +223,8 @@ SystemNetworkContextManager::CreateNetworkContextParams() {
network_context_params->context_name = std::string("system"); network_context_params->context_name = std::string("system");
network_context_params->user_agent = atom::GetApplicationUserAgent();
network_context_params->http_cache_enabled = false; network_context_params->http_cache_enabled = false;
// These are needed for PAC scripts that use file or data URLs (Or FTP URLs?). // These are needed for PAC scripts that use file or data URLs (Or FTP URLs?).

View file

@ -29,7 +29,7 @@ void BeforeStartInUI(base::WeakPtr<URLRequestAsyncAsarJob> job,
if (args->GetNext(&value)) { if (args->GetNext(&value)) {
V8ValueConverter converter; V8ValueConverter converter;
v8::Local<v8::Context> context = args->isolate()->GetCurrentContext(); v8::Local<v8::Context> context = args->isolate()->GetCurrentContext();
request_options.reset(converter.FromV8Value(value, context)); request_options = converter.FromV8Value(value, context);
} }
if (request_options) { if (request_options) {

View file

@ -40,7 +40,7 @@ void BeforeStartInUI(base::WeakPtr<URLRequestBufferJob> job,
if (args->GetNext(&value)) { if (args->GetNext(&value)) {
V8ValueConverter converter; V8ValueConverter converter;
v8::Local<v8::Context> context = args->isolate()->GetCurrentContext(); v8::Local<v8::Context> context = args->isolate()->GetCurrentContext();
request_options.reset(converter.FromV8Value(value, context)); request_options = converter.FromV8Value(value, context);
} }
if (request_options) { if (request_options) {

View file

@ -29,7 +29,7 @@ void BeforeStartInUI(base::WeakPtr<URLRequestStringJob> job,
if (args->GetNext(&value)) { if (args->GetNext(&value)) {
V8ValueConverter converter; V8ValueConverter converter;
v8::Local<v8::Context> context = args->isolate()->GetCurrentContext(); v8::Local<v8::Context> context = args->isolate()->GetCurrentContext();
request_options.reset(converter.FromV8Value(value, context)); request_options = converter.FromV8Value(value, context);
} }
if (request_options) { if (request_options) {

View file

@ -23,6 +23,7 @@
#include "content/browser/renderer_host/cursor_manager.h" #include "content/browser/renderer_host/cursor_manager.h"
#include "content/browser/renderer_host/render_widget_host_delegate.h" #include "content/browser/renderer_host/render_widget_host_delegate.h"
#include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_owner_delegate.h"
#include "content/common/view_messages.h" #include "content/common/view_messages.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
@ -286,6 +287,8 @@ class AtomDelegatedFrameHostClient : public content::DelegatedFrameHostClient {
return view_->render_widget_host()->CollectSurfaceIdsForEviction(); return view_->render_widget_host()->CollectSurfaceIdsForEviction();
} }
bool ShouldShowStaleContentOnEviction() override { return false; }
void OnBeginFrame(base::TimeTicks frame_time) override {} void OnBeginFrame(base::TimeTicks frame_time) override {}
void InvalidateLocalSurfaceIdOnEviction() override {} void InvalidateLocalSurfaceIdOnEviction() override {}
@ -349,12 +352,10 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
content::ImageTransportFactory::GetInstance(); content::ImageTransportFactory::GetInstance();
ui::ContextFactoryPrivate* context_factory_private = ui::ContextFactoryPrivate* context_factory_private =
factory->GetContextFactoryPrivate(); factory->GetContextFactoryPrivate();
compositor_.reset( compositor_.reset(new ui::Compositor(
new ui::Compositor(context_factory_private->AllocateFrameSinkId(), context_factory_private->AllocateFrameSinkId(),
content::GetContextFactory(), context_factory_private, content::GetContextFactory(), context_factory_private,
base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(), false /* enable_pixel_canvas */));
features::IsSurfaceSynchronizationEnabled(),
false /* enable_pixel_canvas */));
compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget);
compositor_->SetRootLayer(root_layer_.get()); compositor_->SetRootLayer(root_layer_.get());
#endif #endif
@ -511,7 +512,7 @@ bool OffScreenRenderWidgetHostView::IsShowing() {
return is_showing_; return is_showing_;
} }
void OffScreenRenderWidgetHostView::EnsureSurfaceSynchronizedForLayoutTest() { void OffScreenRenderWidgetHostView::EnsureSurfaceSynchronizedForWebTest() {
++latest_capture_sequence_number_; ++latest_capture_sequence_number_;
SynchronizeVisualProperties(); SynchronizeVisualProperties();
} }
@ -528,9 +529,9 @@ void OffScreenRenderWidgetHostView::SetBackgroundColor(SkColor color) {
// We short-cut here to show a sensible color before that happens. // We short-cut here to show a sensible color before that happens.
UpdateBackgroundColorFromRenderer(color); UpdateBackgroundColorFromRenderer(color);
if (render_widget_host_) { if (render_widget_host_ && render_widget_host_->owner_delegate()) {
render_widget_host_->SetBackgroundOpaque(SkColorGetA(color) == render_widget_host_->owner_delegate()->SetBackgroundOpaque(
SK_AlphaOPAQUE); SkColorGetA(color) == SK_AlphaOPAQUE);
} }
} }
@ -1080,7 +1081,11 @@ void OffScreenRenderWidgetHostView::SendMouseWheelEvent(
blink::WebMouseWheelEvent mouse_wheel_event(event); blink::WebMouseWheelEvent mouse_wheel_event(event);
mouse_wheel_phase_handler_.SendWheelEndForTouchpadScrollingIfNeeded(); bool should_route_event =
render_widget_host_->delegate() &&
render_widget_host_->delegate()->GetInputEventRouter();
mouse_wheel_phase_handler_.SendWheelEndForTouchpadScrollingIfNeeded(
should_route_event);
mouse_wheel_phase_handler_.AddPhaseIfNeededAndScheduleEndEvent( mouse_wheel_phase_handler_.AddPhaseIfNeededAndScheduleEndEvent(
mouse_wheel_event, false); mouse_wheel_event, false);

View file

@ -101,7 +101,7 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase,
void Show(void) override; void Show(void) override;
void Hide(void) override; void Hide(void) override;
bool IsShowing(void) override; bool IsShowing(void) override;
void EnsureSurfaceSynchronizedForLayoutTest() override; void EnsureSurfaceSynchronizedForWebTest() override;
gfx::Rect GetViewBounds(void) const override; gfx::Rect GetViewBounds(void) const override;
gfx::Size GetVisibleViewportSize() const override; gfx::Size GetVisibleViewportSize() const override;
void SetInsets(const gfx::Insets&) override; void SetInsets(const gfx::Insets&) override;
@ -343,7 +343,7 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase,
// Latest capture sequence number which is incremented when the caller // Latest capture sequence number which is incremented when the caller
// requests surfaces be synchronized via // requests surfaces be synchronized via
// EnsureSurfaceSynchronizedForLayoutTest(). // EnsureSurfaceSynchronizedForWebTest().
uint32_t latest_capture_sequence_number_ = 0u; uint32_t latest_capture_sequence_number_ = 0u;
SkColor background_color_ = SkColor(); SkColor background_color_ = SkColor();

View file

@ -195,4 +195,6 @@ void PrintPreviewMessageHandler::RejectPromise(int request_id) {
promise->RejectWithErrorMessage("Failed to generate PDF"); promise->RejectWithErrorMessage("Failed to generate PDF");
} }
WEB_CONTENTS_USER_DATA_KEY_IMPL(PrintPreviewMessageHandler)
} // namespace atom } // namespace atom

View file

@ -67,6 +67,8 @@ class PrintPreviewMessageHandler
base::WeakPtrFactory<PrintPreviewMessageHandler> weak_ptr_factory_; base::WeakPtrFactory<PrintPreviewMessageHandler> weak_ptr_factory_;
WEB_CONTENTS_USER_DATA_KEY_DECL();
DISALLOW_COPY_AND_ASSIGN(PrintPreviewMessageHandler); DISALLOW_COPY_AND_ASSIGN(PrintPreviewMessageHandler);
}; };

View file

@ -167,20 +167,11 @@ NSString* AtomBundleMover::ContainingDiskImageDevice(NSString* bundlePath) {
NSData* data = NSData* data =
[[[hdiutil standardOutput] fileHandleForReading] readDataToEndOfFile]; [[[hdiutil standardOutput] fileHandleForReading] readDataToEndOfFile];
NSDictionary* info = nil; NSDictionary* info =
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) { [NSPropertyListSerialization propertyListWithData:data
info = [NSPropertyListSerialization
propertyListWithData:data
options:NSPropertyListImmutable options:NSPropertyListImmutable
format:NULL format:NULL
error:NULL]; error:NULL];
} else {
info = [NSPropertyListSerialization
propertyListFromData:data
mutabilityOption:NSPropertyListImmutable
format:NULL
errorDescription:NULL];
}
if (![info isKindOfClass:[NSDictionary class]]) if (![info isKindOfClass:[NSDictionary class]])
return nil; return nil;

View file

@ -16,6 +16,7 @@
#include "base/json/json_reader.h" #include "base/json/json_reader.h"
#include "base/json/json_writer.h" #include "base/json/json_writer.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "base/stl_util.h"
#include "base/strings/pattern.h" #include "base/strings/pattern.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
@ -109,7 +110,7 @@ void SetZoomLevelForWebContents(content::WebContents* web_contents,
double GetNextZoomLevel(double level, bool out) { double GetNextZoomLevel(double level, bool out) {
double factor = content::ZoomLevelToZoomFactor(level); double factor = content::ZoomLevelToZoomFactor(level);
size_t size = arraysize(kPresetZoomFactors); size_t size = base::size(kPresetZoomFactors);
for (size_t i = 0; i < size; ++i) { for (size_t i = 0; i < size; ++i) {
if (!content::ZoomValuesEqual(kPresetZoomFactors[i], factor)) if (!content::ZoomValuesEqual(kPresetZoomFactors[i], factor))
continue; continue;
@ -320,8 +321,8 @@ void InspectableWebContentsImpl::ShowDevTools(bool activate) {
// Show devtools only after it has done loading, this is to make sure the // Show devtools only after it has done loading, this is to make sure the
// SetIsDocked is called *BEFORE* ShowDevTools. // SetIsDocked is called *BEFORE* ShowDevTools.
embedder_message_dispatcher_.reset( embedder_message_dispatcher_ =
DevToolsEmbedderMessageDispatcher::CreateForDevToolsFrontend(this)); DevToolsEmbedderMessageDispatcher::CreateForDevToolsFrontend(this);
if (!external_devtools_web_contents_) { // no external devtools if (!external_devtools_web_contents_) { // no external devtools
managed_devtools_web_contents_ = content::WebContents::Create( managed_devtools_web_contents_ = content::WebContents::Create(
@ -731,10 +732,10 @@ void InspectableWebContentsImpl::RenderFrameHostChanged(
content::RenderFrameHost* new_host) { content::RenderFrameHost* new_host) {
if (new_host->GetParent()) if (new_host->GetParent())
return; return;
frontend_host_.reset(content::DevToolsFrontendHost::Create( frontend_host_ = content::DevToolsFrontendHost::Create(
new_host, new_host,
base::Bind(&InspectableWebContentsImpl::HandleMessageFromDevToolsFrontend, base::Bind(&InspectableWebContentsImpl::HandleMessageFromDevToolsFrontend,
weak_factory_.GetWeakPtr()))); weak_factory_.GetWeakPtr()));
} }
void InspectableWebContentsImpl::WebContentsDestroyed() { void InspectableWebContentsImpl::WebContentsDestroyed() {
@ -835,11 +836,11 @@ void InspectableWebContentsImpl::ReadyToCommitNavigation(
frontend_host_) { frontend_host_) {
return; return;
} }
frontend_host_.reset(content::DevToolsFrontendHost::Create( frontend_host_ = content::DevToolsFrontendHost::Create(
web_contents()->GetMainFrame(), web_contents()->GetMainFrame(),
base::Bind( base::Bind(
&InspectableWebContentsImpl::HandleMessageFromDevToolsFrontend, &InspectableWebContentsImpl::HandleMessageFromDevToolsFrontend,
base::Unretained(this)))); base::Unretained(this)));
return; return;
} }
} }

View file

@ -157,10 +157,13 @@ int ShowMessageBox(NativeWindow* parent_window,
callEndModal:true]; callEndModal:true];
NSWindow* window = parent_window->GetNativeWindow().GetNativeNSWindow(); NSWindow* window = parent_window->GetNativeWindow().GetNativeNSWindow();
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[alert beginSheetModalForWindow:window [alert beginSheetModalForWindow:window
modalDelegate:delegate modalDelegate:delegate
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
contextInfo:nil]; contextInfo:nil];
#pragma clang diagnostic pop
[NSApp runModalForWindow:window]; [NSApp runModalForWindow:window];
return ret_code; return ret_code;
@ -196,11 +199,14 @@ void ShowMessageBox(NativeWindow* parent_window,
NSWindow* window = NSWindow* window =
parent_window ? parent_window->GetNativeWindow().GetNativeNSWindow() parent_window ? parent_window->GetNativeWindow().GetNativeNSWindow()
: nil; : nil;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[alert [alert
beginSheetModalForWindow:window beginSheetModalForWindow:window
modalDelegate:delegate modalDelegate:delegate
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
contextInfo:nil]; contextInfo:nil];
#pragma clang diagnostic pop
} }
} }

View file

@ -82,8 +82,7 @@ int FramelessView::NonClientHitTest(const gfx::Point& cursor) {
return HTCLIENT; return HTCLIENT;
} }
void FramelessView::GetWindowMask(const gfx::Size& size, void FramelessView::GetWindowMask(const gfx::Size& size, SkPath* window_mask) {}
gfx::Path* window_mask) {}
void FramelessView::ResetWindowControls() {} void FramelessView::ResetWindowControls() {}

View file

@ -32,7 +32,7 @@ class FramelessView : public views::NonClientFrameView {
gfx::Rect GetWindowBoundsForClientBounds( gfx::Rect GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const override; const gfx::Rect& client_bounds) const override;
int NonClientHitTest(const gfx::Point& point) override; int NonClientHitTest(const gfx::Point& point) override;
void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) override; void GetWindowMask(const gfx::Size& size, SkPath* window_mask) override;
void ResetWindowControls() override; void ResetWindowControls() override;
void UpdateWindowIcon() override; void UpdateWindowIcon() override;
void UpdateWindowTitle() override; void UpdateWindowTitle() override;

View file

@ -88,10 +88,6 @@ bool MenuDelegate::IsItemChecked(int id) const {
return adapter_->IsItemChecked(id); return adapter_->IsItemChecked(id);
} }
void MenuDelegate::SelectionChanged(views::MenuItemView* menu) {
adapter_->SelectionChanged(menu);
}
void MenuDelegate::WillShowMenu(views::MenuItemView* menu) { void MenuDelegate::WillShowMenu(views::MenuItemView* menu) {
adapter_->WillShowMenu(menu); adapter_->WillShowMenu(menu);
} }

View file

@ -50,7 +50,6 @@ class MenuDelegate : public views::MenuDelegate {
bool IsCommandEnabled(int id) const override; bool IsCommandEnabled(int id) const override;
bool IsCommandVisible(int id) const override; bool IsCommandVisible(int id) const override;
bool IsItemChecked(int id) const override; bool IsItemChecked(int id) const override;
void SelectionChanged(views::MenuItemView* menu) override;
void WillShowMenu(views::MenuItemView* menu) override; void WillShowMenu(views::MenuItemView* menu) override;
void WillHideMenu(views::MenuItemView* menu) override; void WillHideMenu(views::MenuItemView* menu) override;
void OnMenuClosed(views::MenuItemView* menu) override; void OnMenuClosed(views::MenuItemView* menu) override;

View file

@ -37,7 +37,7 @@ SubmenuButton::SubmenuButton(const base::string16& title,
SetInkDropMode(InkDropMode::ON); SetInkDropMode(InkDropMode::ON);
set_ink_drop_base_color( set_ink_drop_base_color(
color_utils::BlendTowardOppositeLuma(background_color_, 0x61)); color_utils::BlendTowardMaxContrast(background_color_, 0x61));
} }
SubmenuButton::~SubmenuButton() {} SubmenuButton::~SubmenuButton() {}

View file

@ -83,7 +83,7 @@ bool ConvertShellLinkToJumpListItem(IShellLink* shell_link,
item->type = JumpListItem::Type::TASK; item->type = JumpListItem::Type::TASK;
wchar_t path[MAX_PATH]; wchar_t path[MAX_PATH];
if (FAILED(shell_link->GetPath(path, arraysize(path), nullptr, 0))) if (FAILED(shell_link->GetPath(path, MAX_PATH, nullptr, 0)))
return false; return false;
CComQIPtr<IPropertyStore> property_store = shell_link; CComQIPtr<IPropertyStore> property_store = shell_link;
@ -100,14 +100,13 @@ bool ConvertShellLinkToJumpListItem(IShellLink* shell_link,
} }
int icon_index; int icon_index;
if (SUCCEEDED( if (SUCCEEDED(shell_link->GetIconLocation(path, MAX_PATH, &icon_index))) {
shell_link->GetIconLocation(path, arraysize(path), &icon_index))) {
item->icon_path = base::FilePath(path); item->icon_path = base::FilePath(path);
item->icon_index = icon_index; item->icon_index = icon_index;
} }
wchar_t item_desc[INFOTIPSIZE]; wchar_t item_desc[INFOTIPSIZE];
if (SUCCEEDED(shell_link->GetDescription(item_desc, arraysize(item_desc)))) if (SUCCEEDED(shell_link->GetDescription(item_desc, INFOTIPSIZE)))
item->description = item_desc; item->description = item_desc;
return true; return true;

View file

@ -16,11 +16,11 @@
namespace { namespace {
std::string MediaStreamTypeToString(content::MediaStreamType type) { std::string MediaStreamTypeToString(blink::MediaStreamType type) {
switch (type) { switch (type) {
case content::MediaStreamType::MEDIA_DEVICE_AUDIO_CAPTURE: case blink::MediaStreamType::MEDIA_DEVICE_AUDIO_CAPTURE:
return "audio"; return "audio";
case content::MediaStreamType::MEDIA_DEVICE_VIDEO_CAPTURE: case blink::MediaStreamType::MEDIA_DEVICE_VIDEO_CAPTURE:
return "video"; return "video";
default: default:
return "unknown"; return "unknown";
@ -40,7 +40,7 @@ void MediaAccessAllowed(const content::MediaStreamRequest& request,
if (allowed) if (allowed)
controller.TakeAction(); controller.TakeAction();
else else
controller.Deny(content::MEDIA_DEVICE_PERMISSION_DENIED); controller.Deny(blink::MEDIA_DEVICE_PERMISSION_DENIED);
} }
void OnPointerLockResponse(content::WebContents* web_contents, bool allowed) { void OnPointerLockResponse(content::WebContents* web_contents, bool allowed) {
@ -105,11 +105,11 @@ void WebContentsPermissionHelper::RequestMediaAccessPermission(
base::DictionaryValue details; base::DictionaryValue details;
std::unique_ptr<base::ListValue> media_types(new base::ListValue); std::unique_ptr<base::ListValue> media_types(new base::ListValue);
if (request.audio_type == if (request.audio_type ==
content::MediaStreamType::MEDIA_DEVICE_AUDIO_CAPTURE) { blink::MediaStreamType::MEDIA_DEVICE_AUDIO_CAPTURE) {
media_types->AppendString("audio"); media_types->AppendString("audio");
} }
if (request.video_type == if (request.video_type ==
content::MediaStreamType::MEDIA_DEVICE_VIDEO_CAPTURE) { blink::MediaStreamType::MEDIA_DEVICE_VIDEO_CAPTURE) {
media_types->AppendString("video"); media_types->AppendString("video");
} }
details.SetList("mediaTypes", std::move(media_types)); details.SetList("mediaTypes", std::move(media_types));
@ -145,7 +145,7 @@ void WebContentsPermissionHelper::RequestOpenExternalPermission(
bool WebContentsPermissionHelper::CheckMediaAccessPermission( bool WebContentsPermissionHelper::CheckMediaAccessPermission(
const GURL& security_origin, const GURL& security_origin,
content::MediaStreamType type) const { blink::MediaStreamType type) const {
base::DictionaryValue details; base::DictionaryValue details;
details.SetString("securityOrigin", security_origin.spec()); details.SetString("securityOrigin", security_origin.spec());
details.SetString("mediaType", MediaStreamTypeToString(type)); details.SetString("mediaType", MediaStreamTypeToString(type));
@ -154,4 +154,6 @@ bool WebContentsPermissionHelper::CheckMediaAccessPermission(
return CheckPermission(content::PermissionType::AUDIO_CAPTURE, &details); return CheckPermission(content::PermissionType::AUDIO_CAPTURE, &details);
} }
WEB_CONTENTS_USER_DATA_KEY_IMPL(WebContentsPermissionHelper)
} // namespace atom } // namespace atom

View file

@ -5,9 +5,10 @@
#ifndef ATOM_BROWSER_WEB_CONTENTS_PERMISSION_HELPER_H_ #ifndef ATOM_BROWSER_WEB_CONTENTS_PERMISSION_HELPER_H_
#define ATOM_BROWSER_WEB_CONTENTS_PERMISSION_HELPER_H_ #define ATOM_BROWSER_WEB_CONTENTS_PERMISSION_HELPER_H_
#include "content/public/browser/media_stream_request.h"
#include "content/public/browser/permission_type.h" #include "content/public/browser/permission_type.h"
#include "content/public/browser/web_contents_user_data.h" #include "content/public/browser/web_contents_user_data.h"
#include "content/public/common/media_stream_request.h" #include "third_party/blink/public/common/mediastream/media_stream_request.h"
namespace atom { namespace atom {
@ -36,7 +37,7 @@ class WebContentsPermissionHelper
// Synchronous Checks // Synchronous Checks
bool CheckMediaAccessPermission(const GURL& security_origin, bool CheckMediaAccessPermission(const GURL& security_origin,
content::MediaStreamType type) const; blink::MediaStreamType type) const;
private: private:
explicit WebContentsPermissionHelper(content::WebContents* web_contents); explicit WebContentsPermissionHelper(content::WebContents* web_contents);
@ -52,6 +53,8 @@ class WebContentsPermissionHelper
content::WebContents* web_contents_; content::WebContents* web_contents_;
WEB_CONTENTS_USER_DATA_KEY_DECL();
DISALLOW_COPY_AND_ASSIGN(WebContentsPermissionHelper); DISALLOW_COPY_AND_ASSIGN(WebContentsPermissionHelper);
}; };

View file

@ -84,9 +84,6 @@ bool GetAsAutoplayPolicy(const base::Value* val,
} else if (policy_str == "user-gesture-required") { } else if (policy_str == "user-gesture-required") {
*out = content::AutoplayPolicy::kUserGestureRequired; *out = content::AutoplayPolicy::kUserGestureRequired;
return true; return true;
} else if (policy_str == "user-gesture-required-for-cross-origin") {
*out = content::AutoplayPolicy::kUserGestureRequiredForCrossOrigin;
return true;
} else if (policy_str == "document-user-activation-required") { } else if (policy_str == "document-user-activation-required") {
*out = content::AutoplayPolicy::kDocumentUserActivationRequired; *out = content::AutoplayPolicy::kDocumentUserActivationRequired;
return true; return true;
@ -436,4 +433,6 @@ void WebContentsPreferences::OverrideWebkitPrefs(
prefs->default_encoding = encoding; prefs->default_encoding = encoding;
} }
WEB_CONTENTS_USER_DATA_KEY_IMPL(WebContentsPreferences)
} // namespace atom } // namespace atom

View file

@ -82,6 +82,8 @@ class WebContentsPreferences
base::Value preference_ = base::Value(base::Value::Type::DICTIONARY); base::Value preference_ = base::Value(base::Value::Type::DICTIONARY);
base::Value last_preference_ = base::Value(base::Value::Type::DICTIONARY); base::Value last_preference_ = base::Value(base::Value::Type::DICTIONARY);
WEB_CONTENTS_USER_DATA_KEY_DECL();
DISALLOW_COPY_AND_ASSIGN(WebContentsPreferences); DISALLOW_COPY_AND_ASSIGN(WebContentsPreferences);
}; };

View file

@ -278,4 +278,6 @@ void WebContentsZoomController::SetZoomFactorOnNavigationIfNeeded(
SetZoomLevel(zoom_level); SetZoomLevel(zoom_level);
} }
WEB_CONTENTS_USER_DATA_KEY_IMPL(WebContentsZoomController)
} // namespace atom } // namespace atom

View file

@ -112,6 +112,8 @@ class WebContentsZoomController
content::HostZoomMap* host_zoom_map_; content::HostZoomMap* host_zoom_map_;
WEB_CONTENTS_USER_DATA_KEY_DECL();
DISALLOW_COPY_AND_ASSIGN(WebContentsZoomController); DISALLOW_COPY_AND_ASSIGN(WebContentsZoomController);
}; };

View file

@ -10,6 +10,7 @@
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkImageInfo.h" #include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/core/SkPixmap.h" #include "third_party/skia/include/core/SkPixmap.h"
#include "ui/base/clipboard/clipboard_format_type.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h" #include "ui/base/clipboard/scoped_clipboard_writer.h"
#include "atom/common/node_includes.h" #include "atom/common/node_includes.h"
@ -36,13 +37,15 @@ std::vector<base::string16> Clipboard::AvailableFormats(mate::Arguments* args) {
bool Clipboard::Has(const std::string& format_string, mate::Arguments* args) { bool Clipboard::Has(const std::string& format_string, mate::Arguments* args) {
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
ui::Clipboard::FormatType format(ui::Clipboard::GetFormatType(format_string)); ui::ClipboardFormatType format(
ui::ClipboardFormatType::GetType(format_string));
return clipboard->IsFormatAvailable(format, GetClipboardType(args)); return clipboard->IsFormatAvailable(format, GetClipboardType(args));
} }
std::string Clipboard::Read(const std::string& format_string) { std::string Clipboard::Read(const std::string& format_string) {
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
ui::Clipboard::FormatType format(ui::Clipboard::GetFormatType(format_string)); ui::ClipboardFormatType format(
ui::ClipboardFormatType::GetType(format_string));
std::string data; std::string data;
clipboard->ReadData(format, &data); clipboard->ReadData(format, &data);
@ -66,7 +69,7 @@ void Clipboard::WriteBuffer(const std::string& format,
ui::ScopedClipboardWriter writer(GetClipboardType(args)); ui::ScopedClipboardWriter writer(GetClipboardType(args));
writer.WriteData( writer.WriteData(
ui::Clipboard::GetFormatType(format).Serialize(), ui::ClipboardFormatType::GetType(format).Serialize(),
std::string(node::Buffer::Data(buffer), node::Buffer::Length(buffer))); std::string(node::Buffer::Data(buffer), node::Buffer::Length(buffer)));
} }
@ -98,11 +101,11 @@ base::string16 Clipboard::ReadText(mate::Arguments* args) {
base::string16 data; base::string16 data;
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
auto type = GetClipboardType(args); auto type = GetClipboardType(args);
if (clipboard->IsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(), if (clipboard->IsFormatAvailable(ui::ClipboardFormatType::GetPlainTextWType(),
type)) { type)) {
clipboard->ReadText(type, &data); clipboard->ReadText(type, &data);
} else if (clipboard->IsFormatAvailable( } else if (clipboard->IsFormatAvailable(
ui::Clipboard::GetPlainTextFormatType(), type)) { ui::ClipboardFormatType::GetPlainTextType(), type)) {
std::string result; std::string result;
clipboard->ReadAsciiText(type, &result); clipboard->ReadAsciiText(type, &result);
data = base::ASCIIToUTF16(result); data = base::ASCIIToUTF16(result);

View file

@ -4,7 +4,12 @@
#include "atom/common/application_info.h" #include "atom/common/application_info.h"
#include "atom/browser/browser.h"
#include "atom/common/atom_version.h"
#include "base/no_destructor.h" #include "base/no_destructor.h"
#include "base/strings/stringprintf.h"
#include "chrome/common/chrome_version.h"
#include "content/public/common/user_agent.h"
namespace atom { namespace atom {
@ -31,4 +36,21 @@ std::string GetOverriddenApplicationVersion() {
return *g_overridden_application_version; return *g_overridden_application_version;
} }
std::string GetApplicationUserAgent() {
// Construct user agent string.
Browser* browser = Browser::Get();
std::string name, user_agent;
if (!base::RemoveChars(browser->GetName(), " ", &name))
name = browser->GetName();
if (name == ATOM_PRODUCT_NAME) {
user_agent = "Chrome/" CHROME_VERSION_STRING " " ATOM_PRODUCT_NAME
"/" ATOM_VERSION_STRING;
} else {
user_agent = base::StringPrintf(
"%s/%s Chrome/%s " ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING,
name.c_str(), browser->GetVersion().c_str(), CHROME_VERSION_STRING);
}
return content::BuildUserAgentFromProduct(user_agent);
}
} // namespace atom } // namespace atom

View file

@ -22,6 +22,8 @@ std::string GetOverriddenApplicationVersion();
std::string GetApplicationName(); std::string GetApplicationName();
std::string GetApplicationVersion(); std::string GetApplicationVersion();
// Returns the user agent of Electron.
std::string GetApplicationUserAgent();
#if defined(OS_WIN) #if defined(OS_WIN)
PCWSTR GetRawAppUserModelID(); PCWSTR GetRawAppUserModelID();

View file

@ -13,6 +13,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/time/time.h" #include "base/time/time.h"
@ -414,7 +415,7 @@ DWORD CrashService::AsyncSendDump(void* context) {
const DWORD kSleepSchedule[] = {24 * kOneHour, 8 * kOneHour, 4 * kOneHour, const DWORD kSleepSchedule[] = {24 * kOneHour, 8 * kOneHour, 4 * kOneHour,
kOneHour, 15 * kOneMinute, 0}; kOneHour, 15 * kOneMinute, 0};
int retry_round = arraysize(kSleepSchedule) - 1; int retry_round = base::size(kSleepSchedule) - 1;
do { do {
::Sleep(kSleepSchedule[retry_round]); ::Sleep(kSleepSchedule[retry_round]);

View file

@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "atom/common/native_mate_converters/callback.h" #include "atom/common/native_mate_converters/callback.h"
#include "base/stl_util.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
@ -151,7 +152,7 @@ v8::Local<v8::Value> BindFunctionWith(v8::Isolate* isolate,
v8::Local<v8::Function> bind_func = v8::Local<v8::Function> bind_func =
v8::Local<v8::Function>::Cast(bind.ToLocalChecked()); v8::Local<v8::Function>::Cast(bind.ToLocalChecked());
v8::Local<v8::Value> converted[] = {func, arg1, arg2}; v8::Local<v8::Value> converted[] = {func, arg1, arg2};
return bind_func->Call(context, func, arraysize(converted), converted) return bind_func->Call(context, func, base::size(converted), converted)
.ToLocalChecked(); .ToLocalChecked();
} }

View file

@ -198,16 +198,16 @@ bool Converter<net::HttpResponseHeaders*>::FromV8(
auto context = isolate->GetCurrentContext(); auto context = isolate->GetCurrentContext();
auto headers = v8::Local<v8::Object>::Cast(val); auto headers = v8::Local<v8::Object>::Cast(val);
auto keys = headers->GetOwnPropertyNames(); auto keys = headers->GetOwnPropertyNames(context).ToLocalChecked();
for (uint32_t i = 0; i < keys->Length(); i++) { for (uint32_t i = 0; i < keys->Length(); i++) {
v8::Local<v8::String> keyVal; v8::Local<v8::Value> keyVal;
if (!keys->Get(i)->ToString(context).ToLocal(&keyVal)) { if (!keys->Get(context, i).ToLocal(&keyVal)) {
return false; return false;
} }
std::string key; std::string key;
mate::ConvertFromV8(isolate, keyVal, &key); mate::ConvertFromV8(isolate, keyVal, &key);
auto localVal = headers->Get(keyVal); auto localVal = headers->Get(context, keyVal).ToLocalChecked();
if (localVal->IsArray()) { if (localVal->IsArray()) {
auto values = v8::Local<v8::Array>::Cast(localVal); auto values = v8::Local<v8::Array>::Cast(localVal);
for (uint32_t j = 0; j < values->Length(); j++) { for (uint32_t j = 0; j < values->Length(); j++) {

View file

@ -27,12 +27,12 @@ Converter<scoped_refptr<network::ResourceRequestBody>>::ToV8(
for (const auto& element : *(val->elements())) { for (const auto& element : *(val->elements())) {
auto post_data_dict = std::make_unique<base::DictionaryValue>(); auto post_data_dict = std::make_unique<base::DictionaryValue>();
auto type = element.type(); auto type = element.type();
if (type == network::DataElement::TYPE_BYTES) { if (type == network::mojom::DataElementType::kBytes) {
auto bytes = std::make_unique<base::Value>(std::vector<char>( auto bytes = std::make_unique<base::Value>(std::vector<char>(
element.bytes(), element.bytes() + (element.length()))); element.bytes(), element.bytes() + (element.length())));
post_data_dict->SetString("type", "rawData"); post_data_dict->SetString("type", "rawData");
post_data_dict->Set("bytes", std::move(bytes)); post_data_dict->Set("bytes", std::move(bytes));
} else if (type == network::DataElement::TYPE_FILE) { } else if (type == network::mojom::DataElementType::kFile) {
post_data_dict->SetString("type", "file"); post_data_dict->SetString("type", "file");
post_data_dict->SetKey("filePath", post_data_dict->SetKey("filePath",
base::Value(element.path().AsUTF8Unsafe())); base::Value(element.path().AsUTF8Unsafe()));
@ -40,7 +40,7 @@ Converter<scoped_refptr<network::ResourceRequestBody>>::ToV8(
post_data_dict->SetInteger("length", static_cast<int>(element.length())); post_data_dict->SetInteger("length", static_cast<int>(element.length()));
post_data_dict->SetDouble( post_data_dict->SetDouble(
"modificationTime", element.expected_modification_time().ToDoubleT()); "modificationTime", element.expected_modification_time().ToDoubleT());
} else if (type == network::DataElement::TYPE_BLOB) { } else if (type == network::mojom::DataElementType::kBlob) {
post_data_dict->SetString("type", "blob"); post_data_dict->SetString("type", "blob");
post_data_dict->SetString("blobUUID", element.blob_uuid()); post_data_dict->SetString("blobUUID", element.blob_uuid());
} }

View file

@ -146,7 +146,7 @@ v8::Local<v8::Value> V8ValueConverter::ToV8Value(
return handle_scope.Escape(ToV8ValueImpl(context->GetIsolate(), value)); return handle_scope.Escape(ToV8ValueImpl(context->GetIsolate(), value));
} }
base::Value* V8ValueConverter::FromV8Value( std::unique_ptr<base::Value> V8ValueConverter::FromV8Value(
v8::Local<v8::Value> val, v8::Local<v8::Value> val,
v8::Local<v8::Context> context) const { v8::Local<v8::Context> context) const {
v8::Context::Scope context_scope(context); v8::Context::Scope context_scope(context);
@ -180,7 +180,8 @@ v8::Local<v8::Value> V8ValueConverter::ToV8ValueImpl(
case base::Value::Type::STRING: { case base::Value::Type::STRING: {
std::string val = value->GetString(); std::string val = value->GetString();
return v8::String::NewFromUtf8(isolate, val.c_str(), return v8::String::NewFromUtf8(isolate, val.c_str(),
v8::String::kNormalString, val.length()); v8::NewStringType::kNormal, val.length())
.ToLocalChecked();
} }
case base::Value::Type::LIST: case base::Value::Type::LIST:
@ -288,7 +289,8 @@ v8::Local<v8::Value> V8ValueConverter::ToArrayBuffer(
return v8::Uint8Array::New(array_buffer, 0, length); return v8::Uint8Array::New(array_buffer, 0, length);
} }
base::Value* V8ValueConverter::FromV8ValueImpl(FromV8ValueState* state, std::unique_ptr<base::Value> V8ValueConverter::FromV8ValueImpl(
FromV8ValueState* state,
v8::Local<v8::Value> val, v8::Local<v8::Value> val,
v8::Isolate* isolate) const { v8::Isolate* isolate) const {
FromV8ValueState::Level state_level(state); FromV8ValueState::Level state_level(state);
@ -296,30 +298,29 @@ base::Value* V8ValueConverter::FromV8ValueImpl(FromV8ValueState* state,
return nullptr; return nullptr;
if (val->IsExternal()) if (val->IsExternal())
return std::make_unique<base::Value>().release(); return std::make_unique<base::Value>();
if (val->IsNull()) if (val->IsNull())
return std::make_unique<base::Value>().release(); return std::make_unique<base::Value>();
auto context = isolate->GetCurrentContext(); auto context = isolate->GetCurrentContext();
if (val->IsBoolean()) if (val->IsBoolean())
return new base::Value(val->ToBoolean(context).ToLocalChecked()->Value()); return std::make_unique<base::Value>(val->ToBoolean(isolate)->Value());
if (val->IsInt32()) if (val->IsInt32())
return new base::Value(val->ToInt32(context).ToLocalChecked()->Value()); return std::make_unique<base::Value>(val.As<v8::Int32>()->Value());
if (val->IsNumber()) { if (val->IsNumber()) {
double val_as_double = val->ToNumber(context).ToLocalChecked()->Value(); double val_as_double = val.As<v8::Number>()->Value();
if (!std::isfinite(val_as_double)) if (!std::isfinite(val_as_double))
return nullptr; return nullptr;
return new base::Value(val_as_double); return std::make_unique<base::Value>(val_as_double);
} }
if (val->IsString()) { if (val->IsString()) {
v8::String::Utf8Value utf8(isolate, v8::String::Utf8Value utf8(isolate, val);
val->ToString(context).ToLocalChecked()); return std::make_unique<base::Value>(std::string(*utf8, utf8.length()));
return new base::Value(std::string(*utf8, utf8.length()));
} }
if (val->IsUndefined()) if (val->IsUndefined())
@ -329,15 +330,16 @@ base::Value* V8ValueConverter::FromV8ValueImpl(FromV8ValueState* state,
if (val->IsDate()) { if (val->IsDate()) {
v8::Date* date = v8::Date::Cast(*val); v8::Date* date = v8::Date::Cast(*val);
v8::Local<v8::Value> toISOString = v8::Local<v8::Value> toISOString =
date->Get(v8::String::NewFromUtf8(isolate, "toISOString")); date->Get(v8::String::NewFromUtf8(isolate, "toISOString",
v8::NewStringType::kNormal)
.ToLocalChecked());
if (toISOString->IsFunction()) { if (toISOString->IsFunction()) {
v8::Local<v8::Value> result = toISOString.As<v8::Function>() v8::Local<v8::Value> result = toISOString.As<v8::Function>()
->Call(context, val, 0, nullptr) ->Call(context, val, 0, nullptr)
.ToLocalChecked(); .ToLocalChecked();
if (!result.IsEmpty()) { if (!result.IsEmpty()) {
v8::String::Utf8Value utf8(isolate, v8::String::Utf8Value utf8(isolate, result);
result->ToString(context).ToLocalChecked()); return std::make_unique<base::Value>(std::string(*utf8, utf8.length()));
return new base::Value(std::string(*utf8, utf8.length()));
} }
} }
} }
@ -345,10 +347,8 @@ base::Value* V8ValueConverter::FromV8ValueImpl(FromV8ValueState* state,
if (val->IsRegExp()) { if (val->IsRegExp()) {
if (!reg_exp_allowed_) if (!reg_exp_allowed_)
// JSON.stringify converts to an object. // JSON.stringify converts to an object.
return FromV8Object(val->ToObject(context).ToLocalChecked(), state, return FromV8Object(val.As<v8::Object>(), state, isolate);
isolate); return std::make_unique<base::Value>(*v8::String::Utf8Value(isolate, val));
return new base::Value(*v8::String::Utf8Value(
isolate, val->ToString(context).ToLocalChecked()));
} }
// v8::Value doesn't have a ToArray() method for some reason. // v8::Value doesn't have a ToArray() method for some reason.
@ -359,8 +359,7 @@ base::Value* V8ValueConverter::FromV8ValueImpl(FromV8ValueState* state,
if (!function_allowed_) if (!function_allowed_)
// JSON.stringify refuses to convert function(){}. // JSON.stringify refuses to convert function(){}.
return nullptr; return nullptr;
return FromV8Object(val->ToObject(context).ToLocalChecked(), state, return FromV8Object(val.As<v8::Object>(), state, isolate);
isolate);
} }
if (node::Buffer::HasInstance(val)) { if (node::Buffer::HasInstance(val)) {
@ -368,20 +367,20 @@ base::Value* V8ValueConverter::FromV8ValueImpl(FromV8ValueState* state,
} }
if (val->IsObject()) { if (val->IsObject()) {
return FromV8Object(val->ToObject(context).ToLocalChecked(), state, return FromV8Object(val.As<v8::Object>(), state, isolate);
isolate);
} }
LOG(ERROR) << "Unexpected v8 value type encountered."; LOG(ERROR) << "Unexpected v8 value type encountered.";
return nullptr; return nullptr;
} }
base::Value* V8ValueConverter::FromV8Array(v8::Local<v8::Array> val, std::unique_ptr<base::Value> V8ValueConverter::FromV8Array(
v8::Local<v8::Array> val,
FromV8ValueState* state, FromV8ValueState* state,
v8::Isolate* isolate) const { v8::Isolate* isolate) const {
ScopedUniquenessGuard uniqueness_guard(state, val); ScopedUniquenessGuard uniqueness_guard(state, val);
if (!uniqueness_guard.is_valid()) if (!uniqueness_guard.is_valid())
return std::make_unique<base::Value>().release(); return std::make_unique<base::Value>();
std::unique_ptr<v8::Context::Scope> scope; std::unique_ptr<v8::Context::Scope> scope;
// If val was created in a different context than our current one, change to // If val was created in a different context than our current one, change to
@ -390,45 +389,54 @@ base::Value* V8ValueConverter::FromV8Array(v8::Local<v8::Array> val,
val->CreationContext() != isolate->GetCurrentContext()) val->CreationContext() != isolate->GetCurrentContext())
scope.reset(new v8::Context::Scope(val->CreationContext())); scope.reset(new v8::Context::Scope(val->CreationContext()));
auto* result = new base::ListValue(); std::unique_ptr<base::ListValue> result(new base::ListValue());
// Only fields with integer keys are carried over to the ListValue. // Only fields with integer keys are carried over to the ListValue.
for (uint32_t i = 0; i < val->Length(); ++i) { for (uint32_t i = 0; i < val->Length(); ++i) {
v8::TryCatch try_catch(isolate); v8::TryCatch try_catch(isolate);
v8::Local<v8::Value> child_v8 = val->Get(i); v8::Local<v8::Value> child_v8;
if (try_catch.HasCaught()) { v8::MaybeLocal<v8::Value> maybe_child =
val->Get(isolate->GetCurrentContext(), i);
if (try_catch.HasCaught() || !maybe_child.ToLocal(&child_v8)) {
LOG(ERROR) << "Getter for index " << i << " threw an exception."; LOG(ERROR) << "Getter for index " << i << " threw an exception.";
child_v8 = v8::Null(isolate); child_v8 = v8::Null(isolate);
} }
if (!val->HasRealIndexedProperty(i)) if (!val->HasRealIndexedProperty(isolate->GetCurrentContext(), i)
.FromMaybe(false)) {
result->Append(std::make_unique<base::Value>());
continue; continue;
}
base::Value* child = FromV8ValueImpl(state, child_v8, isolate); std::unique_ptr<base::Value> child =
FromV8ValueImpl(state, child_v8, isolate);
if (child) if (child)
result->Append(std::unique_ptr<base::Value>(child)); result->Append(std::move(child));
else else
// JSON.stringify puts null in places where values don't serialize, for // JSON.stringify puts null in places where values don't serialize, for
// example undefined and functions. Emulate that behavior. // example undefined and functions. Emulate that behavior.
result->Append(std::make_unique<base::Value>()); result->Append(std::make_unique<base::Value>());
} }
return result; return std::move(result);
} }
base::Value* V8ValueConverter::FromNodeBuffer(v8::Local<v8::Value> value, std::unique_ptr<base::Value> V8ValueConverter::FromNodeBuffer(
v8::Local<v8::Value> value,
FromV8ValueState* state, FromV8ValueState* state,
v8::Isolate* isolate) const { v8::Isolate* isolate) const {
return new base::Value(std::vector<char>( std::vector<char> buffer(
node::Buffer::Data(value), node::Buffer::Data(value),
node::Buffer::Data(value) + node::Buffer::Length(value))); node::Buffer::Data(value) + node::Buffer::Length(value));
return std::make_unique<base::Value>(std::move(buffer));
} }
base::Value* V8ValueConverter::FromV8Object(v8::Local<v8::Object> val, std::unique_ptr<base::Value> V8ValueConverter::FromV8Object(
v8::Local<v8::Object> val,
FromV8ValueState* state, FromV8ValueState* state,
v8::Isolate* isolate) const { v8::Isolate* isolate) const {
ScopedUniquenessGuard uniqueness_guard(state, val); ScopedUniquenessGuard uniqueness_guard(state, val);
if (!uniqueness_guard.is_valid()) if (!uniqueness_guard.is_valid())
return std::make_unique<base::Value>().release(); return std::make_unique<base::Value>();
std::unique_ptr<v8::Context::Scope> scope; std::unique_ptr<v8::Context::Scope> scope;
// If val was created in a different context than our current one, change to // If val was created in a different context than our current one, change to
@ -438,10 +446,15 @@ base::Value* V8ValueConverter::FromV8Object(v8::Local<v8::Object> val,
scope.reset(new v8::Context::Scope(val->CreationContext())); scope.reset(new v8::Context::Scope(val->CreationContext()));
auto result = std::make_unique<base::DictionaryValue>(); auto result = std::make_unique<base::DictionaryValue>();
v8::Local<v8::Array> property_names(val->GetOwnPropertyNames()); v8::Local<v8::Array> property_names;
if (!val->GetOwnPropertyNames(isolate->GetCurrentContext())
.ToLocal(&property_names)) {
return std::move(result);
}
for (uint32_t i = 0; i < property_names->Length(); ++i) { for (uint32_t i = 0; i < property_names->Length(); ++i) {
v8::Local<v8::Value> key(property_names->Get(i)); v8::Local<v8::Value> key =
property_names->Get(isolate->GetCurrentContext(), i).ToLocalChecked();
// Extend this test to cover more types as necessary and if sensible. // Extend this test to cover more types as necessary and if sensible.
if (!key->IsString() && !key->IsNumber()) { if (!key->IsString() && !key->IsNumber()) {
@ -451,21 +464,21 @@ base::Value* V8ValueConverter::FromV8Object(v8::Local<v8::Object> val,
continue; continue;
} }
v8::String::Utf8Value name_utf8( v8::String::Utf8Value name_utf8(isolate, key);
isolate, key->ToString(isolate->GetCurrentContext()).ToLocalChecked());
v8::TryCatch try_catch(isolate); v8::TryCatch try_catch(isolate);
v8::Local<v8::Value> child_v8 = val->Get(key); v8::Local<v8::Value> child_v8;
v8::MaybeLocal<v8::Value> maybe_child =
if (try_catch.HasCaught()) { val->Get(isolate->GetCurrentContext(), key);
if (try_catch.HasCaught() || !maybe_child.ToLocal(&child_v8)) {
LOG(ERROR) << "Getter for property " << *name_utf8 LOG(ERROR) << "Getter for property " << *name_utf8
<< " threw an exception."; << " threw an exception.";
child_v8 = v8::Null(isolate); child_v8 = v8::Null(isolate);
} }
std::unique_ptr<base::Value> child( std::unique_ptr<base::Value> child =
FromV8ValueImpl(state, child_v8, isolate)); FromV8ValueImpl(state, child_v8, isolate);
if (!child.get()) if (!child)
// JSON.stringify skips properties whose values don't serialize, for // JSON.stringify skips properties whose values don't serialize, for
// example undefined and functions. Emulate that behavior. // example undefined and functions. Emulate that behavior.
continue; continue;
@ -497,7 +510,7 @@ base::Value* V8ValueConverter::FromV8Object(v8::Local<v8::Object> val,
std::move(child)); std::move(child));
} }
return result.release(); return std::move(result);
} }
} // namespace atom } // namespace atom

View file

@ -5,6 +5,8 @@
#ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_V8_VALUE_CONVERTER_H_ #ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_V8_VALUE_CONVERTER_H_
#define ATOM_COMMON_NATIVE_MATE_CONVERTERS_V8_VALUE_CONVERTER_H_ #define ATOM_COMMON_NATIVE_MATE_CONVERTERS_V8_VALUE_CONVERTER_H_
#include <memory>
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
@ -26,7 +28,8 @@ class V8ValueConverter {
void SetStripNullFromObjects(bool val); void SetStripNullFromObjects(bool val);
v8::Local<v8::Value> ToV8Value(const base::Value* value, v8::Local<v8::Value> ToV8Value(const base::Value* value,
v8::Local<v8::Context> context) const; v8::Local<v8::Context> context) const;
base::Value* FromV8Value(v8::Local<v8::Value> value, std::unique_ptr<base::Value> FromV8Value(
v8::Local<v8::Value> value,
v8::Local<v8::Context> context) const; v8::Local<v8::Context> context) const;
private: private:
@ -43,16 +46,16 @@ class V8ValueConverter {
v8::Local<v8::Value> ToArrayBuffer(v8::Isolate* isolate, v8::Local<v8::Value> ToArrayBuffer(v8::Isolate* isolate,
const base::Value* value) const; const base::Value* value) const;
base::Value* FromV8ValueImpl(FromV8ValueState* state, std::unique_ptr<base::Value> FromV8ValueImpl(FromV8ValueState* state,
v8::Local<v8::Value> value, v8::Local<v8::Value> value,
v8::Isolate* isolate) const; v8::Isolate* isolate) const;
base::Value* FromV8Array(v8::Local<v8::Array> array, std::unique_ptr<base::Value> FromV8Array(v8::Local<v8::Array> array,
FromV8ValueState* state, FromV8ValueState* state,
v8::Isolate* isolate) const; v8::Isolate* isolate) const;
base::Value* FromNodeBuffer(v8::Local<v8::Value> value, std::unique_ptr<base::Value> FromNodeBuffer(v8::Local<v8::Value> value,
FromV8ValueState* state, FromV8ValueState* state,
v8::Isolate* isolate) const; v8::Isolate* isolate) const;
base::Value* FromV8Object(v8::Local<v8::Object> object, std::unique_ptr<base::Value> FromV8Object(v8::Local<v8::Object> object,
FromV8ValueState* state, FromV8ValueState* state,
v8::Isolate* isolate) const; v8::Isolate* isolate) const;

View file

@ -29,7 +29,6 @@
#undef DISALLOW_COPY_AND_ASSIGN #undef DISALLOW_COPY_AND_ASSIGN
#undef NO_RETURN #undef NO_RETURN
#undef LIKELY #undef LIKELY
#undef arraysize
#undef debug_string // This is defined in macOS SDK in AssertMacros.h. #undef debug_string // This is defined in macOS SDK in AssertMacros.h.
#undef require_string // This is defined in macOS SDK in AssertMacros.h. #undef require_string // This is defined in macOS SDK in AssertMacros.h.
#include "env-inl.h" #include "env-inl.h"

View file

@ -141,8 +141,11 @@ void Beep() {
bool GetLoginItemEnabled() { bool GetLoginItemEnabled() {
BOOL enabled = NO; BOOL enabled = NO;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// SMJobCopyDictionary does not work in sandbox (see rdar://13626319) // SMJobCopyDictionary does not work in sandbox (see rdar://13626319)
CFArrayRef jobs = SMCopyAllJobDictionaries(kSMDomainUserLaunchd); CFArrayRef jobs = SMCopyAllJobDictionaries(kSMDomainUserLaunchd);
#pragma clang diagnostic pop
NSArray* jobs_ = CFBridgingRelease(jobs); NSArray* jobs_ = CFBridgingRelease(jobs);
NSString* identifier = GetLoginHelperBundleIdentifier(); NSString* identifier = GetLoginHelperBundleIdentifier();
if (jobs_ && [jobs_ count] > 0) { if (jobs_ && [jobs_ count] > 0) {

View file

@ -20,6 +20,7 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/win/registry.h" #include "base/win/registry.h"
@ -263,7 +264,7 @@ bool ShowItemInFolder(const base::FilePath& full_path) {
const ITEMIDLIST* highlight[] = {file_item}; const ITEMIDLIST* highlight[] = {file_item};
hr = SHOpenFolderAndSelectItems(dir_item, arraysize(highlight), highlight, hr = SHOpenFolderAndSelectItems(dir_item, base::size(highlight), highlight,
NULL); NULL);
if (!FAILED(hr)) if (!FAILED(hr))
return true; return true;

View file

@ -30,7 +30,10 @@ v8::Maybe<bool> Promise::RejectWithErrorMessage(const std::string& string) {
v8::Local<v8::Context>::New(isolate(), GetContext())); v8::Local<v8::Context>::New(isolate(), GetContext()));
v8::Local<v8::String> error_message = v8::Local<v8::String> error_message =
v8::String::NewFromUtf8(isolate(), string.c_str()); v8::String::NewFromUtf8(isolate(), string.c_str(),
v8::NewStringType::kNormal,
static_cast<int>(string.size()))
.ToLocalChecked();
v8::Local<v8::Value> error = v8::Exception::Error(error_message); v8::Local<v8::Value> error = v8::Exception::Error(error_message);
return Reject(error); return Reject(error);
} }

View file

@ -22,6 +22,7 @@
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h" #include "native_mate/object_template_builder.h"
#include "third_party/blink/public/platform/web_cache.h" #include "third_party/blink/public/platform/web_cache.h"
#include "third_party/blink/public/platform/web_isolated_world_info.h"
#include "third_party/blink/public/web/web_custom_element.h" #include "third_party/blink/public/web/web_custom_element.h"
#include "third_party/blink/public/web/web_document.h" #include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_element.h" #include "third_party/blink/public/web/web_element.h"
@ -377,46 +378,27 @@ void ExecuteJavaScriptInIsolatedWorld(
scriptExecutionType, callback.release()); scriptExecutionType, callback.release());
} }
void SetIsolatedWorldSecurityOrigin(v8::Local<v8::Value> window,
int world_id,
const std::string& origin_url) {
GetRenderFrame(window)->GetWebFrame()->SetIsolatedWorldSecurityOrigin(
world_id, blink::WebSecurityOrigin::CreateFromString(
blink::WebString::FromUTF8(origin_url)));
}
void SetIsolatedWorldContentSecurityPolicy(v8::Local<v8::Value> window,
int world_id,
const std::string& security_policy) {
GetRenderFrame(window)->GetWebFrame()->SetIsolatedWorldContentSecurityPolicy(
world_id, blink::WebString::FromUTF8(security_policy));
}
void SetIsolatedWorldHumanReadableName(v8::Local<v8::Value> window,
int world_id,
const std::string& name) {
GetRenderFrame(window)->GetWebFrame()->SetIsolatedWorldHumanReadableName(
world_id, blink::WebString::FromUTF8(name));
}
void SetIsolatedWorldInfo(v8::Local<v8::Value> window, void SetIsolatedWorldInfo(v8::Local<v8::Value> window,
int world_id, int world_id,
const mate::Dictionary& options, const mate::Dictionary& options,
mate::Arguments* args) { mate::Arguments* args) {
std::string origin, csp, name; std::string origin_url, security_policy, name;
options.Get("securityOrigin", &origin); options.Get("securityOrigin", &origin_url);
options.Get("csp", &csp); options.Get("csp", &security_policy);
options.Get("name", &name); options.Get("name", &name);
if (!csp.empty() && origin.empty()) { if (!security_policy.empty() && origin_url.empty()) {
args->ThrowError( args->ThrowError(
"If csp is specified, securityOrigin should also be specified"); "If csp is specified, securityOrigin should also be specified");
return; return;
} }
SetIsolatedWorldSecurityOrigin(window, world_id, origin); blink::WebIsolatedWorldInfo info;
SetIsolatedWorldContentSecurityPolicy(window, world_id, csp); info.security_origin = blink::WebSecurityOrigin::CreateFromString(
SetIsolatedWorldHumanReadableName(window, world_id, name); blink::WebString::FromUTF8(origin_url));
info.content_security_policy = blink::WebString::FromUTF8(security_policy);
info.human_readable_name = blink::WebString::FromUTF8(name);
GetRenderFrame(window)->GetWebFrame()->SetIsolatedWorldInfo(world_id, info);
} }
blink::WebCache::ResourceTypeStats GetResourceUsage(v8::Isolate* isolate) { blink::WebCache::ResourceTypeStats GetResourceUsage(v8::Isolate* isolate) {
@ -550,12 +532,6 @@ void Initialize(v8::Local<v8::Object> exports,
dict.SetMethod("executeJavaScript", &ExecuteJavaScript); dict.SetMethod("executeJavaScript", &ExecuteJavaScript);
dict.SetMethod("executeJavaScriptInIsolatedWorld", dict.SetMethod("executeJavaScriptInIsolatedWorld",
&ExecuteJavaScriptInIsolatedWorld); &ExecuteJavaScriptInIsolatedWorld);
dict.SetMethod("_setIsolatedWorldSecurityOrigin",
&SetIsolatedWorldSecurityOrigin);
dict.SetMethod("_setIsolatedWorldContentSecurityPolicy",
&SetIsolatedWorldContentSecurityPolicy);
dict.SetMethod("_setIsolatedWorldHumanReadableName",
&SetIsolatedWorldHumanReadableName);
dict.SetMethod("setIsolatedWorldInfo", &SetIsolatedWorldInfo); dict.SetMethod("setIsolatedWorldInfo", &SetIsolatedWorldInfo);
dict.SetMethod("getResourceUsage", &GetResourceUsage); dict.SetMethod("getResourceUsage", &GetResourceUsage);
dict.SetMethod("clearCache", &ClearCache); dict.SetMethod("clearCache", &ClearCache);

View file

@ -21,6 +21,7 @@
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
#include "net/base/net_module.h" #include "net/base/net_module.h"
#include "net/grit/net_resources.h" #include "net/grit/net_resources.h"
#include "third_party/blink/public/platform/web_isolated_world_info.h"
#include "third_party/blink/public/web/blink.h" #include "third_party/blink/public/web/blink.h"
#include "third_party/blink/public/web/web_document.h" #include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_draggable_region.h" #include "third_party/blink/public/web/web_draggable_region.h"
@ -131,16 +132,14 @@ void AtomRenderFrameObserver::OnDestruct() {
void AtomRenderFrameObserver::CreateIsolatedWorldContext() { void AtomRenderFrameObserver::CreateIsolatedWorldContext() {
auto* frame = render_frame_->GetWebFrame(); auto* frame = render_frame_->GetWebFrame();
blink::WebIsolatedWorldInfo info;
// This maps to the name shown in the context combo box in the Console tab // This maps to the name shown in the context combo box in the Console tab
// of the dev tools. // of the dev tools.
frame->SetIsolatedWorldHumanReadableName( info.human_readable_name =
World::ISOLATED_WORLD, blink::WebString::FromUTF8("Electron Isolated Context");
blink::WebString::FromUTF8("Electron Isolated Context"));
// Setup document's origin policy in isolated world // Setup document's origin policy in isolated world
frame->SetIsolatedWorldSecurityOrigin( info.security_origin = frame->GetDocument().GetSecurityOrigin();
World::ISOLATED_WORLD, frame->GetDocument().GetSecurityOrigin()); frame->SetIsolatedWorldInfo(World::ISOLATED_WORLD, info);
// Create initial script context in isolated world // Create initial script context in isolated world
blink::WebScriptSource source("void 0"); blink::WebScriptSource source("void 0");

View file

@ -32,6 +32,7 @@
#include "third_party/blink/public/web/web_plugin_params.h" #include "third_party/blink/public/web/web_plugin_params.h"
#include "third_party/blink/public/web/web_script_source.h" #include "third_party/blink/public/web/web_script_source.h"
#include "third_party/blink/public/web/web_security_policy.h" #include "third_party/blink/public/web/web_security_policy.h"
#include "third_party/blink/public/web/web_view.h"
#include "third_party/blink/renderer/platform/weborigin/scheme_registry.h" #include "third_party/blink/renderer/platform/weborigin/scheme_registry.h"
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
@ -57,6 +58,7 @@
#if BUILDFLAG(ENABLE_PRINTING) #if BUILDFLAG(ENABLE_PRINTING)
#include "atom/renderer/printing/print_render_frame_helper_delegate.h" #include "atom/renderer/printing/print_render_frame_helper_delegate.h"
#include "components/printing/renderer/print_render_frame_helper.h" #include "components/printing/renderer/print_render_frame_helper.h"
#include "printing/print_settings.h"
#endif // BUILDFLAG(ENABLE_PRINTING) #endif // BUILDFLAG(ENABLE_PRINTING)
namespace atom { namespace atom {
@ -221,16 +223,16 @@ void RendererClientBase::RenderFrameCreated(
content::RenderView* render_view = render_frame->GetRenderView(); content::RenderView* render_view = render_frame->GetRenderView();
if (render_frame->IsMainFrame() && render_view) { if (render_frame->IsMainFrame() && render_view) {
blink::WebFrameWidget* web_frame_widget = render_view->GetWebFrameWidget(); blink::WebView* webview = render_view->GetWebView();
if (web_frame_widget) { if (webview) {
base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
if (cmd->HasSwitch(switches::kGuestInstanceID)) { // webview. if (cmd->HasSwitch(switches::kGuestInstanceID)) { // webview.
web_frame_widget->SetBaseBackgroundColor(SK_ColorTRANSPARENT); webview->SetBaseBackgroundColor(SK_ColorTRANSPARENT);
} else { // normal window. } else { // normal window.
std::string name = cmd->GetSwitchValueASCII(switches::kBackgroundColor); std::string name = cmd->GetSwitchValueASCII(switches::kBackgroundColor);
SkColor color = SkColor color =
name.empty() ? SK_ColorTRANSPARENT : ParseHexColor(name); name.empty() ? SK_ColorTRANSPARENT : ParseHexColor(name);
web_frame_widget->SetBaseBackgroundColor(color); webview->SetBaseBackgroundColor(color);
} }
} }
} }
@ -287,6 +289,12 @@ bool RendererClientBase::IsKeySystemsUpdateNeeded() {
#endif #endif
} }
void RendererClientBase::DidSetUserAgent(const std::string& user_agent) {
#if BUILDFLAG(ENABLE_PRINTING)
printing::SetAgent(user_agent);
#endif
}
v8::Local<v8::Context> RendererClientBase::GetContext( v8::Local<v8::Context> RendererClientBase::GetContext(
blink::WebLocalFrame* frame, blink::WebLocalFrame* frame,
v8::Isolate* isolate) const { v8::Isolate* isolate) const {

View file

@ -61,6 +61,7 @@ class RendererClientBase : public content::ContentRendererClient {
std::vector<std::unique_ptr<::media::KeySystemProperties>>* key_systems) std::vector<std::unique_ptr<::media::KeySystemProperties>>* key_systems)
override; override;
bool IsKeySystemsUpdateNeeded() override; bool IsKeySystemsUpdateNeeded() override;
void DidSetUserAgent(const std::string& user_agent) override;
private: private:
std::unique_ptr<PreferencesManager> preferences_manager_; std::unique_ptr<PreferencesManager> preferences_manager_;

View file

@ -7,11 +7,14 @@
#include <utility> #include <utility>
#include "base/command_line.h" #include "base/command_line.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "content/public/child/child_thread.h" #include "content/public/child/child_thread.h"
#include "content/public/common/service_manager_connection.h" #include "content/public/common/service_manager_connection.h"
#include "content/public/common/simple_connection_filter.h" #include "content/public/common/simple_connection_filter.h"
#include "content/public/utility/utility_thread.h"
#include "services/proxy_resolver/proxy_resolver_service.h" #include "services/proxy_resolver/proxy_resolver_service.h"
#include "services/proxy_resolver/public/mojom/proxy_resolver.mojom.h" #include "services/proxy_resolver/public/mojom/proxy_resolver.mojom.h"
#include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/sandbox/switches.h" #include "services/service_manager/sandbox/switches.h"
#if BUILDFLAG(ENABLE_PRINTING) #if BUILDFLAG(ENABLE_PRINTING)
@ -29,6 +32,40 @@
namespace atom { namespace atom {
namespace {
void RunServiceAsyncThenTerminateProcess(
std::unique_ptr<service_manager::Service> service) {
service_manager::Service::RunAsyncUntilTermination(
std::move(service),
base::BindOnce([] { content::UtilityThread::Get()->ReleaseProcess(); }));
}
std::unique_ptr<service_manager::Service> CreateProxyResolverService(
service_manager::mojom::ServiceRequest request) {
return std::make_unique<proxy_resolver::ProxyResolverService>(
std::move(request));
}
using ServiceFactory =
base::OnceCallback<std::unique_ptr<service_manager::Service>()>;
void RunServiceOnIOThread(ServiceFactory factory) {
base::OnceClosure terminate_process = base::BindOnce(
base::IgnoreResult(&base::SequencedTaskRunner::PostTask),
base::SequencedTaskRunnerHandle::Get(), FROM_HERE,
base::BindOnce([] { content::UtilityThread::Get()->ReleaseProcess(); }));
content::ChildThread::Get()->GetIOTaskRunner()->PostTask(
FROM_HERE,
base::BindOnce(
[](ServiceFactory factory, base::OnceClosure terminate_process) {
service_manager::Service::RunAsyncUntilTermination(
std::move(factory).Run(), std::move(terminate_process));
},
std::move(factory), std::move(terminate_process)));
}
} // namespace
AtomContentUtilityClient::AtomContentUtilityClient() : elevated_(false) { AtomContentUtilityClient::AtomContentUtilityClient() : elevated_(false) {
#if BUILDFLAG(ENABLE_PRINTING) && defined(OS_WIN) #if BUILDFLAG(ENABLE_PRINTING) && defined(OS_WIN)
printing_handler_ = std::make_unique<printing::PrintingHandler>(); printing_handler_ = std::make_unique<printing::PrintingHandler>();
@ -84,31 +121,35 @@ bool AtomContentUtilityClient::OnMessageReceived(const IPC::Message& message) {
return false; return false;
} }
void AtomContentUtilityClient::RegisterServices(StaticServiceMap* services) { bool AtomContentUtilityClient::HandleServiceRequest(
service_manager::EmbeddedServiceInfo proxy_resolver_info; const std::string& service_name,
proxy_resolver_info.task_runner = service_manager::mojom::ServiceRequest request) {
content::ChildThread::Get()->GetIOTaskRunner(); if (service_name == proxy_resolver::mojom::kProxyResolverServiceName) {
proxy_resolver_info.factory = RunServiceOnIOThread(
base::BindRepeating(&proxy_resolver::ProxyResolverService::CreateService); base::BindOnce(&CreateProxyResolverService, std::move(request)));
services->emplace(proxy_resolver::mojom::kProxyResolverServiceName, return true;
proxy_resolver_info); }
#if BUILDFLAG(ENABLE_PRINTING) auto service = MaybeCreateMainThreadService(service_name, std::move(request));
service_manager::EmbeddedServiceInfo printing_info; if (service) {
printing_info.factory = RunServiceAsyncThenTerminateProcess(std::move(service));
base::BindRepeating(&printing::PrintingService::CreateService); return true;
services->emplace(printing::mojom::kChromePrintingServiceName, printing_info); }
#endif
return false;
} }
std::unique_ptr<service_manager::Service> std::unique_ptr<service_manager::Service>
AtomContentUtilityClient::HandleServiceRequest( AtomContentUtilityClient::MaybeCreateMainThreadService(
const std::string& service_name, const std::string& service_name,
service_manager::mojom::ServiceRequest request) { service_manager::mojom::ServiceRequest request) {
#if BUILDFLAG(ENABLE_PRINTING) #if BUILDFLAG(ENABLE_PRINTING)
if (service_name == printing::mojom::kServiceName) { if (service_name == printing::mojom::kServiceName) {
return printing::CreatePdfCompositorService(std::string(), return printing::CreatePdfCompositorService(std::move(request));
std::move(request)); }
if (service_name == printing::mojom::kChromePrintingServiceName) {
return std::make_unique<printing::PrintingService>(std::move(request));
} }
#endif #endif

View file

@ -26,13 +26,14 @@ class AtomContentUtilityClient : public content::ContentUtilityClient {
void UtilityThreadStarted() override; void UtilityThreadStarted() override;
bool OnMessageReceived(const IPC::Message& message) override; bool OnMessageReceived(const IPC::Message& message) override;
void RegisterServices(StaticServiceMap* services) override; bool HandleServiceRequest(
std::unique_ptr<service_manager::Service> HandleServiceRequest(
const std::string& service_name, const std::string& service_name,
service_manager::mojom::ServiceRequest request) override; service_manager::mojom::ServiceRequest request) override;
private: private:
std::unique_ptr<service_manager::Service> MaybeCreateMainThreadService(
const std::string& service_name,
service_manager::mojom::ServiceRequest request);
#if BUILDFLAG(ENABLE_PRINTING) && defined(OS_WIN) #if BUILDFLAG(ENABLE_PRINTING) && defined(OS_WIN)
std::unique_ptr<printing::PrintingHandler> printing_handler_; std::unique_ptr<printing::PrintingHandler> printing_handler_;
#endif #endif

View file

@ -13,3 +13,7 @@ ffmpeg_branding = "Chrome"
enable_basic_printing = true enable_basic_printing = true
is_cfi = false is_cfi = false
# FIXME(deepak1556): workaround for https://crbug.com/924225
# remove this when clang roll 352138 lands.
enable_precompiled_headers = false

View file

@ -8,7 +8,7 @@ declare_args() {
# Allow running Electron as a node binary. # Allow running Electron as a node binary.
enable_run_as_node = true enable_run_as_node = true
enable_osr = true enable_osr = false
enable_view_api = false enable_view_api = false

View file

@ -112,30 +112,21 @@ static_library("chrome") {
"//chrome/browser/ui/views/color_chooser_win.cc", "//chrome/browser/ui/views/color_chooser_win.cc",
] ]
} }
if (is_linux) {
sources += [ "//chrome/browser/media/webrtc/window_icon_util_x11.cc" ]
}
} }
if (enable_tts) { if (enable_tts) {
sources += [ sources += [
"//chrome/browser/speech/tts_controller_delegate_impl.cc", "//chrome/browser/speech/tts_controller_delegate_impl.cc",
"//chrome/browser/speech/tts_controller_delegate_impl.h", "//chrome/browser/speech/tts_controller_delegate_impl.h",
"//chrome/browser/speech/tts_mac.mm",
"//chrome/browser/speech/tts_message_filter.cc", "//chrome/browser/speech/tts_message_filter.cc",
"//chrome/browser/speech/tts_message_filter.h", "//chrome/browser/speech/tts_message_filter.h",
"//chrome/browser/speech/tts_platform.h ",
"//chrome/browser/speech/tts_platform_impl.cc",
"//chrome/browser/speech/tts_platform_impl.h",
"//chrome/browser/speech/tts_win.cc",
"//chrome/renderer/tts_dispatcher.cc", "//chrome/renderer/tts_dispatcher.cc",
"//chrome/renderer/tts_dispatcher.h", "//chrome/renderer/tts_dispatcher.h",
] ]
if (is_linux) {
sources += [
"//chrome/browser/media/webrtc/window_icon_util_x11.cc",
"//chrome/browser/speech/tts_linux.cc",
]
deps += [ "//third_party/speech-dispatcher" ]
}
} }
if (enable_widevine) { if (enable_widevine) {

View file

@ -76,6 +76,7 @@
#include "base/rand_util.h" #include "base/rand_util.h"
#include "base/sequenced_task_runner_helpers.h" #include "base/sequenced_task_runner_helpers.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
@ -114,7 +115,7 @@ const char kACKToken[] = "ACK";
const char kShutdownToken[] = "SHUTDOWN"; const char kShutdownToken[] = "SHUTDOWN";
const char kTokenDelimiter = '\0'; const char kTokenDelimiter = '\0';
const int kMaxMessageLength = 32 * 1024; const int kMaxMessageLength = 32 * 1024;
const int kMaxACKMessageLength = arraysize(kShutdownToken) - 1; const int kMaxACKMessageLength = base::size(kShutdownToken) - 1;
const char kLockDelimiter = '-'; const char kLockDelimiter = '-';
@ -225,9 +226,9 @@ ssize_t ReadFromSocket(int fd,
// Set up a sockaddr appropriate for messaging. // Set up a sockaddr appropriate for messaging.
void SetupSockAddr(const std::string& path, struct sockaddr_un* addr) { void SetupSockAddr(const std::string& path, struct sockaddr_un* addr) {
addr->sun_family = AF_UNIX; addr->sun_family = AF_UNIX;
CHECK(path.length() < arraysize(addr->sun_path)) CHECK(path.length() < base::size(addr->sun_path))
<< "Socket path too long: " << path; << "Socket path too long: " << path;
base::strlcpy(addr->sun_path, path.c_str(), arraysize(addr->sun_path)); base::strlcpy(addr->sun_path, path.c_str(), base::size(addr->sun_path));
} }
// Set up a socket appropriate for messaging. // Set up a socket appropriate for messaging.
@ -604,13 +605,13 @@ void ProcessSingleton::LinuxWatcher::HandleMessage(
if (parent_->notification_callback_.Run(argv, base::FilePath(current_dir))) { if (parent_->notification_callback_.Run(argv, base::FilePath(current_dir))) {
// Send back "ACK" message to prevent the client process from starting up. // Send back "ACK" message to prevent the client process from starting up.
reader->FinishWithACK(kACKToken, arraysize(kACKToken) - 1); reader->FinishWithACK(kACKToken, base::size(kACKToken) - 1);
} else { } else {
LOG(WARNING) << "Not handling interprocess notification as browser" LOG(WARNING) << "Not handling interprocess notification as browser"
" is shutting down"; " is shutting down";
// Send back "SHUTDOWN" message, so that the client process can start up // Send back "SHUTDOWN" message, so that the client process can start up
// without killing this process. // without killing this process.
reader->FinishWithACK(kShutdownToken, arraysize(kShutdownToken) - 1); reader->FinishWithACK(kShutdownToken, base::size(kShutdownToken) - 1);
return; return;
} }
} }
@ -654,7 +655,7 @@ void ProcessSingleton::LinuxWatcher::SocketReader::
} }
// Validate the message. The shortest message is kStartToken\0x\0x // Validate the message. The shortest message is kStartToken\0x\0x
const size_t kMinMessageLength = arraysize(kStartToken) + 4; const size_t kMinMessageLength = base::size(kStartToken) + 4;
if (bytes_read_ < kMinMessageLength) { if (bytes_read_ < kMinMessageLength) {
buf_[bytes_read_] = 0; buf_[bytes_read_] = 0;
LOG(ERROR) << "Invalid socket message (wrong length):" << buf_; LOG(ERROR) << "Invalid socket message (wrong length):" << buf_;
@ -857,10 +858,10 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
} }
buf[len] = '\0'; buf[len] = '\0';
if (strncmp(buf, kShutdownToken, arraysize(kShutdownToken) - 1) == 0) { if (strncmp(buf, kShutdownToken, base::size(kShutdownToken) - 1) == 0) {
// The other process is shutting down, it's safe to start a new process. // The other process is shutting down, it's safe to start a new process.
return PROCESS_NONE; return PROCESS_NONE;
} else if (strncmp(buf, kACKToken, arraysize(kACKToken) - 1) == 0) { } else if (strncmp(buf, kACKToken, base::size(kACKToken) - 1) == 0) {
#if defined(TOOLKIT_VIEWS) && defined(OS_LINUX) && !defined(OS_CHROMEOS) #if defined(TOOLKIT_VIEWS) && defined(OS_LINUX) && !defined(OS_CHROMEOS)
// Likely NULL in unit tests. // Likely NULL in unit tests.
views::LinuxUI* linux_ui = views::LinuxUI::instance(); views::LinuxUI* linux_ui = views::LinuxUI::instance();

View file

@ -47,6 +47,7 @@ component("pepper_flash") {
"//skia", "//skia",
"//third_party/adobe/flash:flapper_version_h", "//third_party/adobe/flash:flapper_version_h",
"//ui/base", "//ui/base",
"//ui/base/clipboard",
] ]
if (is_mac) { if (is_mac) {
sources += [ sources += [

View file

@ -377,8 +377,7 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
file or link onto the page causes a navigation. Default is `false`. file or link onto the page causes a navigation. Default is `false`.
* `autoplayPolicy` String (optional) - Autoplay policy to apply to * `autoplayPolicy` String (optional) - Autoplay policy to apply to
content in the window, can be `no-user-gesture-required`, content in the window, can be `no-user-gesture-required`,
`user-gesture-required`, `user-gesture-required-for-cross-origin`, `user-gesture-required`, `document-user-activation-required`. Defaults to
`document-user-activation-required`. Defaults to
`no-user-gesture-required`. `no-user-gesture-required`.
When setting minimum or maximum window size with `minWidth`/`maxWidth`/ When setting minimum or maximum window size with `minWidth`/`maxWidth`/

View file

@ -17,8 +17,6 @@
<part file="electron_strings.grdp" /> <part file="electron_strings.grdp" />
</messages> </messages>
<includes> <includes>
<include name="IDR_ELECTRON_CONTENT_BROWSER_MANIFEST_OVERLAY" file="${target_gen_dir}\electron_content_browser_manifest_overlay.json" use_base_dir="false" type="BINDATA" />
<include name="IDR_ELECTRON_CONTENT_PACKAGED_SERVICES_MANIFEST_OVERLAY" file="${target_gen_dir}\electron_content_packaged_services_manifest_overlay.json" use_base_dir="false" type="BINDATA" />
<include name="IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE" file="${target_gen_dir}\shell_devtools_discovery_page.html" use_base_dir="false" type="BINDATA" /> <include name="IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE" file="${target_gen_dir}\shell_devtools_discovery_page.html" use_base_dir="false" type="BINDATA" />
</includes> </includes>
</release> </release>

View file

@ -251,6 +251,7 @@ filenames = {
"atom/browser/browser_observer.h", "atom/browser/browser_observer.h",
"atom/browser/browser_process_impl.cc", "atom/browser/browser_process_impl.cc",
"atom/browser/browser_process_impl.h", "atom/browser/browser_process_impl.h",
"atom/browser/child_web_contents_tracker.cc",
"atom/browser/child_web_contents_tracker.h", "atom/browser/child_web_contents_tracker.h",
"atom/browser/common_web_contents_delegate_mac.mm", "atom/browser/common_web_contents_delegate_mac.mm",
"atom/browser/common_web_contents_delegate_views.cc", "atom/browser/common_web_contents_delegate_views.cc",

View file

@ -22,4 +22,30 @@ if (process.platform === 'linux') {
}) })
} }
// TODO(deepak1556): Deprecate async api in favor of sync version in 5.0
powerMonitor.querySystemIdleState = function (threshold, callback) {
if (typeof threshold !== 'number') {
throw new Error('Must pass threshold as a number')
}
if (typeof callback !== 'function') {
throw new Error('Must pass callback as a function argument')
}
const idleState = this._querySystemIdleState(threshold)
process.nextTick(() => callback(idleState))
}
// TODO(deepak1556): Deprecate async api in favor of sync version in 5.0
powerMonitor.querySystemIdleTime = function (callback) {
if (typeof callback !== 'function') {
throw new Error('Must pass function as an argument')
}
const idleTime = this._querySystemIdleTime()
process.nextTick(() => callback(idleTime))
}
module.exports = powerMonitor module.exports = powerMonitor

View file

@ -78,6 +78,7 @@ const defaultPrintingSetting = {
printWithCloudPrint: false, printWithCloudPrint: false,
printWithPrivet: false, printWithPrivet: false,
printWithExtension: false, printWithExtension: false,
pagesPerSheet: 1,
deviceName: 'Save as PDF', deviceName: 'Save as PDF',
generateDraftData: true, generateDraftData: true,
fitToPageEnabled: false, fitToPageEnabled: false,

View file

@ -53,17 +53,20 @@ class WebFrame extends EventEmitter {
// TODO(nitsakh): Remove in 6.0 // TODO(nitsakh): Remove in 6.0
setIsolatedWorldSecurityOrigin (worldId, securityOrigin) { setIsolatedWorldSecurityOrigin (worldId, securityOrigin) {
deprecate.warn('webFrame.setIsolatedWorldSecurityOrigin', 'webFrame.setIsolatedWorldInfo') deprecate.warn('webFrame.setIsolatedWorldSecurityOrigin', 'webFrame.setIsolatedWorldInfo')
binding._setIsolatedWorldSecurityOrigin(this.context, worldId, securityOrigin) binding.setIsolatedWorldInfo(this.context, worldId, { securityOrigin })
} }
setIsolatedWorldContentSecurityPolicy (worldId, csp) { setIsolatedWorldContentSecurityPolicy (worldId, csp) {
deprecate.warn('webFrame.setIsolatedWorldContentSecurityPolicy', 'webFrame.setIsolatedWorldInfo') deprecate.warn('webFrame.setIsolatedWorldContentSecurityPolicy', 'webFrame.setIsolatedWorldInfo')
binding._setIsolatedWorldContentSecurityPolicy(this.context, worldId, csp) binding.setIsolatedWorldInfo(this.context, worldId, {
securityOrigin: window.location.origin,
csp
})
} }
setIsolatedWorldHumanReadableName (worldId, name) { setIsolatedWorldHumanReadableName (worldId, name) {
deprecate.warn('webFrame.setIsolatedWorldHumanReadableName', 'webFrame.setIsolatedWorldInfo') deprecate.warn('webFrame.setIsolatedWorldHumanReadableName', 'webFrame.setIsolatedWorldInfo')
binding._setIsolatedWorldHumanReadableName(this.context, worldId, name) binding.setIsolatedWorldInfo(this.context, worldId, { name })
} }
} }

23
manifests/BUILD.gn Normal file
View file

@ -0,0 +1,23 @@
import("//printing/buildflags/buildflags.gni")
source_set("manifests") {
sources = [
"//electron/atom/app/manifests.cc",
"//electron/atom/app/manifests.h",
]
include_dirs = [ "//electron" ]
deps = [
"//printing/buildflags",
"//services/proxy_resolver:proxy_resolver_manifest",
]
if (enable_basic_printing) {
deps += [ "//components/services/pdf_compositor:pdf_compositor_manifest" ]
}
if (enable_print_preview) {
deps += [ "//chrome/services/printing:manifest" ]
}
}

View file

@ -1,14 +0,0 @@
{
"name": "content_browser",
"display_name": "Electron (browser process)",
"interface_provider_specs": {
"service_manager:connector": {
"requires": {
"device": [ "device:geolocation_control" ],
"proxy_resolver": [ "factory" ],
"chrome_printing": [ "converter" ],
"pdf_compositor": [ "compositor"]
}
}
}
}

View file

@ -1,5 +0,0 @@
{
"name": "content_packaged_services",
"display_name": "Electron Packaged Services",
"interface_provider_specs": {}
}

View file

@ -140,13 +140,16 @@ bool Converter<double>::FromV8(Isolate* isolate,
} }
Local<Value> Converter<const char*>::ToV8(Isolate* isolate, const char* val) { Local<Value> Converter<const char*>::ToV8(Isolate* isolate, const char* val) {
return v8::String::NewFromUtf8(isolate, val); return v8::String::NewFromUtf8(isolate, val, v8::NewStringType::kNormal)
.ToLocalChecked();
} }
Local<Value> Converter<base::StringPiece>::ToV8(Isolate* isolate, Local<Value> Converter<base::StringPiece>::ToV8(Isolate* isolate,
const base::StringPiece& val) { const base::StringPiece& val) {
return v8::String::NewFromUtf8(isolate, val.data(), v8::String::kNormalString, return v8::String::NewFromUtf8(isolate, val.data(),
static_cast<uint32_t>(val.length())); v8::NewStringType::kNormal,
static_cast<uint32_t>(val.length()))
.ToLocalChecked();
} }
Local<Value> Converter<std::string>::ToV8(Isolate* isolate, Local<Value> Converter<std::string>::ToV8(Isolate* isolate,
@ -255,8 +258,9 @@ bool Converter<Local<Value>>::FromV8(Isolate* isolate,
v8::Local<v8::String> StringToSymbol(v8::Isolate* isolate, v8::Local<v8::String> StringToSymbol(v8::Isolate* isolate,
const base::StringPiece& val) { const base::StringPiece& val) {
return v8::String::NewFromUtf8(isolate, val.data(), return v8::String::NewFromUtf8(isolate, val.data(),
v8::String::kInternalizedString, v8::NewStringType::kInternalized,
static_cast<uint32_t>(val.length())); static_cast<uint32_t>(val.length()))
.ToLocalChecked();
} }
} // namespace mate } // namespace mate

View file

@ -277,7 +277,8 @@ struct Converter<std::map<std::string, T>> {
v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Local<v8::Object> dict = val->ToObject(context).ToLocalChecked(); v8::Local<v8::Object> dict = val->ToObject(context).ToLocalChecked();
v8::Local<v8::Array> keys = dict->GetOwnPropertyNames(); v8::Local<v8::Array> keys =
dict->GetOwnPropertyNames(context).ToLocalChecked();
for (uint32_t i = 0; i < keys->Length(); ++i) { for (uint32_t i = 0; i < keys->Length(); ++i) {
v8::Local<v8::Value> key = keys->Get(i); v8::Local<v8::Value> key = keys->Get(i);
T value; T value;

View file

@ -6,17 +6,13 @@
namespace mate { namespace mate {
Promise::Promise() Promise::Promise() : isolate_(NULL) {}
: isolate_(NULL) {
}
Promise::Promise(v8::Isolate* isolate) Promise::Promise(v8::Isolate* isolate) : isolate_(isolate) {
: isolate_(isolate) {
resolver_ = v8::Promise::Resolver::New(isolate); resolver_ = v8::Promise::Resolver::New(isolate);
} }
Promise::~Promise() { Promise::~Promise() {}
}
Promise Promise::Create(v8::Isolate* isolate) { Promise Promise::Create(v8::Isolate* isolate) {
return Promise(isolate); return Promise(isolate);
@ -28,7 +24,10 @@ Promise Promise::Create() {
void Promise::RejectWithErrorMessage(const std::string& string) { void Promise::RejectWithErrorMessage(const std::string& string) {
v8::Local<v8::String> error_message = v8::Local<v8::String> error_message =
v8::String::NewFromUtf8(isolate(), string.c_str()); v8::String::NewFromUtf8(isolate(), string.c_str(),
v8::NewStringType::kNormal,
static_cast<int>(string.size()))
.ToLocalChecked();
v8::Local<v8::Value> error = v8::Exception::Error(error_message); v8::Local<v8::Value> error = v8::Exception::Error(error_message);
resolver_->Reject(mate::ConvertToV8(isolate(), error)); resolver_->Reject(mate::ConvertToV8(isolate(), error));
} }

View file

@ -71,7 +71,7 @@ index acc4719b7e9c4c4461fc6142f2ae9156b407915b..8b008a401ec2f2d0673f6876609dd578
callback(EVP_aes_256_ecb(), "aes-256-ecb", NULL, arg); callback(EVP_aes_256_ecb(), "aes-256-ecb", NULL, arg);
callback(EVP_aes_256_ofb(), "aes-256-ofb", NULL, arg); callback(EVP_aes_256_ofb(), "aes-256-ofb", NULL, arg);
diff --git a/include/openssl/cipher.h b/include/openssl/cipher.h diff --git a/include/openssl/cipher.h b/include/openssl/cipher.h
index 59634138cb60237f008eb99e7d8df54da7629c1a..b30b8434b301fb5b8630ae954698b6fee255df77 100644 index e9545c82ca7e663ae25d9e85d29acea2be54d38f..4902859cdb96012eae7956d9fc3b1dcd47a71c07 100644
--- a/include/openssl/cipher.h --- a/include/openssl/cipher.h
+++ b/include/openssl/cipher.h +++ b/include/openssl/cipher.h
@@ -421,6 +421,7 @@ OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_192_ofb(void); @@ -421,6 +421,7 @@ OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_192_ofb(void);

View file

@ -69,5 +69,5 @@ content_allow_embedder_to_prevent_locking_scheme_registry.patch
support_mixed_sandbox_with_zygote.patch support_mixed_sandbox_with_zygote.patch
disable_color_correct_rendering.patch disable_color_correct_rendering.patch
disable_time_ticks_dcheck.patch disable_time_ticks_dcheck.patch
fix_test_compilation_error.patch
autofill_size_calculation.patch autofill_size_calculation.patch
revert_build_swiftshader_for_arm32.patch

View file

@ -39,10 +39,10 @@ index 2aef366ac8194aa261cbca6abc051f7da8a988d3..3c7d66c81032636abcca4f1538ce9b7f
GIN_EXPORT static ArrayBufferAllocator* SharedInstance(); GIN_EXPORT static ArrayBufferAllocator* SharedInstance();
diff --git a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc diff --git a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
index 0050eb07bf1f1e8515663dfd14f2a3a1292edd96..96e8702f7e9f2a04a4edbc794d5c45e3e04bf8fb 100644 index bec05f5222c6653f6f42c87a2f71e4aa0f244b5e..96533b347ca9e1e140fb019a2b95093d5e1aee73 100644
--- a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc --- a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
+++ b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc +++ b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
@@ -662,6 +662,10 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { @@ -649,6 +649,10 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
size, WTF::ArrayBufferContents::kDontInitialize); size, WTF::ArrayBufferContents::kDontInitialize);
} }

View file

@ -6,10 +6,10 @@ Subject: allow_webview_file_url.patch
Allow webview to load non-web URLs. Allow webview to load non-web URLs.
diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc
index 83b81f3e28f5f4f3a9fe3c2146c50a966f7e2ec2..d0f2bde4f6f7bb1a8b6cfc5dc990cb30d4432504 100644 index a206be71b8d9f28d659000cd2ea72cdb8f876e07..f4ad084900723a5c0cf78affae7744d8039a8395 100644
--- a/content/browser/loader/resource_dispatcher_host_impl.cc --- a/content/browser/loader/resource_dispatcher_host_impl.cc
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc +++ b/content/browser/loader/resource_dispatcher_host_impl.cc
@@ -1462,6 +1462,8 @@ void ResourceDispatcherHostImpl::BeginNavigationRequest( @@ -1447,6 +1447,8 @@ void ResourceDispatcherHostImpl::BeginNavigationRequest(
!policy->IsWebSafeScheme(info.common_params.url.scheme()) && !policy->IsWebSafeScheme(info.common_params.url.scheme()) &&
!is_external_protocol; !is_external_protocol;

View file

@ -5,14 +5,14 @@ Subject: blink-worker-enable-csp-in-file-scheme.patch
diff --git a/third_party/blink/renderer/core/workers/worker_classic_script_loader.cc b/third_party/blink/renderer/core/workers/worker_classic_script_loader.cc diff --git a/third_party/blink/renderer/core/workers/worker_classic_script_loader.cc b/third_party/blink/renderer/core/workers/worker_classic_script_loader.cc
index c0cec745454d8e7ec0730852bb324bcae72ed42e..4550698d31ae2c1a511820ae88ce1d914fe10f7f 100644 index c404b0a5966416599a62075e0a616fda368e07ec..98a3e02f1335dd7256b7926bc6e7774c79e00d4a 100644
--- a/third_party/blink/renderer/core/workers/worker_classic_script_loader.cc --- a/third_party/blink/renderer/core/workers/worker_classic_script_loader.cc
+++ b/third_party/blink/renderer/core/workers/worker_classic_script_loader.cc +++ b/third_party/blink/renderer/core/workers/worker_classic_script_loader.cc
@@ -285,7 +285,6 @@ void WorkerClassicScriptLoader::ProcessContentSecurityPolicy( @@ -308,7 +308,6 @@ void WorkerClassicScriptLoader::ProcessContentSecurityPolicy(
// document (which is implemented in WorkerMessagingProxy, and // document (which is implemented in WorkerMessagingProxy, and
// m_contentSecurityPolicy should be left as nullptr to inherit the policy). // m_contentSecurityPolicy should be left as nullptr to inherit the policy).
if (!response.Url().ProtocolIs("blob") && if (!response.CurrentRequestUrl().ProtocolIs("blob") &&
- !response.Url().ProtocolIs("file") && - !response.CurrentRequestUrl().ProtocolIs("file") &&
!response.Url().ProtocolIs("filesystem")) { !response.CurrentRequestUrl().ProtocolIs("filesystem")) {
content_security_policy_ = ContentSecurityPolicy::Create(); content_security_policy_ = ContentSecurityPolicy::Create();
content_security_policy_->SetOverrideURLForSelf(response.Url()); content_security_policy_->SetOverrideURLForSelf(

View file

@ -10,10 +10,10 @@ to fix electron/electron#13787. The backport landed in Chromium 67 but the
DidCreateScriptContext re-ordering needs to be upstreamed or kept indefinitely DidCreateScriptContext re-ordering needs to be upstreamed or kept indefinitely
diff --git a/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc b/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc diff --git a/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc b/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc
index b43ca24b2595bbd20fb5cfa68a22ebec87acda33..496e5d16d49977cb2107a7101064093be19b1515 100644 index 9c3e848f01aef165c21a6d6043b6f9038d31cb66..7c16e8da1052b50f36da8102fdd8b9206dd7883d 100644
--- a/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc --- a/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc
+++ b/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc +++ b/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc
@@ -177,11 +177,10 @@ void LocalWindowProxy::Initialize() { @@ -190,11 +190,10 @@ void LocalWindowProxy::Initialize() {
GetFrame()->IsMainFrame()); GetFrame()->IsMainFrame());
MainThreadDebugger::Instance()->ContextCreated(script_state_, GetFrame(), MainThreadDebugger::Instance()->ContextCreated(script_state_, GetFrame(),
origin); origin);

View file

@ -14,10 +14,10 @@ when there is code doing that.
This patch reverts the change to fix the crash in Electron. This patch reverts the change to fix the crash in Electron.
diff --git a/third_party/blink/renderer/core/frame/local_frame.cc b/third_party/blink/renderer/core/frame/local_frame.cc diff --git a/third_party/blink/renderer/core/frame/local_frame.cc b/third_party/blink/renderer/core/frame/local_frame.cc
index 72df3508f9ea9219d3ca3aa716afcad01b378f7e..a7b8051311ef259c3297925c2f5050372ec3ac5b 100644 index 9c8ffb99f78ef29df08e139551af984dc23e9de2..8196880b6da930557d22f4c29a6de35c1aa7a763 100644
--- a/third_party/blink/renderer/core/frame/local_frame.cc --- a/third_party/blink/renderer/core/frame/local_frame.cc
+++ b/third_party/blink/renderer/core/frame/local_frame.cc +++ b/third_party/blink/renderer/core/frame/local_frame.cc
@@ -399,10 +399,6 @@ void LocalFrame::DetachImpl(FrameDetachType type) { @@ -403,10 +403,6 @@ void LocalFrame::DetachImpl(FrameDetachType type) {
} }
CHECK(!view_ || !view_->IsAttached()); CHECK(!view_ || !view_->IsAttached());
@ -28,7 +28,7 @@ index 72df3508f9ea9219d3ca3aa716afcad01b378f7e..a7b8051311ef259c3297925c2f505037
if (!Client()) if (!Client())
return; return;
@@ -420,6 +416,10 @@ void LocalFrame::DetachImpl(FrameDetachType type) { @@ -424,6 +420,10 @@ void LocalFrame::DetachImpl(FrameDetachType type) {
// Notify ScriptController that the frame is closing, since its cleanup ends // Notify ScriptController that the frame is closing, since its cleanup ends
// up calling back to LocalFrameClient via WindowProxy. // up calling back to LocalFrameClient via WindowProxy.
GetScriptController().ClearForClose(); GetScriptController().ClearForClose();

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