chore: bump chromium to f5b345dd470f14eef6e44732ccf23 (master) (#20649)

This commit is contained in:
Electron Bot 2019-10-28 18:12:35 -04:00 committed by Jeremy Apthorp
parent fb8b1fd1c9
commit b6246dcf12
154 changed files with 1490 additions and 1197 deletions

View file

@ -49,21 +49,20 @@ struct Converter<net::CanonicalCookie> {
};
template <>
struct Converter<network::mojom::CookieChangeCause> {
static v8::Local<v8::Value> ToV8(
v8::Isolate* isolate,
const network::mojom::CookieChangeCause& val) {
struct Converter<net::CookieChangeCause> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const net::CookieChangeCause& val) {
switch (val) {
case network::mojom::CookieChangeCause::INSERTED:
case network::mojom::CookieChangeCause::EXPLICIT:
case net::CookieChangeCause::INSERTED:
case net::CookieChangeCause::EXPLICIT:
return gin::StringToV8(isolate, "explicit");
case network::mojom::CookieChangeCause::OVERWRITE:
case net::CookieChangeCause::OVERWRITE:
return gin::StringToV8(isolate, "overwrite");
case network::mojom::CookieChangeCause::EXPIRED:
case net::CookieChangeCause::EXPIRED:
return gin::StringToV8(isolate, "expired");
case network::mojom::CookieChangeCause::EVICTED:
case net::CookieChangeCause::EVICTED:
return gin::StringToV8(isolate, "evicted");
case network::mojom::CookieChangeCause::EXPIRED_OVERWRITE:
case net::CookieChangeCause::EXPIRED_OVERWRITE:
return gin::StringToV8(isolate, "expired-overwrite");
default:
return gin::StringToV8(isolate, "unknown");
@ -324,10 +323,11 @@ v8::Local<v8::Promise> Cookies::FlushStore() {
return handle;
}
void Cookies::OnCookieChanged(const CookieDetails* details) {
Emit("changed", gin::ConvertToV8(isolate(), *(details->cookie)),
gin::ConvertToV8(isolate(), details->cause),
gin::ConvertToV8(isolate(), details->removed));
void Cookies::OnCookieChanged(const net::CookieChangeInfo& change) {
Emit("changed", gin::ConvertToV8(isolate(), change.cookie),
gin::ConvertToV8(isolate(), change.cause),
gin::ConvertToV8(isolate(),
change.cause != net::CookieChangeCause::INSERTED));
}
// static

View file

@ -11,7 +11,7 @@
#include "base/callback_list.h"
#include "gin/handle.h"
#include "net/cookies/canonical_cookie.h"
#include "shell/browser/net/cookie_details.h"
#include "net/cookies/cookie_change_dispatcher.h"
#include "shell/common/gin_helper/trackable_object.h"
#include "shell/common/promise_util.h"
@ -52,10 +52,11 @@ class Cookies : public gin_helper::TrackableObject<Cookies> {
v8::Local<v8::Promise> FlushStore();
// CookieChangeNotifier subscription:
void OnCookieChanged(const CookieDetails*);
void OnCookieChanged(const net::CookieChangeInfo& change);
private:
std::unique_ptr<base::CallbackList<void(const CookieDetails*)>::Subscription>
std::unique_ptr<base::CallbackList<void(
const net::CookieChangeInfo& change)>::Subscription>
cookie_change_subscription_;
scoped_refptr<AtomBrowserContext> browser_context_;

View file

@ -95,6 +95,7 @@ void DesktopCapturer::StartHandling(bool capture_window,
content::DesktopMediaID::TYPE_WINDOW,
content::desktop_capture::CreateWindowCapturer());
window_capturer_->SetThumbnailSize(thumbnail_size);
window_capturer_->AddObserver(this);
window_capturer_->Update(base::BindOnce(
&DesktopCapturer::UpdateSourcesList, weak_ptr_factory_.GetWeakPtr(),
window_capturer_.get()));
@ -105,6 +106,7 @@ void DesktopCapturer::StartHandling(bool capture_window,
content::DesktopMediaID::TYPE_SCREEN,
content::desktop_capture::CreateScreenCapturer());
screen_capturer_->SetThumbnailSize(thumbnail_size);
screen_capturer_->AddObserver(this);
screen_capturer_->Update(base::BindOnce(
&DesktopCapturer::UpdateSourcesList, weak_ptr_factory_.GetWeakPtr(),
screen_capturer_.get()));
@ -112,6 +114,10 @@ void DesktopCapturer::StartHandling(bool capture_window,
}
}
void DesktopCapturer::OnSourceUnchanged(DesktopMediaList* list) {
UpdateSourcesList(list);
}
void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
if (capture_window_ &&
list->GetMediaListType() == content::DesktopMediaID::TYPE_WINDOW) {

View file

@ -18,7 +18,8 @@ namespace electron {
namespace api {
class DesktopCapturer : public gin_helper::TrackableObject<DesktopCapturer> {
class DesktopCapturer : public gin_helper::TrackableObject<DesktopCapturer>,
public DesktopMediaListObserver {
public:
struct Source {
DesktopMediaList::Source media_list_source;
@ -43,6 +44,16 @@ class DesktopCapturer : public gin_helper::TrackableObject<DesktopCapturer> {
explicit DesktopCapturer(v8::Isolate* isolate);
~DesktopCapturer() override;
// DesktopMediaListObserver:
void OnSourceAdded(DesktopMediaList* list, int index) override {}
void OnSourceRemoved(DesktopMediaList* list, int index) override {}
void OnSourceMoved(DesktopMediaList* list,
int old_index,
int new_index) override {}
void OnSourceNameChanged(DesktopMediaList* list, int index) override {}
void OnSourceThumbnailChanged(DesktopMediaList* list, int index) override {}
void OnSourceUnchanged(DesktopMediaList* list) override;
private:
void UpdateSourcesList(DesktopMediaList* list);

View file

@ -19,6 +19,7 @@
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/options_switches.h"
#include "shell/common/promise_util.h"
#include "url/url_util.h"
namespace {

View file

@ -8,6 +8,7 @@
#include <memory>
#include <string>
#include "base/values.h"
#include "gin/handle.h"
#include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/event_emitter.h"
@ -19,10 +20,6 @@
#include "ui/gfx/sys_color_change_listener.h"
#endif
namespace base {
class DictionaryValue;
}
namespace electron {
namespace api {

View file

@ -44,6 +44,7 @@
#include "content/public/common/context_menu_params.h"
#include "electron/buildflags/buildflags.h"
#include "electron/shell/common/api/api.mojom.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "ppapi/buildflags/buildflags.h"
#include "shell/browser/api/atom_api_browser_window.h"
@ -86,6 +87,7 @@
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/page/page_zoom.h"
#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
#include "third_party/blink/public/mojom/frame/fullscreen.mojom.h"
#include "third_party/blink/public/platform/web_cursor_info.h"
#include "third_party/blink/public/platform/web_input_event.h"
#include "ui/display/screen.h"
@ -728,7 +730,7 @@ void WebContents::ContentsZoomChange(bool zoom_in) {
void WebContents::EnterFullscreenModeForTab(
content::WebContents* source,
const GURL& origin,
const blink::WebFullscreenOptions& options) {
const blink::mojom::FullscreenOptions& options) {
auto* permission_helper =
WebContentsPermissionHelper::FromWebContents(source);
auto callback =
@ -740,7 +742,7 @@ void WebContents::EnterFullscreenModeForTab(
void WebContents::OnEnterFullscreenModeForTab(
content::WebContents* source,
const GURL& origin,
const blink::WebFullscreenOptions& options,
const blink::mojom::FullscreenOptions& options,
bool allowed) {
if (!allowed)
return;
@ -1473,9 +1475,7 @@ void WebContents::SetWebRTCIPHandlingPolicy(
web_contents()->GetMutableRendererPrefs()->webrtc_ip_handling_policy =
webrtc_ip_handling_policy;
content::RenderViewHost* host = web_contents()->GetRenderViewHost();
if (host)
host->SyncRendererPrefs();
web_contents()->SyncRendererPrefs();
}
bool WebContents::IsCrashed() const {
@ -1795,11 +1795,8 @@ void WebContents::Print(gin_helper::Arguments* args) {
// We don't want to allow the user to enable these settings
// but we need to set them or a CHECK is hit.
settings.SetBoolean(printing::kSettingPrintToPDF, false);
settings.SetBoolean(printing::kSettingCloudPrintDialog, false);
settings.SetBoolean(printing::kSettingPrintWithPrivet, false);
settings.SetInteger(printing::kSettingPrinterType, printing::kLocalPrinter);
settings.SetBoolean(printing::kSettingShouldPrintSelectionOnly, false);
settings.SetBoolean(printing::kSettingPrintWithExtension, false);
settings.SetBoolean(printing::kSettingRasterizePdf, false);
// Set custom page ranges to print
@ -2030,10 +2027,11 @@ bool WebContents::SendIPCMessageWithSender(bool internal,
}
for (auto* frame_host : target_hosts) {
mojom::ElectronRendererAssociatedPtr electron_ptr;
mojo::AssociatedRemote<mojom::ElectronRenderer> electron_renderer;
frame_host->GetRemoteAssociatedInterfaces()->GetInterface(
mojo::MakeRequest(&electron_ptr));
electron_ptr->Message(internal, false, channel, std::move(args), sender_id);
&electron_renderer);
electron_renderer->Message(internal, false, channel, std::move(args),
sender_id);
}
return true;
}
@ -2058,11 +2056,10 @@ bool WebContents::SendIPCMessageToFrame(bool internal,
if (!(*iter)->IsRenderFrameLive())
return false;
mojom::ElectronRendererAssociatedPtr electron_ptr;
(*iter)->GetRemoteAssociatedInterfaces()->GetInterface(
mojo::MakeRequest(&electron_ptr));
electron_ptr->Message(internal, send_to_all, channel, std::move(message),
0 /* sender_id */);
mojo::AssociatedRemote<mojom::ElectronRenderer> electron_renderer;
(*iter)->GetRemoteAssociatedInterfaces()->GetInterface(&electron_renderer);
electron_renderer->Message(internal, send_to_all, channel, std::move(message),
0 /* sender_id */);
return true;
}
@ -2457,14 +2454,15 @@ v8::Local<v8::Promise> WebContents::TakeHeapSnapshot(
// This dance with `base::Owned` is to ensure that the interface stays alive
// until the callback is called. Otherwise it would be closed at the end of
// this function.
auto electron_ptr = std::make_unique<mojom::ElectronRendererAssociatedPtr>();
auto electron_renderer =
std::make_unique<mojo::AssociatedRemote<mojom::ElectronRenderer>>();
frame_host->GetRemoteAssociatedInterfaces()->GetInterface(
mojo::MakeRequest(electron_ptr.get()));
auto* raw_ptr = electron_ptr.get();
electron_renderer.get());
auto* raw_ptr = electron_renderer.get();
(*raw_ptr)->TakeHeapSnapshot(
mojo::WrapPlatformFile(file.TakePlatformFile()),
base::BindOnce(
[](mojom::ElectronRendererAssociatedPtr* ep,
[](mojo::AssociatedRemote<mojom::ElectronRenderer>* ep,
util::Promise<void*> promise, bool success) {
if (success) {
promise.Resolve();
@ -2472,7 +2470,7 @@ v8::Local<v8::Promise> WebContents::TakeHeapSnapshot(
promise.RejectWithErrorMessage("takeHeapSnapshot failed");
}
},
base::Owned(std::move(electron_ptr)), std::move(promise)));
base::Owned(std::move(electron_renderer)), std::move(promise)));
return handle;
}

View file

@ -275,10 +275,11 @@ class WebContents : public gin_helper::TrackableObject<WebContents>,
void SetZoomLimits(double min_zoom, double max_zoom) override;
// Callback triggered on permission response.
void OnEnterFullscreenModeForTab(content::WebContents* source,
const GURL& origin,
const blink::WebFullscreenOptions& options,
bool allowed);
void OnEnterFullscreenModeForTab(
content::WebContents* source,
const GURL& origin,
const blink::mojom::FullscreenOptions& options,
bool allowed);
// Create window with the given disposition.
void OnCreateWindow(const GURL& target_url,
@ -383,7 +384,7 @@ class WebContents : public gin_helper::TrackableObject<WebContents>,
void EnterFullscreenModeForTab(
content::WebContents* source,
const GURL& origin,
const blink::WebFullscreenOptions& options) override;
const blink::mojom::FullscreenOptions& options) override;
void ExitFullscreenModeForTab(content::WebContents* source) override;
void RendererUnresponsive(
content::WebContents* source,

View file

@ -10,6 +10,7 @@
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "media/capture/mojom/video_capture_types.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/skbitmap_operations.h"
@ -85,7 +86,8 @@ void FrameSubscriber::OnFrameCaptured(
base::ReadOnlySharedMemoryRegion data,
::media::mojom::VideoFrameInfoPtr info,
const gfx::Rect& content_rect,
viz::mojom::FrameSinkVideoConsumerFrameCallbacksPtr callbacks) {
mojo::PendingRemote<viz::mojom::FrameSinkVideoConsumerFrameCallbacks>
callbacks) {
gfx::Size size = GetRenderViewSize();
if (size != content_rect.size()) {
video_capturer_->SetResolutionConstraints(size, size, true);
@ -93,8 +95,10 @@ void FrameSubscriber::OnFrameCaptured(
return;
}
mojo::Remote<viz::mojom::FrameSinkVideoConsumerFrameCallbacks>
callbacks_remote(std::move(callbacks));
if (!data.IsValid()) {
callbacks->Done();
callbacks_remote->Done();
return;
}
base::ReadOnlySharedMemoryMapping mapping = data.Map();
@ -120,7 +124,7 @@ void FrameSubscriber::OnFrameCaptured(
base::ReadOnlySharedMemoryMapping mapping;
// Prevents FrameSinkVideoCapturer from recycling the shared memory that
// backs |frame_|.
viz::mojom::FrameSinkVideoConsumerFrameCallbacksPtr releaser;
mojo::Remote<viz::mojom::FrameSinkVideoConsumerFrameCallbacks> releaser;
};
SkBitmap bitmap;
@ -133,7 +137,7 @@ void FrameSubscriber::OnFrameCaptured(
[](void* addr, void* context) {
delete static_cast<FramePinner*>(context);
},
new FramePinner{std::move(mapping), std::move(callbacks)});
new FramePinner{std::move(mapping), std::move(callbacks_remote)});
bitmap.setImmutable();
Done(content_rect, bitmap);

View file

@ -12,6 +12,7 @@
#include "components/viz/host/client_frame_sink_video_capturer.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "v8/include/v8.h"
namespace gfx {
@ -49,7 +50,8 @@ class FrameSubscriber : public content::WebContentsObserver,
base::ReadOnlySharedMemoryRegion data,
::media::mojom::VideoFrameInfoPtr info,
const gfx::Rect& content_rect,
viz::mojom::FrameSinkVideoConsumerFrameCallbacksPtr callbacks) override;
mojo::PendingRemote<viz::mojom::FrameSinkVideoConsumerFrameCallbacks>
callbacks) override;
void OnStopped() override;
void Done(const gfx::Rect& damage, const SkBitmap& frame);

View file

@ -29,11 +29,11 @@
#include "content/public/browser/browser_ppapi_host.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/overlay_window.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/service_names.mojom.h"
@ -406,11 +406,6 @@ void AtomBrowserClient::OverrideWebkitPrefs(content::RenderViewHost* host,
prefs->picture_in_picture_enabled = false;
#endif
ui::NativeTheme* native_theme = ui::NativeTheme::GetInstanceForNativeUi();
prefs->preferred_color_scheme = native_theme->ShouldUseDarkColors()
? blink::PreferredColorScheme::kDark
: blink::PreferredColorScheme::kLight;
SetFontDefaults(prefs);
// Custom preferences of guest page.
@ -527,48 +522,53 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
std::string process_type =
command_line->GetSwitchValueASCII(::switches::kProcessType);
if (process_type != ::switches::kRendererProcess)
return;
// Copy following switches to child process.
static const char* const kCommonSwitchNames[] = {
switches::kStandardSchemes, switches::kEnableSandbox,
switches::kSecureSchemes, switches::kBypassCSPSchemes,
switches::kCORSSchemes, switches::kFetchSchemes,
switches::kServiceWorkerSchemes, switches::kEnableApiFilteringLogging};
command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
kCommonSwitchNames,
base::size(kCommonSwitchNames));
#if defined(OS_WIN)
// Append --app-user-model-id.
PWSTR current_app_id;
if (SUCCEEDED(GetCurrentProcessExplicitAppUserModelID(&current_app_id))) {
command_line->AppendSwitchNative(switches::kAppUserModelId, current_app_id);
CoTaskMemFree(current_app_id);
if (process_type == ::switches::kUtilityProcess ||
process_type == ::switches::kRendererProcess) {
// Copy following switches to child process.
static const char* const kCommonSwitchNames[] = {
switches::kStandardSchemes, switches::kEnableSandbox,
switches::kSecureSchemes, switches::kBypassCSPSchemes,
switches::kCORSSchemes, switches::kFetchSchemes,
switches::kServiceWorkerSchemes, switches::kEnableApiFilteringLogging};
command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
kCommonSwitchNames,
base::size(kCommonSwitchNames));
}
if (process_type == ::switches::kRendererProcess) {
#if defined(OS_WIN)
// Append --app-user-model-id.
PWSTR current_app_id;
if (SUCCEEDED(GetCurrentProcessExplicitAppUserModelID(&current_app_id))) {
command_line->AppendSwitchNative(switches::kAppUserModelId,
current_app_id);
CoTaskMemFree(current_app_id);
}
#endif
if (delegate_) {
auto app_path = static_cast<api::App*>(delegate_)->GetAppPath();
command_line->AppendSwitchPath(switches::kAppPath, app_path);
}
if (delegate_) {
auto app_path = static_cast<api::App*>(delegate_)->GetAppPath();
command_line->AppendSwitchPath(switches::kAppPath, app_path);
}
content::WebContents* web_contents = GetWebContentsFromProcessID(process_id);
if (web_contents) {
auto* web_preferences = WebContentsPreferences::From(web_contents);
if (web_preferences)
web_preferences->AppendCommandLineSwitches(
command_line, IsRendererSubFrame(process_id));
auto preloads =
SessionPreferences::GetValidPreloads(web_contents->GetBrowserContext());
if (!preloads.empty())
command_line->AppendSwitchNative(
switches::kPreloadScripts,
base::JoinString(preloads, kPathDelimiter));
if (CanUseCustomSiteInstance()) {
command_line->AppendSwitch(
switches::kDisableElectronSiteInstanceOverrides);
content::WebContents* web_contents =
GetWebContentsFromProcessID(process_id);
if (web_contents) {
auto* web_preferences = WebContentsPreferences::From(web_contents);
if (web_preferences)
web_preferences->AppendCommandLineSwitches(
command_line, IsRendererSubFrame(process_id));
auto preloads = SessionPreferences::GetValidPreloads(
web_contents->GetBrowserContext());
if (!preloads.empty())
command_line->AppendSwitchNative(
switches::kPreloadScripts,
base::JoinString(preloads, kPathDelimiter));
if (CanUseCustomSiteInstance()) {
command_line->AppendSwitch(
switches::kDisableElectronSiteInstanceOverrides);
}
}
}
}
@ -580,16 +580,6 @@ void AtomBrowserClient::AdjustUtilityServiceProcessCommandLine(
if (identity.name() == audio::mojom::kServiceName)
command_line->AppendSwitch(::switches::kMessageLoopTypeUi);
#endif
if (identity.name() == content::mojom::kNetworkServiceName) {
// Copy following switches to network service process.
static const char* const kCommonSwitchNames[] = {
switches::kStandardSchemes, switches::kSecureSchemes,
switches::kBypassCSPSchemes, switches::kCORSSchemes,
switches::kFetchSchemes, switches::kServiceWorkerSchemes};
command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
kCommonSwitchNames,
base::size(kCommonSwitchNames));
}
}
void AtomBrowserClient::DidCreatePpapiPlugin(content::BrowserPpapiHost* host) {
@ -863,7 +853,8 @@ bool AtomBrowserClient::HandleExternalProtocol(
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
network::mojom::URLLoaderFactoryPtr* out_factory) {
const base::Optional<url::Origin>& initiating_origin,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
base::PostTask(FROM_HERE, {BrowserThread::UI},
base::BindOnce(&HandleExternalProtocolInUI, url,
web_contents_getter, has_user_gesture));
@ -997,25 +988,26 @@ bool AtomBrowserClient::WillCreateURLLoaderFactory(
DCHECK(web_request.get());
auto proxied_receiver = std::move(*factory_receiver);
network::mojom::URLLoaderFactoryPtrInfo target_factory_info;
*factory_receiver = mojo::MakeRequest(&target_factory_info);
mojo::PendingRemote<network::mojom::URLLoaderFactory> target_factory_remote;
*factory_receiver = target_factory_remote.InitWithNewPipeAndPassReceiver();
mojo::PendingReceiver<network::mojom::TrustedURLLoaderHeaderClient>
header_client_receiver;
if (header_client)
header_client_receiver = header_client->InitWithNewPipeAndPassReceiver();
new ProxyingURLLoaderFactory(
web_request.get(), protocol->intercept_handlers(), render_process_id,
std::move(proxied_receiver), std::move(target_factory_info),
std::move(header_client_receiver), type);
new ProxyingURLLoaderFactory(web_request.get(),
protocol->intercept_handlers(), browser_context,
render_process_id, std::move(proxied_receiver),
std::move(target_factory_remote),
std::move(header_client_receiver), type);
if (bypass_redirect_checks)
*bypass_redirect_checks = true;
return true;
}
network::mojom::URLLoaderFactoryPtrInfo
mojo::PendingRemote<network::mojom::URLLoaderFactory>
AtomBrowserClient::CreateURLLoaderFactoryForNetworkRequests(
content::RenderProcessHost* process,
network::mojom::NetworkContext* network_context,
@ -1036,12 +1028,12 @@ AtomBrowserClient::CreateURLLoaderFactoryForNetworkRequests(
params->is_corb_enabled = false;
// Create the URLLoaderFactory.
network::mojom::URLLoaderFactoryPtrInfo factory_info;
network_context->CreateURLLoaderFactory(mojo::MakeRequest(&factory_info),
std::move(params));
return factory_info;
mojo::PendingRemote<network::mojom::URLLoaderFactory> factory_remote;
network_context->CreateURLLoaderFactory(
factory_remote.InitWithNewPipeAndPassReceiver(), std::move(params));
return factory_remote;
}
return network::mojom::URLLoaderFactoryPtrInfo();
return mojo::NullRemote();
}
#if defined(OS_WIN)

View file

@ -15,12 +15,13 @@
#include "base/synchronization/lock.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/render_process_host_observer.h"
#include "content/public/browser/web_contents.h"
#include "electron/buildflags/buildflags.h"
#include "net/ssl/client_cert_identity.h"
namespace content {
class QuotaPermissionContext;
class ClientCertificateDelegate;
class QuotaPermissionContext;
} // namespace content
namespace net {
@ -180,7 +181,7 @@ class AtomBrowserClient : public content::ContentBrowserClient,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
header_client,
bool* bypass_redirect_checks) override;
network::mojom::URLLoaderFactoryPtrInfo
mojo::PendingRemote<network::mojom::URLLoaderFactory>
CreateURLLoaderFactoryForNetworkRequests(
content::RenderProcessHost* process,
network::mojom::NetworkContext* network_context,
@ -206,7 +207,9 @@ class AtomBrowserClient : public content::ContentBrowserClient,
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
network::mojom::URLLoaderFactoryPtr* out_factory) override;
const base::Optional<url::Origin>& initiating_origin,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
override;
// content::RenderProcessHostObserver:
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;

View file

@ -31,6 +31,7 @@
#include "net/base/escape.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "shell/browser/atom_browser_client.h"
#include "shell/browser/atom_browser_main_parts.h"
#include "shell/browser/atom_download_manager_delegate.h"
@ -270,9 +271,9 @@ AtomBrowserContext::GetURLLoaderFactory() {
if (url_loader_factory_)
return url_loader_factory_;
network::mojom::URLLoaderFactoryPtr network_factory;
mojo::PendingReceiver<network::mojom::URLLoaderFactory> factory_request =
mojo::MakeRequest(&network_factory);
mojo::PendingRemote<network::mojom::URLLoaderFactory> network_factory_remote;
mojo::PendingReceiver<network::mojom::URLLoaderFactory> factory_receiver =
network_factory_remote.InitWithNewPipeAndPassReceiver();
// Consult the embedder.
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>
@ -281,7 +282,7 @@ AtomBrowserContext::GetURLLoaderFactory() {
->WillCreateURLLoaderFactory(
this, nullptr, -1,
content::ContentBrowserClient::URLLoaderFactoryType::kNavigation,
url::Origin(), &factory_request, &header_client, nullptr);
url::Origin(), &factory_receiver, &header_client, nullptr);
network::mojom::URLLoaderFactoryParamsPtr params =
network::mojom::URLLoaderFactoryParams::New();
@ -296,10 +297,10 @@ AtomBrowserContext::GetURLLoaderFactory() {
auto* storage_partition =
content::BrowserContext::GetDefaultStoragePartition(this);
storage_partition->GetNetworkContext()->CreateURLLoaderFactory(
std::move(factory_request), std::move(params));
std::move(factory_receiver), std::move(params));
url_loader_factory_ =
base::MakeRefCounted<network::WrapperSharedURLLoaderFactory>(
std::move(network_factory));
std::move(network_factory_remote));
return url_loader_factory_;
}
@ -331,6 +332,11 @@ AtomBrowserContext::GetClientHintsControllerDelegate() {
return nullptr;
}
content::StorageNotificationService*
AtomBrowserContext::GetStorageNotificationService() {
return nullptr;
}
void AtomBrowserContext::SetCorsOriginAccessListForOrigin(
const url::Origin& source_origin,
std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns,

View file

@ -113,6 +113,7 @@ class AtomBrowserContext
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
override;
content::StorageNotificationService* GetStorageNotificationService() override;
// extensions deps
void SetCorsOriginAccessListForOrigin(

View file

@ -17,7 +17,7 @@
#if defined(USE_X11)
#include "chrome/browser/ui/libgtkui/gtk_util.h"
#include "chrome/browser/ui/libgtkui/unity_service.h"
#include "shell/browser/linux/unity_service.h"
#endif
namespace electron {
@ -52,7 +52,11 @@ bool SetDefaultWebClient(const std::string& protocol) {
argv.emplace_back(kXdgSettingsDefaultSchemeHandler);
argv.push_back(protocol);
}
argv.push_back(libgtkui::GetDesktopName(env.get()));
std::string desktop_name;
if (!env->GetVar("CHROME_DESKTOP", &desktop_name)) {
return false;
}
argv.push_back(desktop_name);
int exit_code;
bool ran_ok = LaunchXdgUtility(argv, &exit_code);
@ -92,7 +96,10 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol,
argv.emplace_back("check");
argv.emplace_back(kXdgSettingsDefaultSchemeHandler);
argv.push_back(protocol);
argv.push_back(libgtkui::GetDesktopName(env.get()));
std::string desktop_name;
if (!env->GetVar("CHROME_DESKTOP", &desktop_name))
return false;
argv.push_back(desktop_name);
std::string reply;
int success_code;

View file

@ -267,11 +267,6 @@ resource_coordinator::TabManager* BrowserProcessImpl::GetTabManager() {
return nullptr;
}
shell_integration::DefaultWebClientState
BrowserProcessImpl::CachedDefaultWebClientState() {
return shell_integration::UNKNOWN_DEFAULT;
}
void BrowserProcessImpl::SetApplicationLocale(const std::string& locale) {
locale_ = locale;
}

View file

@ -90,8 +90,6 @@ class BrowserProcessImpl : public BrowserProcess {
resource_coordinator::ResourceCoordinatorParts* resource_coordinator_parts()
override;
resource_coordinator::TabManager* GetTabManager() override;
shell_integration::DefaultWebClientState CachedDefaultWebClientState()
override;
void CreateDevToolsProtocolHandler() override {}
void CreateDevToolsAutoOpener() override {}
void set_background_mode_manager_for_test(

View file

@ -39,7 +39,7 @@
#include "shell/browser/web_dialog_helper.h"
#include "shell/common/atom_constants.h"
#include "shell/common/options_switches.h"
#include "storage/browser/fileapi/isolated_context.h"
#include "storage/browser/file_system/isolated_context.h"
#if BUILDFLAG(ENABLE_COLOR_CHOOSER)
#include "chrome/browser/ui/color_chooser.h"
@ -328,7 +328,7 @@ void CommonWebContentsDelegate::EnumerateDirectory(
void CommonWebContentsDelegate::EnterFullscreenModeForTab(
content::WebContents* source,
const GURL& origin,
const blink::WebFullscreenOptions& options) {
const blink::mojom::FullscreenOptions& options) {
if (!owner_window_)
return;
if (IsFullscreenForTabOrPending(source)) {
@ -352,7 +352,7 @@ bool CommonWebContentsDelegate::IsFullscreenForTabOrPending(
return html_fullscreen_;
}
blink::WebSecurityStyle CommonWebContentsDelegate::GetSecurityStyle(
blink::SecurityStyle CommonWebContentsDelegate::GetSecurityStyle(
content::WebContents* web_contents,
content::SecurityStyleExplanations* security_style_explanations) {
SecurityStateTabHelper* helper =

View file

@ -92,10 +92,10 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate,
void EnterFullscreenModeForTab(
content::WebContents* source,
const GURL& origin,
const blink::WebFullscreenOptions& options) override;
const blink::mojom::FullscreenOptions& options) override;
void ExitFullscreenModeForTab(content::WebContents* source) override;
bool IsFullscreenForTabOrPending(const content::WebContents* source) override;
blink::WebSecurityStyle GetSecurityStyle(
blink::SecurityStyle GetSecurityStyle(
content::WebContents* web_contents,
content::SecurityStyleExplanations* explanations) override;
bool TakeFocus(content::WebContents* source, bool reverse) override;

View file

@ -11,7 +11,6 @@
#include "content/public/browser/storage_partition.h"
#include "net/cookies/canonical_cookie.h"
#include "shell/browser/atom_browser_context.h"
#include "shell/browser/net/cookie_details.h"
using content::BrowserThread;
@ -24,9 +23,10 @@ CookieChangeNotifier::CookieChangeNotifier(AtomBrowserContext* browser_context)
CookieChangeNotifier::~CookieChangeNotifier() = default;
std::unique_ptr<base::CallbackList<void(const CookieDetails*)>::Subscription>
std::unique_ptr<
base::CallbackList<void(const net::CookieChangeInfo& change)>::Subscription>
CookieChangeNotifier::RegisterCookieChangeCallback(
const base::Callback<void(const CookieDetails*)>& cb) {
const base::Callback<void(const net::CookieChangeInfo& change)>& cb) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
return cookie_change_sub_list_.Add(cb);
@ -57,14 +57,10 @@ void CookieChangeNotifier::OnConnectionError() {
StartListening();
}
void CookieChangeNotifier::OnCookieChange(
const net::CanonicalCookie& cookie,
network::mojom::CookieChangeCause cause) {
void CookieChangeNotifier::OnCookieChange(const net::CookieChangeInfo& change) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
CookieDetails cookie_details(
&cookie, cause != network::mojom::CookieChangeCause::INSERTED, cause);
cookie_change_sub_list_.Notify(&cookie_details);
cookie_change_sub_list_.Notify(change);
}
} // namespace electron

View file

@ -10,12 +10,12 @@
#include "base/callback_list.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "net/cookies/cookie_change_dispatcher.h"
#include "services/network/public/mojom/cookie_manager.mojom.h"
namespace electron {
class AtomBrowserContext;
struct CookieDetails;
// Sends cookie-change notifications on the UI thread.
class CookieChangeNotifier : public network::mojom::CookieChangeListener {
@ -24,20 +24,21 @@ class CookieChangeNotifier : public network::mojom::CookieChangeListener {
~CookieChangeNotifier() override;
// Register callbacks that needs to notified on any cookie store changes.
std::unique_ptr<base::CallbackList<void(const CookieDetails*)>::Subscription>
std::unique_ptr<base::CallbackList<
void(const net::CookieChangeInfo& change)>::Subscription>
RegisterCookieChangeCallback(
const base::Callback<void(const CookieDetails*)>& cb);
const base::Callback<void(const net::CookieChangeInfo& change)>& cb);
private:
void StartListening();
void OnConnectionError();
// network::mojom::CookieChangeListener implementation.
void OnCookieChange(const net::CanonicalCookie& cookie,
network::mojom::CookieChangeCause cause) override;
void OnCookieChange(const net::CookieChangeInfo& change) override;
AtomBrowserContext* browser_context_;
base::CallbackList<void(const CookieDetails*)> cookie_change_sub_list_;
base::CallbackList<void(const net::CookieChangeInfo& change)>
cookie_change_sub_list_;
mojo::Receiver<network::mojom::CookieChangeListener> receiver_;

View file

@ -0,0 +1,143 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "shell/browser/linux/unity_service.h"
#include <dlfcn.h>
#include <gtk/gtk.h>
#include <memory>
#include <string>
#include "base/environment.h"
#include "base/nix/xdg_util.h"
// Unity data typedefs.
typedef struct _UnityInspector UnityInspector;
typedef UnityInspector* (*unity_inspector_get_default_func)(void);
typedef gboolean (*unity_inspector_get_unity_running_func)(
UnityInspector* self);
typedef struct _UnityLauncherEntry UnityLauncherEntry;
typedef UnityLauncherEntry* (*unity_launcher_entry_get_for_desktop_id_func)(
const gchar* desktop_id);
typedef void (*unity_launcher_entry_set_count_func)(UnityLauncherEntry* self,
gint64 value);
typedef void (*unity_launcher_entry_set_count_visible_func)(
UnityLauncherEntry* self,
gboolean value);
typedef void (*unity_launcher_entry_set_progress_func)(UnityLauncherEntry* self,
gdouble value);
typedef void (*unity_launcher_entry_set_progress_visible_func)(
UnityLauncherEntry* self,
gboolean value);
namespace {
bool attempted_load = false;
// Unity has a singleton object that we can ask whether the unity is running.
UnityInspector* inspector = nullptr;
// A link to the desktop entry in the panel.
UnityLauncherEntry* chrome_entry = nullptr;
// Retrieved functions from libunity.
unity_inspector_get_unity_running_func get_unity_running = nullptr;
unity_launcher_entry_set_count_func entry_set_count = nullptr;
unity_launcher_entry_set_count_visible_func entry_set_count_visible = nullptr;
unity_launcher_entry_set_progress_func entry_set_progress = nullptr;
unity_launcher_entry_set_progress_visible_func entry_set_progress_visible =
nullptr;
void EnsureLibUnityLoaded() {
using base::nix::GetDesktopEnvironment;
if (attempted_load)
return;
attempted_load = true;
std::unique_ptr<base::Environment> env(base::Environment::Create());
base::nix::DesktopEnvironment desktop_env = GetDesktopEnvironment(env.get());
// The "icon-tasks" KDE task manager also honors Unity Launcher API.
if (desktop_env != base::nix::DESKTOP_ENVIRONMENT_UNITY &&
desktop_env != base::nix::DESKTOP_ENVIRONMENT_KDE4 &&
desktop_env != base::nix::DESKTOP_ENVIRONMENT_KDE5)
return;
// Ubuntu still hasn't given us a nice libunity.so symlink.
void* unity_lib = dlopen("libunity.so.4", RTLD_LAZY);
if (!unity_lib)
unity_lib = dlopen("libunity.so.6", RTLD_LAZY);
if (!unity_lib)
unity_lib = dlopen("libunity.so.9", RTLD_LAZY);
if (!unity_lib)
return;
unity_inspector_get_default_func inspector_get_default =
reinterpret_cast<unity_inspector_get_default_func>(
dlsym(unity_lib, "unity_inspector_get_default"));
if (inspector_get_default) {
inspector = inspector_get_default();
get_unity_running =
reinterpret_cast<unity_inspector_get_unity_running_func>(
dlsym(unity_lib, "unity_inspector_get_unity_running"));
}
unity_launcher_entry_get_for_desktop_id_func entry_get_for_desktop_id =
reinterpret_cast<unity_launcher_entry_get_for_desktop_id_func>(
dlsym(unity_lib, "unity_launcher_entry_get_for_desktop_id"));
if (entry_get_for_desktop_id) {
std::string desktop_id = getenv("CHROME_DESKTOP");
chrome_entry = entry_get_for_desktop_id(desktop_id.c_str());
entry_set_count = reinterpret_cast<unity_launcher_entry_set_count_func>(
dlsym(unity_lib, "unity_launcher_entry_set_count"));
entry_set_count_visible =
reinterpret_cast<unity_launcher_entry_set_count_visible_func>(
dlsym(unity_lib, "unity_launcher_entry_set_count_visible"));
entry_set_progress =
reinterpret_cast<unity_launcher_entry_set_progress_func>(
dlsym(unity_lib, "unity_launcher_entry_set_progress"));
entry_set_progress_visible =
reinterpret_cast<unity_launcher_entry_set_progress_visible_func>(
dlsym(unity_lib, "unity_launcher_entry_set_progress_visible"));
}
}
} // namespace
namespace unity {
bool IsRunning() {
EnsureLibUnityLoaded();
if (inspector && get_unity_running)
return get_unity_running(inspector);
return false;
}
void SetDownloadCount(int count) {
EnsureLibUnityLoaded();
if (chrome_entry && entry_set_count && entry_set_count_visible) {
entry_set_count(chrome_entry, count);
entry_set_count_visible(chrome_entry, count != 0);
}
}
void SetProgressFraction(float percentage) {
EnsureLibUnityLoaded();
if (chrome_entry && entry_set_progress && entry_set_progress_visible) {
entry_set_progress(chrome_entry, percentage);
entry_set_progress_visible(chrome_entry,
percentage > 0.0 && percentage < 1.0);
}
}
} // namespace unity

View file

@ -0,0 +1,23 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SHELL_BROWSER_LINUX_UNITY_SERVICE_H_
#define SHELL_BROWSER_LINUX_UNITY_SERVICE_H_
namespace unity {
// Returns whether unity is currently running.
bool IsRunning();
// If unity is running, sets the download counter in the dock icon. Any value
// other than 0 displays the badge.
void SetDownloadCount(int count);
// If unity is running, sets the download progress bar in the dock icon. Any
// value between 0.0 and 1.0 (exclusive) shows the progress bar.
void SetProgressFraction(float percentage);
} // namespace unity
#endif // SHELL_BROWSER_LINUX_UNITY_SERVICE_H_

View file

@ -45,8 +45,8 @@
#if defined(USE_X11)
#include "base/strings/string_util.h"
#include "chrome/browser/ui/libgtkui/unity_service.h"
#include "shell/browser/browser.h"
#include "shell/browser/linux/unity_service.h"
#include "shell/browser/ui/views/frameless_view.h"
#include "shell/browser/ui/views/global_menu_bar_x11.h"
#include "shell/browser/ui/views/native_frame_view.h"
@ -179,7 +179,7 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
// The given window is most likely not rectangular since it uses
// transparency and has no standard frame, don't show a shadow for it.
if (transparent() && !has_frame())
params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_NONE;
params.shadow_type = views::Widget::InitParams::ShadowType::kNone;
bool focusable;
if (options.Get(options::kFocusable, &focusable) && !focusable)
@ -471,8 +471,9 @@ void NativeWindowViews::SetEnabledInternal(bool enable) {
#if defined(OS_WIN)
::EnableWindow(GetAcceleratedWidget(), enable);
#elif defined(USE_X11)
views::DesktopWindowTreeHostX11* tree_host =
views::DesktopWindowTreeHostX11::GetHostForXID(GetAcceleratedWidget());
views::DesktopWindowTreeHostLinux* tree_host =
views::DesktopWindowTreeHostLinux::GetHostForWidget(
GetAcceleratedWidget());
if (enable) {
tree_host->RemoveEventRewriter(event_disabler_.get());
event_disabler_.reset();
@ -1267,8 +1268,8 @@ void NativeWindowViews::SetIcon(HICON window_icon, HICON app_icon) {
}
#elif defined(USE_X11)
void NativeWindowViews::SetIcon(const gfx::ImageSkia& icon) {
auto* tree_host = static_cast<views::DesktopWindowTreeHost*>(
views::DesktopWindowTreeHostX11::GetHostForXID(GetAcceleratedWidget()));
auto* tree_host = views::DesktopWindowTreeHostLinux::GetHostForWidget(
GetAcceleratedWidget());
tree_host->SetWindowIcons(icon, icon);
}
#endif

View file

@ -11,6 +11,7 @@
#include "base/guid.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/system/data_pipe_producer.h"
#include "mojo/public/cpp/system/string_data_source.h"
#include "net/base/filename_util.h"
@ -183,8 +184,8 @@ void AtomURLLoaderFactory::CreateLoaderAndStart(
}
void AtomURLLoaderFactory::Clone(
network::mojom::URLLoaderFactoryRequest request) {
bindings_.AddBinding(this, std::move(request));
mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver) {
receivers_.Add(this, std::move(receiver));
}
// static

View file

@ -9,7 +9,8 @@
#include <string>
#include <utility>
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "net/url_request/url_request_job_factory.h"
#include "services/network/public/cpp/resource_response.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
@ -50,7 +51,8 @@ class AtomURLLoaderFactory : public network::mojom::URLLoaderFactory {
network::mojom::URLLoaderClientPtr client,
const net::MutableNetworkTrafficAnnotationTag&
traffic_annotation) override;
void Clone(network::mojom::URLLoaderFactoryRequest request) override;
void Clone(mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver)
override;
static void StartLoading(
network::mojom::URLLoaderRequest loader,
@ -99,7 +101,7 @@ class AtomURLLoaderFactory : public network::mojom::URLLoaderFactory {
// TODO(zcbenz): This comes from extensions/browser/extension_protocols.cc
// but I don't know what it actually does, find out the meanings of |Clone|
// and |bindings_| and add comments for them.
mojo::BindingSet<network::mojom::URLLoaderFactory> bindings_;
mojo::ReceiverSet<network::mojom::URLLoaderFactory> receivers_;
ProtocolType type_;
ProtocolHandler handler_;

View file

@ -1,31 +0,0 @@
// Copyright (c) 2017 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_BROWSER_NET_COOKIE_DETAILS_H_
#define SHELL_BROWSER_NET_COOKIE_DETAILS_H_
#include "base/macros.h"
#include "services/network/public/mojom/cookie_manager.mojom.h"
namespace net {
class CanonicalCookie;
}
namespace electron {
struct CookieDetails {
public:
CookieDetails(const net::CanonicalCookie* cookie_copy,
bool is_removed,
network::mojom::CookieChangeCause cause)
: cookie(cookie_copy), removed(is_removed), cause(cause) {}
const net::CanonicalCookie* cookie;
bool removed;
network::mojom::CookieChangeCause cause;
};
} // namespace electron
#endif // SHELL_BROWSER_NET_COOKIE_DETAILS_H_

View file

@ -6,6 +6,7 @@
#include <utility>
#include "content/public/browser/browser_context.h"
#include "extensions/browser/extension_navigation_ui_data.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "net/base/completion_repeating_callback.h"
@ -46,6 +47,7 @@ ProxyingURLLoaderFactory::InProgressRequest::InProgressRequest(
traffic_annotation_(traffic_annotation),
proxied_loader_binding_(this, std::move(loader_request)),
target_client_(std::move(client)),
current_response_(network::mojom::URLResponseHead::New()),
proxied_client_binding_(this),
// TODO(zcbenz): We should always use "extraHeaders" mode to be compatible
// with old APIs.
@ -192,12 +194,12 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnReceiveResponse(
if (current_request_uses_header_client_) {
// Use the headers we got from OnHeadersReceived as that'll contain
// Set-Cookie if it existed.
auto saved_headers = current_response_.headers;
current_response_ = head;
current_response_.headers = saved_headers;
auto saved_headers = current_response_->headers;
current_response_ = std::move(head);
current_response_->headers = saved_headers;
ContinueToResponseStarted(net::OK);
} else {
current_response_ = head;
current_response_ = std::move(head);
HandleResponseOrRedirectHeaders(
base::BindOnce(&InProgressRequest::ContinueToResponseStarted,
weak_factory_.GetWeakPtr()));
@ -212,16 +214,16 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnReceiveRedirect(
if (current_request_uses_header_client_) {
// Use the headers we got from OnHeadersReceived as that'll contain
// Set-Cookie if it existed.
auto saved_headers = current_response_.headers;
current_response_ = head;
auto saved_headers = current_response_->headers;
current_response_ = std::move(head);
// If this redirect is from an HSTS upgrade, OnHeadersReceived will not be
// called before OnReceiveRedirect, so make sure the saved headers exist
// before setting them.
if (saved_headers)
current_response_.headers = saved_headers;
current_response_->headers = saved_headers;
ContinueToBeforeRedirect(redirect_info, net::OK);
} else {
current_response_ = head;
current_response_ = std::move(head);
HandleResponseOrRedirectHeaders(
base::BindOnce(&InProgressRequest::ContinueToBeforeRedirect,
weak_factory_.GetWeakPtr(), redirect_info));
@ -286,6 +288,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnBeforeSendHeaders(
void ProxyingURLLoaderFactory::InProgressRequest::OnHeadersReceived(
const std::string& headers,
const net::IPEndPoint& endpoint,
OnHeadersReceivedCallback callback) {
if (!current_request_uses_header_client_) {
std::move(callback).Run(net::OK, base::nullopt, GURL());
@ -293,7 +296,8 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnHeadersReceived(
}
on_headers_received_callback_ = std::move(callback);
current_response_.headers =
current_response_ = network::mojom::URLResponseHead::New();
current_response_->headers =
base::MakeRefCounted<net::HttpResponseHeaders>(headers);
HandleResponseOrRedirectHeaders(
base::BindOnce(&InProgressRequest::ContinueToHandleOverrideHeaders,
@ -447,7 +451,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::
// Make sure to update current_response_, since when OnReceiveResponse
// is called we will not use its headers as it might be missing the
// Set-Cookie line (as that gets stripped over IPC).
current_response_.headers = override_headers_;
current_response_->headers = override_headers_;
}
}
std::move(on_headers_received_callback_).Run(net::OK, headers, redirect_url_);
@ -466,7 +470,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToResponseStarted(
DCHECK(!current_request_uses_header_client_ || !override_headers_);
if (override_headers_)
current_response_.headers = override_headers_;
current_response_->headers = override_headers_;
std::string redirect_location;
if (override_headers_ && override_headers_->IsRedirect(&redirect_location)) {
@ -496,12 +500,12 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToResponseStarted(
return;
}
info_->AddResponseInfoFromResourceResponse(current_response_);
info_->AddResponseInfoFromResourceResponse(*current_response_);
proxied_client_binding_.ResumeIncomingMethodCallProcessing();
factory_->web_request_api()->OnResponseStarted(&info_.value(), request_);
target_client_->OnReceiveResponse(current_response_);
target_client_->OnReceiveResponse(std::move(current_response_));
}
void ProxyingURLLoaderFactory::InProgressRequest::ContinueToBeforeRedirect(
@ -512,14 +516,15 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToBeforeRedirect(
return;
}
info_->AddResponseInfoFromResourceResponse(current_response_);
info_->AddResponseInfoFromResourceResponse(*current_response_);
if (proxied_client_binding_.is_bound())
proxied_client_binding_.ResumeIncomingMethodCallProcessing();
factory_->web_request_api()->OnBeforeRedirect(&info_.value(), request_,
redirect_info.new_url);
target_client_->OnReceiveRedirect(redirect_info, current_response_);
target_client_->OnReceiveRedirect(redirect_info,
std::move(current_response_));
request_.url = redirect_info.new_url;
request_.method = redirect_info.new_method;
request_.site_for_cookies = redirect_info.new_site_for_cookies;
@ -557,14 +562,14 @@ void ProxyingURLLoaderFactory::InProgressRequest::
redirect_info.new_url = redirect_url_;
redirect_info.new_site_for_cookies = redirect_url_;
network::ResourceResponseHead head;
auto head = network::mojom::URLResponseHead::New();
std::string headers = base::StringPrintf(
"HTTP/1.1 %i Internal Redirect\n"
"Location: %s\n"
"Non-Authoritative-Reason: WebRequest API\n\n",
kInternalRedirectStatusCode, redirect_url_.spec().c_str());
if (network::features::ShouldEnableOutOfBlinkCors()) {
if (factory_->browser_context_->ShouldEnableOutOfBlinkCors()) {
// Cross-origin requests need to modify the Origin header to 'null'. Since
// CorsURLLoader sets |request_initiator| to the Origin request header in
// NetworkService, we need to modify |request_initiator| here to craft the
@ -595,11 +600,11 @@ void ProxyingURLLoaderFactory::InProgressRequest::
http_origin.c_str());
}
}
head.headers = base::MakeRefCounted<net::HttpResponseHeaders>(
head->headers = base::MakeRefCounted<net::HttpResponseHeaders>(
net::HttpUtil::AssembleRawHeaders(headers));
head.encoded_data_length = 0;
head->encoded_data_length = 0;
current_response_ = head;
current_response_ = std::move(head);
ContinueToBeforeRedirect(redirect_info, net::OK);
}
@ -608,14 +613,14 @@ void ProxyingURLLoaderFactory::InProgressRequest::
override_headers_ = nullptr;
redirect_url_ = GURL();
info_->AddResponseInfoFromResourceResponse(current_response_);
info_->AddResponseInfoFromResourceResponse(*current_response_);
net::CompletionRepeatingCallback copyable_callback =
base::AdaptCallbackForRepeating(std::move(continuation));
DCHECK(info_.has_value());
int result = factory_->web_request_api()->OnHeadersReceived(
&info_.value(), request_, copyable_callback,
current_response_.headers.get(), &override_headers_, &redirect_url_);
current_response_->headers.get(), &override_headers_, &redirect_url_);
if (result == net::ERR_BLOCKED_BY_CLIENT) {
OnRequestError(network::URLLoaderCompletionStatus(result));
return;
@ -651,21 +656,23 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnRequestError(
ProxyingURLLoaderFactory::ProxyingURLLoaderFactory(
WebRequestAPI* web_request_api,
const HandlersMap& intercepted_handlers,
content::BrowserContext* browser_context,
int render_process_id,
network::mojom::URLLoaderFactoryRequest loader_request,
network::mojom::URLLoaderFactoryPtrInfo target_factory_info,
mojo::PendingRemote<network::mojom::URLLoaderFactory> target_factory_remote,
mojo::PendingReceiver<network::mojom::TrustedURLLoaderHeaderClient>
header_client_receiver,
content::ContentBrowserClient::URLLoaderFactoryType loader_factory_type)
: web_request_api_(web_request_api),
intercepted_handlers_(intercepted_handlers),
browser_context_(browser_context),
render_process_id_(render_process_id),
loader_factory_type_(loader_factory_type) {
target_factory_.Bind(std::move(target_factory_info));
target_factory_.set_connection_error_handler(base::BindOnce(
target_factory_.Bind(std::move(target_factory_remote));
target_factory_.set_disconnect_handler(base::BindOnce(
&ProxyingURLLoaderFactory::OnTargetFactoryError, base::Unretained(this)));
proxy_bindings_.AddBinding(this, std::move(loader_request));
proxy_bindings_.set_connection_error_handler(base::BindRepeating(
proxy_receivers_.Add(this, std::move(loader_request));
proxy_receivers_.set_disconnect_handler(base::BindRepeating(
&ProxyingURLLoaderFactory::OnProxyBindingError, base::Unretained(this)));
if (header_client_receiver)
@ -727,8 +734,8 @@ void ProxyingURLLoaderFactory::CreateLoaderAndStart(
}
void ProxyingURLLoaderFactory::Clone(
network::mojom::URLLoaderFactoryRequest loader_request) {
proxy_bindings_.AddBinding(this, std::move(loader_request));
mojo::PendingReceiver<network::mojom::URLLoaderFactory> loader_receiver) {
proxy_receivers_.Add(this, std::move(loader_receiver));
}
void ProxyingURLLoaderFactory::OnLoaderCreated(
@ -750,13 +757,13 @@ bool ProxyingURLLoaderFactory::IsForServiceWorkerScript() const {
void ProxyingURLLoaderFactory::OnTargetFactoryError() {
target_factory_.reset();
proxy_bindings_.CloseAllBindings();
proxy_receivers_.Clear();
MaybeDeleteThis();
}
void ProxyingURLLoaderFactory::OnProxyBindingError() {
if (proxy_bindings_.empty())
if (proxy_receivers_.empty())
target_factory_.reset();
MaybeDeleteThis();

View file

@ -14,11 +14,15 @@
#include "base/optional.h"
#include "content/public/browser/content_browser_client.h"
#include "extensions/browser/api/web_request/web_request_info.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/resource_response.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "services/network/public/mojom/url_loader.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "shell/browser/net/atom_url_loader_factory.h"
namespace electron {
@ -122,6 +126,7 @@ class ProxyingURLLoaderFactory
void OnBeforeSendHeaders(const net::HttpRequestHeaders& headers,
OnBeforeSendHeadersCallback callback) override;
void OnHeadersReceived(const std::string& headers,
const net::IPEndPoint& endpoint,
OnHeadersReceivedCallback callback) override;
private:
@ -156,7 +161,7 @@ class ProxyingURLLoaderFactory
base::Optional<extensions::WebRequestInfo> info_;
network::ResourceResponseHead current_response_;
network::mojom::URLResponseHeadPtr current_response_;
scoped_refptr<net::HttpResponseHeaders> override_headers_;
GURL redirect_url_;
@ -201,9 +206,11 @@ class ProxyingURLLoaderFactory
ProxyingURLLoaderFactory(
WebRequestAPI* web_request_api,
const HandlersMap& intercepted_handlers,
content::BrowserContext* browser_context,
int render_process_id,
network::mojom::URLLoaderFactoryRequest loader_request,
network::mojom::URLLoaderFactoryPtrInfo target_factory_info,
mojo::PendingRemote<network::mojom::URLLoaderFactory>
target_factory_remote,
mojo::PendingReceiver<network::mojom::TrustedURLLoaderHeaderClient>
header_client_receiver,
content::ContentBrowserClient::URLLoaderFactoryType loader_factory_type);
@ -218,13 +225,18 @@ class ProxyingURLLoaderFactory
network::mojom::URLLoaderClientPtr client,
const net::MutableNetworkTrafficAnnotationTag&
traffic_annotation) override;
void Clone(network::mojom::URLLoaderFactoryRequest request) override;
void Clone(mojo::PendingReceiver<network::mojom::URLLoaderFactory>
loader_receiver) override;
// network::mojom::TrustedURLLoaderHeaderClient:
void OnLoaderCreated(
int32_t request_id,
mojo::PendingReceiver<network::mojom::TrustedHeaderClient> receiver)
override;
void OnLoaderForCorsPreflightCreated(
const network::ResourceRequest& request,
mojo::PendingReceiver<network::mojom::TrustedHeaderClient> receiver)
override {}
WebRequestAPI* web_request_api() { return web_request_api_; }
@ -248,9 +260,10 @@ class ProxyingURLLoaderFactory
// In this way we can avoid using code from api namespace in this file.
const HandlersMap& intercepted_handlers_;
content::BrowserContext* const browser_context_;
const int render_process_id_;
mojo::BindingSet<network::mojom::URLLoaderFactory> proxy_bindings_;
network::mojom::URLLoaderFactoryPtr target_factory_;
mojo::ReceiverSet<network::mojom::URLLoaderFactory> proxy_receivers_;
mojo::Remote<network::mojom::URLLoaderFactory> target_factory_;
mojo::Receiver<network::mojom::TrustedURLLoaderHeaderClient>
url_loader_header_client_receiver_{this};
const content::ContentBrowserClient::URLLoaderFactoryType

View file

@ -9,7 +9,7 @@
#include "base/bind.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "net/proxy_resolution/proxy_info.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "shell/browser/atom_browser_context.h"
@ -19,12 +19,12 @@ using content::BrowserThread;
namespace electron {
ResolveProxyHelper::ResolveProxyHelper(AtomBrowserContext* browser_context)
: binding_(this), browser_context_(browser_context) {}
: browser_context_(browser_context) {}
ResolveProxyHelper::~ResolveProxyHelper() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(!owned_self_);
DCHECK(!binding_.is_bound());
DCHECK(!receiver_.is_bound());
// Clear all pending requests if the ProxyService is still alive.
pending_requests_.clear();
}
@ -36,7 +36,7 @@ void ResolveProxyHelper::ResolveProxy(const GURL& url,
pending_requests_.emplace_back(url, std::move(callback));
// If nothing is in progress, start.
if (!binding_.is_bound()) {
if (!receiver_.is_bound()) {
DCHECK_EQ(1u, pending_requests_.size());
StartPendingRequest();
}
@ -44,13 +44,13 @@ void ResolveProxyHelper::ResolveProxy(const GURL& url,
void ResolveProxyHelper::StartPendingRequest() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(!binding_.is_bound());
DCHECK(!receiver_.is_bound());
DCHECK(!pending_requests_.empty());
// Start the request.
network::mojom::ProxyLookupClientPtr proxy_lookup_client;
binding_.Bind(mojo::MakeRequest(&proxy_lookup_client));
binding_.set_connection_error_handler(
mojo::PendingRemote<network::mojom::ProxyLookupClient> proxy_lookup_client =
receiver_.BindNewPipeAndPassRemote();
receiver_.set_disconnect_handler(
base::BindOnce(&ResolveProxyHelper::OnProxyLookupComplete,
base::Unretained(this), net::ERR_ABORTED, base::nullopt));
content::BrowserContext::GetDefaultStoragePartition(browser_context_)
@ -65,7 +65,7 @@ void ResolveProxyHelper::OnProxyLookupComplete(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(!pending_requests_.empty());
binding_.Close();
receiver_.reset();
// Clear the current (completed) request.
PendingRequest completed_request = std::move(pending_requests_.front());

View file

@ -10,7 +10,7 @@
#include "base/memory/ref_counted.h"
#include "base/optional.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "services/network/public/mojom/proxy_lookup_client.mojom.h"
#include "url/gurl.h"
@ -61,8 +61,8 @@ class ResolveProxyHelper
scoped_refptr<ResolveProxyHelper> owned_self_;
std::deque<PendingRequest> pending_requests_;
// Binding for the currently in-progress request, if any.
mojo::Binding<network::mojom::ProxyLookupClient> binding_;
// Receiver for the currently in-progress request, if any.
mojo::Receiver<network::mojom::ProxyLookupClient> receiver_{this};
// Weak Ref
AtomBrowserContext* browser_context_;

View file

@ -15,6 +15,7 @@
#include "content/public/common/content_features.h"
#include "content/public/common/service_names.mojom.h"
#include "mojo/public/cpp/bindings/associated_interface_ptr.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "net/net_buildflags.h"
#include "services/network/network_service.h"
#include "services/network/public/cpp/cross_thread_shared_url_loader_factory_info.h"
@ -84,10 +85,11 @@ class SystemNetworkContextManager::URLLoaderFactoryForSystem
std::move(client), traffic_annotation);
}
void Clone(network::mojom::URLLoaderFactoryRequest request) override {
void Clone(mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver)
override {
if (!manager_)
return;
manager_->GetURLLoaderFactory()->Clone(std::move(request));
manager_->GetURLLoaderFactory()->Clone(std::move(receiver));
}
// SharedURLLoaderFactory implementation:
@ -127,7 +129,7 @@ network::mojom::NetworkContext* SystemNetworkContextManager::GetContext() {
network::mojom::URLLoaderFactory*
SystemNetworkContextManager::GetURLLoaderFactory() {
// Create the URLLoaderFactory as needed.
if (url_loader_factory_ && !url_loader_factory_.encountered_error()) {
if (url_loader_factory_ && url_loader_factory_.is_connected()) {
return url_loader_factory_.get();
}
@ -135,8 +137,9 @@ SystemNetworkContextManager::GetURLLoaderFactory() {
network::mojom::URLLoaderFactoryParams::New();
params->process_id = network::mojom::kBrowserProcessId;
params->is_corb_enabled = false;
GetContext()->CreateURLLoaderFactory(mojo::MakeRequest(&url_loader_factory_),
std::move(params));
url_loader_factory_.reset();
GetContext()->CreateURLLoaderFactory(
url_loader_factory_.BindNewPipeAndPassReceiver(), std::move(params));
return url_loader_factory_.get();
}

View file

@ -97,7 +97,7 @@ class SystemNetworkContextManager {
// URLLoaderFactory backed by the NetworkContext returned by GetContext(), so
// consumers don't all need to create their own factory.
scoped_refptr<URLLoaderFactoryForSystem> shared_url_loader_factory_;
network::mojom::URLLoaderFactoryPtr url_loader_factory_;
mojo::Remote<network::mojom::URLLoaderFactory> url_loader_factory_;
DISALLOW_COPY_AND_ASSIGN(SystemNetworkContextManager);
};

View file

@ -13,8 +13,8 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/libgtkui/gtk_util.h"
#include "chrome/browser/ui/libgtkui/skia_utils_gtk.h"
#include "shell/browser/notifications/notification_delegate.h"
#include "shell/browser/ui/gtk_util.h"
#include "shell/common/application_info.h"
#include "shell/common/platform_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
@ -111,7 +111,7 @@ void LibnotifyNotification::Show(const NotificationOptions& options) {
libnotify_loader_.notify_notification_set_urgency(notification_, urgency);
if (!options.icon.drawsNothing()) {
GdkPixbuf* pixbuf = libgtkui::GdkPixbufFromSkBitmap(options.icon);
GdkPixbuf* pixbuf = gtk_util::GdkPixbufFromSkBitmap(options.icon);
libnotify_loader_.notify_notification_set_image_from_pixbuf(notification_,
pixbuf);
g_object_unref(pixbuf);

View file

@ -11,6 +11,7 @@
#include "base/i18n/rtl.h"
#include "chrome/browser/ui/autofill/popup_view_common.h"
#include "electron/buildflags/buildflags.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "shell/browser/native_window_views.h"
#include "shell/browser/ui/autofill_popup.h"
#include "shell/common/api/api.mojom.h"
@ -113,9 +114,8 @@ void AutofillPopup::SetItems(const std::vector<base::string16>& values,
}
void AutofillPopup::AcceptSuggestion(int index) {
mojom::ElectronAutofillAgentAssociatedPtr autofill_agent;
frame_host_->GetRemoteAssociatedInterfaces()->GetInterface(
mojo::MakeRequest(&autofill_agent));
mojo::AssociatedRemote<mojom::ElectronAutofillAgent> autofill_agent;
frame_host_->GetRemoteAssociatedInterfaces()->GetInterface(&autofill_agent);
autofill_agent->AcceptDataListSuggestion(GetValueAt(index));
}

View file

@ -60,9 +60,10 @@ class BundledDataSource : public content::URLDataSource {
// content::URLDataSource implementation.
std::string GetSource() override { return kChromeUIDevToolsHost; }
void StartDataRequest(const std::string& path,
void StartDataRequest(const GURL& url,
const content::WebContents::Getter& wc_getter,
const GotDataCallback& callback) override {
const std::string path = content::URLDataSource::URLToRequestPath(url);
// Serve request from local bundle.
std::string bundled_path_prefix(kChromeUIDevToolsBundledPath);
bundled_path_prefix += "/";

View file

@ -5,7 +5,7 @@
#include <memory>
#include "shell/browser/ui/file_dialog.h"
#include "shell/browser/ui/util_gtk.h"
#include "shell/browser/ui/gtk_util.h"
#include "base/callback.h"
#include "base/files/file_util.h"

View file

@ -0,0 +1,82 @@
// 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 "shell/browser/ui/gtk_util.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <stdint.h>
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkUnPreMultiply.h"
namespace gtk_util {
// Copied from L40-L55 in
// https://cs.chromium.org/chromium/src/chrome/browser/ui/libgtkui/select_file_dialog_impl_gtk.cc
#if GTK_CHECK_VERSION(3, 90, 0)
// GTK stock items have been deprecated. The docs say to switch to using the
// strings "_Open", etc. However this breaks i18n. We could supply our own
// internationalized strings, but the "_" in these strings is significant: it's
// the keyboard shortcut to select these actions. TODO: Provide
// internationalized strings when GTK provides support for it.
const char* const kCancelLabel = "_Cancel";
const char* const kNoLabel = "_No";
const char* const kOkLabel = "_OK";
const char* const kOpenLabel = "_Open";
const char* const kSaveLabel = "_Save";
const char* const kYesLabel = "_Yes";
#else
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
const char* const kCancelLabel = GTK_STOCK_CANCEL;
const char* const kNoLabel = GTK_STOCK_NO;
const char* const kOkLabel = GTK_STOCK_OK;
const char* const kOpenLabel = GTK_STOCK_OPEN;
const char* const kSaveLabel = GTK_STOCK_SAVE;
const char* const kYesLabel = GTK_STOCK_YES;
G_GNUC_END_IGNORE_DEPRECATIONS
#endif
GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap& bitmap) {
if (bitmap.isNull())
return nullptr;
int width = bitmap.width();
int height = bitmap.height();
GdkPixbuf* pixbuf =
gdk_pixbuf_new(GDK_COLORSPACE_RGB, // The only colorspace gtk supports.
TRUE, // There is an alpha channel.
8, width, height);
// SkBitmaps are premultiplied, we need to unpremultiply them.
const int kBytesPerPixel = 4;
uint8_t* divided = gdk_pixbuf_get_pixels(pixbuf);
for (int y = 0, i = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
uint32_t pixel = bitmap.getAddr32(0, y)[x];
int alpha = SkColorGetA(pixel);
if (alpha != 0 && alpha != 255) {
SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel);
divided[i + 0] = SkColorGetR(unmultiplied);
divided[i + 1] = SkColorGetG(unmultiplied);
divided[i + 2] = SkColorGetB(unmultiplied);
divided[i + 3] = alpha;
} else {
divided[i + 0] = SkColorGetR(pixel);
divided[i + 1] = SkColorGetG(pixel);
divided[i + 2] = SkColorGetB(pixel);
divided[i + 3] = alpha;
}
i += kBytesPerPixel;
}
}
return pixbuf;
}
} // namespace gtk_util

View file

@ -2,8 +2,12 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_BROWSER_UI_UTIL_GTK_H_
#define SHELL_BROWSER_UI_UTIL_GTK_H_
#ifndef SHELL_BROWSER_UI_GTK_UTIL_H_
#define SHELL_BROWSER_UI_GTK_UTIL_H_
#include <gtk/gtk.h>
class SkBitmap;
namespace gtk_util {
@ -16,6 +20,11 @@ extern const char* const kOpenLabel;
extern const char* const kSaveLabel;
extern const char* const kYesLabel;
// Convert and copy a SkBitmap to a GdkPixbuf. NOTE: this uses BGRAToRGBA, so
// it is an expensive operation. The returned GdkPixbuf will have a refcount of
// 1, and the caller is responsible for unrefing it when done.
GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap& bitmap);
} // namespace gtk_util
#endif // SHELL_BROWSER_UI_UTIL_GTK_H_
#endif // SHELL_BROWSER_UI_GTK_UTIL_H_

View file

@ -805,22 +805,6 @@ bool InspectableWebContentsImpl::DidAddMessageToConsole(
return true;
}
bool InspectableWebContentsImpl::ShouldCreateWebContents(
content::WebContents* web_contents,
content::RenderFrameHost* opener,
content::SiteInstance* source_site_instance,
int32_t route_id,
int32_t main_frame_route_id,
int32_t main_frame_widget_route_id,
content::mojom::WindowContainerType window_container_type,
const GURL& opener_url,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
content::SessionStorageNamespace* session_storage_namespace) {
return false;
}
bool InspectableWebContentsImpl::HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) {

View file

@ -176,19 +176,6 @@ class InspectableWebContentsImpl
const base::string16& message,
int32_t line_no,
const base::string16& source_id) override;
bool ShouldCreateWebContents(
content::WebContents* web_contents,
content::RenderFrameHost* opener,
content::SiteInstance* source_site_instance,
int32_t route_id,
int32_t main_frame_route_id,
int32_t main_frame_widget_route_id,
content::mojom::WindowContainerType window_container_type,
const GURL& opener_url,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
content::SessionStorageNamespace* session_storage_namespace) override;
bool HandleKeyboardEvent(content::WebContents*,
const content::NativeWebKeyboardEvent&) override;
void CloseContents(content::WebContents* source) override;

View file

@ -2,14 +2,13 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/browser/ui/gtk_util.h"
#include "shell/browser/ui/message_box.h"
#include "shell/browser/ui/util_gtk.h"
#include "base/callback.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/libgtkui/gtk_util.h"
#include "chrome/browser/ui/libgtkui/skia_utils_gtk.h"
#include "shell/browser/browser.h"
#include "shell/browser/native_window_observer.h"
#include "shell/browser/native_window_views.h"
@ -56,7 +55,7 @@ class GtkMessageBox : public NativeWindowObserver {
static constexpr int pixel_width = 48;
static constexpr int pixel_height = 48;
GdkPixbuf* pixbuf =
libgtkui::GdkPixbufFromSkBitmap(*settings.icon.bitmap());
gtk_util::GdkPixbufFromSkBitmap(*settings.icon.bitmap());
GdkPixbuf* scaled_pixbuf = gdk_pixbuf_scale_simple(
pixbuf, pixel_width, pixel_height, GDK_INTERP_BILINEAR);
GtkWidget* w = gtk_image_new_from_pixbuf(scaled_pixbuf);

View file

@ -1,36 +0,0 @@
// 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 "shell/browser/ui/util_gtk.h"
#include <gtk/gtk.h>
namespace gtk_util {
// Copied from L40-L55 in
// https://cs.chromium.org/chromium/src/chrome/browser/ui/libgtkui/select_file_dialog_impl_gtk.cc
#if GTK_CHECK_VERSION(3, 90, 0)
// GTK stock items have been deprecated. The docs say to switch to using the
// strings "_Open", etc. However this breaks i18n. We could supply our own
// internationalized strings, but the "_" in these strings is significant: it's
// the keyboard shortcut to select these actions. TODO: Provide
// internationalized strings when GTK provides support for it.
const char* const kCancelLabel = "_Cancel";
const char* const kNoLabel = "_No";
const char* const kOkLabel = "_OK";
const char* const kOpenLabel = "_Open";
const char* const kSaveLabel = "_Save";
const char* const kYesLabel = "_Yes";
#else
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
const char* const kCancelLabel = GTK_STOCK_CANCEL;
const char* const kNoLabel = GTK_STOCK_NO;
const char* const kOkLabel = GTK_STOCK_OK;
const char* const kOpenLabel = GTK_STOCK_OPEN;
const char* const kSaveLabel = GTK_STOCK_SAVE;
const char* const kYesLabel = GTK_STOCK_YES;
G_GNUC_END_IGNORE_DEPRECATIONS
#endif
} // namespace gtk_util