Merge pull request #10213 from electron/upgrade-to-chromium-61

[WIP] Upgrade to Chromium 61
This commit is contained in:
shelley vohr 2017-11-24 10:17:52 +01:00 committed by GitHub
commit c18afc924b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
147 changed files with 897 additions and 623 deletions

View file

@ -6,7 +6,7 @@ jobs:
- image: electronbuilds/electron:0.0.3
environment:
TARGET_ARCH: arm
resource_class: xlarge
resource_class: 2xlarge
steps:
- checkout
- run:
@ -63,7 +63,7 @@ jobs:
- image: electronbuilds/electron:0.0.3
environment:
TARGET_ARCH: arm64
resource_class: xlarge
resource_class: 2xlarge
steps:
- checkout
- run:

View file

@ -12,6 +12,7 @@
#include "atom/common/native_mate_converters/string16_converter.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/task_scheduler/task_scheduler.h"
#include "base/threading/thread_task_runner_handle.h"
#include "gin/array_buffer.h"
#include "gin/public/isolate_holder.h"
@ -40,6 +41,10 @@ int NodeMain(int argc, char *argv[]) {
gin::V8Initializer::LoadV8Snapshot();
gin::V8Initializer::LoadV8Natives();
// V8 requires a task scheduler apparently
base::TaskScheduler::CreateAndStartWithDefaultParams("Electron");
JavascriptEnvironment gin_env;
int exec_argc;
@ -88,6 +93,13 @@ int NodeMain(int argc, char *argv[]) {
node::FreeEnvironment(env);
}
// According to "src/gin/shell/gin_main.cc":
//
// gin::IsolateHolder waits for tasks running in TaskScheduler in its
// destructor and thus must be destroyed before TaskScheduler starts skipping
// CONTINUE_ON_SHUTDOWN tasks.
base::TaskScheduler::GetInstance()->Shutdown();
v8::V8::Dispose();
return exit_code;

View file

@ -31,7 +31,7 @@ bool UvTaskRunner::PostDelayedTask(const tracked_objects::Location& from_here,
return true;
}
bool UvTaskRunner::RunsTasksOnCurrentThread() const {
bool UvTaskRunner::RunsTasksInCurrentSequence() const {
return true;
}

View file

@ -23,7 +23,7 @@ class UvTaskRunner : public base::SingleThreadTaskRunner {
bool PostDelayedTask(const tracked_objects::Location& from_here,
base::OnceClosure task,
base::TimeDelta delay) override;
bool RunsTasksOnCurrentThread() const override;
bool RunsTasksInCurrentSequence() const override;
bool PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
base::OnceClosure task,

View file

@ -45,6 +45,7 @@
#include "content/public/common/content_switches.h"
#include "media/audio/audio_manager.h"
#include "native_mate/object_template_builder.h"
#include "net/ssl/client_cert_identity.h"
#include "net/ssl/ssl_cert_request_info.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/image/image.h"
@ -420,19 +421,26 @@ bool NotificationCallbackWrapper(
return !Browser::Get()->is_shutting_down();
}
void GotPrivateKey(std::shared_ptr<content::ClientCertificateDelegate> delegate,
scoped_refptr<net::X509Certificate> cert,
scoped_refptr<net::SSLPrivateKey> private_key) {
delegate->ContinueWithCertificate(cert, private_key);
}
void OnClientCertificateSelected(
v8::Isolate* isolate,
std::shared_ptr<content::ClientCertificateDelegate> delegate,
std::shared_ptr<net::ClientCertIdentityList> identities,
mate::Arguments* args) {
if (args->Length() == 2) {
delegate->ContinueWithCertificate(nullptr);
delegate->ContinueWithCertificate(nullptr, nullptr);
return;
}
v8::Local<v8::Value> val;
args->GetNext(&val);
if (val->IsNull()) {
delegate->ContinueWithCertificate(nullptr);
delegate->ContinueWithCertificate(nullptr, nullptr);
return;
}
@ -448,8 +456,17 @@ void OnClientCertificateSelected(
auto certs = net::X509Certificate::CreateCertificateListFromBytes(
data.c_str(), data.length(), net::X509Certificate::FORMAT_AUTO);
if (!certs.empty())
delegate->ContinueWithCertificate(certs[0].get());
if (!certs.empty()) {
scoped_refptr<net::X509Certificate> cert(certs[0].get());
for (size_t i = 0; i < identities->size(); ++i) {
if (cert->Equals((*identities)[i]->certificate())) {
net::ClientCertIdentity::SelfOwningAcquirePrivateKey(
std::move((*identities)[i]),
base::Bind(&GotPrivateKey, delegate, std::move(cert)));
break;
}
}
}
}
void PassLoginInformation(scoped_refptr<LoginHandler> login_handler,
@ -655,15 +672,12 @@ void App::OnCreateWindow(
const std::string& frame_name,
WindowOpenDisposition disposition,
const std::vector<std::string>& features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
int render_process_id,
int render_frame_id) {
const scoped_refptr<content::ResourceRequestBody>& body,
content::RenderFrameHost* opener) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
content::RenderFrameHost* rfh =
content::RenderFrameHost::FromID(render_process_id, render_frame_id);
content::WebContents* web_contents =
content::WebContents::FromRenderFrameHost(rfh);
content::WebContents::FromRenderFrameHost(opener);
if (web_contents) {
auto api_web_contents = WebContents::CreateFrom(isolate(), web_contents);
api_web_contents->OnCreateWindow(target_url,
@ -702,22 +716,35 @@ void App::AllowCertificateError(
void App::SelectClientCertificate(
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
net::ClientCertIdentityList identities,
std::unique_ptr<content::ClientCertificateDelegate> delegate) {
std::shared_ptr<content::ClientCertificateDelegate>
shared_delegate(delegate.release());
// Convert the ClientCertIdentityList to a CertificateList
// to avoid changes in the API.
auto client_certs = net::CertificateList();
for (const std::unique_ptr<net::ClientCertIdentity>& identity : identities)
client_certs.push_back(identity->certificate());
auto shared_identities =
std::make_shared<net::ClientCertIdentityList>(std::move(identities));
bool prevent_default =
Emit("select-client-certificate",
WebContents::CreateFrom(isolate(), web_contents),
cert_request_info->host_and_port.ToString(),
cert_request_info->client_certs,
base::Bind(&OnClientCertificateSelected,
isolate(),
shared_delegate));
cert_request_info->host_and_port.ToString(), std::move(client_certs),
base::Bind(&OnClientCertificateSelected, isolate(), shared_delegate,
shared_identities));
// Default to first certificate from the platform store.
if (!prevent_default)
shared_delegate->ContinueWithCertificate(
cert_request_info->client_certs[0].get());
if (!prevent_default) {
scoped_refptr<net::X509Certificate> cert =
(*shared_identities)[0]->certificate();
net::ClientCertIdentity::SelfOwningAcquirePrivateKey(
std::move((*shared_identities)[0]),
base::Bind(&GotPrivateKey, shared_delegate, std::move(cert)));
}
}
void App::OnGpuProcessCrashed(base::TerminationStatus status) {

View file

@ -25,6 +25,7 @@
#include "native_mate/dictionary.h"
#include "native_mate/handle.h"
#include "net/base/completion_callback.h"
#include "net/ssl/client_cert_identity.h"
#if defined(USE_NSS_CERTS)
#include "chrome/browser/certificate_manager_model.h"
@ -80,9 +81,8 @@ class App : public AtomBrowserClient::Delegate,
const std::string& frame_name,
WindowOpenDisposition disposition,
const std::vector<std::string>& features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
int render_process_id,
int render_frame_id);
const scoped_refptr<content::ResourceRequestBody>& body,
content::RenderFrameHost* opener);
#if defined(USE_NSS_CERTS)
void OnCertificateManagerModelCreated(
@ -150,6 +150,7 @@ class App : public AtomBrowserClient::Delegate,
void SelectClientCertificate(
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
net::ClientCertIdentityList client_certs,
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
// content::GpuDataManagerObserver:

View file

@ -10,6 +10,7 @@
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "base/json/json_writer.h"
#include "base/memory/ptr_util.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/web_contents.h"
#include "native_mate/dictionary.h"
@ -143,7 +144,7 @@ void Debugger::SendCommand(mate::Arguments* args) {
request.SetInteger("id", request_id);
request.SetString("method", method);
if (!command_params.empty())
request.Set("params", command_params.DeepCopy());
request.Set("params", base::WrapUnique(command_params.DeepCopy()));
std::string json_args;
base::JSONWriter::Write(request, &json_args);

View file

@ -53,8 +53,7 @@ class Menu : public mate::TrackableObject<Menu>,
void ExecuteCommand(int command_id, int event_flags) override;
void MenuWillShow(ui::SimpleMenuModel* source) override;
virtual void PopupAt(
Window* window, int x, int y, int positioning_item, bool async) = 0;
virtual void PopupAt(Window* window, int x, int y, int positioning_item) = 0;
virtual void ClosePopupAt(int32_t window_id) = 0;
std::unique_ptr<AtomMenuModel> model_;

View file

@ -22,11 +22,12 @@ class MenuMac : public Menu {
protected:
MenuMac(v8::Isolate* isolate, v8::Local<v8::Object> wrapper);
void PopupAt(
Window* window, int x, int y, int positioning_item, bool async) override;
void PopupAt(Window* window, int x, int y, int positioning_item) override;
void PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
int32_t window_id, int x, int y, int positioning_item,
bool async);
int32_t window_id,
int x,
int y,
int positioning_item);
void ClosePopupAt(int32_t window_id) override;
private:

View file

@ -27,24 +27,22 @@ MenuMac::MenuMac(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
weak_factory_(this) {
}
void MenuMac::PopupAt(
Window* window, int x, int y, int positioning_item, bool async) {
void MenuMac::PopupAt(Window* window, int x, int y, int positioning_item) {
NativeWindow* native_window = window->window();
if (!native_window)
return;
auto popup = base::Bind(&MenuMac::PopupOnUI, weak_factory_.GetWeakPtr(),
native_window->GetWeakPtr(), window->ID(), x, y,
positioning_item, async);
if (async)
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, popup);
else
popup.Run();
positioning_item);
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, popup);
}
void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
int32_t window_id, int x, int y, int positioning_item,
bool async) {
int32_t window_id,
int x,
int y,
int positioning_item) {
if (!native_window)
return;
brightray::InspectableWebContents* web_contents =
@ -92,29 +90,21 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
if (rightmostMenuPoint > screenRight)
position.x = position.x - [menu size].width;
[popup_controllers_[window_id] setCloseCallback:close_callback];
// Make sure events can be pumped while the menu is up.
base::MessageLoop::ScopedNestableTaskAllower allow(
base::MessageLoop::current());
if (async) {
[popup_controllers_[window_id] setCloseCallback:close_callback];
// Make sure events can be pumped while the menu is up.
base::MessageLoop::ScopedNestableTaskAllower allow(
base::MessageLoop::current());
// One of the events that could be pumped is |window.close()|.
// User-initiated event-tracking loops protect against this by
// setting flags in -[CrApplication sendEvent:], but since
// web-content menus are initiated by IPC message the setup has to
// be done manually.
base::mac::ScopedSendingEvent sendingEventScoper;
// One of the events that could be pumped is |window.close()|.
// User-initiated event-tracking loops protect against this by
// setting flags in -[CrApplication sendEvent:], but since
// web-content menus are initiated by IPC message the setup has to
// be done manually.
base::mac::ScopedSendingEvent sendingEventScoper;
// Don't emit unresponsive event when showing menu.
atom::UnresponsiveSuppressor suppressor;
[menu popUpMenuPositioningItem:item atLocation:position inView:view];
} else {
// Don't emit unresponsive event when showing menu.
atom::UnresponsiveSuppressor suppressor;
[menu popUpMenuPositioningItem:item atLocation:position inView:view];
close_callback.Run();
}
// Don't emit unresponsive event when showing menu.
atom::UnresponsiveSuppressor suppressor;
[menu popUpMenuPositioningItem:item atLocation:position inView:view];
}
void MenuMac::ClosePopupAt(int32_t window_id) {

View file

@ -20,8 +20,7 @@ MenuViews::MenuViews(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
weak_factory_(this) {
}
void MenuViews::PopupAt(
Window* window, int x, int y, int positioning_item, bool async) {
void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) {
NativeWindow* native_window = static_cast<NativeWindow*>(window->window());
if (!native_window)
return;
@ -42,8 +41,6 @@ void MenuViews::PopupAt(
}
int flags = MenuRunner::CONTEXT_MENU | MenuRunner::HAS_MNEMONICS;
if (async)
flags |= MenuRunner::ASYNC;
// Don't emit unresponsive event when showing menu.
atom::UnresponsiveSuppressor suppressor;
@ -54,12 +51,12 @@ void MenuViews::PopupAt(
&MenuViews::ClosePopupAt, weak_factory_.GetWeakPtr(), window_id);
menu_runners_[window_id] = std::unique_ptr<MenuRunner>(new MenuRunner(
model(), flags, close_callback));
ignore_result(menu_runners_[window_id]->RunMenuAt(
menu_runners_[window_id]->RunMenuAt(
static_cast<NativeWindowViews*>(window->window())->widget(),
NULL,
gfx::Rect(location, gfx::Size()),
views::MENU_ANCHOR_TOPLEFT,
ui::MENU_SOURCE_MOUSE));
ui::MENU_SOURCE_MOUSE);
}
void MenuViews::ClosePopupAt(int32_t window_id) {

View file

@ -21,8 +21,7 @@ class MenuViews : public Menu {
MenuViews(v8::Isolate* isolate, v8::Local<v8::Object> wrapper);
protected:
void PopupAt(
Window* window, int x, int y, int positioning_item, bool async) override;
void PopupAt(Window* window, int x, int y, int positioning_item) override;
void ClosePopupAt(int32_t window_id) override;
private:

View file

@ -9,13 +9,15 @@
#include "atom/common/native_mate_converters/gfx_converter.h"
#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/node_includes.h"
#include "base/strings/utf_string_conversions.h"
#include "brightray/browser/browser_client.h"
#include "native_mate/constructor.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
#include "url/gurl.h"
// Must be the last in the includes list.
// See https://github.com/electron/electron/issues/10363
#include "atom/common/node_includes.h"
namespace mate {
template<>

View file

@ -9,8 +9,8 @@
#include <memory>
#include "atom/browser/api/trackable_object.h"
#include "device/power_save_blocker/power_save_blocker.h"
#include "native_mate/handle.h"
#include "services/device/wake_lock/power_save_blocker/power_save_blocker.h"
namespace mate {
class Dictionary;

View file

@ -623,7 +623,8 @@ void Session::SetUserAgent(const std::string& user_agent,
std::string accept_lang = l10n_util::GetApplicationLocale("");
args->GetNext(&accept_lang);
auto getter = browser_context_->GetRequestContext();
scoped_refptr<brightray::URLRequestContextGetter> getter(
browser_context_->GetRequestContext());
getter->GetNetworkTaskRunner()->PostTask(
FROM_HERE,
base::Bind(&SetUserAgentInIO, getter, accept_lang, user_agent));

View file

@ -43,6 +43,7 @@
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/options_switches.h"
#include "base/message_loop/message_loop.h"
#include "base/process/process_handle.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
@ -493,19 +494,20 @@ void WebContents::OnCreateWindow(
const std::string& frame_name,
WindowOpenDisposition disposition,
const std::vector<std::string>& features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body) {
const scoped_refptr<content::ResourceRequestBody>& body) {
if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN)
Emit("-new-window", target_url, frame_name, disposition, features, body);
else
Emit("new-window", target_url, frame_name, disposition, features);
}
void WebContents::WebContentsCreated(content::WebContents* source_contents,
int opener_render_process_id,
int opener_render_frame_id,
const std::string& frame_name,
const GURL& target_url,
content::WebContents* new_contents) {
void WebContents::WebContentsCreated(
content::WebContents* source_contents,
int opener_render_process_id,
int opener_render_frame_id,
const std::string& frame_name,
const GURL& target_url,
content::WebContents* new_contents) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
auto api_web_contents = CreateFrom(isolate(), new_contents, BROWSER_WINDOW);
@ -836,10 +838,10 @@ void WebContents::DidFinishNavigation(
bool is_main_frame = navigation_handle->IsInMainFrame();
if (navigation_handle->HasCommitted() && !navigation_handle->IsErrorPage()) {
auto url = navigation_handle->GetURL();
bool is_in_page = navigation_handle->IsSameDocument();
if (is_main_frame && !is_in_page) {
bool is_same_document = navigation_handle->IsSameDocument();
if (is_main_frame && !is_same_document) {
Emit("did-navigate", url);
} else if (is_in_page) {
} else if (is_same_document) {
Emit("did-navigate-in-page", url, is_main_frame);
}
} else {
@ -864,7 +866,7 @@ void WebContents::DidUpdateFaviconURL(
const std::vector<content::FaviconURL>& urls) {
std::set<GURL> unique_urls;
for (const auto& iter : urls) {
if (iter.icon_type != content::FaviconURL::FAVICON)
if (iter.icon_type != content::FaviconURL::IconType::kFavicon)
continue;
const GURL& url = iter.icon_url;
if (url.is_valid())
@ -986,7 +988,7 @@ void WebContents::WebContentsDestroyed() {
void WebContents::NavigationEntryCommitted(
const content::LoadCommittedDetails& details) {
Emit("navigation-entry-commited", details.entry->GetURL(),
details.is_in_page, details.did_replace_entry);
details.is_same_document, details.did_replace_entry);
}
int64_t WebContents::GetID() const {
@ -1042,7 +1044,7 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
if (options.Get("extraHeaders", &extra_headers))
params.extra_headers = extra_headers;
scoped_refptr<content::ResourceRequestBodyImpl> body;
scoped_refptr<content::ResourceRequestBody> body;
if (options.Get("postData", &body)) {
params.post_data = body;
params.load_type = content::NavigationController::LOAD_TYPE_HTTP_POST;
@ -1083,7 +1085,7 @@ void WebContents::DownloadURL(const GURL& url) {
download_manager->DownloadUrl(
content::DownloadUrlParameters::CreateForWebContentsMainFrame(
web_contents(), url));
web_contents(), url, NO_TRAFFIC_ANNOTATION_YET));
}
GURL WebContents::GetURL() const {
@ -1476,7 +1478,8 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
if (!view)
return;
int type = mate::GetWebInputEventType(isolate, input_event);
blink::WebInputEvent::Type type = mate::GetWebInputEventType(isolate,
input_event);
if (blink::WebInputEvent::IsMouseEventType(type)) {
blink::WebMouseEvent mouse_event;
if (mate::ConvertFromV8(isolate, input_event, &mouse_event)) {
@ -1489,7 +1492,7 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
blink::WebInputEvent::kNoModifiers,
ui::EventTimeForNow());
if (mate::ConvertFromV8(isolate, input_event, &keyboard_event)) {
view->ProcessKeyboardEvent(keyboard_event);
view->ProcessKeyboardEvent(keyboard_event, ui::LatencyInfo());
return;
}
} else if (type == blink::WebInputEvent::kMouseWheel) {

View file

@ -15,6 +15,7 @@
#include "atom/browser/ui/autofill_popup.h"
#include "content/common/cursors/webcursor.h"
#include "content/public/browser/keyboard_event_processing_result.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/favicon_url.h"
#include "native_mate/handle.h"
@ -30,7 +31,7 @@ class InspectableWebContents;
}
namespace content {
class ResourceRequestBodyImpl;
class ResourceRequestBody;
}
namespace mate {
@ -208,7 +209,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
const std::string& frame_name,
WindowOpenDisposition disposition,
const std::vector<std::string>& features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body);
const scoped_refptr<content::ResourceRequestBody>& body);
// Returns the web preferences of current WebContents.
v8::Local<v8::Value> GetWebPreferences(v8::Isolate* isolate);
@ -247,12 +248,14 @@ class WebContents : public mate::TrackableObject<WebContents>,
const base::string16& message,
int32_t line_no,
const base::string16& source_id) override;
void WebContentsCreated(content::WebContents* source_contents,
int opener_render_process_id,
int opener_render_frame_id,
const std::string& frame_name,
const GURL& target_url,
content::WebContents* new_contents) override;
void WebContentsCreated(
content::WebContents* source_contents,
int opener_render_process_id,
int opener_render_frame_id,
const std::string& frame_name,
const GURL& target_url,
content::WebContents* new_contents)
override;
void AddNewContents(content::WebContents* source,
content::WebContents* new_contents,
WindowOpenDisposition disposition,

View file

@ -7,10 +7,12 @@
#include "atom/browser/web_view_manager.h"
#include "atom/common/native_mate_converters/content_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "atom/common/options_switches.h"
#include "content/public/browser/browser_context.h"
#include "native_mate/dictionary.h"
// Must be the last in the includes list.
// See https://github.com/electron/electron/issues/10363
#include "atom/common/node_includes.h"
using atom::WebContentsPreferences;

View file

@ -89,7 +89,6 @@ void FrameSubscriber::OnFrameDelivered(const FrameCaptureCallback& callback,
auto local_buffer = buffer.ToLocalChecked();
{
SkAutoLockPixels lock(bitmap);
auto source = static_cast<const unsigned char*>(bitmap.getPixels());
auto target = node::Buffer::Data(local_buffer);

View file

@ -29,8 +29,7 @@ class GeoURLRequestContextGetter : public net::URLRequestContextGetter {
net::URLRequestContextBuilder builder;
builder.set_proxy_config_service(
net::ProxyService::CreateSystemProxyConfigService(
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)));
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)));
url_request_context_ = builder.Build();
}
return url_request_context_.get();

View file

@ -72,8 +72,7 @@ void AtomBlobReader::StartReading(
}
auto blob_reader = blob_data_handle->CreateReader(
file_system_context_.get(),
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get());
file_system_context_.get());
BlobReadHelper* blob_read_helper =
new BlobReadHelper(std::move(blob_reader), callback);
blob_read_helper->Read();

View file

@ -30,7 +30,6 @@
#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
#include "chrome/browser/renderer_host/pepper/widevine_cdm_message_filter.h"
#include "chrome/browser/speech/tts_message_filter.h"
#include "content/common/resource_request_body_impl.h"
#include "content/public/browser/browser_ppapi_host.h"
#include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/render_process_host.h"
@ -39,6 +38,7 @@
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/resource_request_body.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/web_preferences.h"
#include "net/ssl/ssl_cert_request_info.h"
@ -184,7 +184,6 @@ void AtomBrowserClient::OverrideWebkitPrefs(
content::RenderViewHost* host, content::WebPreferences* prefs) {
prefs->javascript_enabled = true;
prefs->web_security_enabled = true;
prefs->javascript_can_open_windows_automatically = true;
prefs->plugins_enabled = true;
prefs->dom_paste_enabled = true;
prefs->allow_scripts_to_close_windows = true;
@ -316,10 +315,12 @@ void AtomBrowserClient::AllowCertificateError(
void AtomBrowserClient::SelectClientCertificate(
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
net::ClientCertIdentityList client_certs,
std::unique_ptr<content::ClientCertificateDelegate> delegate) {
if (!cert_request_info->client_certs.empty() && delegate_) {
delegate_->SelectClientCertificate(
web_contents, cert_request_info, std::move(delegate));
if (!client_certs.empty() && delegate_) {
delegate_->SelectClientCertificate(web_contents, cert_request_info,
std::move(client_certs),
std::move(delegate));
}
}
@ -331,8 +332,7 @@ void AtomBrowserClient::ResourceDispatcherHostCreated() {
}
bool AtomBrowserClient::CanCreateWindow(
int opener_render_process_id,
int opener_render_frame_id,
content::RenderFrameHost* opener,
const GURL& opener_url,
const GURL& opener_top_level_frame_url,
const GURL& source_origin,
@ -343,13 +343,14 @@ bool AtomBrowserClient::CanCreateWindow(
WindowOpenDisposition disposition,
const blink::mojom::WindowFeatures& features,
const std::vector<std::string>& additional_features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
const scoped_refptr<content::ResourceRequestBody>& body,
bool user_gesture,
bool opener_suppressed,
content::ResourceContext* context,
bool* no_javascript_access) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
int opener_render_process_id = opener->GetProcess()->GetID();
if (IsRendererSandboxed(opener_render_process_id)) {
*no_javascript_access = false;
return true;
@ -375,8 +376,7 @@ bool AtomBrowserClient::CanCreateWindow(
disposition,
additional_features,
body,
opener_render_process_id,
opener_render_frame_id));
opener));
}
return false;

View file

@ -12,6 +12,7 @@
#include "brightray/browser/browser_client.h"
#include "content/public/browser/render_process_host_observer.h"
#include "net/ssl/client_cert_identity.h"
namespace content {
class QuotaPermissionContext;
@ -77,11 +78,11 @@ class AtomBrowserClient : public brightray::BrowserClient,
void SelectClientCertificate(
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
net::ClientCertIdentityList client_certs,
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
void ResourceDispatcherHostCreated() override;
bool CanCreateWindow(
int opener_render_process_id,
int opener_render_frame_id,
content::RenderFrameHost* opener,
const GURL& opener_url,
const GURL& opener_top_level_frame_url,
const GURL& source_origin,
@ -92,10 +93,9 @@ class AtomBrowserClient : public brightray::BrowserClient,
WindowOpenDisposition disposition,
const blink::mojom::WindowFeatures& features,
const std::vector<std::string>& additional_features,
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
const scoped_refptr<content::ResourceRequestBody>& body,
bool user_gesture,
bool opener_suppressed,
content::ResourceContext* context,
bool* no_javascript_access) override;
void GetAdditionalAllowedSchemesForFileSystem(
std::vector<std::string>* schemes) override;

View file

@ -81,7 +81,7 @@ void OnPdfResourceIntercepted(
download_manager->DownloadUrl(
content::DownloadUrlParameters::CreateForWebContentsMainFrame(
web_contents, original_url));
web_contents, original_url, NO_TRAFFIC_ANNOTATION_YET));
return;
}

View file

@ -52,8 +52,8 @@ void AtomSpeechRecognitionManagerDelegate::OnAudioLevelsChange(
void AtomSpeechRecognitionManagerDelegate::CheckRecognitionIsAllowed(
int session_id,
base::Callback<void(bool ask_user, bool is_allowed)> callback) {
callback.Run(true, true);
base::OnceCallback<void(bool ask_user, bool is_allowed)> callback) {
std::move(callback).Run(true, true);
}
content::SpeechRecognitionEventListener*

View file

@ -38,7 +38,8 @@ class AtomSpeechRecognitionManagerDelegate
// content::SpeechRecognitionManagerDelegate:
void CheckRecognitionIsAllowed(
int session_id,
base::Callback<void(bool ask_user, bool is_allowed)> callback) override;
base::OnceCallback<void(bool ask_user, bool is_allowed)> callback)
override;
content::SpeechRecognitionEventListener* GetEventListener() override;
bool FilterProfanities(int render_process_id) override;

View file

@ -35,12 +35,12 @@ bool BridgeTaskRunner::PostDelayedTask(
from_here, std::move(task), delay);
}
bool BridgeTaskRunner::RunsTasksOnCurrentThread() const {
bool BridgeTaskRunner::RunsTasksInCurrentSequence() const {
auto message_loop = base::MessageLoop::current();
if (!message_loop)
return true;
return message_loop->task_runner()->RunsTasksOnCurrentThread();
return message_loop->task_runner()->RunsTasksInCurrentSequence();
}
bool BridgeTaskRunner::PostNonNestableDelayedTask(

View file

@ -27,7 +27,7 @@ class BridgeTaskRunner : public base::SingleThreadTaskRunner {
bool PostDelayedTask(const tracked_objects::Location& from_here,
base::OnceClosure task,
base::TimeDelta delay) override;
bool RunsTasksOnCurrentThread() const override;
bool RunsTasksInCurrentSequence() const override;
bool PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
base::OnceClosure task,

View file

@ -11,6 +11,7 @@
#include "atom/browser/native_window.h"
#include "atom/browser/window_list.h"
#include "base/files/file_util.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/threading/thread_task_runner_handle.h"

View file

@ -180,12 +180,13 @@ void CommonWebContentsDelegate::SetOwnerWindow(NativeWindow* owner_window) {
void CommonWebContentsDelegate::SetOwnerWindow(
content::WebContents* web_contents, NativeWindow* owner_window) {
owner_window_ = owner_window ? owner_window->GetWeakPtr() : nullptr;
NativeWindowRelay* relay = new NativeWindowRelay(owner_window_);
auto relay = base::MakeUnique<NativeWindowRelay>(owner_window_);
auto relay_key = relay->key;
if (owner_window) {
web_contents->SetUserData(relay->key, relay);
web_contents->SetUserData(relay_key, std::move(relay));
} else {
web_contents->RemoveUserData(relay->key);
delete relay;
web_contents->RemoveUserData(relay_key);
relay.reset();
}
}

View file

@ -14,7 +14,7 @@
#include "base/strings/sys_string_conversions.h"
#include "base/values.h"
#if BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM)
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
// On macOS 10.12, the IME system attempts to allocate a 2^64 size buffer,
// which would typically cause an OOM crash. To avoid this, the problematic
// method is swizzled out and the make-OOM-fatal bit is disabled for the
@ -35,7 +35,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
base::allocator::SetCallNewHandlerOnMallocFailure(true);
}
@end
#endif // BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM)
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
@implementation AtomApplicationDelegate
@ -63,7 +63,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
atom::Browser::Get()->DidFinishLaunching(*empty_info);
}
#if BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM)
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
// Disable fatal OOM to hack around an OS bug https://crbug.com/654695.
if (base::mac::IsOS10_12()) {
g_swizzle_imk_input_session = new base::mac::ScopedObjCClassSwizzler(

View file

@ -24,7 +24,7 @@ void NativeBrowserViewViews::SetBounds(const gfx::Rect& bounds) {
void NativeBrowserViewViews::SetBackgroundColor(SkColor color) {
auto* view = GetInspectableWebContentsView()->GetView();
view->set_background(views::Background::CreateSolidBackground(color));
view->SetBackground(views::CreateSolidBackground(color));
}
// static

View file

@ -4,6 +4,9 @@
#include "atom/browser/native_window_views.h"
#if defined(OS_WIN)
#include <objbase.h>
#endif
#include <string>
#include <vector>
@ -757,8 +760,9 @@ void NativeWindowViews::FlashFrame(bool flash) {
void NativeWindowViews::SetSkipTaskbar(bool skip) {
#if defined(OS_WIN)
base::win::ScopedComPtr<ITaskbarList> taskbar;
if (FAILED(taskbar.CreateInstance(CLSID_TaskbarList, NULL,
CLSCTX_INPROC_SERVER)) ||
if (FAILED(::CoCreateInstance(CLSID_TaskbarList, nullptr,
CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&taskbar))) ||
FAILED(taskbar->HrInit()))
return;
if (skip) {
@ -792,7 +796,7 @@ bool NativeWindowViews::IsKiosk() {
void NativeWindowViews::SetBackgroundColor(const std::string& color_name) {
// web views' background color.
SkColor background_color = ParseHexColor(color_name);
set_background(views::Background::CreateSolidBackground(background_color));
SetBackground(views::CreateSolidBackground(background_color));
#if defined(OS_WIN)
// Set the background color of native window.

View file

@ -69,7 +69,8 @@ scoped_refptr<AtomURLRequest> AtomURLRequest::Create(
if (!browser_context || url.empty() || !delegate) {
return nullptr;
}
auto request_context_getter = browser_context->url_request_context_getter();
scoped_refptr<brightray::URLRequestContextGetter> request_context_getter(
browser_context->url_request_context_getter());
DCHECK(request_context_getter);
if (!request_context_getter) {
return nullptr;
@ -439,7 +440,7 @@ bool AtomURLRequest::CopyAndPostBuffer(int bytes_read) {
// data is only a wrapper for the asynchronous response_read_buffer_.
// Make a deep copy of payload and transfer ownership to the UI thread.
auto buffer_copy = new net::IOBufferWithSize(bytes_read);
auto buffer_copy = make_scoped_refptr(new net::IOBufferWithSize(bytes_read));
memcpy(buffer_copy->data(), response_read_buffer_->data(), bytes_read);
return content::BrowserThread::PostTask(

View file

@ -41,7 +41,7 @@ void URLRequestBufferJob::StartAsync(std::unique_ptr<base::Value> options) {
dict->GetString("charset", &charset_);
dict->GetBinary("data", &binary);
} else if (options->IsType(base::Value::Type::BINARY)) {
options->GetAsBinary(&binary);
binary = options.get();
}
if (mime_type_.empty()) {
@ -60,8 +60,8 @@ void URLRequestBufferJob::StartAsync(std::unique_ptr<base::Value> options) {
}
data_ = new base::RefCountedBytes(
reinterpret_cast<const unsigned char*>(binary->GetBuffer()),
binary->GetSize());
reinterpret_cast<const unsigned char*>(binary->GetBlob().data()),
binary->GetBlob().size());
status_code_ = net::HTTP_OK;
net::URLRequestSimpleJob::Start();
}

View file

@ -98,7 +98,6 @@ void URLRequestFetchJob::BeforeStartInUI(
url_request_context_getter_ = new brightray::URLRequestContextGetter(
this, nullptr, nullptr, base::FilePath(), true,
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE),
nullptr, content::URLRequestInterceptorScopedVector());
} else {
mate::Handle<api::Session> session;

View file

@ -13,10 +13,13 @@
namespace atom {
NodeDebugger::NodeDebugger(node::Environment* env) : env_(env) {
NodeDebugger::NodeDebugger(node::Environment* env)
: env_(env), platform_(nullptr) {
}
NodeDebugger::~NodeDebugger() {
if (platform_)
FreePlatform(platform_);
}
void NodeDebugger::Start() {
@ -35,17 +38,20 @@ void NodeDebugger::Start() {
if (options.inspector_enabled()) {
// Use custom platform since the gin platform does not work correctly
// with node's inspector agent
platform_.reset(v8::platform::CreateDefaultPlatform());
// with node's inspector agent. We use the default thread pool size
// specified by node.cc
platform_ = node::CreatePlatform(
/* thread_pool_size */ 4, env_->event_loop(),
/* tracing_controller */ nullptr);
// Set process._debugWaitConnect if --inspect-brk was specified to stop
// the debugger on the first line
if (options.wait_for_connect()) {
mate::Dictionary process(env_->isolate(), env_->process_object());
process.Set("_debugWaitConnect", true);
process.Set("_breakFirstLine", true);
}
inspector->Start(platform_.get(), nullptr, options);
inspector->Start(platform_, nullptr, options);
}
}

View file

@ -5,16 +5,11 @@
#ifndef ATOM_BROWSER_NODE_DEBUGGER_H_
#define ATOM_BROWSER_NODE_DEBUGGER_H_
#include <memory>
#include "base/macros.h"
namespace node {
class Environment;
}
namespace v8 {
class Platform;
class NodePlatform;
}
namespace atom {
@ -29,7 +24,7 @@ class NodeDebugger {
private:
node::Environment* env_;
std::unique_ptr<v8::Platform> platform_;
node::NodePlatform* platform_;
DISALLOW_COPY_AND_ASSIGN(NodeDebugger);
};

View file

@ -84,18 +84,21 @@ void OffScreenOutputDevice::SetActive(bool active, bool paint) {
return;
active_ = active;
if (active_ && paint)
if (!active_ && !pending_damage_rect_.IsEmpty() && paint)
OnPaint(gfx::Rect(viewport_pixel_size_));
}
void OffScreenOutputDevice::OnPaint(const gfx::Rect& damage_rect) {
gfx::Rect rect = damage_rect;
if (!pending_damage_rect_.IsEmpty()) {
rect.Union(pending_damage_rect_);
pending_damage_rect_.SetRect(0, 0, 0, 0);
}
rect.Intersect(gfx::Rect(viewport_pixel_size_));
if (rect.IsEmpty())
return;
SkAutoLockPixels bitmap_pixels_lock(*bitmap_);
callback_.Run(rect, *bitmap_);
}

View file

@ -35,6 +35,7 @@ class OffScreenOutputDevice : public cc::SoftwareOutputDevice {
std::unique_ptr<SkCanvas> canvas_;
std::unique_ptr<SkBitmap> bitmap_;
gfx::Rect pending_damage_rect_;
DISALLOW_COPY_AND_ASSIGN(OffScreenOutputDevice);
};

View file

@ -16,7 +16,7 @@
#include "base/time/time.h"
#include "cc/output/copy_output_request.h"
#include "cc/scheduler/delay_based_time_source.h"
#include "components/display_compositor/gl_helper.h"
#include "components/viz/common/gl_helper.h"
#include "content/browser/renderer_host/compositor_resize_lock.h"
#include "content/browser/renderer_host/render_widget_host_delegate.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
@ -301,8 +301,8 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
factory->GetContextFactoryPrivate();
compositor_.reset(
new ui::Compositor(context_factory_private->AllocateFrameSinkId(),
content::GetContextFactory(), context_factory_private,
base::ThreadTaskRunnerHandle::Get()));
content::GetContextFactory(), context_factory_private,
base::ThreadTaskRunnerHandle::Get(), false));
compositor_->SetAcceleratedWidget(native_window_->GetAcceleratedWidget());
compositor_->SetRootLayer(root_layer_.get());
#endif
@ -378,9 +378,8 @@ void OffScreenRenderWidgetHostView::SendBeginFrame(
DCHECK(begin_frame_args.IsValid());
begin_frame_number_++;
render_widget_host_->Send(new ViewMsg_BeginFrame(
render_widget_host_->GetRoutingID(),
begin_frame_args));
if (renderer_compositor_frame_sink_)
renderer_compositor_frame_sink_->OnBeginFrame(begin_frame_args);
}
bool OffScreenRenderWidgetHostView::OnMessageReceived(
@ -528,7 +527,7 @@ void OffScreenRenderWidgetHostView::UnlockMouse() {
}
void OffScreenRenderWidgetHostView::DidCreateNewRendererCompositorFrameSink(
cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink) {
cc::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink) {
renderer_compositor_frame_sink_ = renderer_compositor_frame_sink;
if (GetDelegatedFrameHost()) {
GetDelegatedFrameHost()->DidCreateNewRendererCompositorFrameSink(
@ -537,7 +536,7 @@ void OffScreenRenderWidgetHostView::DidCreateNewRendererCompositorFrameSink(
}
void OffScreenRenderWidgetHostView::SubmitCompositorFrame(
const cc::LocalSurfaceId& local_surface_id,
const viz::LocalSurfaceId& local_surface_id,
cc::CompositorFrame frame) {
TRACE_EVENT0("electron",
"OffScreenRenderWidgetHostView::SubmitCompositorFrame");
@ -778,8 +777,7 @@ OffScreenRenderWidgetHostView::DelegatedFrameHostCreateResizeLock() {
return base::MakeUnique<content::CompositorResizeLock>(this, desired_size);
}
void
OffScreenRenderWidgetHostView::OnBeginFrame(const cc::BeginFrameArgs& args) {
void OffScreenRenderWidgetHostView::OnBeginFrame() {
}
std::unique_ptr<ui::CompositorLock>
@ -796,7 +794,7 @@ void OffScreenRenderWidgetHostView::CompositorResizeLockEnded() {
bool OffScreenRenderWidgetHostView::TransformPointToLocalCoordSpace(
const gfx::Point& point,
const cc::SurfaceId& original_surface,
const viz::SurfaceId& original_surface,
gfx::Point* transformed_point) {
// Transformations use physical pixels rather than DIP, so conversion
// is necessary.
@ -943,9 +941,6 @@ void CopyBitmapTo(
const SkBitmap& destination,
const SkBitmap& source,
const gfx::Rect& pos) {
SkAutoLockPixels source_pixels_lock(source);
SkAutoLockPixels destination_pixels_lock(destination);
char* src = static_cast<char*>(source.getPixels());
char* dest = static_cast<char*>(destination.getPixels());
int pixelsize = source.bytesPerPixel();
@ -1017,7 +1012,7 @@ void OffScreenRenderWidgetHostView::OnPaint(
void OffScreenRenderWidgetHostView::OnPopupPaint(
const gfx::Rect& damage_rect, const SkBitmap& bitmap) {
if (popup_host_view_ && popup_bitmap_.get())
bitmap.deepCopyTo(popup_bitmap_.get());
popup_bitmap_.reset(new SkBitmap(bitmap));
InvalidateBounds(popup_host_view_->popup_position_);
}
@ -1058,10 +1053,11 @@ void OffScreenRenderWidgetHostView::WasResized() {
}
void OffScreenRenderWidgetHostView::ProcessKeyboardEvent(
const content::NativeWebKeyboardEvent& event) {
const content::NativeWebKeyboardEvent& event,
const ui::LatencyInfo& latency) {
if (!render_widget_host_)
return;
render_widget_host_->ForwardKeyboardEvent(event);
render_widget_host_->ForwardKeyboardEventWithLatencyInfo(event, latency);
}
void OffScreenRenderWidgetHostView::ProcessMouseEvent(
@ -1257,7 +1253,7 @@ void OffScreenRenderWidgetHostView::ResizeRootLayer() {
GetCompositor()->SetScaleAndSize(scale_factor_, size_in_pixels);
}
cc::FrameSinkId OffScreenRenderWidgetHostView::AllocateFrameSinkId(
viz::FrameSinkId OffScreenRenderWidgetHostView::AllocateFrameSinkId(
bool is_guest_view_hack) {
// GuestViews have two RenderWidgetHostViews and so we need to make sure
// we don't have FrameSinkId collisions.
@ -1267,7 +1263,7 @@ cc::FrameSinkId OffScreenRenderWidgetHostView::AllocateFrameSinkId(
content::ImageTransportFactory::GetInstance();
return is_guest_view_hack
? factory->GetContextFactoryPrivate()->AllocateFrameSinkId()
: cc::FrameSinkId(base::checked_cast<uint32_t>(
: viz::FrameSinkId(base::checked_cast<uint32_t>(
render_widget_host_->GetProcess()->GetID()),
base::checked_cast<uint32_t>(
render_widget_host_->GetRoutingID()));

View file

@ -116,9 +116,9 @@ class OffScreenRenderWidgetHostView
// content::RenderWidgetHostViewBase:
void DidCreateNewRendererCompositorFrameSink(
cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink)
cc::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink)
override;
void SubmitCompositorFrame(const cc::LocalSurfaceId& local_surface_id,
void SubmitCompositorFrame(const viz::LocalSurfaceId& local_surface_id,
cc::CompositorFrame frame) override;
void ClearCompositorFrame(void) override;
@ -176,7 +176,7 @@ class OffScreenRenderWidgetHostView
bool DelegatedFrameCanCreateResizeLock() const override;
std::unique_ptr<content::CompositorResizeLock>
DelegatedFrameHostCreateResizeLock() override;
void OnBeginFrame(const cc::BeginFrameArgs& args) override;
void OnBeginFrame() override;
// CompositorResizeLockClient implementation.
std::unique_ptr<ui::CompositorLock> GetCompositorLock(
ui::CompositorLockClient* client) override;
@ -185,7 +185,7 @@ class OffScreenRenderWidgetHostView
bool TransformPointToLocalCoordSpace(
const gfx::Point& point,
const cc::SurfaceId& original_surface,
const viz::SurfaceId& original_surface,
gfx::Point* transformed_point) override;
bool TransformPointToCoordSpaceForView(
const gfx::Point& point,
@ -237,7 +237,8 @@ class OffScreenRenderWidgetHostView
void WasResized();
void ProcessKeyboardEvent(
const content::NativeWebKeyboardEvent& event) override;
const content::NativeWebKeyboardEvent& event,
const ui::LatencyInfo& latency) override;
void ProcessMouseEvent(const blink::WebMouseEvent& event,
const ui::LatencyInfo& latency) override;
void ProcessMouseWheelEvent(const blink::WebMouseWheelEvent& event,
@ -274,7 +275,7 @@ class OffScreenRenderWidgetHostView
void SetupFrameRate(bool force);
void ResizeRootLayer();
cc::FrameSinkId AllocateFrameSinkId(bool is_guest_view_hack);
viz::FrameSinkId AllocateFrameSinkId(bool is_guest_view_hack);
// Applies background color without notifying the RenderWidget about
// opaqueness changes.
@ -337,7 +338,7 @@ class OffScreenRenderWidgetHostView
std::string selected_text_;
#endif
cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink_;
cc::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink_;
SkColor background_color_;

View file

@ -38,12 +38,8 @@ class MacHelper :
return color;
}
void BrowserCompositorMacSendBeginFrame(
const cc::BeginFrameArgs& args) override {
view_->render_widget_host()->Send(
new ViewMsg_BeginFrame(view_->render_widget_host()->GetRoutingID(),
args));
}
void BrowserCompositorMacOnBeginFrame() override {}
// ui::AcceleratedWidgetMacNSView:
NSView* AcceleratedWidgetGetNSView() const override {
return [view_->window()->GetNativeWindow() contentView];

View file

@ -10,6 +10,7 @@
#include "atom/browser/native_window.h"
#include "base/strings/sys_string_conversions.h"
#include "net/cert/cert_database.h"
#include "net/cert/x509_util_ios_and_mac.h"
#include "net/cert/x509_util_mac.h"
@interface TrustDelegate : NSObject {

View file

@ -9,6 +9,7 @@
#include "base/callback.h"
#include "net/cert/cert_database.h"
#include "net/cert/x509_util_win.h"
namespace certificate_trust {
@ -68,12 +69,12 @@ void ShowCertificateTrust(atom::NativeWindow* parent_window,
const ShowTrustCallback& callback) {
PCCERT_CHAIN_CONTEXT chain_context;
auto cert_context = cert->CreateOSCertChainForCert();
auto cert_context = net::x509_util::CreateCertContextWithChain(cert.get());
auto params = GetCertificateChainParameters();
if (CertGetCertificateChain(NULL,
cert_context,
cert_context.get(),
NULL,
NULL,
&params,
@ -84,14 +85,12 @@ void ShowCertificateTrust(atom::NativeWindow* parent_window,
if (error_status == CERT_TRUST_IS_SELF_SIGNED ||
error_status == CERT_TRUST_IS_UNTRUSTED_ROOT) {
// these are the only scenarios we're interested in supporting
AddToTrustedRootStore(cert_context, cert);
AddToTrustedRootStore(cert_context.get(), cert);
}
CertFreeCertificateChain(chain_context);
}
CertFreeCertificateContext(cert_context);
callback.Run();
}

View file

@ -197,7 +197,7 @@ void GtkMessageBox::OnResponseDialog(GtkWidget* widget, int response) {
}
void GtkMessageBox::OnCheckboxToggled(GtkWidget* widget) {
checkbox_checked_ = GTK_TOGGLE_BUTTON(widget)->active;
checkbox_checked_ = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
}
} // namespace

View file

@ -98,7 +98,7 @@ void FramelessView::UpdateWindowTitle() {
void FramelessView::SizeConstraintsChanged() {
}
gfx::Size FramelessView::GetPreferredSize() const {
gfx::Size FramelessView::CalculatePreferredSize() const {
return frame_->non_client_view()->GetWindowBoundsForClientBounds(
gfx::Rect(frame_->client_view()->GetPreferredSize())).size();
}

View file

@ -39,7 +39,7 @@ class FramelessView : public views::NonClientFrameView {
void SizeConstraintsChanged() override;
// Overridden from View:
gfx::Size GetPreferredSize() const override;
gfx::Size CalculatePreferredSize() const override;
gfx::Size GetMinimumSize() const override;
gfx::Size GetMaximumSize() const override;
const char* GetClassName() const override;

View file

@ -52,8 +52,7 @@ MenuBar::MenuBar(NativeWindow* window)
menu_model_(NULL),
window_(window) {
UpdateMenuBarColor();
SetLayoutManager(new views::BoxLayout(
views::BoxLayout::kHorizontal, 0, 0, 0));
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal));
}
MenuBar::~MenuBar() {
@ -169,7 +168,7 @@ void MenuBar::UpdateMenuBarColor() {
GetMenuBarColor(&enabled_color_, &disabled_color_, &highlight_color_,
&hover_color_, &background_color_);
#endif
set_background(views::Background::CreateSolidBackground(background_color_));
SetBackground(views::CreateSolidBackground(background_color_));
}
} // namespace atom

View file

@ -38,12 +38,12 @@ void MenuDelegate::RunMenu(AtomMenuModel* model, views::MenuButton* button) {
menu_runner_.reset(new views::MenuRunner(
item,
views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS));
ignore_result(menu_runner_->RunMenuAt(
menu_runner_->RunMenuAt(
button->GetWidget()->GetTopLevelWidget(),
button,
bounds,
views::MENU_ANCHOR_TOPRIGHT,
ui::MENU_SOURCE_MOUSE));
ui::MENU_SOURCE_MOUSE);
}
void MenuDelegate::ExecuteCommand(int id) {
@ -95,8 +95,7 @@ void MenuDelegate::WillHideMenu(views::MenuItemView* menu) {
adapter_->WillHideMenu(menu);
}
void MenuDelegate::OnMenuClosed(views::MenuItemView* menu,
views::MenuRunner::RunResult result) {
void MenuDelegate::OnMenuClosed(views::MenuItemView* menu) {
// Only switch to new menu when current menu is closed.
if (button_to_open_)
button_to_open_->Activate(nullptr);

View file

@ -40,8 +40,7 @@ class MenuDelegate : public views::MenuDelegate {
void SelectionChanged(views::MenuItemView* menu) override;
void WillShowMenu(views::MenuItemView* menu) override;
void WillHideMenu(views::MenuItemView* menu) override;
void OnMenuClosed(views::MenuItemView* menu,
views::MenuRunner::RunResult result) override;
void OnMenuClosed(views::MenuItemView* menu) override;
views::MenuItemView* GetSiblingMenu(
views::MenuItemView* menu,
const gfx::Point& screen_point,

View file

@ -77,8 +77,8 @@ void SubmenuButton::SetUnderlineColor(SkColor color) {
underline_color_ = color;
}
void SubmenuButton::OnPaint(gfx::Canvas* canvas) {
views::MenuButton::OnPaint(canvas);
void SubmenuButton::PaintButtonContents(gfx::Canvas* canvas) {
views::MenuButton::PaintButtonContents(canvas);
if (show_underline_ && (underline_start_ != underline_end_)) {
int padding = (width() - text_width_) / 2;

View file

@ -27,7 +27,7 @@ class SubmenuButton : public views::MenuButton {
base::char16 accelerator() const { return accelerator_; }
// views::MenuButton:
void OnPaint(gfx::Canvas* canvas) override;
void PaintButtonContents(gfx::Canvas* canvas) override;
// views::InkDropHostView:
std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;

View file

@ -144,7 +144,7 @@ class PdfViewerUI::ResourceRequester
std::unique_ptr<content::ResourceHandler> handler =
base::MakeUnique<content::StreamResourceHandler>(
request.get(), stream_context->registry(), origin);
request.get(), stream_context->registry(), origin, false);
info->set_is_stream(true);
stream_info_.reset(new content::StreamInfo);
stream_info_->handle =

View file

@ -152,8 +152,8 @@ void NotifyIcon::PopUpContextMenu(const gfx::Point& pos,
menu_runner_.reset(new views::MenuRunner(
menu_model != nullptr ? menu_model : menu_model_,
views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS));
ignore_result(menu_runner_->RunMenuAt(
NULL, NULL, rect, views::MENU_ANCHOR_TOPLEFT, ui::MENU_SOURCE_MOUSE));
menu_runner_->RunMenuAt(
NULL, NULL, rect, views::MENU_ANCHOR_TOPLEFT, ui::MENU_SOURCE_MOUSE);
}
void NotifyIcon::SetContextMenu(AtomMenuModel* menu_model) {

View file

@ -10,8 +10,6 @@
#include "atom/browser/ui/win/notify_icon.h"
#include "base/bind.h"
#include "base/stl_util.h"
#include "base/threading/non_thread_safe.h"
#include "base/threading/thread.h"
#include "base/win/win_util.h"
#include "base/win/wrapped_window_proc.h"
#include "ui/events/event_constants.h"

View file

@ -4,6 +4,7 @@
#include "atom/browser/ui/win/taskbar_host.h"
#include <objbase.h>
#include <string>
#include "atom/browser/native_window.h"
@ -203,9 +204,9 @@ bool TaskbarHost::HandleThumbarButtonEvent(int button_id) {
}
bool TaskbarHost::InitializeTaskbar() {
if (FAILED(taskbar_.CreateInstance(CLSID_TaskbarList,
nullptr,
CLSCTX_INPROC_SERVER)) ||
if (FAILED(::CoCreateInstance(CLSID_TaskbarList, nullptr,
CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&taskbar_))) ||
FAILED(taskbar_->HrInit())) {
return false;
} else {

View file

@ -7,6 +7,7 @@
#include <X11/Xlib.h>
#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/x/x11_atom_cache.h"
namespace atom {
@ -22,7 +23,6 @@ const char* kAtomsToCache[] = {
WindowStateWatcher::WindowStateWatcher(NativeWindowViews* window)
: window_(window),
widget_(window->GetAcceleratedWidget()),
atom_cache_(gfx::GetXDisplay(), kAtomsToCache),
was_minimized_(false),
was_maximized_(false) {
ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
@ -70,7 +70,7 @@ void WindowStateWatcher::DidProcessEvent(const ui::PlatformEvent& event) {
bool WindowStateWatcher::IsWindowStateEvent(const ui::PlatformEvent& event) {
::Atom changed_atom = event->xproperty.atom;
return (changed_atom == atom_cache_.GetAtom("_NET_WM_STATE") &&
return (changed_atom == gfx::GetAtom("_NET_WM_STATE") &&
event->type == PropertyNotify &&
event->xproperty.window == widget_);
}

View file

@ -8,7 +8,6 @@
#include "ui/events/platform/platform_event_observer.h"
#include "atom/browser/native_window_views.h"
#include "ui/gfx/x/x11_atom_cache.h"
namespace atom {
@ -28,8 +27,6 @@ class WindowStateWatcher : public ui::PlatformEventObserver {
NativeWindowViews* window_;
gfx::AcceleratedWidget widget_;
ui::X11AtomCache atom_cache_;
bool was_minimized_;
bool was_maximized_;

View file

@ -13,6 +13,7 @@
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/options_switches.h"
#include "base/command_line.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "cc/base/switches.h"
#include "content/public/browser/render_process_host.h"
@ -44,7 +45,7 @@ WebContentsPreferences::WebContentsPreferences(
copied.Delete("session");
mate::ConvertFromV8(isolate, copied.GetHandle(), &web_preferences_);
web_contents->SetUserData(UserDataKey(), this);
web_contents->SetUserData(UserDataKey(), base::WrapUnique(this));
instances_.push_back(this);
}

View file

@ -89,7 +89,7 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
gfx::Size GetDefaultSize() const;
// The WebContents that attaches this guest view.
content::WebContents* embedder_web_contents_;
content::WebContents* embedder_web_contents_ = nullptr;
// The zoom controller of the embedder that is used
// to subscribe for zoom changes.

View file

@ -8,10 +8,47 @@
#include "atom/common/native_mate_converters/string16_converter.h"
#include "base/strings/utf_string_conversions.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/core/SkPixmap.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
#include "atom/common/node_includes.h"
namespace {
// TODO(alexeykuzmin): It is a copy of `sk_tool_utils::copy_to()`,
// use the original function if possible, skia doesn't export it.
bool copy_to(SkBitmap* dst, SkColorType dstColorType, const SkBitmap& src) {
SkPixmap srcPM;
if (!src.peekPixels(&srcPM)) {
return false;
}
SkBitmap tmpDst;
SkImageInfo dstInfo = srcPM.info().makeColorType(dstColorType);
if (!tmpDst.setInfo(dstInfo)) {
return false;
}
if (!tmpDst.tryAllocPixels()) {
return false;
}
SkPixmap dstPM;
if (!tmpDst.peekPixels(&dstPM)) {
return false;
}
if (!srcPM.readPixels(dstPM)) {
return false;
}
dst->swap(tmpDst);
return true;
}
} // namespace
namespace atom {
namespace api {
@ -167,12 +204,13 @@ gfx::Image Clipboard::ReadImage(mate::Arguments* args) {
void Clipboard::WriteImage(const gfx::Image& image, mate::Arguments* args) {
ui::ScopedClipboardWriter writer(GetClipboardType(args));
SkBitmap orig = image.AsBitmap();
SkBitmap bmp;
// TODO(ferreus): Replace with sk_tools_utils::copy_to (chrome60)
if (image.AsBitmap().deepCopyTo(&bmp)) {
if (copy_to(&bmp, orig.colorType(), orig)) {
writer.WriteImage(bmp);
} else {
writer.WriteImage(image.AsBitmap());
writer.WriteImage(orig);
}
}

View file

@ -8,7 +8,7 @@
#ifndef ATOM_COMMON_CHROME_VERSION_H_
#define ATOM_COMMON_CHROME_VERSION_H_
#define CHROME_VERSION_STRING "59.0.3071.115"
#define CHROME_VERSION_STRING "61.0.3163.100"
#define CHROME_VERSION "v" CHROME_VERSION_STRING
#endif // ATOM_COMMON_CHROME_VERSION_H_

View file

@ -137,7 +137,8 @@ struct Converter<blink::WebInputEvent::Modifiers> {
}
};
int GetWebInputEventType(v8::Isolate* isolate, v8::Local<v8::Value> val) {
blink::WebInputEvent::Type GetWebInputEventType(v8::Isolate* isolate,
v8::Local<v8::Value> val) {
blink::WebInputEvent::Type type = blink::WebInputEvent::kUndefined;
mate::Dictionary dict;
ConvertFromV8(isolate, val, &dict) && dict.Get("type", &type);
@ -342,8 +343,6 @@ bool Converter<blink::WebDeviceEmulationParams>::FromV8(
dict.Get("viewPosition", &out->view_position);
dict.Get("deviceScaleFactor", &out->device_scale_factor);
dict.Get("viewSize", &out->view_size);
dict.Get("fitToView", &out->fit_to_view);
dict.Get("offset", &out->offset);
dict.Get("scale", &out->scale);
return true;
}

View file

@ -7,10 +7,11 @@
#include "native_mate/converter.h"
#include "third_party/WebKit/public/platform/WebCache.h"
#include "third_party/WebKit/public/platform/WebInputEvent.h"
#include "third_party/WebKit/public/web/WebContextMenuData.h"
namespace blink {
class WebInputEvent;
class WebMouseEvent;
class WebMouseWheelEvent;
class WebKeyboardEvent;
@ -27,7 +28,8 @@ struct NativeWebKeyboardEvent;
namespace mate {
int GetWebInputEventType(v8::Isolate* isolate, v8::Local<v8::Value> val);
blink::WebInputEvent::Type GetWebInputEventType(v8::Isolate* isolate,
v8::Local<v8::Value> val);
template<>
struct Converter<blink::WebInputEvent> {

View file

@ -15,12 +15,12 @@
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/ui_base_types_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "content/common/resource_request_body_impl.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/context_menu_params.h"
#include "content/public/common/resource_request_body.h"
#include "native_mate/dictionary.h"
using content::ResourceRequestBodyImpl;
using content::ResourceRequestBody;
namespace {
@ -203,9 +203,9 @@ bool Converter<content::StopFindAction>::FromV8(
// static
v8::Local<v8::Value>
Converter<scoped_refptr<ResourceRequestBodyImpl>>::ToV8(
Converter<scoped_refptr<ResourceRequestBody>>::ToV8(
v8::Isolate* isolate,
const scoped_refptr<ResourceRequestBodyImpl>& val) {
const scoped_refptr<ResourceRequestBody>& val) {
if (!val)
return v8::Null(isolate);
std::unique_ptr<base::ListValue> list(new base::ListValue);
@ -213,13 +213,13 @@ Converter<scoped_refptr<ResourceRequestBodyImpl>>::ToV8(
std::unique_ptr<base::DictionaryValue> post_data_dict(
new base::DictionaryValue);
auto type = element.type();
if (type == ResourceRequestBodyImpl::Element::TYPE_BYTES) {
if (type == ResourceRequestBody::Element::TYPE_BYTES) {
std::unique_ptr<base::Value> bytes(
base::Value::CreateWithCopiedBuffer(
element.bytes(), static_cast<size_t>(element.length())));
post_data_dict->SetString("type", "rawData");
post_data_dict->Set("bytes", std::move(bytes));
} else if (type == ResourceRequestBodyImpl::Element::TYPE_FILE) {
} else if (type == ResourceRequestBody::Element::TYPE_FILE) {
post_data_dict->SetString("type", "file");
post_data_dict->SetStringWithoutPathExpansion(
"filePath", element.path().AsUTF8Unsafe());
@ -227,7 +227,7 @@ Converter<scoped_refptr<ResourceRequestBodyImpl>>::ToV8(
post_data_dict->SetInteger("length", static_cast<int>(element.length()));
post_data_dict->SetDouble(
"modificationTime", element.expected_modification_time().ToDoubleT());
} else if (type == ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM) {
} else if (type == ResourceRequestBody::Element::TYPE_FILE_FILESYSTEM) {
post_data_dict->SetString("type", "fileSystem");
post_data_dict->SetStringWithoutPathExpansion(
"fileSystemURL", element.filesystem_url().spec());
@ -235,7 +235,7 @@ Converter<scoped_refptr<ResourceRequestBodyImpl>>::ToV8(
post_data_dict->SetInteger("length", static_cast<int>(element.length()));
post_data_dict->SetDouble(
"modificationTime", element.expected_modification_time().ToDoubleT());
} else if (type == ResourceRequestBodyImpl::Element::TYPE_BLOB) {
} else if (type == ResourceRequestBody::Element::TYPE_BLOB) {
post_data_dict->SetString("type", "blob");
post_data_dict->SetString("blobUUID", element.blob_uuid());
}
@ -245,14 +245,14 @@ Converter<scoped_refptr<ResourceRequestBodyImpl>>::ToV8(
}
// static
bool Converter<scoped_refptr<ResourceRequestBodyImpl>>::FromV8(
bool Converter<scoped_refptr<ResourceRequestBody>>::FromV8(
v8::Isolate* isolate,
v8::Local<v8::Value> val,
scoped_refptr<ResourceRequestBodyImpl>* out) {
scoped_refptr<ResourceRequestBody>* out) {
std::unique_ptr<base::ListValue> list(new base::ListValue);
if (!ConvertFromV8(isolate, val, list.get()))
return false;
*out = new content::ResourceRequestBodyImpl();
*out = new content::ResourceRequestBody();
for (size_t i = 0; i < list->GetSize(); ++i) {
base::DictionaryValue* dict = nullptr;
std::string type;
@ -262,7 +262,7 @@ bool Converter<scoped_refptr<ResourceRequestBodyImpl>>::FromV8(
if (type == "rawData") {
base::Value* bytes = nullptr;
dict->GetBinary("bytes", &bytes);
(*out)->AppendBytes(bytes->GetBuffer(), bytes->GetSize());
(*out)->AppendBytes(bytes->GetBlob().data(), bytes->GetBlob().size());
} else if (type == "file") {
std::string file;
int offset = 0, length = -1;

View file

@ -15,7 +15,7 @@
namespace content {
struct ContextMenuParams;
class ResourceRequestBodyImpl;
class ResourceRequestBody;
class WebContents;
}
@ -49,12 +49,12 @@ struct Converter<content::PermissionType> {
};
template<>
struct Converter<scoped_refptr<content::ResourceRequestBodyImpl>> {
struct Converter<scoped_refptr<content::ResourceRequestBody>> {
static v8::Local<v8::Value> ToV8(
v8::Isolate* isolate,
const scoped_refptr<content::ResourceRequestBodyImpl>& val);
const scoped_refptr<content::ResourceRequestBody>& val);
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
scoped_refptr<content::ResourceRequestBodyImpl>* out);
scoped_refptr<content::ResourceRequestBody>* out);
};
template<>

View file

@ -255,8 +255,8 @@ v8::Local<v8::Value> V8ValueConverter::ToV8Object(
v8::Local<v8::Value> V8ValueConverter::ToArrayBuffer(
v8::Isolate* isolate, const base::Value* value) const {
const char* data = value->GetBuffer();
size_t length = value->GetSize();
const char* data = value->GetBlob().data();
size_t length = value->GetBlob().size();
if (!disable_node_) {
return node::Buffer::Copy(isolate, data, length).ToLocalChecked();
@ -495,7 +495,7 @@ base::Value* V8ValueConverter::FromV8Object(
continue;
result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()),
child.release());
std::move(child));
}
return result.release();

View file

@ -31,5 +31,6 @@
#include "vendor/node/src/node_buffer.h"
#include "vendor/node/src/node_debug_options.h"
#include "vendor/node/src/node_internals.h"
#include "vendor/node/src/node_platform.h"
#endif // ATOM_COMMON_NODE_INCLUDES_H_

View file

@ -10,6 +10,7 @@
#include <comdef.h>
#include <commdlg.h>
#include <dwmapi.h>
#include <objbase.h>
#include <shellapi.h>
#include <shlobj.h>
@ -243,7 +244,7 @@ bool ShowItemInFolder(const base::FilePath& full_path) {
}
base::win::ScopedComPtr<IShellFolder> desktop;
HRESULT hr = SHGetDesktopFolder(desktop.Receive());
HRESULT hr = SHGetDesktopFolder(desktop.GetAddressOf());
if (FAILED(hr))
return false;
@ -328,7 +329,8 @@ bool MoveItemToTrash(const base::FilePath& path) {
return false;
base::win::ScopedComPtr<IFileOperation> pfo;
if (FAILED(pfo.CreateInstance(CLSID_FileOperation)))
if (FAILED(::CoCreateInstance(CLSID_FileOperation, nullptr, CLSCTX_ALL,
IID_PPV_ARGS(&pfo))))
return false;
// Elevation prompt enabled for UAC protected files. This overrides the
@ -356,9 +358,10 @@ bool MoveItemToTrash(const base::FilePath& path) {
// Create an IShellItem from the supplied source path.
base::win::ScopedComPtr<IShellItem> delete_item;
if (FAILED(SHCreateItemFromParsingName(path.value().c_str(),
NULL,
IID_PPV_ARGS(delete_item.Receive()))))
if (FAILED(SHCreateItemFromParsingName(
path.value().c_str(),
NULL,
IID_PPV_ARGS(delete_item.GetAddressOf()))))
return false;
base::win::ScopedComPtr<IFileOperationProgressSink> delete_sink(
@ -368,7 +371,7 @@ bool MoveItemToTrash(const base::FilePath& path) {
// Processes the queued command DeleteItem. This will trigger
// the DeleteFileProgressSink to check for Recycle Bin.
return SUCCEEDED(pfo->DeleteItem(delete_item.get(), delete_sink.get())) &&
return SUCCEEDED(pfo->DeleteItem(delete_item.Get(), delete_sink.Get())) &&
SUCCEEDED(pfo->PerformOperations());
}

View file

@ -59,6 +59,10 @@ void ReferenceSymbols() {
icu::DateIntervalFormat::createInstance(UnicodeString(),
icu::Locale::getRoot(), status);
reinterpret_cast<icu::Transliterator*>(nullptr)->clone();
UParseError parse_error;
icu::Transliterator::createFromRules(UnicodeString(), UnicodeString(),
UTRANS_FORWARD, parse_error,
status);
}
} // namespace node

View file

@ -11,8 +11,8 @@
#include "base/callback.h"
#include "chrome/renderer/spellchecker/spellcheck_worditerator.h"
#include "native_mate/scoped_persistent.h"
#include "third_party/WebKit/public/platform/WebSpellCheckPanelHostClient.h"
#include "third_party/WebKit/public/platform/WebVector.h"
#include "third_party/WebKit/public/web/WebSpellCheckClient.h"
#include "third_party/WebKit/public/web/WebTextCheckClient.h"
namespace blink {
@ -24,7 +24,7 @@ namespace atom {
namespace api {
class SpellCheckClient : public blink::WebSpellCheckClient,
class SpellCheckClient : public blink::WebSpellCheckPanelHostClient,
public blink::WebTextCheckClient {
public:
SpellCheckClient(const std::string& language,
@ -44,7 +44,7 @@ class SpellCheckClient : public blink::WebSpellCheckClient,
const blink::WebString& textToCheck,
blink::WebTextCheckingCompletion* completionCallback) override;
// blink::WebSpellCheckClient:
// blink::WebSpellCheckPanelHostClient:
void ShowSpellingUI(bool show) override;
bool IsShowingSpellingUI() override;
void UpdateSpellingUIWithMisspelledWord(

View file

@ -141,7 +141,7 @@ void WebFrame::SetSpellCheckProvider(mate::Arguments* args,
spell_check_client_.reset(new SpellCheckClient(
language, auto_spell_correct_turned_on, args->isolate(), provider));
web_frame_->View()->SetSpellCheckClient(spell_check_client_.get());
web_frame_->SetSpellCheckPanelHostClient(spell_check_client_.get());
web_frame_->SetTextCheckClient(spell_check_client_.get());
}

View file

@ -4,8 +4,13 @@
#include "atom/renderer/atom_render_frame_observer.h"
#include <vector>
#include "atom/common/api/api_messages.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_view.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebDraggableRegion.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebScriptSource.h"
@ -35,6 +40,21 @@ void AtomRenderFrameObserver::DidCreateScriptContext(
}
}
void AtomRenderFrameObserver::DraggableRegionsChanged() {
blink::WebVector<blink::WebDraggableRegion> webregions =
render_frame_->GetWebFrame()->GetDocument().DraggableRegions();
std::vector<DraggableRegion> regions;
for (auto& webregion : webregions) {
DraggableRegion region;
render_frame_->GetRenderView()->ConvertViewportToWindowViaWidget(
&webregion.bounds);
region.bounds = webregion.bounds;
region.draggable = webregion.draggable;
regions.push_back(region);
}
Send(new AtomViewHostMsg_UpdateDraggableRegions(routing_id(), regions));
}
void AtomRenderFrameObserver::WillReleaseScriptContext(
v8::Local<v8::Context> context,
int world_id) {

View file

@ -27,6 +27,7 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver {
void DidClearWindowObject() override;
void DidCreateScriptContext(v8::Handle<v8::Context> context,
int world_id) override;
void DraggableRegionsChanged() override;
void WillReleaseScriptContext(v8::Local<v8::Context> context,
int world_id) override;
void OnDestruct() override;

View file

@ -24,7 +24,7 @@
#include "net/base/net_module.h"
#include "net/grit/net_resources.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebDraggableRegion.h"
#include "third_party/WebKit/public/web/WebElement.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebKit.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
@ -75,8 +75,7 @@ AtomRenderViewObserver::AtomRenderViewObserver(
content::RenderView* render_view,
AtomRendererClient* renderer_client)
: content::RenderViewObserver(render_view),
renderer_client_(renderer_client),
document_created_(false) {
renderer_client_(renderer_client) {
// Initialise resource for directory listing.
net::NetModule::SetResourceProvider(NetResourceProvider);
}
@ -84,10 +83,10 @@ AtomRenderViewObserver::AtomRenderViewObserver(
AtomRenderViewObserver::~AtomRenderViewObserver() {
}
void AtomRenderViewObserver::EmitIPCEvent(blink::WebFrame* frame,
void AtomRenderViewObserver::EmitIPCEvent(blink::WebLocalFrame* frame,
const base::string16& channel,
const base::ListValue& args) {
if (!frame || frame->IsWebRemoteFrame())
if (!frame)
return;
v8::Isolate* isolate = blink::MainThreadIsolate();
@ -113,25 +112,6 @@ void AtomRenderViewObserver::EmitIPCEvent(blink::WebFrame* frame,
}
}
void AtomRenderViewObserver::DidCreateDocumentElement(
blink::WebLocalFrame* frame) {
document_created_ = true;
}
void AtomRenderViewObserver::DraggableRegionsChanged(blink::WebFrame* frame) {
blink::WebVector<blink::WebDraggableRegion> webregions =
frame->GetDocument().DraggableRegions();
std::vector<DraggableRegion> regions;
for (auto& webregion : webregions) {
DraggableRegion region;
render_view()->ConvertViewportToWindowViaWidget(&webregion.bounds);
region.bounds = webregion.bounds;
region.draggable = webregion.draggable;
regions.push_back(region);
}
Send(new AtomViewHostMsg_UpdateDraggableRegions(routing_id(), regions));
}
bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(AtomRenderViewObserver, message)
@ -150,23 +130,33 @@ void AtomRenderViewObserver::OnDestruct() {
void AtomRenderViewObserver::OnBrowserMessage(bool send_to_all,
const base::string16& channel,
const base::ListValue& args) {
if (!document_created_)
return;
if (!render_view()->GetWebView())
return;
blink::WebFrame* frame = render_view()->GetWebView()->MainFrame();
if (!frame || frame->IsWebRemoteFrame())
if (!frame || !frame->IsWebLocalFrame())
return;
EmitIPCEvent(frame, channel, args);
// Don't handle browser messages before document element is created.
// When we receive a message from the browser, we try to transfer it
// to a web page, and when we do that Blink creates an empty
// document element if it hasn't been created yet, and it makes our init
// script to run while `window.location` is still "about:blank".
blink::WebDocument document = frame->ToWebLocalFrame()->GetDocument();
blink::WebElement html_element = document.DocumentElement();
if (html_element.IsNull()) {
return;
}
EmitIPCEvent(frame->ToWebLocalFrame(), channel, args);
// Also send the message to all sub-frames.
if (send_to_all) {
for (blink::WebFrame* child = frame->FirstChild(); child;
child = child->NextSibling())
EmitIPCEvent(child, channel, args);
if (child->IsWebLocalFrame()) {
EmitIPCEvent(child->ToWebLocalFrame(), channel, args);
}
}
}

View file

@ -7,7 +7,7 @@
#include "base/strings/string16.h"
#include "content/public/renderer/render_view_observer.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
namespace base {
class ListValue;
@ -25,14 +25,12 @@ class AtomRenderViewObserver : public content::RenderViewObserver {
protected:
virtual ~AtomRenderViewObserver();
virtual void EmitIPCEvent(blink::WebFrame* frame,
virtual void EmitIPCEvent(blink::WebLocalFrame* frame,
const base::string16& channel,
const base::ListValue& args);
private:
// content::RenderViewObserver implementation.
void DidCreateDocumentElement(blink::WebLocalFrame* frame) override;
void DraggableRegionsChanged(blink::WebFrame* frame) override;
bool OnMessageReceived(const IPC::Message& message) override;
void OnDestruct() override;
@ -44,9 +42,6 @@ class AtomRenderViewObserver : public content::RenderViewObserver {
AtomRendererClient* renderer_client_;
// Whether the document object has been created.
bool document_created_;
DISALLOW_COPY_AND_ASSIGN(AtomRenderViewObserver);
};

View file

@ -107,10 +107,10 @@ class AtomSandboxedRenderViewObserver : public AtomRenderViewObserver {
}
protected:
void EmitIPCEvent(blink::WebFrame* frame,
void EmitIPCEvent(blink::WebLocalFrame* frame,
const base::string16& channel,
const base::ListValue& args) override {
if (!frame || frame->IsWebRemoteFrame())
if (!frame)
return;
auto isolate = blink::MainThreadIsolate();

View file

@ -17,6 +17,7 @@
#include "atom/renderer/guest_view_container.h"
#include "atom/renderer/preferences_manager.h"
#include "base/command_line.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_split.h"
#include "chrome/renderer/media/chrome_key_systems.h"
#include "chrome/renderer/pepper/pepper_helper.h"
@ -179,14 +180,14 @@ void RendererClientBase::DidClearWindowObject(
render_frame->GetWebFrame()->ExecuteScript(blink::WebScriptSource("void 0"));
}
blink::WebSpeechSynthesizer* RendererClientBase::OverrideSpeechSynthesizer(
std::unique_ptr<blink::WebSpeechSynthesizer>
RendererClientBase::OverrideSpeechSynthesizer(
blink::WebSpeechSynthesizerClient* client) {
return new TtsDispatcher(client);
return base::MakeUnique<TtsDispatcher>(client);
}
bool RendererClientBase::OverrideCreatePlugin(
content::RenderFrame* render_frame,
blink::WebLocalFrame* frame,
const blink::WebPluginParams& params,
blink::WebPlugin** plugin) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
@ -216,7 +217,7 @@ void RendererClientBase::AddSupportedKeySystems(
}
v8::Local<v8::Context> RendererClientBase::GetContext(
blink::WebFrame* frame, v8::Isolate* isolate) {
blink::WebLocalFrame* frame, v8::Isolate* isolate) {
if (isolated_world())
return frame->WorldScriptContext(isolate, World::ISOLATED_WORLD);
else

View file

@ -9,6 +9,7 @@
#include <vector>
#include "content/public/renderer/content_renderer_client.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
namespace atom {
@ -30,7 +31,7 @@ class RendererClientBase : public content::ContentRendererClient {
// Get the context that the Electron API is running in.
v8::Local<v8::Context> GetContext(
blink::WebFrame* frame, v8::Isolate* isolate);
blink::WebLocalFrame* frame, v8::Isolate* isolate);
protected:
void AddRenderBindings(v8::Isolate* isolate,
@ -40,10 +41,9 @@ class RendererClientBase : public content::ContentRendererClient {
void RenderThreadStarted() override;
void RenderFrameCreated(content::RenderFrame*) override;
void RenderViewCreated(content::RenderView*) override;
blink::WebSpeechSynthesizer* OverrideSpeechSynthesizer(
std::unique_ptr<blink::WebSpeechSynthesizer> OverrideSpeechSynthesizer(
blink::WebSpeechSynthesizerClient* client) override;
bool OverrideCreatePlugin(content::RenderFrame* render_frame,
blink::WebLocalFrame* frame,
const blink::WebPluginParams& params,
blink::WebPlugin** plugin) override;
content::BrowserPluginDelegate* CreateBrowserPluginDelegate(

View file

@ -5,6 +5,7 @@
#include "atom/utility/atom_content_utility_client.h"
#if defined(OS_WIN)
#include "base/memory/ptr_util.h"
#include "chrome/utility/printing_handler_win.h"
#endif
@ -12,7 +13,7 @@ namespace atom {
AtomContentUtilityClient::AtomContentUtilityClient() {
#if defined(OS_WIN)
handlers_.push_back(new printing::PrintingHandlerWin());
handlers_.push_back(base::MakeUnique<printing::PrintingHandlerWin>());
#endif
}
@ -22,7 +23,7 @@ AtomContentUtilityClient::~AtomContentUtilityClient() {
bool AtomContentUtilityClient::OnMessageReceived(
const IPC::Message& message) {
#if defined(OS_WIN)
for (auto* handler : handlers_) {
for (const auto& handler : handlers_) {
if (handler->OnMessageReceived(message))
return true;
}

View file

@ -5,10 +5,10 @@
#ifndef ATOM_UTILITY_ATOM_CONTENT_UTILITY_CLIENT_H_
#define ATOM_UTILITY_ATOM_CONTENT_UTILITY_CLIENT_H_
#include <memory>
#include <vector>
#include "base/compiler_specific.h"
#include "base/memory/scoped_vector.h"
#include "content/public/utility/content_utility_client.h"
class UtilityMessageHandler;
@ -24,7 +24,7 @@ class AtomContentUtilityClient : public content::ContentUtilityClient {
private:
#if defined(OS_WIN)
typedef ScopedVector<UtilityMessageHandler> Handlers;
typedef std::vector<std::unique_ptr<UtilityMessageHandler>> Handlers;
Handlers handlers_;
#endif

View file

@ -1,7 +1,7 @@
{
'variables': {
# The libraries brightray will be compiled to.
'linux_system_libraries': 'gtk+-2.0 dbus-1 x11 x11-xcb xcb xi xcursor xdamage xrandr xcomposite xext xfixes xrender xtst xscrnsaver gconf-2.0 gmodule-2.0 nss',
'linux_system_libraries': 'gtk+-3.0 dbus-1 x11 x11-xcb xcb xi xcursor xdamage xrandr xcomposite xext xfixes xrender xtst xscrnsaver gconf-2.0 gmodule-2.0 nss',
'conditions': [
['target_arch=="mips64el"', {
'linux_system_libraries': '<(linux_system_libraries) libpulse',
@ -112,6 +112,10 @@
'<(libchromiumcontent_dir)/libyuv.a',
'<(libchromiumcontent_dir)/librenderer.a',
'<(libchromiumcontent_dir)/libsecurity_state.a',
# components/network_session_configurator/common/
'<(libchromiumcontent_dir)/libcommon.a',
# services/device/wake_lock/power_save_blocker/
'<(libchromiumcontent_dir)/libpower_save_blocker.a',
# Friends of libpdf.a:
# On Linux we have to use "--whole-archive" to include
# all symbols, otherwise there will be plenty of
@ -165,6 +169,14 @@
],
},
}],
# On ARM64 libchromiumcontent always links to system libfreetype
['target_arch=="arm64"', {
'link_settings': {
'libraries': [
'-lfreetype',
],
},
}],
],
}], # OS=="linux"
['OS=="mac"', {
@ -193,6 +205,10 @@
'<(libchromiumcontent_dir)/libyuv.a',
'<(libchromiumcontent_dir)/librenderer.a',
'<(libchromiumcontent_dir)/libsecurity_state.a',
# components/network_session_configurator/common/
'<(libchromiumcontent_dir)/libcommon.a',
# services/device/wake_lock/power_save_blocker/
'<(libchromiumcontent_dir)/libpower_save_blocker.a',
# Friends of libpdf.a:
'<(libchromiumcontent_dir)/libpdf.a',
'<(libchromiumcontent_dir)/libppapi_cpp_objects.a',
@ -212,7 +228,6 @@
'<(libchromiumcontent_dir)/libjavascript.a',
'<(libchromiumcontent_dir)/libpdfwindow.a',
'<(libchromiumcontent_dir)/libfx_agg.a',
'<(libchromiumcontent_dir)/libfx_freetype.a',
'<(libchromiumcontent_dir)/libfx_lcms2.a',
'<(libchromiumcontent_dir)/libfx_libopenjpeg.a',
'<(libchromiumcontent_dir)/libfx_zlib.a',
@ -286,6 +301,10 @@
'<(libchromiumcontent_dir)/libyuv.lib',
'<(libchromiumcontent_dir)/renderer.lib',
'<(libchromiumcontent_dir)/security_state.lib',
# components/network_session_configurator/common/
'<(libchromiumcontent_dir)/common.lib',
# services/device/wake_lock/power_save_blocker/
'<(libchromiumcontent_dir)/power_save_blocker.lib',
# Friends of pdf.lib:
'<(libchromiumcontent_dir)/pdf.lib',
'<(libchromiumcontent_dir)/ppapi_cpp_objects.lib',

View file

@ -54,11 +54,6 @@
'WarningLevel': '4',
'WarnAsError': 'true',
'DebugInformationFormat': '3',
# Programs that use the Standard C++ library must be compiled with
# C++
# exception handling enabled.
# http://support.microsoft.com/kb/154419
'ExceptionHandling': 1,
},
'VCLinkerTool': {
'GenerateDebugInformation': 'true',
@ -126,11 +121,18 @@
'USE_NSS', # deprecated after Chrome 45.
],
}],
['OS in ["linux", "mac"]', {
'defines': [
'WEBRTC_POSIX',
'UCHAR_TYPE=uint16_t',
],
}],
['OS=="linux"', {
'defines': [
'_LARGEFILE_SOURCE',
'_LARGEFILE64_SOURCE',
'_FILE_OFFSET_BITS=64',
'WEBRTC_LINUX',
],
'cflags_cc': [
'-D__STRICT_ANSI__',
@ -163,6 +165,7 @@
# The usage of "webrtc/modules/desktop_capture/desktop_capture_options.h"
# is required to see this macro.
'WEBRTC_WIN',
'UCHAR_TYPE=wchar_t',
],
'conditions': [
['target_arch=="x64"', {

View file

@ -10,7 +10,6 @@
#include "brightray/browser/brightray_paths.h"
#include "brightray/browser/browser_client.h"
#include "brightray/browser/inspectable_web_contents_impl.h"
#include "brightray/browser/media/media_device_id_salt.h"
#include "brightray/browser/network_delegate.h"
#include "brightray/browser/special_storage_policy.h"
#include "brightray/browser/zoom_level_delegate.h"
@ -54,13 +53,6 @@ class BrowserContext::ResourceContext : public content::ResourceContext {
return getter_->GetURLRequestContext();
}
std::string GetMediaDeviceIDSalt() override {
auto media_device_id_salt_ = getter_->GetMediaDeviceIDSalt();
if (media_device_id_salt_)
return media_device_id_salt_->GetSalt();
return content::ResourceContext::GetMediaDeviceIDSalt();
}
URLRequestContextGetter* getter_;
};
@ -142,7 +134,6 @@ net::URLRequestContextGetter* BrowserContext::CreateRequestContext(
GetPath(),
in_memory_,
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE),
protocol_handlers,
std::move(protocol_interceptors));
resource_context_->set_url_request_context_getter(url_request_getter_.get());
@ -153,12 +144,10 @@ net::NetworkDelegate* BrowserContext::CreateNetworkDelegate() {
return new NetworkDelegate;
}
MediaDeviceIDSalt* BrowserContext::GetMediaDeviceIDSalt() {
if (IsOffTheRecord())
return nullptr;
std::string BrowserContext::GetMediaDeviceIDSalt() {
if (!media_device_id_salt_.get())
media_device_id_salt_.reset(new MediaDeviceIDSalt(prefs_.get()));
return media_device_id_salt_.get();
return media_device_id_salt_->GetSalt();
}
base::FilePath BrowserContext::GetPath() const {
@ -212,6 +201,11 @@ BrowserContext::GetBackgroundSyncController() {
return nullptr;
}
content::BrowsingDataRemoverDelegate*
BrowserContext::GetBrowsingDataRemoverDelegate() {
return nullptr;
}
net::URLRequestContextGetter*
BrowserContext::CreateRequestContextForStoragePartition(
const base::FilePath& partition_path,

View file

@ -10,6 +10,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "brightray/browser/media/media_device_id_salt.h"
#include "brightray/browser/net/devtools_network_controller_handle.h"
#include "brightray/browser/permission_manager.h"
#include "brightray/browser/url_request_context_getter.h"
@ -24,7 +25,6 @@ class SpecialStoragePolicy;
namespace brightray {
class MediaDeviceIDSalt;
class PermissionManager;
class BrowserContext : public base::RefCounted<BrowserContext>,
@ -55,6 +55,8 @@ class BrowserContext : public base::RefCounted<BrowserContext>,
content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
content::PermissionManager* GetPermissionManager() override;
content::BackgroundSyncController* GetBackgroundSyncController() override;
content::BrowsingDataRemoverDelegate* GetBrowsingDataRemoverDelegate()
override;
net::URLRequestContextGetter* CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) override;
@ -67,6 +69,7 @@ class BrowserContext : public base::RefCounted<BrowserContext>,
net::URLRequestContextGetter* CreateMediaRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory) override;
std::string GetMediaDeviceIDSalt() override;
URLRequestContextGetter* url_request_context_getter() const {
return url_request_getter_.get();
@ -88,7 +91,6 @@ class BrowserContext : public base::RefCounted<BrowserContext>,
// URLRequestContextGetter::Delegate:
net::NetworkDelegate* CreateNetworkDelegate() override;
MediaDeviceIDSalt* GetMediaDeviceIDSalt() override;
base::FilePath GetPath() const override;

View file

@ -13,6 +13,7 @@
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "brightray/browser/browser_context.h"

View file

@ -200,6 +200,8 @@ DevToolsEmbedderMessageDispatcher::CreateForDevToolsFrontend(
d->RegisterHandler("setPreference", &Delegate::SetPreference, delegate);
d->RegisterHandler("removePreference", &Delegate::RemovePreference, delegate);
d->RegisterHandler("clearPreferences", &Delegate::ClearPreferences, delegate);
d->RegisterHandler("registerExtensionsAPI", &Delegate::RegisterExtensionsAPI,
delegate);
return d;
}

View file

@ -78,6 +78,8 @@ class DevToolsEmbedderMessageDispatcher {
const std::string& value) = 0;
virtual void RemovePreference(const std::string& name) = 0;
virtual void ClearPreferences() = 0;
virtual void RegisterExtensionsAPI(const std::string& origin,
const std::string& script) = 0;
};
using DispatchCallback = Delegate::DispatchCallback;

View file

@ -7,10 +7,13 @@
#include "brightray/browser/inspectable_web_contents_impl.h"
#include "base/guid.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram.h"
#include "base/strings/pattern.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@ -25,6 +28,7 @@
#include "components/prefs/scoped_user_pref_update.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/host_zoom_map.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/common/user_agent.h"
@ -596,6 +600,12 @@ void InspectableWebContentsImpl::ClearPreferences() {
update.Get()->Clear();
}
void InspectableWebContentsImpl::RegisterExtensionsAPI(
const std::string& origin,
const std::string& script) {
extensions_api_[origin + "/"] = script;
}
void InspectableWebContentsImpl::HandleMessageFromDevToolsFrontend(
const std::string& message) {
std::string method;
@ -682,6 +692,7 @@ bool InspectableWebContentsImpl::DidAddMessageToConsole(
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,
@ -735,20 +746,51 @@ void InspectableWebContentsImpl::EnumerateDirectory(
delegate->EnumerateDirectory(source, request_id, path);
}
void InspectableWebContentsImpl::OnWebContentsFocused() {
void InspectableWebContentsImpl::OnWebContentsFocused(
content::RenderWidgetHost* render_widget_host) {
#if defined(TOOLKIT_VIEWS)
if (view_->GetDelegate())
view_->GetDelegate()->DevToolsFocused();
#endif
}
void InspectableWebContentsImpl::DidStartNavigationToPendingEntry(
const GURL& url,
content::ReloadType reload_type) {
frontend_host_.reset(content::DevToolsFrontendHost::Create(
web_contents()->GetMainFrame(),
base::Bind(&InspectableWebContentsImpl::HandleMessageFromDevToolsFrontend,
base::Unretained(this))));
void InspectableWebContentsImpl::ReadyToCommitNavigation(
content::NavigationHandle* navigation_handle) {
if (navigation_handle->IsInMainFrame()) {
if (navigation_handle->GetRenderFrameHost() ==
devtools_web_contents_->GetMainFrame() &&
frontend_host_) {
return;
}
frontend_host_.reset(content::DevToolsFrontendHost::Create(
web_contents()->GetMainFrame(),
base::Bind(
&InspectableWebContentsImpl::HandleMessageFromDevToolsFrontend,
base::Unretained(this))));
return;
}
}
void InspectableWebContentsImpl::DidFinishNavigation(
content::NavigationHandle* navigation_handle) {
if (navigation_handle->IsInMainFrame() ||
!navigation_handle->GetURL().SchemeIs("chrome-extension") ||
!navigation_handle->HasCommitted())
return;
content::RenderFrameHost* frame = navigation_handle->GetRenderFrameHost();
auto origin = navigation_handle->GetURL().GetOrigin().spec();
auto it = extensions_api_.find(origin);
if (it == extensions_api_.end())
return;
// Injected Script from devtools frontend doesn't expose chrome,
// most likely bug in chromium.
base::ReplaceFirstSubstringAfterOffset(&it->second, 0, "var chrome",
"var chrome = window.chrome ");
auto script = base::StringPrintf("%s(\"%s\")", it->second.c_str(),
base::GenerateGUID().c_str());
// Invoking content::DevToolsFrontendHost::SetupExtensionsAPI(frame, script);
// should be enough, but it seems to be a noop currently.
frame->ExecuteJavaScriptForTests(base::UTF8ToUTF16(script));
}
void InspectableWebContentsImpl::OnURLFetchComplete(
@ -758,10 +800,10 @@ void InspectableWebContentsImpl::OnURLFetchComplete(
DCHECK(it != pending_requests_.end());
base::DictionaryValue response;
auto* headers = new base::DictionaryValue();
auto headers = base::MakeUnique<base::DictionaryValue>();
net::HttpResponseHeaders* rh = source->GetResponseHeaders();
response.SetInteger("statusCode", rh ? rh->response_code() : 200);
response.Set("headers", headers);
response.Set("headers", std::move(headers));
size_t iterator = 0;
std::string name;

View file

@ -113,6 +113,8 @@ class InspectableWebContentsImpl :
const std::string& value) override;
void RemovePreference(const std::string& name) override;
void ClearPreferences() override;
void RegisterExtensionsAPI(const std::string& origin,
const std::string& script) override;
// content::DevToolsFrontendHostDelegate:
void HandleMessageFromDevToolsFrontend(const std::string& message);
@ -127,10 +129,12 @@ class InspectableWebContentsImpl :
void RenderFrameHostChanged(content::RenderFrameHost* old_host,
content::RenderFrameHost* new_host) override;
void WebContentsDestroyed() override;
void OnWebContentsFocused() override;
void DidStartNavigationToPendingEntry(
const GURL& url,
content::ReloadType reload_type) override;
void OnWebContentsFocused(
content::RenderWidgetHost* render_widget_host) override;
void ReadyToCommitNavigation(
content::NavigationHandle* navigation_handle) override;
void DidFinishNavigation(
content::NavigationHandle* navigation_handle) override;
// content::WebContentsDelegate:
bool DidAddMessageToConsole(content::WebContents* source,
@ -140,6 +144,7 @@ class InspectableWebContentsImpl :
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,
@ -190,6 +195,9 @@ class InspectableWebContentsImpl :
std::unique_ptr<content::WebContents> devtools_web_contents_;
std::unique_ptr<InspectableWebContentsView> view_;
using ExtensionsAPIs = std::map<std::string, std::string>;
ExtensionsAPIs extensions_api_;
base::WeakPtrFactory<InspectableWebContentsImpl> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsImpl);

View file

@ -5,8 +5,8 @@
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/resource_context.h"
using content::BrowserThread;
@ -24,7 +24,7 @@ MediaDeviceIDSalt::MediaDeviceIDSalt(PrefService* pref_service) {
media_device_id_salt_.Init(kMediaDeviceIdSalt, pref_service);
if (media_device_id_salt_.GetValue().empty()) {
media_device_id_salt_.SetValue(
content::ResourceContext::CreateRandomMediaDeviceIDSalt());
content::BrowserContext::CreateRandomMediaDeviceIDSalt());
}
}
@ -47,7 +47,7 @@ void MediaDeviceIDSalt::RegisterPrefs(PrefRegistrySimple* registry) {
void MediaDeviceIDSalt::Reset(PrefService* pref_service) {
pref_service->SetString(
kMediaDeviceIdSalt,
content::ResourceContext::CreateRandomMediaDeviceIDSalt());
content::BrowserContext::CreateRandomMediaDeviceIDSalt());
}
} // namespace brightray

View file

@ -5,7 +5,9 @@
#include "brightray/browser/net/devtools_network_protocol_handler.h"
#include <string>
#include <utility>
#include "base/memory/ptr_util.h"
#include "base/strings/stringprintf.h"
#include "brightray/browser/browser_context.h"
#include "brightray/browser/net/devtools_network_conditions.h"
@ -60,17 +62,17 @@ bool ParseCommand(const base::DictionaryValue* command,
std::unique_ptr<base::DictionaryValue>
CreateSuccessResponse(int id, std::unique_ptr<base::DictionaryValue> result) {
std::unique_ptr<base::DictionaryValue> response(new base::DictionaryValue);
auto response = base::MakeUnique<base::DictionaryValue>();
response->SetInteger(kId, id);
response->Set(params::kResult, result.release());
response->Set(params::kResult, std::move(result));
return response;
}
std::unique_ptr<base::DictionaryValue>
CreateFailureResponse(int id, const std::string& param) {
std::unique_ptr<base::DictionaryValue> response(new base::DictionaryValue);
auto error_object = new base::DictionaryValue;
response->Set(kError, error_object);
auto response = base::MakeUnique<base::DictionaryValue>();
auto error_object = base::MakeUnique<base::DictionaryValue>();
response->Set(kError, std::move(error_object));
error_object->SetInteger(params::kErrorCode, kErrorInvalidParams);
error_object->SetString(params::kErrorMessage,
base::StringPrintf("Missing or Invalid '%s' parameter", param.c_str()));

View file

@ -5,6 +5,7 @@
#include "brightray/browser/net/devtools_network_transaction.h"
#include <string>
#include <utility>
#include "brightray/browser/net/devtools_network_controller.h"
#include "brightray/browser/net/devtools_network_upload_data_stream.h"
@ -165,18 +166,18 @@ int DevToolsNetworkTransaction::RestartIgnoringLastError(
}
int DevToolsNetworkTransaction::RestartWithCertificate(
net::X509Certificate* client_cert,
net::SSLPrivateKey* client_private_key,
scoped_refptr<net::X509Certificate> client_cert,
scoped_refptr<net::SSLPrivateKey> client_private_key,
const net::CompletionCallback& callback) {
if (CheckFailed())
return net::ERR_INTERNET_DISCONNECTED;
if (!interceptor_) {
return transaction_->RestartWithCertificate(
client_cert, client_private_key, callback);
std::move(client_cert), std::move(client_private_key), callback);
}
int result = transaction_->RestartWithCertificate(
client_cert, client_private_key,
std::move(client_cert), std::move(client_private_key),
base::Bind(&DevToolsNetworkTransaction::IOCallback,
base::Unretained(this), callback, true));
return Throttle(callback, true, result);

View file

@ -34,9 +34,10 @@ class DevToolsNetworkTransaction : public net::HttpTransaction {
const net::NetLogWithSource& net_log) override;
int RestartIgnoringLastError(
const net::CompletionCallback& callback) override;
int RestartWithCertificate(net::X509Certificate* client_cert,
net::SSLPrivateKey* client_private_key,
const net::CompletionCallback& callback) override;
int RestartWithCertificate(
scoped_refptr<net::X509Certificate> client_cert,
scoped_refptr<net::SSLPrivateKey> client_private_key,
const net::CompletionCallback& callback) override;
int RestartWithAuth(const net::AuthCredentials& credentials,
const net::CompletionCallback& callback) override;
bool IsReadyToRestartForAuth() override;

View file

@ -4,10 +4,15 @@
#include "brightray/browser/net_log.h"
#include <utility>
#include "base/callback.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "content/public/common/content_switches.h"
#include "net/log/file_net_log_observer.h"
#include "net/log/net_log_util.h"
namespace brightray {
@ -18,12 +23,12 @@ std::unique_ptr<base::DictionaryValue> GetConstants() {
std::unique_ptr<base::DictionaryValue> constants = net::GetNetConstants();
// Adding client information to constants dictionary.
auto* client_info = new base::DictionaryValue();
auto client_info = base::MakeUnique<base::DictionaryValue>();
client_info->SetString(
"command_line",
base::CommandLine::ForCurrentProcess()->GetCommandLineString());
constants->Set("clientInfo", client_info);
constants->Set("clientInfo", std::move(client_info));
return constants;
}
@ -33,32 +38,26 @@ NetLog::NetLog() {
}
NetLog::~NetLog() {
if (file_net_log_observer_) {
file_net_log_observer_->StopObserving(nullptr, base::Closure());
file_net_log_observer_.reset();
}
}
void NetLog::StartLogging(net::URLRequestContext* url_request_context) {
void NetLog::StartLogging() {
auto command_line = base::CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kLogNetLog))
return;
base::FilePath log_path =
command_line->GetSwitchValuePath(switches::kLogNetLog);
#if defined(OS_WIN)
log_file_.reset(_wfopen(log_path.value().c_str(), L"w"));
#elif defined(OS_POSIX)
log_file_.reset(fopen(log_path.value().c_str(), "w"));
#endif
if (!log_file_) {
LOG(ERROR) << "Could not open file: " << log_path.value()
<< "for net logging";
return;
}
std::unique_ptr<base::Value> constants(GetConstants());
write_to_file_observer_.StartObserving(this,
std::move(log_file_),
constants.get(),
url_request_context);
net::NetLogCaptureMode capture_mode =
net::NetLogCaptureMode::IncludeCookiesAndCredentials();
file_net_log_observer_ =
net::FileNetLogObserver::CreateUnbounded(log_path, std::move(constants));
file_net_log_observer_->StartObserving(this, capture_mode);
}
} // namespace brightray

View file

@ -5,9 +5,11 @@
#ifndef BRIGHTRAY_BROWSER_NET_LOG_H_
#define BRIGHTRAY_BROWSER_NET_LOG_H_
#include "base/files/scoped_file.h"
#include "net/log/net_log.h"
#include "net/log/write_to_file_net_log_observer.h"
namespace net {
class FileNetLogObserver;
}
namespace brightray {
@ -16,11 +18,11 @@ class NetLog : public net::NetLog {
NetLog();
~NetLog() override;
void StartLogging(net::URLRequestContext* url_request_context);
void StartLogging();
private:
base::ScopedFILE log_file_;
net::WriteToFileNetLogObserver write_to_file_observer_;
// This observer handles writing NetLogs.
std::unique_ptr<net::FileNetLogObserver> file_net_log_observer_;
DISALLOW_COPY_AND_ASSIGN(NetLog);
};

View file

@ -123,8 +123,10 @@ bool NetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
return true;
}
bool NetworkDelegate::OnCanAccessFile(const net::URLRequest& request,
const base::FilePath& path) const {
bool NetworkDelegate::OnCanAccessFile(
const net::URLRequest& request,
const base::FilePath& original_path,
const base::FilePath& absolute_path) const {
return true;
}
@ -145,4 +147,28 @@ bool NetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader(
return false;
}
// TODO(deepak1556) : Enable after hooking into the reporting service
// https://crbug.com/704259
bool NetworkDelegate::OnCanQueueReportingReport(
const url::Origin& origin) const {
return false;
}
bool NetworkDelegate::OnCanSendReportingReport(
const url::Origin& origin) const {
return false;
}
bool NetworkDelegate::OnCanSetReportingClient(
const url::Origin& origin,
const GURL& endpoint) const {
return false;
}
bool NetworkDelegate::OnCanUseReportingClient(
const url::Origin& origin,
const GURL& endpoint) const {
return false;
}
} // namespace brightray

View file

@ -58,7 +58,8 @@ class NetworkDelegate : public net::NetworkDelegate {
const std::string& cookie_line,
net::CookieOptions* options) override;
bool OnCanAccessFile(const net::URLRequest& request,
const base::FilePath& path) const override;
const base::FilePath& original_path,
const base::FilePath& absolute_path) const override;
bool OnCanEnablePrivacyMode(
const GURL& url,
const GURL& first_party_for_cookies) const override;
@ -67,6 +68,12 @@ class NetworkDelegate : public net::NetworkDelegate {
const net::URLRequest& request,
const GURL& target_url,
const GURL& referrer_url) const override;
bool OnCanQueueReportingReport(const url::Origin& origin) const override;
bool OnCanSendReportingReport(const url::Origin& origin) const override;
bool OnCanSetReportingClient(const url::Origin& origin,
const GURL& endpoint) const override;
bool OnCanUseReportingClient(const url::Origin& origin,
const GURL& endpoint) const override;
private:
std::vector<std::string> ignore_connections_limit_domains_;

View file

@ -7,11 +7,9 @@
#include <string>
#include "content/public/browser/desktop_notification_delegate.h"
namespace brightray {
class NotificationDelegate : public content::DesktopNotificationDelegate {
class NotificationDelegate {
public:
// The native Notification object is destroyed.
virtual void NotificationDestroyed() {}
@ -22,6 +20,14 @@ class NotificationDelegate : public content::DesktopNotificationDelegate {
// Notification was replied to
virtual void NotificationReplied(const std::string& reply) {}
virtual void NotificationAction(int index) {}
virtual void NotificationClick() {}
virtual void NotificationClosed() {}
virtual void NotificationDisplayed() {}
protected:
NotificationDelegate() = default;
~NotificationDelegate() = default;
};
} // namespace brightray

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