Merge remote-tracking branch 'origin/master' into renaesop_master
This commit is contained in:
commit
84a9b6a42d
336 changed files with 16704 additions and 2418 deletions
|
@ -464,8 +464,8 @@ int ImportIntoCertStore(
|
|||
|
||||
if (!cert_path.empty()) {
|
||||
if (base::ReadFileToString(base::FilePath(cert_path), &file_data)) {
|
||||
auto module = model->cert_db()->GetPublicModule();
|
||||
rv = model->ImportFromPKCS12(module,
|
||||
auto module = model->cert_db()->GetPrivateSlot();
|
||||
rv = model->ImportFromPKCS12(module.get(),
|
||||
file_data,
|
||||
password,
|
||||
true,
|
||||
|
|
|
@ -62,6 +62,10 @@ struct Converter<net::CookieStore::ChangeCause> {
|
|||
switch (val) {
|
||||
case net::CookieStore::ChangeCause::INSERTED:
|
||||
case net::CookieStore::ChangeCause::EXPLICIT:
|
||||
case net::CookieStore::ChangeCause::EXPLICIT_DELETE_BETWEEN:
|
||||
case net::CookieStore::ChangeCause::EXPLICIT_DELETE_PREDICATE:
|
||||
case net::CookieStore::ChangeCause::EXPLICIT_DELETE_SINGLE:
|
||||
case net::CookieStore::ChangeCause::EXPLICIT_DELETE_CANONICAL:
|
||||
return mate::StringToV8(isolate, "explicit");
|
||||
case net::CookieStore::ChangeCause::OVERWRITE:
|
||||
return mate::StringToV8(isolate, "overwrite");
|
||||
|
@ -228,8 +232,8 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
|||
GetCookieStore(getter)->SetCookieWithDetailsAsync(
|
||||
GURL(url), name, value, domain, path, creation_time,
|
||||
expiration_time, last_access_time, secure, http_only,
|
||||
net::CookieSameSite::DEFAULT_MODE, false,
|
||||
net::COOKIE_PRIORITY_DEFAULT, base::Bind(OnSetCookie, callback));
|
||||
net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT,
|
||||
base::Bind(OnSetCookie, callback));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include "atom/browser/api/atom_api_desktop_capturer.h"
|
||||
|
||||
using base::PlatformThreadRef;
|
||||
|
||||
#include "atom/common/api/atom_api_native_image.h"
|
||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
|
|
|
@ -50,20 +50,25 @@ void RegisterStandardSchemes(const std::vector<std::string>& schemes,
|
|||
mate::Arguments* args) {
|
||||
g_standard_schemes = schemes;
|
||||
|
||||
mate::Dictionary opts;
|
||||
bool secure = false;
|
||||
args->GetNext(&opts) && opts.Get("secure", &secure);
|
||||
|
||||
// Dynamically register the schemes.
|
||||
auto* policy = content::ChildProcessSecurityPolicy::GetInstance();
|
||||
for (const std::string& scheme : schemes) {
|
||||
url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITHOUT_PORT);
|
||||
if (secure) {
|
||||
url::AddSecureScheme(scheme.c_str());
|
||||
}
|
||||
policy->RegisterWebSafeScheme(scheme);
|
||||
}
|
||||
|
||||
// add switches to register as standard
|
||||
// Add the schemes to command line switches, so child processes can also
|
||||
// register them.
|
||||
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
||||
atom::switches::kStandardSchemes, base::JoinString(schemes, ","));
|
||||
|
||||
mate::Dictionary opts;
|
||||
bool secure = false;
|
||||
if (args->GetNext(&opts) && opts.Get("secure", &secure) && secure) {
|
||||
// add switches to register as secure
|
||||
if (secure) {
|
||||
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
||||
atom::switches::kSecureSchemes, base::JoinString(schemes, ","));
|
||||
}
|
||||
|
|
|
@ -432,7 +432,8 @@ void DownloadIdCallback(content::DownloadManager* download_manager,
|
|||
last_modified, offset, length, std::string(),
|
||||
content::DownloadItem::INTERRUPTED,
|
||||
content::DownloadDangerType::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
|
||||
content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, false);
|
||||
content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, false,
|
||||
std::vector<content::DownloadItem::ReceivedSlice>());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include "atom/browser/atom_browser_client.h"
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
#include "atom/browser/atom_javascript_dialog_manager.h"
|
||||
#include "atom/browser/child_web_contents_tracker.h"
|
||||
#include "atom/browser/lib/bluetooth_chooser.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/net/atom_network_delegate.h"
|
||||
|
@ -39,6 +41,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/process/process_handle.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "base/values.h"
|
||||
|
@ -49,6 +52,7 @@
|
|||
#include "chrome/browser/ssl/security_state_tab_helper.h"
|
||||
#include "content/browser/frame_host/navigation_entry_impl.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_view_base.h"
|
||||
#include "content/browser/web_contents/web_contents_impl.h"
|
||||
#include "content/common/view_messages.h"
|
||||
#include "content/public/browser/favicon_status.h"
|
||||
|
@ -78,6 +82,7 @@
|
|||
#include "third_party/WebKit/public/platform/WebInputEvent.h"
|
||||
#include "third_party/WebKit/public/web/WebFindOptions.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/events/base_event_utils.h"
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
#include "ui/aura/window.h"
|
||||
|
@ -332,6 +337,9 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
|
|||
else if (options.Get("offscreen", &b) && b)
|
||||
type_ = OFF_SCREEN;
|
||||
|
||||
// Init embedder earlier
|
||||
options.Get("embedder", &embedder_);
|
||||
|
||||
// Whether to enable DevTools.
|
||||
options.Get("devTools", &enable_devtools_);
|
||||
|
||||
|
@ -356,7 +364,18 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
|
|||
session->browser_context(), site_instance);
|
||||
guest_delegate_.reset(new WebViewGuestDelegate);
|
||||
params.guest_delegate = guest_delegate_.get();
|
||||
web_contents = content::WebContents::Create(params);
|
||||
|
||||
if (embedder_ && embedder_->IsOffScreen()) {
|
||||
auto* view = new OffScreenWebContentsView(false,
|
||||
base::Bind(&WebContents::OnPaint, base::Unretained(this)));
|
||||
params.view = view;
|
||||
params.delegate_view = view;
|
||||
|
||||
web_contents = content::WebContents::Create(params);
|
||||
view->SetWebContents(web_contents);
|
||||
} else {
|
||||
web_contents = content::WebContents::Create(params);
|
||||
}
|
||||
} else if (IsOffScreen()) {
|
||||
bool transparent = false;
|
||||
options.Get("transparent", &transparent);
|
||||
|
@ -406,7 +425,7 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
|
|||
guest_delegate_->Initialize(this);
|
||||
|
||||
NativeWindow* owner_window = nullptr;
|
||||
if (options.Get("embedder", &embedder_) && embedder_) {
|
||||
if (embedder_) {
|
||||
// New WebContents's owner_window is the embedder's owner_window.
|
||||
auto relay =
|
||||
NativeWindowRelay::FromWebContents(embedder_->web_contents());
|
||||
|
@ -502,6 +521,7 @@ void WebContents::AddNewContents(content::WebContents* source,
|
|||
const gfx::Rect& initial_rect,
|
||||
bool user_gesture,
|
||||
bool* was_blocked) {
|
||||
new ChildWebContentsTracker(new_contents);
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
auto api_web_contents = CreateFrom(isolate(), new_contents);
|
||||
|
@ -585,8 +605,8 @@ bool WebContents::PreHandleKeyboardEvent(
|
|||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event,
|
||||
bool* is_keyboard_shortcut) {
|
||||
if (event.type == blink::WebInputEvent::Type::RawKeyDown
|
||||
|| event.type == blink::WebInputEvent::Type::KeyUp)
|
||||
if (event.type() == blink::WebInputEvent::Type::RawKeyDown ||
|
||||
event.type() == blink::WebInputEvent::Type::KeyUp)
|
||||
return Emit("before-input-event", event);
|
||||
else
|
||||
return false;
|
||||
|
@ -698,6 +718,15 @@ std::unique_ptr<content::BluetoothChooser> WebContents::RunBluetoothChooser(
|
|||
return std::move(bluetooth_chooser);
|
||||
}
|
||||
|
||||
content::JavaScriptDialogManager*
|
||||
WebContents::GetJavaScriptDialogManager(
|
||||
content::WebContents* source) {
|
||||
if (!dialog_manager_)
|
||||
dialog_manager_.reset(new AtomJavaScriptDialogManager(this));
|
||||
|
||||
return dialog_manager_.get();
|
||||
}
|
||||
|
||||
void WebContents::BeforeUnloadFired(const base::TimeTicks& proceed_time) {
|
||||
// Do nothing, we override this method just to avoid compilation error since
|
||||
// there are two virtual functions named BeforeUnloadFired.
|
||||
|
@ -890,6 +919,15 @@ void WebContents::Observe(int type,
|
|||
}
|
||||
}
|
||||
|
||||
void WebContents::BeforeUnloadDialogCancelled() {
|
||||
if (deferred_load_url_.id) {
|
||||
auto& controller = web_contents()->GetController();
|
||||
if (!controller.GetPendingEntry()) {
|
||||
deferred_load_url_.id = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WebContents::DevToolsReloadPage() {
|
||||
Emit("devtools-reload-page");
|
||||
}
|
||||
|
@ -906,7 +944,7 @@ void WebContents::DevToolsOpened() {
|
|||
devtools_web_contents_.Reset(isolate(), handle.ToV8());
|
||||
|
||||
// Set inspected tabID.
|
||||
base::FundamentalValue tab_id(ID());
|
||||
base::Value tab_id(ID());
|
||||
managed_web_contents()->CallClientFunction(
|
||||
"DevToolsAPI.setInspectedTabId", &tab_id, nullptr, nullptr);
|
||||
|
||||
|
@ -979,7 +1017,7 @@ void WebContents::NavigationEntryCommitted(
|
|||
|
||||
int64_t WebContents::GetID() const {
|
||||
int64_t process_id = web_contents()->GetRenderProcessHost()->GetID();
|
||||
int64_t routing_id = web_contents()->GetRoutingID();
|
||||
int64_t routing_id = web_contents()->GetRenderViewHost()->GetRoutingID();
|
||||
int64_t rv = (process_id << 32) + routing_id;
|
||||
return rv;
|
||||
}
|
||||
|
@ -988,6 +1026,11 @@ int WebContents::GetProcessID() const {
|
|||
return web_contents()->GetRenderProcessHost()->GetID();
|
||||
}
|
||||
|
||||
base::ProcessId WebContents::GetOSProcessID() const {
|
||||
auto process_handle = web_contents()->GetRenderProcessHost()->GetHandle();
|
||||
return base::GetProcId(process_handle);
|
||||
}
|
||||
|
||||
WebContents::Type WebContents::GetType() const {
|
||||
return type_;
|
||||
}
|
||||
|
@ -1345,7 +1388,7 @@ void WebContents::SelectAll() {
|
|||
}
|
||||
|
||||
void WebContents::Unselect() {
|
||||
web_contents()->Unselect();
|
||||
web_contents()->CollapseSelection();
|
||||
}
|
||||
|
||||
void WebContents::Replace(const base::string16& word) {
|
||||
|
@ -1420,30 +1463,31 @@ bool WebContents::SendIPCMessage(bool all_frames,
|
|||
|
||||
void WebContents::SendInputEvent(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> input_event) {
|
||||
const auto view = web_contents()->GetRenderWidgetHostView();
|
||||
const auto view = static_cast<content::RenderWidgetHostViewBase*>(
|
||||
web_contents()->GetRenderWidgetHostView());
|
||||
if (!view)
|
||||
return;
|
||||
const auto host = view->GetRenderWidgetHost();
|
||||
if (!host)
|
||||
return;
|
||||
|
||||
int type = mate::GetWebInputEventType(isolate, input_event);
|
||||
if (blink::WebInputEvent::isMouseEventType(type)) {
|
||||
blink::WebMouseEvent mouse_event;
|
||||
if (mate::ConvertFromV8(isolate, input_event, &mouse_event)) {
|
||||
host->ForwardMouseEvent(mouse_event);
|
||||
view->ProcessMouseEvent(mouse_event, ui::LatencyInfo());
|
||||
return;
|
||||
}
|
||||
} else if (blink::WebInputEvent::isKeyboardEventType(type)) {
|
||||
content::NativeWebKeyboardEvent keyboard_event;
|
||||
content::NativeWebKeyboardEvent keyboard_event(
|
||||
blink::WebKeyboardEvent::RawKeyDown,
|
||||
blink::WebInputEvent::NoModifiers,
|
||||
ui::EventTimeForNow());
|
||||
if (mate::ConvertFromV8(isolate, input_event, &keyboard_event)) {
|
||||
host->ForwardKeyboardEvent(keyboard_event);
|
||||
view->ProcessKeyboardEvent(keyboard_event);
|
||||
return;
|
||||
}
|
||||
} else if (type == blink::WebInputEvent::MouseWheel) {
|
||||
blink::WebMouseWheelEvent mouse_wheel_event;
|
||||
if (mate::ConvertFromV8(isolate, input_event, &mouse_wheel_event)) {
|
||||
host->ForwardWheelEvent(mouse_wheel_event);
|
||||
view->ProcessMouseWheelEvent(mouse_wheel_event, ui::LatencyInfo());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1525,8 +1569,7 @@ void WebContents::CapturePage(mate::Arguments* args) {
|
|||
}
|
||||
|
||||
const auto view = web_contents()->GetRenderWidgetHostView();
|
||||
const auto host = view ? view->GetRenderWidgetHost() : nullptr;
|
||||
if (!view || !host) {
|
||||
if (!view) {
|
||||
callback.Run(gfx::Image());
|
||||
return;
|
||||
}
|
||||
|
@ -1546,10 +1589,10 @@ void WebContents::CapturePage(mate::Arguments* args) {
|
|||
if (scale > 1.0f)
|
||||
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
|
||||
|
||||
host->CopyFromBackingStore(gfx::Rect(rect.origin(), view_size),
|
||||
bitmap_size,
|
||||
base::Bind(&OnCapturePageDone, callback),
|
||||
kBGRA_8888_SkColorType);
|
||||
view->CopyFromSurface(gfx::Rect(rect.origin(), view_size),
|
||||
bitmap_size,
|
||||
base::Bind(&OnCapturePageDone, callback),
|
||||
kBGRA_8888_SkColorType);
|
||||
}
|
||||
|
||||
void WebContents::OnCursorChange(const content::WebCursor& cursor) {
|
||||
|
@ -1581,9 +1624,7 @@ bool WebContents::IsOffScreen() const {
|
|||
}
|
||||
|
||||
void WebContents::OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap) {
|
||||
mate::Handle<NativeImage> image =
|
||||
NativeImage::Create(isolate(), gfx::Image::CreateFrom1xBitmap(bitmap));
|
||||
Emit("paint", dirty_rect, image);
|
||||
Emit("paint", dirty_rect, gfx::Image::CreateFrom1xBitmap(bitmap));
|
||||
}
|
||||
|
||||
void WebContents::StartPainting() {
|
||||
|
@ -1647,6 +1688,18 @@ void WebContents::Invalidate() {
|
|||
}
|
||||
}
|
||||
|
||||
gfx::Size WebContents::GetSizeForNewRenderView(
|
||||
content::WebContents* wc) const {
|
||||
if (IsOffScreen() && wc == web_contents()) {
|
||||
auto relay = NativeWindowRelay::FromWebContents(web_contents());
|
||||
if (relay) {
|
||||
return relay->window->GetSize();
|
||||
}
|
||||
}
|
||||
|
||||
return gfx::Size();
|
||||
}
|
||||
|
||||
void WebContents::SetZoomLevel(double level) {
|
||||
zoom_controller_->SetZoomLevel(level);
|
||||
}
|
||||
|
@ -1747,6 +1800,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
|||
.MakeDestroyable()
|
||||
.SetMethod("getId", &WebContents::GetID)
|
||||
.SetMethod("getProcessId", &WebContents::GetProcessID)
|
||||
.SetMethod("getOSProcessId", &WebContents::GetOSProcessID)
|
||||
.SetMethod("equal", &WebContents::Equal)
|
||||
.SetMethod("_loadURL", &WebContents::LoadURL)
|
||||
.SetMethod("downloadURL", &WebContents::DownloadURL)
|
||||
|
|
|
@ -42,6 +42,7 @@ namespace atom {
|
|||
|
||||
struct SetSizeParams;
|
||||
class AtomBrowserContext;
|
||||
class AtomJavaScriptDialogManager;
|
||||
class WebContentsZoomController;
|
||||
class WebViewGuestDelegate;
|
||||
|
||||
|
@ -83,6 +84,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
|
||||
int64_t GetID() const;
|
||||
int GetProcessID() const;
|
||||
base::ProcessId GetOSProcessID() const;
|
||||
Type GetType() const;
|
||||
bool Equal(const WebContents* web_contents) const;
|
||||
void LoadURL(const GURL& url, const mate::Dictionary& options);
|
||||
|
@ -185,6 +187,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
void SetFrameRate(int frame_rate);
|
||||
int GetFrameRate() const;
|
||||
void Invalidate();
|
||||
gfx::Size GetSizeForNewRenderView(content::WebContents*) const override;
|
||||
|
||||
// Methods for zoom handling.
|
||||
void SetZoomLevel(double level);
|
||||
|
@ -298,6 +301,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
std::unique_ptr<content::BluetoothChooser> RunBluetoothChooser(
|
||||
content::RenderFrameHost* frame,
|
||||
const content::BluetoothChooser::EventHandler& handler) override;
|
||||
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
|
||||
content::WebContents* source) override;
|
||||
|
||||
// content::WebContentsObserver:
|
||||
void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
|
||||
|
@ -342,6 +347,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
void Observe(int type,
|
||||
const content::NotificationSource& source,
|
||||
const content::NotificationDetails& details) override;
|
||||
void BeforeUnloadDialogCancelled() override;
|
||||
|
||||
// brightray::InspectableWebContentsDelegate:
|
||||
void DevToolsReloadPage() override;
|
||||
|
@ -389,6 +395,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
v8::Global<v8::Value> devtools_web_contents_;
|
||||
v8::Global<v8::Value> debugger_;
|
||||
|
||||
std::unique_ptr<AtomJavaScriptDialogManager> dialog_manager_;
|
||||
std::unique_ptr<WebViewGuestDelegate> guest_delegate_;
|
||||
|
||||
// The host webcontents that may contain this webcontents.
|
||||
|
|
|
@ -24,6 +24,7 @@ FrameSubscriber::FrameSubscriber(v8::Isolate* isolate,
|
|||
view_(view),
|
||||
callback_(callback),
|
||||
only_dirty_(only_dirty),
|
||||
source_id_for_copy_request_(base::UnguessableToken::Create()),
|
||||
weak_factory_(this) {
|
||||
}
|
||||
|
||||
|
@ -32,8 +33,7 @@ bool FrameSubscriber::ShouldCaptureFrame(
|
|||
base::TimeTicks present_time,
|
||||
scoped_refptr<media::VideoFrame>* storage,
|
||||
DeliverFrameCallback* callback) {
|
||||
const auto host = view_ ? view_->GetRenderWidgetHost() : nullptr;
|
||||
if (!view_ || !host)
|
||||
if (!view_)
|
||||
return false;
|
||||
|
||||
if (dirty_rect.IsEmpty())
|
||||
|
@ -54,7 +54,7 @@ bool FrameSubscriber::ShouldCaptureFrame(
|
|||
|
||||
rect = gfx::Rect(rect.origin(), bitmap_size);
|
||||
|
||||
host->CopyFromBackingStore(
|
||||
view_->CopyFromSurface(
|
||||
rect,
|
||||
rect.size(),
|
||||
base::Bind(&FrameSubscriber::OnFrameDelivered,
|
||||
|
@ -64,6 +64,10 @@ bool FrameSubscriber::ShouldCaptureFrame(
|
|||
return false;
|
||||
}
|
||||
|
||||
const base::UnguessableToken& FrameSubscriber::GetSourceIdForCopyRequest() {
|
||||
return source_id_for_copy_request_;
|
||||
}
|
||||
|
||||
void FrameSubscriber::OnFrameDelivered(const FrameCaptureCallback& callback,
|
||||
const gfx::Rect& damage_rect,
|
||||
const SkBitmap& bitmap,
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
#include "base/callback.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_view_frame_subscriber.h"
|
||||
#include "content/public/browser/readback_types.h"
|
||||
#include "content/public/browser/render_widget_host_view.h"
|
||||
#include "content/public/browser/render_widget_host_view_frame_subscriber.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
#include "v8/include/v8.h"
|
||||
|
@ -32,6 +32,7 @@ class FrameSubscriber : public content::RenderWidgetHostViewFrameSubscriber {
|
|||
base::TimeTicks present_time,
|
||||
scoped_refptr<media::VideoFrame>* storage,
|
||||
DeliverFrameCallback* callback) override;
|
||||
const base::UnguessableToken& GetSourceIdForCopyRequest() override;
|
||||
|
||||
private:
|
||||
void OnFrameDelivered(const FrameCaptureCallback& callback,
|
||||
|
@ -44,6 +45,8 @@ class FrameSubscriber : public content::RenderWidgetHostViewFrameSubscriber {
|
|||
FrameCaptureCallback callback_;
|
||||
bool only_dirty_;
|
||||
|
||||
base::UnguessableToken source_id_for_copy_request_;
|
||||
|
||||
base::WeakPtrFactory<FrameSubscriber> weak_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(FrameSubscriber);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "atom/browser/atom_quota_permission_context.h"
|
||||
#include "atom/browser/atom_resource_dispatcher_host_delegate.h"
|
||||
#include "atom/browser/atom_speech_recognition_manager_delegate.h"
|
||||
#include "atom/browser/child_web_contents_tracker.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/web_contents_permission_helper.h"
|
||||
#include "atom/browser/web_contents_preferences.h"
|
||||
|
@ -87,17 +88,31 @@ content::WebContents* AtomBrowserClient::GetWebContentsFromProcessID(
|
|||
}
|
||||
|
||||
bool AtomBrowserClient::ShouldCreateNewSiteInstance(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
content::BrowserContext* browser_context,
|
||||
content::SiteInstance* current_instance,
|
||||
const GURL& url) {
|
||||
|
||||
if (url.SchemeIs(url::kJavaScriptScheme))
|
||||
// "javacript:" scheme should always use same SiteInstance
|
||||
return false;
|
||||
|
||||
if (!IsRendererSandboxed(current_instance->GetProcess()->GetID()))
|
||||
// non-sandboxed renderers should always create a new SiteInstance
|
||||
return true;
|
||||
int process_id = current_instance->GetProcess()->GetID();
|
||||
if (!IsRendererSandboxed(process_id)) {
|
||||
if (!RendererUsesNativeWindowOpen(process_id)) {
|
||||
// non-sandboxed renderers without native window.open should always create
|
||||
// a new SiteInstance
|
||||
return true;
|
||||
}
|
||||
auto web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
if (!ChildWebContentsTracker::IsChildWebContents(web_contents)) {
|
||||
// Root WebContents should always create new process to make sure
|
||||
// native addons are loaded correctly after reload / navigation.
|
||||
// (Non-root WebContents opened by window.open() should try to
|
||||
// reuse process to allow synchronous cross-window scripting.)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Create new a SiteInstance if navigating to a different site.
|
||||
auto src_url = current_instance->GetSiteURL();
|
||||
|
@ -109,19 +124,27 @@ bool AtomBrowserClient::ShouldCreateNewSiteInstance(
|
|||
content::SiteInstance::GetSiteForURL(browser_context, url) != src_url;
|
||||
}
|
||||
|
||||
void AtomBrowserClient::AddSandboxedRendererId(int process_id) {
|
||||
base::AutoLock auto_lock(sandboxed_renderers_lock_);
|
||||
sandboxed_renderers_.insert(process_id);
|
||||
void AtomBrowserClient::AddProcessPreferences(
|
||||
int process_id, AtomBrowserClient::ProcessPreferences prefs) {
|
||||
base::AutoLock auto_lock(process_preferences_lock_);
|
||||
process_preferences_[process_id] = prefs;
|
||||
}
|
||||
|
||||
void AtomBrowserClient::RemoveSandboxedRendererId(int process_id) {
|
||||
base::AutoLock auto_lock(sandboxed_renderers_lock_);
|
||||
sandboxed_renderers_.erase(process_id);
|
||||
void AtomBrowserClient::RemoveProcessPreferences(int process_id) {
|
||||
base::AutoLock auto_lock(process_preferences_lock_);
|
||||
process_preferences_.erase(process_id);
|
||||
}
|
||||
|
||||
bool AtomBrowserClient::IsRendererSandboxed(int process_id) {
|
||||
base::AutoLock auto_lock(sandboxed_renderers_lock_);
|
||||
return sandboxed_renderers_.count(process_id);
|
||||
base::AutoLock auto_lock(process_preferences_lock_);
|
||||
auto it = process_preferences_.find(process_id);
|
||||
return it != process_preferences_.end() && it->second.sandbox;
|
||||
}
|
||||
|
||||
bool AtomBrowserClient::RendererUsesNativeWindowOpen(int process_id) {
|
||||
base::AutoLock auto_lock(process_preferences_lock_);
|
||||
auto it = process_preferences_.find(process_id);
|
||||
return it != process_preferences_.end() && it->second.native_window_open;
|
||||
}
|
||||
|
||||
void AtomBrowserClient::RenderProcessWillLaunch(
|
||||
|
@ -133,11 +156,13 @@ void AtomBrowserClient::RenderProcessWillLaunch(
|
|||
new WidevineCdmMessageFilter(process_id, host->GetBrowserContext()));
|
||||
|
||||
content::WebContents* web_contents = GetWebContentsFromProcessID(process_id);
|
||||
if (WebContentsPreferences::IsSandboxed(web_contents)) {
|
||||
AddSandboxedRendererId(host->GetID());
|
||||
// ensure the sandboxed renderer id is removed later
|
||||
host->AddObserver(this);
|
||||
}
|
||||
ProcessPreferences process_prefs;
|
||||
process_prefs.sandbox = WebContentsPreferences::IsSandboxed(web_contents);
|
||||
process_prefs.native_window_open
|
||||
= WebContentsPreferences::UsesNativeWindowOpen(web_contents);
|
||||
AddProcessPreferences(host->GetID(), process_prefs);
|
||||
// ensure the ProcessPreferences is removed later
|
||||
host->AddObserver(this);
|
||||
}
|
||||
|
||||
content::SpeechRecognitionManagerDelegate*
|
||||
|
@ -182,7 +207,8 @@ void AtomBrowserClient::OverrideSiteInstanceForNavigation(
|
|||
return;
|
||||
}
|
||||
|
||||
if (!ShouldCreateNewSiteInstance(browser_context, current_instance, url))
|
||||
if (!ShouldCreateNewSiteInstance(render_frame_host, browser_context,
|
||||
current_instance, url))
|
||||
return;
|
||||
|
||||
scoped_refptr<content::SiteInstance> site_instance =
|
||||
|
@ -296,27 +322,27 @@ void AtomBrowserClient::ResourceDispatcherHostCreated() {
|
|||
}
|
||||
|
||||
bool AtomBrowserClient::CanCreateWindow(
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
const GURL& opener_url,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
WindowContainerType container_type,
|
||||
content::mojom::WindowContainerType container_type,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::WebWindowFeatures& features,
|
||||
const blink::mojom::WindowFeatures& features,
|
||||
const std::vector<std::string>& additional_features,
|
||||
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
|
||||
bool user_gesture,
|
||||
bool opener_suppressed,
|
||||
content::ResourceContext* context,
|
||||
int render_process_id,
|
||||
int opener_render_view_id,
|
||||
int opener_render_frame_id,
|
||||
bool* no_javascript_access) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
||||
|
||||
if (IsRendererSandboxed(render_process_id)) {
|
||||
if (IsRendererSandboxed(opener_render_process_id)
|
||||
|| RendererUsesNativeWindowOpen(opener_render_process_id)) {
|
||||
*no_javascript_access = false;
|
||||
return true;
|
||||
}
|
||||
|
@ -330,7 +356,7 @@ bool AtomBrowserClient::CanCreateWindow(
|
|||
disposition,
|
||||
additional_features,
|
||||
body,
|
||||
render_process_id,
|
||||
opener_render_process_id,
|
||||
opener_render_frame_id));
|
||||
}
|
||||
|
||||
|
@ -381,7 +407,7 @@ void AtomBrowserClient::RenderProcessHostDestroyed(
|
|||
break;
|
||||
}
|
||||
}
|
||||
RemoveSandboxedRendererId(process_id);
|
||||
RemoveProcessPreferences(process_id);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -80,23 +80,22 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
|||
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
|
||||
void ResourceDispatcherHostCreated() override;
|
||||
bool CanCreateWindow(
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
const GURL& opener_url,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
WindowContainerType container_type,
|
||||
content::mojom::WindowContainerType container_type,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::WebWindowFeatures& features,
|
||||
const blink::mojom::WindowFeatures& features,
|
||||
const std::vector<std::string>& additional_features,
|
||||
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
|
||||
bool user_gesture,
|
||||
bool opener_suppressed,
|
||||
content::ResourceContext* context,
|
||||
int render_process_id,
|
||||
int opener_render_view_id,
|
||||
int opener_render_frame_id,
|
||||
bool* no_javascript_access) override;
|
||||
void GetAdditionalAllowedSchemesForFileSystem(
|
||||
std::vector<std::string>* schemes) override;
|
||||
|
@ -112,19 +111,24 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
|||
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
||||
|
||||
private:
|
||||
bool ShouldCreateNewSiteInstance(content::BrowserContext* browser_context,
|
||||
bool ShouldCreateNewSiteInstance(content::RenderFrameHost* render_frame_host,
|
||||
content::BrowserContext* browser_context,
|
||||
content::SiteInstance* current_instance,
|
||||
const GURL& dest_url);
|
||||
// Add/remove a process id to `sandboxed_renderers_`.
|
||||
void AddSandboxedRendererId(int process_id);
|
||||
void RemoveSandboxedRendererId(int process_id);
|
||||
struct ProcessPreferences {
|
||||
bool sandbox;
|
||||
bool native_window_open;
|
||||
};
|
||||
void AddProcessPreferences(int process_id, ProcessPreferences prefs);
|
||||
void RemoveProcessPreferences(int process_id);
|
||||
bool IsRendererSandboxed(int process_id);
|
||||
bool RendererUsesNativeWindowOpen(int process_id);
|
||||
|
||||
// pending_render_process => current_render_process.
|
||||
std::map<int, int> pending_processes_;
|
||||
// Set that contains the process ids of all sandboxed renderers
|
||||
std::set<int> sandboxed_renderers_;
|
||||
base::Lock sandboxed_renderers_lock_;
|
||||
|
||||
std::map<int, ProcessPreferences> process_preferences_;
|
||||
base::Lock process_preferences_lock_;
|
||||
|
||||
std::unique_ptr<AtomResourceDispatcherHostDelegate>
|
||||
resource_dispatcher_host_delegate_;
|
||||
|
|
|
@ -129,17 +129,14 @@ void AtomBrowserMainParts::PostEarlyInitialization() {
|
|||
|
||||
node_bindings_->Initialize();
|
||||
|
||||
// Support the "--debug" switch.
|
||||
node_debugger_.reset(new NodeDebugger(js_env_->isolate()));
|
||||
|
||||
// Create the global environment.
|
||||
node::Environment* env =
|
||||
node_bindings_->CreateEnvironment(js_env_->context());
|
||||
node_env_.reset(new NodeEnvironment(env));
|
||||
|
||||
// Make sure node can get correct environment when debugging.
|
||||
if (node_debugger_->IsRunning())
|
||||
env->AssignToContext(v8::Debug::GetDebugContext(js_env_->isolate()));
|
||||
// Enable support for v8 inspector
|
||||
node_debugger_.reset(new NodeDebugger(env));
|
||||
node_debugger_->Start();
|
||||
|
||||
// Add Electron extended APIs.
|
||||
atom_bindings_->BindTo(js_env_->isolate(), env->process_object());
|
||||
|
|
|
@ -7,33 +7,37 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/api/atom_api_web_contents.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/ui/message_box.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
|
||||
using content::JavaScriptMessageType;
|
||||
using content::JavaScriptDialogType;
|
||||
|
||||
namespace atom {
|
||||
|
||||
AtomJavaScriptDialogManager::AtomJavaScriptDialogManager(
|
||||
api::WebContents* api_web_contents)
|
||||
: api_web_contents_(api_web_contents) {}
|
||||
|
||||
void AtomJavaScriptDialogManager::RunJavaScriptDialog(
|
||||
content::WebContents* web_contents,
|
||||
const GURL& origin_url,
|
||||
JavaScriptMessageType message_type,
|
||||
JavaScriptDialogType dialog_type,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback,
|
||||
bool* did_suppress_message) {
|
||||
|
||||
if (message_type != JavaScriptMessageType::JAVASCRIPT_MESSAGE_TYPE_ALERT &&
|
||||
message_type != JavaScriptMessageType::JAVASCRIPT_MESSAGE_TYPE_CONFIRM) {
|
||||
if (dialog_type != JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_ALERT &&
|
||||
dialog_type != JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_CONFIRM) {
|
||||
callback.Run(false, base::string16());
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> buttons = {"OK"};
|
||||
if (message_type == JavaScriptMessageType::JAVASCRIPT_MESSAGE_TYPE_CONFIRM) {
|
||||
if (dialog_type == JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_CONFIRM) {
|
||||
buttons.push_back("Cancel");
|
||||
}
|
||||
|
||||
|
@ -49,13 +53,13 @@ void AtomJavaScriptDialogManager::RunBeforeUnloadDialog(
|
|||
content::WebContents* web_contents,
|
||||
bool is_reload,
|
||||
const DialogClosedCallback& callback) {
|
||||
// FIXME(zcbenz): the |message_text| is removed, figure out what should we do.
|
||||
callback.Run(false, base::ASCIIToUTF16("This should not be displayed"));
|
||||
bool default_prevented = api_web_contents_->Emit("will-prevent-unload");
|
||||
callback.Run(default_prevented, base::string16());
|
||||
return;
|
||||
}
|
||||
|
||||
void AtomJavaScriptDialogManager::CancelDialogs(
|
||||
content::WebContents* web_contents,
|
||||
bool suppress_callbacks,
|
||||
bool reset_state) {
|
||||
}
|
||||
|
||||
|
|
|
@ -11,13 +11,19 @@
|
|||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
class WebContents;
|
||||
}
|
||||
|
||||
class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
|
||||
public:
|
||||
explicit AtomJavaScriptDialogManager(api::WebContents* api_web_contents);
|
||||
|
||||
// content::JavaScriptDialogManager implementations.
|
||||
void RunJavaScriptDialog(
|
||||
content::WebContents* web_contents,
|
||||
const GURL& origin_url,
|
||||
content::JavaScriptMessageType javascript_message_type,
|
||||
content::JavaScriptDialogType dialog_type,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback,
|
||||
|
@ -27,13 +33,13 @@ class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
|
|||
bool is_reload,
|
||||
const DialogClosedCallback& callback) override;
|
||||
void CancelDialogs(content::WebContents* web_contents,
|
||||
bool suppress_callbacks,
|
||||
bool reset_state) override;
|
||||
|
||||
private:
|
||||
static void OnMessageBoxCallback(const DialogClosedCallback& callback,
|
||||
int code,
|
||||
bool checkbox_checked);
|
||||
api::WebContents* api_web_contents_;
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -131,7 +131,7 @@ int AtomPermissionManager::RequestPermissions(
|
|||
|
||||
auto web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
int request_id = pending_requests_.Add(new PendingRequest(
|
||||
int request_id = pending_requests_.Add(base::MakeUnique<PendingRequest>(
|
||||
render_frame_host, permissions, response_callback));
|
||||
|
||||
for (size_t i = 0; i < permissions.size(); ++i) {
|
||||
|
@ -187,12 +187,6 @@ blink::mojom::PermissionStatus AtomPermissionManager::GetPermissionStatus(
|
|||
return blink::mojom::PermissionStatus::GRANTED;
|
||||
}
|
||||
|
||||
void AtomPermissionManager::RegisterPermissionUsage(
|
||||
content::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
const GURL& embedding_origin) {
|
||||
}
|
||||
|
||||
int AtomPermissionManager::SubscribePermissionStatusChange(
|
||||
content::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
|
|
|
@ -66,9 +66,6 @@ class AtomPermissionManager : public content::PermissionManager {
|
|||
content::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
const GURL& embedding_origin) override;
|
||||
void RegisterPermissionUsage(content::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
const GURL& embedding_origin) override;
|
||||
int SubscribePermissionStatusChange(
|
||||
content::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
|
@ -79,7 +76,7 @@ class AtomPermissionManager : public content::PermissionManager {
|
|||
|
||||
private:
|
||||
class PendingRequest;
|
||||
using PendingRequestsMap = IDMap<PendingRequest, IDMapOwnPointer>;
|
||||
using PendingRequestsMap = IDMap<std::unique_ptr<PendingRequest>>;
|
||||
|
||||
RequestHandler request_handler_;
|
||||
|
||||
|
|
33
atom/browser/child_web_contents_tracker.cc
Normal file
33
atom/browser/child_web_contents_tracker.cc
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) 2017 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/child_web_contents_tracker.h"
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
std::unordered_set<content::WebContents*> g_child_web_contents;
|
||||
|
||||
} // namespace
|
||||
|
||||
ChildWebContentsTracker::ChildWebContentsTracker(
|
||||
content::WebContents* web_contents)
|
||||
: content::WebContentsObserver(web_contents) {
|
||||
g_child_web_contents.insert(web_contents);
|
||||
}
|
||||
|
||||
bool ChildWebContentsTracker::IsChildWebContents(
|
||||
content::WebContents* web_contents) {
|
||||
return g_child_web_contents.find(web_contents) != g_child_web_contents.end();
|
||||
}
|
||||
|
||||
void ChildWebContentsTracker::WebContentsDestroyed() {
|
||||
g_child_web_contents.erase(web_contents());
|
||||
delete this;
|
||||
}
|
||||
|
||||
} // namespace atom
|
25
atom/browser/child_web_contents_tracker.h
Normal file
25
atom/browser/child_web_contents_tracker.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Copyright (c) 2017 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_CHILD_WEB_CONTENTS_TRACKER_H_
|
||||
#define ATOM_BROWSER_CHILD_WEB_CONTENTS_TRACKER_H_
|
||||
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
// ChildWebContentsTracker tracks child WebContents
|
||||
// created by native `window.open()`
|
||||
class ChildWebContentsTracker : public content::WebContentsObserver {
|
||||
public:
|
||||
explicit ChildWebContentsTracker(content::WebContents* web_contents);
|
||||
static bool IsChildWebContents(content::WebContents* web_contents);
|
||||
|
||||
protected:
|
||||
void WebContentsDestroyed() override;
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_CHILD_WEB_CONTENTS_TRACKER_H_
|
|
@ -9,7 +9,6 @@
|
|||
#include <vector>
|
||||
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/atom_javascript_dialog_manager.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/ui/file_dialog.h"
|
||||
#include "atom/browser/web_dialog_helper.h"
|
||||
|
@ -230,15 +229,6 @@ bool CommonWebContentsDelegate::CanOverscrollContent() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
content::JavaScriptDialogManager*
|
||||
CommonWebContentsDelegate::GetJavaScriptDialogManager(
|
||||
content::WebContents* source) {
|
||||
if (!dialog_manager_)
|
||||
dialog_manager_.reset(new AtomJavaScriptDialogManager);
|
||||
|
||||
return dialog_manager_.get();
|
||||
}
|
||||
|
||||
content::ColorChooser* CommonWebContentsDelegate::OpenColorChooser(
|
||||
content::WebContents* web_contents,
|
||||
SkColor color,
|
||||
|
@ -494,9 +484,9 @@ void CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated(
|
|||
int request_id,
|
||||
const std::string& file_system_path,
|
||||
int total_work) {
|
||||
base::FundamentalValue request_id_value(request_id);
|
||||
base::Value request_id_value(request_id);
|
||||
base::StringValue file_system_path_value(file_system_path);
|
||||
base::FundamentalValue total_work_value(total_work);
|
||||
base::Value total_work_value(total_work);
|
||||
web_contents_->CallClientFunction("DevToolsAPI.indexingTotalWorkCalculated",
|
||||
&request_id_value,
|
||||
&file_system_path_value,
|
||||
|
@ -507,9 +497,9 @@ void CommonWebContentsDelegate::OnDevToolsIndexingWorked(
|
|||
int request_id,
|
||||
const std::string& file_system_path,
|
||||
int worked) {
|
||||
base::FundamentalValue request_id_value(request_id);
|
||||
base::Value request_id_value(request_id);
|
||||
base::StringValue file_system_path_value(file_system_path);
|
||||
base::FundamentalValue worked_value(worked);
|
||||
base::Value worked_value(worked);
|
||||
web_contents_->CallClientFunction("DevToolsAPI.indexingWorked",
|
||||
&request_id_value,
|
||||
&file_system_path_value,
|
||||
|
@ -520,7 +510,7 @@ void CommonWebContentsDelegate::OnDevToolsIndexingDone(
|
|||
int request_id,
|
||||
const std::string& file_system_path) {
|
||||
devtools_indexing_jobs_.erase(request_id);
|
||||
base::FundamentalValue request_id_value(request_id);
|
||||
base::Value request_id_value(request_id);
|
||||
base::StringValue file_system_path_value(file_system_path);
|
||||
web_contents_->CallClientFunction("DevToolsAPI.indexingDone",
|
||||
&request_id_value,
|
||||
|
@ -536,7 +526,7 @@ void CommonWebContentsDelegate::OnDevToolsSearchCompleted(
|
|||
for (const auto& file_path : file_paths) {
|
||||
file_paths_value.AppendString(file_path);
|
||||
}
|
||||
base::FundamentalValue request_id_value(request_id);
|
||||
base::Value request_id_value(request_id);
|
||||
base::StringValue file_system_path_value(file_system_path);
|
||||
web_contents_->CallClientFunction("DevToolsAPI.searchCompleted",
|
||||
&request_id_value,
|
||||
|
|
|
@ -20,7 +20,6 @@ using brightray::DevToolsFileSystemIndexer;
|
|||
namespace atom {
|
||||
|
||||
class AtomBrowserContext;
|
||||
class AtomJavaScriptDialogManager;
|
||||
class NativeWindow;
|
||||
class WebDialogHelper;
|
||||
|
||||
|
@ -62,8 +61,6 @@ class CommonWebContentsDelegate
|
|||
content::WebContents* source,
|
||||
const content::OpenURLParams& params) override;
|
||||
bool CanOverscrollContent() const override;
|
||||
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
|
||||
content::WebContents* source) override;
|
||||
content::ColorChooser* OpenColorChooser(
|
||||
content::WebContents* web_contents,
|
||||
SkColor color,
|
||||
|
@ -147,7 +144,6 @@ class CommonWebContentsDelegate
|
|||
bool native_fullscreen_;
|
||||
|
||||
std::unique_ptr<WebDialogHelper> web_dialog_helper_;
|
||||
std::unique_ptr<AtomJavaScriptDialogManager> dialog_manager_;
|
||||
scoped_refptr<DevToolsFileSystemIndexer> devtools_file_system_indexer_;
|
||||
|
||||
// Make sure BrowserContext is alwasys destroyed after WebContents.
|
||||
|
|
|
@ -20,7 +20,7 @@ void CommonWebContentsDelegate::HandleKeyboardEvent(
|
|||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
if (event.skip_in_browser ||
|
||||
event.type == content::NativeWebKeyboardEvent::Char)
|
||||
event.type() == content::NativeWebKeyboardEvent::Char)
|
||||
return;
|
||||
|
||||
// Escape exits tabbed fullscreen mode.
|
||||
|
|
|
@ -8,16 +8,45 @@
|
|||
|
||||
#include "base/command_line.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "gin/array_buffer.h"
|
||||
#include "gin/v8_initializer.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "atom/node/osfhandle.h"
|
||||
#endif
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
void* ArrayBufferAllocator::Allocate(size_t length) {
|
||||
#if defined(OS_WIN)
|
||||
return node::ArrayBufferCalloc(length);
|
||||
#else
|
||||
return calloc(1, length);
|
||||
#endif
|
||||
}
|
||||
|
||||
void* ArrayBufferAllocator::AllocateUninitialized(size_t length) {
|
||||
#if defined(OS_WIN)
|
||||
return node::ArrayBufferMalloc(length);
|
||||
#else
|
||||
return malloc(length);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ArrayBufferAllocator::Free(void* data, size_t length) {
|
||||
#if defined(OS_WIN)
|
||||
node::ArrayBufferFree(data, length);
|
||||
#else
|
||||
free(data);
|
||||
#endif
|
||||
}
|
||||
|
||||
JavascriptEnvironment::JavascriptEnvironment()
|
||||
: initialized_(Initialize()),
|
||||
isolate_holder_(base::ThreadTaskRunnerHandle::Get()),
|
||||
isolate_(isolate_holder_.isolate()),
|
||||
isolate_scope_(isolate_),
|
||||
locker_(isolate_),
|
||||
|
@ -44,7 +73,7 @@ bool JavascriptEnvironment::Initialize() {
|
|||
|
||||
gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
|
||||
gin::IsolateHolder::kStableV8Extras,
|
||||
gin::ArrayBufferAllocator::SharedInstance());
|
||||
&allocator_);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,14 @@ class Environment;
|
|||
|
||||
namespace atom {
|
||||
|
||||
// ArrayBuffer's allocator, used on Chromium's side.
|
||||
class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
|
||||
public:
|
||||
void* Allocate(size_t length) override;
|
||||
void* AllocateUninitialized(size_t length) override;
|
||||
void Free(void* data, size_t length) override;
|
||||
};
|
||||
|
||||
// Manage the V8 isolate and context automatically.
|
||||
class JavascriptEnvironment {
|
||||
public:
|
||||
|
@ -31,6 +39,7 @@ class JavascriptEnvironment {
|
|||
bool Initialize();
|
||||
|
||||
bool initialized_;
|
||||
ArrayBufferAllocator allocator_;
|
||||
gin::IsolateHolder isolate_holder_;
|
||||
v8::Isolate* isolate_;
|
||||
v8::Isolate::Scope isolate_scope_;
|
||||
|
|
|
@ -15,12 +15,12 @@ LayeredResourceHandler::LayeredResourceHandler(
|
|||
|
||||
LayeredResourceHandler::~LayeredResourceHandler() {}
|
||||
|
||||
bool LayeredResourceHandler::OnResponseStarted(
|
||||
void LayeredResourceHandler::OnResponseStarted(
|
||||
content::ResourceResponse* response,
|
||||
bool* defer) {
|
||||
std::unique_ptr<content::ResourceController> controller) {
|
||||
if (delegate_)
|
||||
delegate_->OnResponseStarted(response);
|
||||
return next_handler_->OnResponseStarted(response, defer);
|
||||
next_handler_->OnResponseStarted(response, std::move(controller));
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -26,8 +26,9 @@ class LayeredResourceHandler : public content::LayeredResourceHandler {
|
|||
~LayeredResourceHandler() override;
|
||||
|
||||
// content::LayeredResourceHandler:
|
||||
bool OnResponseStarted(content::ResourceResponse* response,
|
||||
bool* defer) override;
|
||||
void OnResponseStarted(
|
||||
content::ResourceResponse* response,
|
||||
std::unique_ptr<content::ResourceController> controller) override;
|
||||
|
||||
private:
|
||||
Delegate* delegate_;
|
||||
|
|
|
@ -147,6 +147,7 @@ class NativeWindow : public base::SupportsUserData,
|
|||
virtual void SetMenu(AtomMenuModel* menu);
|
||||
virtual void SetParentWindow(NativeWindow* parent);
|
||||
virtual void SetBrowserView(NativeBrowserView* browser_view) = 0;
|
||||
virtual gfx::NativeView GetNativeView() = 0;
|
||||
virtual gfx::NativeWindow GetNativeWindow() = 0;
|
||||
virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0;
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ class NativeWindowMac : public NativeWindow,
|
|||
void SetContentProtection(bool enable) override;
|
||||
void SetBrowserView(NativeBrowserView* browser_view) override;
|
||||
void SetParentWindow(NativeWindow* parent) override;
|
||||
gfx::NativeView GetNativeView() override;
|
||||
gfx::NativeWindow GetNativeWindow() override;
|
||||
gfx::AcceleratedWidget GetAcceleratedWidget() override;
|
||||
void SetProgressBar(double progress, const ProgressState state) override;
|
||||
|
|
|
@ -1314,6 +1314,10 @@ void NativeWindowMac::SetParentWindow(NativeWindow* parent) {
|
|||
[parent->GetNativeWindow() addChildWindow:window_ ordered:NSWindowAbove];
|
||||
}
|
||||
|
||||
gfx::NativeView NativeWindowMac::GetNativeView() {
|
||||
return inspectable_web_contents()->GetView()->GetNativeView();
|
||||
}
|
||||
|
||||
gfx::NativeWindow NativeWindowMac::GetNativeWindow() {
|
||||
return window_;
|
||||
}
|
||||
|
@ -1458,7 +1462,7 @@ void NativeWindowMac::SetEscapeTouchBarItem(const mate::PersistentDictionary& it
|
|||
}
|
||||
|
||||
void NativeWindowMac::OnInputEvent(const blink::WebInputEvent& event) {
|
||||
switch (event.type) {
|
||||
switch (event.type()) {
|
||||
case blink::WebInputEvent::GestureScrollBegin:
|
||||
case blink::WebInputEvent::GestureScrollUpdate:
|
||||
case blink::WebInputEvent::GestureScrollEnd:
|
||||
|
|
|
@ -86,7 +86,7 @@ bool IsAltKey(const content::NativeWebKeyboardEvent& event) {
|
|||
|
||||
bool IsAltModifier(const content::NativeWebKeyboardEvent& event) {
|
||||
typedef content::NativeWebKeyboardEvent::Modifiers Modifiers;
|
||||
int modifiers = event.modifiers;
|
||||
int modifiers = event.modifiers();
|
||||
modifiers &= ~Modifiers::NumLockOn;
|
||||
modifiers &= ~Modifiers::CapsLockOn;
|
||||
return (modifiers == Modifiers::AltKey) ||
|
||||
|
@ -767,13 +767,14 @@ void NativeWindowViews::SetBackgroundColor(const std::string& color_name) {
|
|||
}
|
||||
|
||||
void NativeWindowViews::SetHasShadow(bool has_shadow) {
|
||||
wm::SetShadowType(
|
||||
wm::SetShadowElevation(
|
||||
GetNativeWindow(),
|
||||
has_shadow ? wm::SHADOW_TYPE_RECTANGULAR : wm::SHADOW_TYPE_NONE);
|
||||
has_shadow ? wm::ShadowElevation::MEDIUM : wm::ShadowElevation::NONE);
|
||||
}
|
||||
|
||||
bool NativeWindowViews::HasShadow() {
|
||||
return wm::GetShadowType(GetNativeWindow()) != wm::SHADOW_TYPE_NONE;
|
||||
return GetNativeWindow()->GetProperty(wm::kShadowElevationKey)
|
||||
!= wm::ShadowElevation::NONE;
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetIgnoreMouseEvents(bool ignore) {
|
||||
|
@ -923,6 +924,10 @@ void NativeWindowViews::SetParentWindow(NativeWindow* parent) {
|
|||
#endif
|
||||
}
|
||||
|
||||
gfx::NativeView NativeWindowViews::GetNativeView() {
|
||||
return window_->GetNativeView();
|
||||
}
|
||||
|
||||
gfx::NativeWindow NativeWindowViews::GetNativeWindow() {
|
||||
return window_->GetNativeWindow();
|
||||
}
|
||||
|
@ -1234,10 +1239,10 @@ void NativeWindowViews::HandleKeyboardEvent(
|
|||
// Show accelerator when "Alt" is pressed.
|
||||
if (menu_bar_visible_ && IsAltKey(event))
|
||||
menu_bar_->SetAcceleratorVisibility(
|
||||
event.type == blink::WebInputEvent::RawKeyDown);
|
||||
event.type() == blink::WebInputEvent::RawKeyDown);
|
||||
|
||||
// Show the submenu when "Alt+Key" is pressed.
|
||||
if (event.type == blink::WebInputEvent::RawKeyDown && !IsAltKey(event) &&
|
||||
if (event.type() == blink::WebInputEvent::RawKeyDown && !IsAltKey(event) &&
|
||||
IsAltModifier(event)) {
|
||||
if (!menu_bar_visible_ &&
|
||||
(menu_bar_->GetAcceleratorIndex(event.windowsKeyCode) != -1))
|
||||
|
@ -1250,10 +1255,10 @@ void NativeWindowViews::HandleKeyboardEvent(
|
|||
return;
|
||||
|
||||
// Toggle the menu bar only when a single Alt is released.
|
||||
if (event.type == blink::WebInputEvent::RawKeyDown && IsAltKey(event)) {
|
||||
if (event.type() == blink::WebInputEvent::RawKeyDown && IsAltKey(event)) {
|
||||
// When a single Alt is pressed:
|
||||
menu_bar_alt_pressed_ = true;
|
||||
} else if (event.type == blink::WebInputEvent::KeyUp && IsAltKey(event) &&
|
||||
} else if (event.type() == blink::WebInputEvent::KeyUp && IsAltKey(event) &&
|
||||
menu_bar_alt_pressed_) {
|
||||
// When a single Alt is released right after a Alt is pressed:
|
||||
menu_bar_alt_pressed_ = false;
|
||||
|
|
|
@ -106,6 +106,7 @@ class NativeWindowViews : public NativeWindow,
|
|||
void SetMenu(AtomMenuModel* menu_model) override;
|
||||
void SetBrowserView(NativeBrowserView* browser_view) override;
|
||||
void SetParentWindow(NativeWindow* parent) override;
|
||||
gfx::NativeView GetNativeView() override;
|
||||
gfx::NativeWindow GetNativeWindow() override;
|
||||
void SetOverlayIcon(const gfx::Image& overlay,
|
||||
const std::string& description) override;
|
||||
|
|
|
@ -50,15 +50,16 @@ bool AtomURLRequestJobFactory::InterceptProtocol(
|
|||
return false;
|
||||
ProtocolHandler* original_protocol_handler = protocol_handler_map_[scheme];
|
||||
protocol_handler_map_[scheme] = protocol_handler.release();
|
||||
original_protocols_.set(scheme, base::WrapUnique(original_protocol_handler));
|
||||
original_protocols_[scheme].reset(original_protocol_handler);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AtomURLRequestJobFactory::UninterceptProtocol(const std::string& scheme) {
|
||||
if (!original_protocols_.contains(scheme))
|
||||
auto it = original_protocols_.find(scheme);
|
||||
if (it == original_protocols_.end())
|
||||
return false;
|
||||
protocol_handler_map_[scheme] =
|
||||
original_protocols_.take_and_erase(scheme).release();
|
||||
protocol_handler_map_[scheme] = it->second.release();
|
||||
original_protocols_.erase(it);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -78,7 +79,9 @@ bool AtomURLRequestJobFactory::HasProtocolHandler(
|
|||
}
|
||||
|
||||
void AtomURLRequestJobFactory::Clear() {
|
||||
base::STLDeleteValues(&protocol_handler_map_);
|
||||
for (auto& it : protocol_handler_map_)
|
||||
delete it.second;
|
||||
protocol_handler_map_.clear();
|
||||
}
|
||||
|
||||
net::URLRequestJob* AtomURLRequestJobFactory::MaybeCreateJobWithProtocolHandler(
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/scoped_ptr_hash_map.h"
|
||||
#include "net/url_request/url_request_job_factory.h"
|
||||
|
||||
namespace atom {
|
||||
|
@ -64,7 +64,7 @@ class AtomURLRequestJobFactory : public net::URLRequestJobFactory {
|
|||
ProtocolHandlerMap protocol_handler_map_;
|
||||
|
||||
// Map that stores the original protocols of schemes.
|
||||
using OriginalProtocolsMap = base::ScopedPtrHashMap<
|
||||
using OriginalProtocolsMap = std::unordered_map<
|
||||
std::string, std::unique_ptr<ProtocolHandler>>;
|
||||
// Can only be accessed in IO thread.
|
||||
OriginalProtocolsMap original_protocols_;
|
||||
|
|
|
@ -59,11 +59,11 @@ void AskForOptions(v8::Isolate* isolate,
|
|||
}
|
||||
|
||||
bool IsErrorOptions(base::Value* value, int* error) {
|
||||
if (value->IsType(base::Value::TYPE_DICTIONARY)) {
|
||||
if (value->IsType(base::Value::Type::DICTIONARY)) {
|
||||
base::DictionaryValue* dict = static_cast<base::DictionaryValue*>(value);
|
||||
if (dict->GetInteger("error", error))
|
||||
return true;
|
||||
} else if (value->IsType(base::Value::TYPE_INTEGER)) {
|
||||
} else if (value->IsType(base::Value::Type::INTEGER)) {
|
||||
if (value->GetAsInteger(error))
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/http/http_response_headers.h"
|
||||
#include "net/http/http_status_code.h"
|
||||
#include "net/url_request/url_request_context_getter.h"
|
||||
#include "net/url_request/url_request_job.h"
|
||||
#include "v8/include/v8.h"
|
||||
|
@ -82,6 +83,9 @@ class JsAsker : public RequestJob {
|
|||
base::Bind(&JsAsker::OnResponse,
|
||||
weak_factory_.GetWeakPtr())));
|
||||
}
|
||||
|
||||
int GetResponseCode() const override { return net::HTTP_OK; }
|
||||
|
||||
void GetResponseInfo(net::HttpResponseInfo* info) override {
|
||||
info->headers = new net::HttpResponseHeaders("");
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "atom/common/atom_constants.h"
|
||||
#include "base/threading/sequenced_worker_pool.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -18,10 +19,10 @@ URLRequestAsyncAsarJob::URLRequestAsyncAsarJob(
|
|||
|
||||
void URLRequestAsyncAsarJob::StartAsync(std::unique_ptr<base::Value> options) {
|
||||
base::FilePath::StringType file_path;
|
||||
if (options->IsType(base::Value::TYPE_DICTIONARY)) {
|
||||
if (options->IsType(base::Value::Type::DICTIONARY)) {
|
||||
static_cast<base::DictionaryValue*>(options.get())->GetString(
|
||||
"path", &file_path);
|
||||
} else if (options->IsType(base::Value::TYPE_STRING)) {
|
||||
} else if (options->IsType(base::Value::Type::STRING)) {
|
||||
options->GetAsString(&file_path);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,13 +34,13 @@ URLRequestBufferJob::URLRequestBufferJob(
|
|||
|
||||
void URLRequestBufferJob::StartAsync(std::unique_ptr<base::Value> options) {
|
||||
const base::BinaryValue* binary = nullptr;
|
||||
if (options->IsType(base::Value::TYPE_DICTIONARY)) {
|
||||
if (options->IsType(base::Value::Type::DICTIONARY)) {
|
||||
base::DictionaryValue* dict =
|
||||
static_cast<base::DictionaryValue*>(options.get());
|
||||
dict->GetString("mimeType", &mime_type_);
|
||||
dict->GetString("charset", &charset_);
|
||||
dict->GetBinary("data", &binary);
|
||||
} else if (options->IsType(base::Value::TYPE_BINARY)) {
|
||||
} else if (options->IsType(base::Value::Type::BINARY)) {
|
||||
options->GetAsBinary(&binary);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ void URLRequestBufferJob::StartAsync(std::unique_ptr<base::Value> options) {
|
|||
}
|
||||
|
||||
void URLRequestBufferJob::GetResponseInfo(net::HttpResponseInfo* info) {
|
||||
std::string status("HTTP/1.1 ");
|
||||
std::string status("HTTP/1.1 200 OK");
|
||||
status.append(base::IntToString(status_code_));
|
||||
status.append(" ");
|
||||
status.append(net::GetHttpReasonPhrase(status_code_));
|
||||
|
|
|
@ -9,14 +9,18 @@
|
|||
|
||||
#include "atom/browser/api/atom_api_session.h"
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "base/guid.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "brightray/browser/url_request_context_getter.h"
|
||||
#include "content/browser/streams/stream_context.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/http/http_response_headers.h"
|
||||
#include "net/url_request/url_fetcher.h"
|
||||
#include "net/url_request/url_fetcher_response_writer.h"
|
||||
#include "url/url_constants.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
|
@ -62,7 +66,8 @@ class ResponsePiper : public net::URLFetcherResponseWriter {
|
|||
job_->HeadersCompleted();
|
||||
first_write_ = false;
|
||||
}
|
||||
return job_->DataAvailable(buffer, num_bytes, callback);
|
||||
job_->stream()->AddData(buffer->data(), num_bytes);
|
||||
return num_bytes;
|
||||
}
|
||||
int Finish(int net_error, const net::CompletionCallback& callback) override {
|
||||
return net::OK;
|
||||
|
@ -77,12 +82,11 @@ class ResponsePiper : public net::URLFetcherResponseWriter {
|
|||
|
||||
} // namespace
|
||||
|
||||
URLRequestFetchJob::URLRequestFetchJob(
|
||||
net::URLRequest* request, net::NetworkDelegate* network_delegate)
|
||||
URLRequestFetchJob::URLRequestFetchJob(net::URLRequest* request,
|
||||
net::NetworkDelegate* network_delegate)
|
||||
: JsAsker<net::URLRequestJob>(request, network_delegate),
|
||||
pending_buffer_size_(0),
|
||||
write_num_bytes_(0) {
|
||||
}
|
||||
total_bytes_read_(0) {}
|
||||
|
||||
void URLRequestFetchJob::BeforeStartInUI(
|
||||
v8::Isolate* isolate, v8::Local<v8::Value> value) {
|
||||
|
@ -112,7 +116,7 @@ void URLRequestFetchJob::BeforeStartInUI(
|
|||
}
|
||||
|
||||
void URLRequestFetchJob::StartAsync(std::unique_ptr<base::Value> options) {
|
||||
if (!options->IsType(base::Value::TYPE_DICTIONARY)) {
|
||||
if (!options->IsType(base::Value::Type::DICTIONARY)) {
|
||||
NotifyStartError(net::URLRequestStatus(
|
||||
net::URLRequestStatus::FAILED, net::ERR_NOT_IMPLEMENTED));
|
||||
return;
|
||||
|
@ -169,7 +173,22 @@ void URLRequestFetchJob::StartAsync(std::unique_ptr<base::Value> options) {
|
|||
fetcher_->SetExtraRequestHeaders(
|
||||
request()->extra_request_headers().ToString());
|
||||
|
||||
fetcher_->Start();
|
||||
// Create readable stream for URLFetcher response.
|
||||
content::StreamContext* stream_context =
|
||||
static_cast<brightray::URLRequestContextGetter*>(request_context_getter())
|
||||
->stream_context();
|
||||
|
||||
if (stream_context) {
|
||||
GURL stream_url(std::string(url::kBlobScheme) + ":" +
|
||||
formated_url.GetOrigin().spec() + base::GenerateGUID());
|
||||
stream_ =
|
||||
new content::Stream(stream_context->registry(), nullptr, stream_url);
|
||||
stream_->SetReadObserver(this);
|
||||
fetcher_->Start();
|
||||
} else {
|
||||
NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::CANCELED,
|
||||
net::ERR_ABORTED));
|
||||
}
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::HeadersCompleted() {
|
||||
|
@ -178,53 +197,55 @@ void URLRequestFetchJob::HeadersCompleted() {
|
|||
NotifyHeadersComplete();
|
||||
}
|
||||
|
||||
int URLRequestFetchJob::DataAvailable(net::IOBuffer* buffer,
|
||||
int num_bytes,
|
||||
const net::CompletionCallback& callback) {
|
||||
// When pending_buffer_ is empty, there's no ReadRawData() operation waiting
|
||||
// for IO completion, we have to save the parameters until the request is
|
||||
// ready to read data.
|
||||
if (!pending_buffer_.get()) {
|
||||
write_buffer_ = buffer;
|
||||
write_num_bytes_ = num_bytes;
|
||||
write_callback_ = callback;
|
||||
return net::ERR_IO_PENDING;
|
||||
}
|
||||
|
||||
// Write data to the pending buffer and clear them after the writing.
|
||||
int bytes_read = BufferCopy(buffer, num_bytes,
|
||||
pending_buffer_.get(), pending_buffer_size_);
|
||||
ClearPendingBuffer();
|
||||
ReadRawDataComplete(bytes_read);
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::Kill() {
|
||||
JsAsker<URLRequestJob>::Kill();
|
||||
ClearStream();
|
||||
fetcher_.reset();
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::OnDataAvailable(content::Stream* stream) {
|
||||
if (!pending_buffer_.get())
|
||||
return;
|
||||
|
||||
int result = 0;
|
||||
auto state = stream_->ReadRawData(pending_buffer_.get(), pending_buffer_size_,
|
||||
&result);
|
||||
if (state == content::Stream::STREAM_ABORTED)
|
||||
result = net::ERR_CONNECTION_RESET;
|
||||
|
||||
// Clear the buffers before notifying the read is complete, so that it is
|
||||
// safe for the observer to read.
|
||||
pending_buffer_ = nullptr;
|
||||
pending_buffer_size_ = 0;
|
||||
|
||||
if (result > 0)
|
||||
total_bytes_read_ += result;
|
||||
ReadRawDataComplete(result);
|
||||
}
|
||||
|
||||
int URLRequestFetchJob::ReadRawData(net::IOBuffer* dest, int dest_size) {
|
||||
if (GetResponseCode() == 204) {
|
||||
request()->set_received_response_content_length(prefilter_bytes_read());
|
||||
return net::OK;
|
||||
}
|
||||
|
||||
// When write_buffer_ is empty, there is no data valable yet, we have to save
|
||||
// the dest buffer util DataAvailable.
|
||||
if (!write_buffer_.get()) {
|
||||
pending_buffer_ = dest;
|
||||
pending_buffer_size_ = dest_size;
|
||||
return net::ERR_IO_PENDING;
|
||||
int bytes_read = 0;
|
||||
switch (stream_->ReadRawData(dest, dest_size, &bytes_read)) {
|
||||
case content::Stream::STREAM_HAS_DATA:
|
||||
total_bytes_read_ += bytes_read;
|
||||
return bytes_read;
|
||||
case content::Stream::STREAM_COMPLETE:
|
||||
return stream_->GetStatus();
|
||||
case content::Stream::STREAM_EMPTY:
|
||||
pending_buffer_ = dest;
|
||||
pending_buffer_size_ = dest_size;
|
||||
return net::ERR_IO_PENDING;
|
||||
case content::Stream::STREAM_ABORTED:
|
||||
// Handle this as connection reset.
|
||||
return net::ERR_CONNECTION_RESET;
|
||||
}
|
||||
|
||||
// Read from the write buffer and clear them after reading.
|
||||
int bytes_read = BufferCopy(write_buffer_.get(), write_num_bytes_,
|
||||
dest, dest_size);
|
||||
net::CompletionCallback write_callback = write_callback_;
|
||||
ClearWriteBuffer();
|
||||
write_callback.Run(bytes_read);
|
||||
return bytes_read;
|
||||
NOTREACHED();
|
||||
return net::ERR_FAILED;
|
||||
}
|
||||
|
||||
bool URLRequestFetchJob::GetMimeType(std::string* mime_type) const {
|
||||
|
@ -246,11 +267,18 @@ int URLRequestFetchJob::GetResponseCode() const {
|
|||
return response_info_->headers->response_code();
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::OnURLFetchComplete(const net::URLFetcher* source) {
|
||||
ClearPendingBuffer();
|
||||
ClearWriteBuffer();
|
||||
int64_t URLRequestFetchJob::GetTotalReceivedBytes() const {
|
||||
int64_t total_received_bytes = 0;
|
||||
if (response_info_)
|
||||
total_received_bytes = response_info_->headers->raw_headers().size();
|
||||
if (stream_.get())
|
||||
total_received_bytes += total_bytes_read_;
|
||||
return total_received_bytes;
|
||||
}
|
||||
|
||||
if (fetcher_->GetStatus().is_success()) {
|
||||
void URLRequestFetchJob::OnURLFetchComplete(const net::URLFetcher* source) {
|
||||
auto status = fetcher_->GetStatus();
|
||||
if (status.is_success()) {
|
||||
if (!response_info_) {
|
||||
// Since we notify header completion only after first write there will be
|
||||
// no response object constructed for http respones with no content 204.
|
||||
|
@ -258,28 +286,16 @@ void URLRequestFetchJob::OnURLFetchComplete(const net::URLFetcher* source) {
|
|||
HeadersCompleted();
|
||||
return;
|
||||
}
|
||||
ReadRawDataComplete(0);
|
||||
stream_->Finalize(0);
|
||||
} else {
|
||||
NotifyStartError(fetcher_->GetStatus());
|
||||
stream_->Finalize(status.error());
|
||||
NotifyStartError(status);
|
||||
}
|
||||
}
|
||||
|
||||
int URLRequestFetchJob::BufferCopy(net::IOBuffer* source, int num_bytes,
|
||||
net::IOBuffer* target, int target_size) {
|
||||
int bytes_written = std::min(num_bytes, target_size);
|
||||
memcpy(target->data(), source->data(), bytes_written);
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::ClearPendingBuffer() {
|
||||
pending_buffer_ = nullptr;
|
||||
pending_buffer_size_ = 0;
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::ClearWriteBuffer() {
|
||||
write_buffer_ = nullptr;
|
||||
write_num_bytes_ = 0;
|
||||
write_callback_.Reset();
|
||||
void URLRequestFetchJob::ClearStream() {
|
||||
stream_->RemoveReadObserver(this);
|
||||
stream_ = nullptr;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -9,21 +9,23 @@
|
|||
|
||||
#include "atom/browser/net/js_asker.h"
|
||||
#include "browser/url_request_context_getter.h"
|
||||
#include "content/browser/streams/stream.h"
|
||||
#include "content/browser/streams/stream_read_observer.h"
|
||||
#include "net/url_request/url_fetcher_delegate.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class URLRequestFetchJob : public JsAsker<net::URLRequestJob>,
|
||||
public net::URLFetcherDelegate,
|
||||
public brightray::URLRequestContextGetter::Delegate {
|
||||
public brightray::URLRequestContextGetter::Delegate,
|
||||
public content::StreamReadObserver {
|
||||
public:
|
||||
URLRequestFetchJob(net::URLRequest*, net::NetworkDelegate*);
|
||||
|
||||
// Called by response writer.
|
||||
void HeadersCompleted();
|
||||
int DataAvailable(net::IOBuffer* buffer,
|
||||
int num_bytes,
|
||||
const net::CompletionCallback& callback);
|
||||
|
||||
content::Stream* stream() const { return stream_.get(); }
|
||||
|
||||
protected:
|
||||
// JsAsker:
|
||||
|
@ -36,28 +38,26 @@ class URLRequestFetchJob : public JsAsker<net::URLRequestJob>,
|
|||
bool GetMimeType(std::string* mime_type) const override;
|
||||
void GetResponseInfo(net::HttpResponseInfo* info) override;
|
||||
int GetResponseCode() const override;
|
||||
int64_t GetTotalReceivedBytes() const override;
|
||||
|
||||
// net::URLFetcherDelegate:
|
||||
void OnURLFetchComplete(const net::URLFetcher* source) override;
|
||||
|
||||
// content::StreamReadObserver:
|
||||
void OnDataAvailable(content::Stream* stream) override;
|
||||
|
||||
private:
|
||||
int BufferCopy(net::IOBuffer* source, int num_bytes,
|
||||
net::IOBuffer* target, int target_size);
|
||||
void ClearPendingBuffer();
|
||||
void ClearWriteBuffer();
|
||||
void ClearStream();
|
||||
|
||||
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
|
||||
std::unique_ptr<net::URLFetcher> fetcher_;
|
||||
std::unique_ptr<net::HttpResponseInfo> response_info_;
|
||||
scoped_refptr<content::Stream> stream_;
|
||||
|
||||
// Saved arguments passed to ReadRawData.
|
||||
scoped_refptr<net::IOBuffer> pending_buffer_;
|
||||
int pending_buffer_size_;
|
||||
|
||||
// Saved arguments passed to DataAvailable.
|
||||
scoped_refptr<net::IOBuffer> write_buffer_;
|
||||
int write_num_bytes_;
|
||||
net::CompletionCallback write_callback_;
|
||||
int total_bytes_read_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(URLRequestFetchJob);
|
||||
};
|
||||
|
|
|
@ -17,13 +17,13 @@ URLRequestStringJob::URLRequestStringJob(
|
|||
}
|
||||
|
||||
void URLRequestStringJob::StartAsync(std::unique_ptr<base::Value> options) {
|
||||
if (options->IsType(base::Value::TYPE_DICTIONARY)) {
|
||||
if (options->IsType(base::Value::Type::DICTIONARY)) {
|
||||
base::DictionaryValue* dict =
|
||||
static_cast<base::DictionaryValue*>(options.get());
|
||||
dict->GetString("mimeType", &mime_type_);
|
||||
dict->GetString("charset", &charset_);
|
||||
dict->GetString("data", &data_);
|
||||
} else if (options->IsType(base::Value::TYPE_STRING)) {
|
||||
} else if (options->IsType(base::Value::Type::STRING)) {
|
||||
options->GetAsString(&data_);
|
||||
}
|
||||
net::URLRequestSimpleJob::Start();
|
||||
|
|
|
@ -4,202 +4,47 @@
|
|||
|
||||
#include "atom/browser/node_debugger.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/test/embedded_test_server/tcp_listen_socket.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "libplatform/libplatform.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
// NodeDebugger is stored in Isolate's data, slots 0, 1, 3 have already been
|
||||
// taken by gin, blink and node, using 2 is a safe option for now.
|
||||
const int kIsolateSlot = 2;
|
||||
|
||||
const char* kContentLength = "Content-Length";
|
||||
|
||||
} // namespace
|
||||
|
||||
NodeDebugger::NodeDebugger(v8::Isolate* isolate)
|
||||
: isolate_(isolate),
|
||||
thread_("NodeDebugger"),
|
||||
content_length_(-1),
|
||||
weak_factory_(this) {
|
||||
bool use_debug_agent = false;
|
||||
int port = 5858;
|
||||
|
||||
std::string port_str;
|
||||
base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
|
||||
if (cmd->HasSwitch("debug")) {
|
||||
use_debug_agent = true;
|
||||
port_str = cmd->GetSwitchValueASCII("debug");
|
||||
} else if (cmd->HasSwitch("debug-brk")) {
|
||||
use_debug_agent = true;
|
||||
port_str = cmd->GetSwitchValueASCII("debug-brk");
|
||||
}
|
||||
|
||||
if (use_debug_agent) {
|
||||
if (!port_str.empty())
|
||||
base::StringToInt(port_str, &port);
|
||||
|
||||
isolate_->SetData(kIsolateSlot, this);
|
||||
v8::Debug::SetMessageHandler(isolate_, DebugMessageHandler);
|
||||
|
||||
weak_up_ui_handle_.data = this;
|
||||
uv_async_init(uv_default_loop(), &weak_up_ui_handle_, ProcessMessageInUI);
|
||||
|
||||
// Start a new IO thread.
|
||||
base::Thread::Options options;
|
||||
options.message_loop_type = base::MessageLoop::TYPE_IO;
|
||||
if (!thread_.StartWithOptions(options)) {
|
||||
LOG(ERROR) << "Unable to start debugger thread";
|
||||
return;
|
||||
}
|
||||
|
||||
// Start the server in new IO thread.
|
||||
thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&NodeDebugger::StartServer, weak_factory_.GetWeakPtr(),
|
||||
port));
|
||||
}
|
||||
NodeDebugger::NodeDebugger(node::Environment* env) : env_(env) {
|
||||
}
|
||||
|
||||
NodeDebugger::~NodeDebugger() {
|
||||
thread_.Stop();
|
||||
}
|
||||
|
||||
bool NodeDebugger::IsRunning() const {
|
||||
return thread_.IsRunning();
|
||||
}
|
||||
|
||||
void NodeDebugger::StartServer(int port) {
|
||||
server_ = net::test_server::TCPListenSocket::CreateAndListen(
|
||||
"127.0.0.1", port, this);
|
||||
if (!server_) {
|
||||
LOG(ERROR) << "Cannot start debugger server";
|
||||
void NodeDebugger::Start() {
|
||||
auto inspector = env_->inspector_agent();
|
||||
if (inspector == nullptr)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void NodeDebugger::CloseSession() {
|
||||
accepted_socket_.reset();
|
||||
}
|
||||
|
||||
void NodeDebugger::OnMessage(const std::string& message) {
|
||||
if (message.find("\"type\":\"request\",\"command\":\"disconnect\"}") !=
|
||||
std::string::npos)
|
||||
CloseSession();
|
||||
|
||||
base::string16 message16 = base::UTF8ToUTF16(message);
|
||||
v8::Debug::SendCommand(
|
||||
isolate_,
|
||||
reinterpret_cast<const uint16_t*>(message16.data()), message16.size());
|
||||
|
||||
uv_async_send(&weak_up_ui_handle_);
|
||||
}
|
||||
|
||||
void NodeDebugger::SendMessage(const std::string& message) {
|
||||
if (accepted_socket_) {
|
||||
std::string header = base::StringPrintf(
|
||||
"%s: %d\r\n\r\n", kContentLength, static_cast<int>(message.size()));
|
||||
accepted_socket_->Send(header);
|
||||
accepted_socket_->Send(message);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeDebugger::SendConnectMessage() {
|
||||
accepted_socket_->Send(base::StringPrintf(
|
||||
"Type: connect\r\n"
|
||||
"V8-Version: %s\r\n"
|
||||
"Protocol-Version: 1\r\n"
|
||||
"Embedding-Host: %s\r\n"
|
||||
"%s: 0\r\n",
|
||||
v8::V8::GetVersion(), ATOM_PRODUCT_NAME, kContentLength), true);
|
||||
}
|
||||
|
||||
// static
|
||||
void NodeDebugger::ProcessMessageInUI(uv_async_t* handle) {
|
||||
NodeDebugger* self = static_cast<NodeDebugger*>(handle->data);
|
||||
v8::Debug::ProcessDebugMessages(self->isolate_);
|
||||
}
|
||||
|
||||
// static
|
||||
void NodeDebugger::DebugMessageHandler(const v8::Debug::Message& message) {
|
||||
NodeDebugger* self = static_cast<NodeDebugger*>(
|
||||
message.GetIsolate()->GetData(kIsolateSlot));
|
||||
|
||||
if (self) {
|
||||
std::string message8(*v8::String::Utf8Value(message.GetJSON()));
|
||||
self->thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&NodeDebugger::SendMessage, self->weak_factory_.GetWeakPtr(),
|
||||
message8));
|
||||
}
|
||||
}
|
||||
|
||||
void NodeDebugger::DidAccept(
|
||||
net::test_server::StreamListenSocket* server,
|
||||
std::unique_ptr<net::test_server::StreamListenSocket> socket) {
|
||||
// Only accept one session.
|
||||
if (accepted_socket_) {
|
||||
socket->Send(std::string("Remote debugging session already active"), true);
|
||||
return;
|
||||
node::DebugOptions options;
|
||||
for (auto& arg : base::CommandLine::ForCurrentProcess()->argv()) {
|
||||
#if defined(OS_WIN)
|
||||
options.ParseOption(base::UTF16ToUTF8(arg));
|
||||
#else
|
||||
options.ParseOption(arg);
|
||||
#endif
|
||||
}
|
||||
|
||||
accepted_socket_ = std::move(socket);
|
||||
SendConnectMessage();
|
||||
}
|
||||
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());
|
||||
|
||||
void NodeDebugger::DidRead(net::test_server::StreamListenSocket* socket,
|
||||
const char* data,
|
||||
int len) {
|
||||
buffer_.append(data, len);
|
||||
|
||||
do {
|
||||
if (buffer_.empty())
|
||||
return;
|
||||
|
||||
// Read the "Content-Length" header.
|
||||
if (content_length_ < 0) {
|
||||
size_t pos = buffer_.find("\r\n\r\n");
|
||||
if (pos == std::string::npos)
|
||||
return;
|
||||
|
||||
// We can be sure that the header is "Content-Length: xxx\r\n".
|
||||
std::string content_length = buffer_.substr(16, pos - 16);
|
||||
if (!base::StringToInt(content_length, &content_length_)) {
|
||||
DidClose(accepted_socket_.get());
|
||||
return;
|
||||
}
|
||||
|
||||
// Strip header from buffer.
|
||||
buffer_ = buffer_.substr(pos + 4);
|
||||
// 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);
|
||||
}
|
||||
|
||||
// Read the message.
|
||||
if (buffer_.size() >= static_cast<size_t>(content_length_)) {
|
||||
std::string message = buffer_.substr(0, content_length_);
|
||||
buffer_ = buffer_.substr(content_length_);
|
||||
|
||||
OnMessage(message);
|
||||
|
||||
// Get ready for next message.
|
||||
content_length_ = -1;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
|
||||
void NodeDebugger::DidClose(net::test_server::StreamListenSocket* socket) {
|
||||
// If we lost the connection, then simulate a disconnect msg:
|
||||
OnMessage("{\"seq\":1,\"type\":\"request\",\"command\":\"disconnect\"}");
|
||||
inspector->Start(platform_.get(), nullptr, options);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -6,56 +6,22 @@
|
|||
#define ATOM_BROWSER_NODE_DEBUGGER_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/threading/thread.h"
|
||||
#include "net/test/embedded_test_server/stream_listen_socket.h"
|
||||
#include "v8/include/v8-debug.h"
|
||||
#include "vendor/node/deps/uv/include/uv.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
// Add support for node's "--debug" switch.
|
||||
class NodeDebugger : public net::test_server::StreamListenSocket::Delegate {
|
||||
// Add support for node's "--inspect" switch.
|
||||
class NodeDebugger {
|
||||
public:
|
||||
explicit NodeDebugger(v8::Isolate* isolate);
|
||||
virtual ~NodeDebugger();
|
||||
explicit NodeDebugger(node::Environment* env);
|
||||
~NodeDebugger();
|
||||
|
||||
bool IsRunning() const;
|
||||
void Start();
|
||||
|
||||
private:
|
||||
void StartServer(int port);
|
||||
void CloseSession();
|
||||
void OnMessage(const std::string& message);
|
||||
void SendMessage(const std::string& message);
|
||||
void SendConnectMessage();
|
||||
|
||||
static void ProcessMessageInUI(uv_async_t* handle);
|
||||
|
||||
static void DebugMessageHandler(const v8::Debug::Message& message);
|
||||
|
||||
// net::test_server::StreamListenSocket::Delegate:
|
||||
void DidAccept(
|
||||
net::test_server::StreamListenSocket* server,
|
||||
std::unique_ptr<net::test_server::StreamListenSocket> socket) override;
|
||||
void DidRead(net::test_server::StreamListenSocket* socket,
|
||||
const char* data,
|
||||
int len) override;
|
||||
void DidClose(net::test_server::StreamListenSocket* socket) override;
|
||||
|
||||
v8::Isolate* isolate_;
|
||||
|
||||
uv_async_t weak_up_ui_handle_;
|
||||
|
||||
base::Thread thread_;
|
||||
std::unique_ptr<net::test_server::StreamListenSocket> server_;
|
||||
std::unique_ptr<net::test_server::StreamListenSocket> accepted_socket_;
|
||||
|
||||
std::string buffer_;
|
||||
int content_length_;
|
||||
|
||||
base::WeakPtrFactory<NodeDebugger> weak_factory_;
|
||||
node::Environment* env_;
|
||||
std::unique_ptr<v8::Platform> platform_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NodeDebugger);
|
||||
};
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
|
||||
#include "atom/browser/osr/osr_output_device.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkDevice.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
#include "third_party/skia/include/core/SkRect.h"
|
||||
#include "third_party/skia/src/core/SkDevice.h"
|
||||
#include "ui/gfx/skia_util.h"
|
||||
|
||||
namespace atom {
|
||||
|
@ -36,8 +38,11 @@ void OffScreenOutputDevice::Resize(
|
|||
return;
|
||||
}
|
||||
|
||||
if (transparent_)
|
||||
bitmap_->eraseARGB(0, 0, 0, 0);
|
||||
if (transparent_) {
|
||||
bitmap_->eraseColor(SK_ColorTRANSPARENT);
|
||||
} else {
|
||||
bitmap_->eraseColor(SK_ColorWHITE);
|
||||
}
|
||||
|
||||
canvas_.reset(new SkCanvas(*bitmap_));
|
||||
}
|
||||
|
@ -47,6 +52,17 @@ SkCanvas* OffScreenOutputDevice::BeginPaint(const gfx::Rect& damage_rect) {
|
|||
DCHECK(bitmap_.get());
|
||||
|
||||
damage_rect_ = damage_rect;
|
||||
SkIRect damage = SkIRect::MakeXYWH(
|
||||
damage_rect_.x(),
|
||||
damage_rect_.y(),
|
||||
damage_rect_.width(),
|
||||
damage_rect_.height());
|
||||
|
||||
if (transparent_) {
|
||||
bitmap_->erase(SK_ColorTRANSPARENT, damage);
|
||||
} else {
|
||||
bitmap_->erase(SK_ColorWHITE, damage);
|
||||
}
|
||||
|
||||
return canvas_.get();
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -5,6 +5,7 @@
|
|||
#ifndef ATOM_BROWSER_OSR_OSR_RENDER_WIDGET_HOST_VIEW_H_
|
||||
#define ATOM_BROWSER_OSR_OSR_RENDER_WIDGET_HOST_VIEW_H_
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -20,10 +21,13 @@
|
|||
#include "base/time/time.h"
|
||||
#include "cc/output/compositor_frame.h"
|
||||
#include "cc/scheduler/begin_frame_source.h"
|
||||
#include "content/browser/frame_host/render_widget_host_view_guest.h"
|
||||
#include "content/browser/renderer_host/delegated_frame_host.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_view_base.h"
|
||||
#include "content/browser/renderer_host/resize_lock.h"
|
||||
#include "content/browser/web_contents/web_contents_view.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "third_party/WebKit/public/platform/WebVector.h"
|
||||
#include "ui/base/ime/text_input_client.h"
|
||||
#include "ui/compositor/compositor.h"
|
||||
|
@ -69,6 +73,7 @@ class OffScreenRenderWidgetHostView
|
|||
OffScreenRenderWidgetHostView(bool transparent,
|
||||
const OnPaintCallback& callback,
|
||||
content::RenderWidgetHost* render_widget_host,
|
||||
OffScreenRenderWidgetHostView* parent_host_view,
|
||||
NativeWindow* native_window);
|
||||
~OffScreenRenderWidgetHostView() override;
|
||||
|
||||
|
@ -126,28 +131,33 @@ class OffScreenRenderWidgetHostView
|
|||
#endif
|
||||
void SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params &)
|
||||
override;
|
||||
void CopyFromCompositingSurface(const gfx::Rect &,
|
||||
const gfx::Size &,
|
||||
const content::ReadbackRequestCallback &,
|
||||
const SkColorType) override;
|
||||
void CopyFromCompositingSurfaceToVideoFrame(
|
||||
const gfx::Rect &,
|
||||
const scoped_refptr<media::VideoFrame> &,
|
||||
const base::Callback<void(const gfx::Rect &, bool),
|
||||
base::internal::CopyMode::Copyable> &) override;
|
||||
bool CanCopyToVideoFrame(void) const override;
|
||||
void CopyFromSurface(
|
||||
const gfx::Rect& src_subrect,
|
||||
const gfx::Size& dst_size,
|
||||
const content::ReadbackRequestCallback& callback,
|
||||
const SkColorType color_type) override;
|
||||
void CopyFromSurfaceToVideoFrame(
|
||||
const gfx::Rect& src_subrect,
|
||||
scoped_refptr<media::VideoFrame> target,
|
||||
const base::Callback<void(const gfx::Rect&, bool)>& callback) override;
|
||||
void BeginFrameSubscription(
|
||||
std::unique_ptr<content::RenderWidgetHostViewFrameSubscriber>) override;
|
||||
void EndFrameSubscription() override;
|
||||
void InitAsGuest(
|
||||
content::RenderWidgetHostView*,
|
||||
content::RenderWidgetHostViewGuest*) override;
|
||||
bool HasAcceleratedSurface(const gfx::Size &) override;
|
||||
gfx::Rect GetBoundsInRootWindow(void) override;
|
||||
void LockCompositingSurface(void) override;
|
||||
void UnlockCompositingSurface(void) override;
|
||||
void ImeCompositionRangeChanged(
|
||||
const gfx::Range &, const std::vector<gfx::Rect>&) override;
|
||||
gfx::Size GetPhysicalBackingSize() const override;
|
||||
gfx::Size GetRequestedRendererSize() const override;
|
||||
|
||||
content::RenderWidgetHostViewBase* CreateViewForWidget(
|
||||
content::RenderWidgetHost*,
|
||||
content::RenderWidgetHost*,
|
||||
content::WebContentsView*) override;
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
// content::DelegatedFrameHostClient:
|
||||
int DelegatedFrameHostGetGpuMemoryBufferClientId(void) const;
|
||||
|
@ -166,6 +176,15 @@ class OffScreenRenderWidgetHostView
|
|||
void SetBeginFrameSource(cc::BeginFrameSource* source) override;
|
||||
#endif // !defined(OS_MACOSX)
|
||||
|
||||
bool TransformPointToLocalCoordSpace(
|
||||
const gfx::Point& point,
|
||||
const cc::SurfaceId& original_surface,
|
||||
gfx::Point* transformed_point) override;
|
||||
bool TransformPointToCoordSpaceForView(
|
||||
const gfx::Point& point,
|
||||
RenderWidgetHostViewBase* target_view,
|
||||
gfx::Point* transformed_point) override;
|
||||
|
||||
// ui::CompositorDelegate:
|
||||
std::unique_ptr<cc::SoftwareOutputDevice> CreateSoftwareOutputDevice(
|
||||
ui::Compositor* compositor) override;
|
||||
|
@ -182,11 +201,36 @@ class OffScreenRenderWidgetHostView
|
|||
base::TimeDelta vsync_period);
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
void CreatePlatformWidget();
|
||||
void CreatePlatformWidget(bool is_guest_view_hack);
|
||||
void DestroyPlatformWidget();
|
||||
#endif
|
||||
|
||||
void CancelWidget();
|
||||
void AddGuestHostView(OffScreenRenderWidgetHostView* guest_host);
|
||||
void RemoveGuestHostView(OffScreenRenderWidgetHostView* guest_host);
|
||||
|
||||
void RegisterGuestViewFrameSwappedCallback(
|
||||
content::RenderWidgetHostViewGuest* guest_host_view);
|
||||
void OnGuestViewFrameSwapped(
|
||||
content::RenderWidgetHostViewGuest* guest_host_view);
|
||||
|
||||
void OnPaint(const gfx::Rect& damage_rect, const SkBitmap& bitmap);
|
||||
void OnPopupPaint(const gfx::Rect& damage_rect, const SkBitmap& bitmap);
|
||||
|
||||
bool IsPopupWidget() const {
|
||||
return popup_type_ != blink::WebPopupTypeNone;
|
||||
}
|
||||
|
||||
void HoldResize();
|
||||
void ReleaseResize();
|
||||
void WasResized();
|
||||
|
||||
void ProcessKeyboardEvent(
|
||||
const content::NativeWebKeyboardEvent& event) override;
|
||||
void ProcessMouseEvent(const blink::WebMouseEvent& event,
|
||||
const ui::LatencyInfo& latency) override;
|
||||
void ProcessMouseWheelEvent(const blink::WebMouseWheelEvent& event,
|
||||
const ui::LatencyInfo& latency) override;
|
||||
|
||||
void SetPainting(bool painting);
|
||||
bool IsPainting() const;
|
||||
|
@ -199,6 +243,7 @@ class OffScreenRenderWidgetHostView
|
|||
content::DelegatedFrameHost* GetDelegatedFrameHost() const;
|
||||
|
||||
void Invalidate();
|
||||
void InvalidateBounds(const gfx::Rect&);
|
||||
|
||||
content::RenderWidgetHostImpl* render_widget_host() const
|
||||
{ return render_widget_host_; }
|
||||
|
@ -206,29 +251,53 @@ class OffScreenRenderWidgetHostView
|
|||
gfx::Size size() const { return size_; }
|
||||
float scale_factor() const { return scale_factor_; }
|
||||
|
||||
void set_popup_host_view(OffScreenRenderWidgetHostView* popup_view) {
|
||||
popup_host_view_ = popup_view;
|
||||
}
|
||||
|
||||
void set_child_host_view(OffScreenRenderWidgetHostView* child_view) {
|
||||
child_host_view_ = child_view;
|
||||
}
|
||||
|
||||
private:
|
||||
void SetupFrameRate(bool force);
|
||||
void ResizeRootLayer();
|
||||
|
||||
cc::FrameSinkId AllocateFrameSinkId(bool is_guest_view_hack);
|
||||
|
||||
// Weak ptrs.
|
||||
content::RenderWidgetHostImpl* render_widget_host_;
|
||||
|
||||
OffScreenRenderWidgetHostView* parent_host_view_;
|
||||
OffScreenRenderWidgetHostView* popup_host_view_;
|
||||
std::unique_ptr<SkBitmap> popup_bitmap_;
|
||||
OffScreenRenderWidgetHostView* child_host_view_;
|
||||
std::set<OffScreenRenderWidgetHostView*> guest_host_views_;
|
||||
|
||||
NativeWindow* native_window_;
|
||||
OffScreenOutputDevice* software_output_device_;
|
||||
|
||||
const bool transparent_;
|
||||
OnPaintCallback callback_;
|
||||
OnPaintCallback parent_callback_;
|
||||
|
||||
int frame_rate_;
|
||||
int frame_rate_threshold_ms_;
|
||||
int frame_rate_threshold_us_;
|
||||
|
||||
base::Time last_time_;
|
||||
|
||||
float scale_factor_;
|
||||
bool is_showing_;
|
||||
gfx::Vector2dF last_scroll_offset_;
|
||||
gfx::Size size_;
|
||||
bool painting_;
|
||||
|
||||
bool is_showing_;
|
||||
bool is_destroyed_;
|
||||
gfx::Rect popup_position_;
|
||||
|
||||
bool hold_resize_;
|
||||
bool pending_resize_;
|
||||
|
||||
std::unique_ptr<ui::Layer> root_layer_;
|
||||
std::unique_ptr<ui::Compositor> compositor_;
|
||||
std::unique_ptr<content::DelegatedFrameHost> delegated_frame_host_;
|
||||
|
@ -236,6 +305,10 @@ class OffScreenRenderWidgetHostView
|
|||
std::unique_ptr<AtomCopyFrameGenerator> copy_frame_generator_;
|
||||
std::unique_ptr<AtomBeginFrameTimer> begin_frame_timer_;
|
||||
|
||||
// Provides |source_id| for BeginFrameArgs that we create.
|
||||
cc::StubBeginFrameSource begin_frame_source_;
|
||||
uint64_t begin_frame_number_ = cc::BeginFrameArgs::kStartingFrameNumber;
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
CALayer* background_layer_;
|
||||
std::unique_ptr<content::BrowserCompositorMac> browser_compositor_;
|
||||
|
|
|
@ -121,10 +121,12 @@ void OffScreenRenderWidgetHostView::SelectionChanged(
|
|||
RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
|
||||
}
|
||||
|
||||
void OffScreenRenderWidgetHostView::CreatePlatformWidget() {
|
||||
void OffScreenRenderWidgetHostView::CreatePlatformWidget(
|
||||
bool is_guest_view_hack) {
|
||||
mac_helper_ = new MacHelper(this);
|
||||
browser_compositor_.reset(new content::BrowserCompositorMac(
|
||||
mac_helper_, mac_helper_, render_widget_host_->is_hidden(), true));
|
||||
mac_helper_, mac_helper_, render_widget_host_->is_hidden(), true,
|
||||
AllocateFrameSinkId(is_guest_view_hack)));
|
||||
}
|
||||
|
||||
void OffScreenRenderWidgetHostView::DestroyPlatformWidget() {
|
||||
|
|
|
@ -4,7 +4,11 @@
|
|||
|
||||
#include "atom/browser/osr/osr_web_contents_view.h"
|
||||
|
||||
#include "atom/common/api/api_messages.h"
|
||||
#include "content/browser/web_contents/web_contents_impl.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "third_party/WebKit/public/platform/WebScreenInfo.h"
|
||||
#include "ui/display/screen.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -27,19 +31,33 @@ OffScreenWebContentsView::~OffScreenWebContentsView() {
|
|||
void OffScreenWebContentsView::SetWebContents(
|
||||
content::WebContents* web_contents) {
|
||||
web_contents_ = web_contents;
|
||||
|
||||
RenderViewCreated(web_contents_->GetRenderViewHost());
|
||||
}
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
gfx::NativeView OffScreenWebContentsView::GetNativeView() const {
|
||||
return gfx::NativeView();
|
||||
if (!web_contents_) return gfx::NativeView();
|
||||
|
||||
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
|
||||
if (!relay) return gfx::NativeView();
|
||||
return relay->window->GetNativeView();
|
||||
}
|
||||
|
||||
gfx::NativeView OffScreenWebContentsView::GetContentNativeView() const {
|
||||
return gfx::NativeView();
|
||||
if (!web_contents_) return gfx::NativeView();
|
||||
|
||||
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
|
||||
if (!relay) return gfx::NativeView();
|
||||
return relay->window->GetNativeView();
|
||||
}
|
||||
|
||||
gfx::NativeWindow OffScreenWebContentsView::GetTopLevelNativeWindow() const {
|
||||
return gfx::NativeWindow();
|
||||
if (!web_contents_) return gfx::NativeWindow();
|
||||
|
||||
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
|
||||
if (!relay) return gfx::NativeWindow();
|
||||
return relay->window->GetNativeWindow();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -67,7 +85,7 @@ content::DropData* OffScreenWebContentsView::GetDropData() const {
|
|||
}
|
||||
|
||||
gfx::Rect OffScreenWebContentsView::GetViewBounds() const {
|
||||
return view_ ? view_->GetViewBounds() : gfx::Rect();
|
||||
return GetView() ? GetView()->GetViewBounds() : gfx::Rect();
|
||||
}
|
||||
|
||||
void OffScreenWebContentsView::CreateView(const gfx::Size& initial_size,
|
||||
|
@ -77,19 +95,40 @@ void OffScreenWebContentsView::CreateView(const gfx::Size& initial_size,
|
|||
content::RenderWidgetHostViewBase*
|
||||
OffScreenWebContentsView::CreateViewForWidget(
|
||||
content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack) {
|
||||
if (render_widget_host->GetView()) {
|
||||
return static_cast<content::RenderWidgetHostViewBase*>(
|
||||
render_widget_host->GetView());
|
||||
}
|
||||
|
||||
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
|
||||
view_ = new OffScreenRenderWidgetHostView(
|
||||
transparent_, callback_, render_widget_host, relay->window.get());
|
||||
return view_;
|
||||
return new OffScreenRenderWidgetHostView(
|
||||
transparent_,
|
||||
callback_,
|
||||
render_widget_host,
|
||||
nullptr,
|
||||
relay->window.get());
|
||||
}
|
||||
|
||||
content::RenderWidgetHostViewBase*
|
||||
OffScreenWebContentsView::CreateViewForPopupWidget(
|
||||
content::RenderWidgetHost* render_widget_host) {
|
||||
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
|
||||
view_ = new OffScreenRenderWidgetHostView(
|
||||
transparent_, callback_, render_widget_host, relay->window.get());
|
||||
return view_;
|
||||
|
||||
content::WebContentsImpl *web_contents_impl =
|
||||
static_cast<content::WebContentsImpl*>(web_contents_);
|
||||
|
||||
OffScreenRenderWidgetHostView *view =
|
||||
static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents_impl->GetOuterWebContents()
|
||||
? web_contents_impl->GetOuterWebContents()->GetRenderWidgetHostView()
|
||||
: web_contents_impl->GetRenderWidgetHostView());
|
||||
|
||||
return new OffScreenRenderWidgetHostView(
|
||||
transparent_,
|
||||
callback_,
|
||||
render_widget_host,
|
||||
view,
|
||||
relay->window.get());
|
||||
}
|
||||
|
||||
void OffScreenWebContentsView::SetPageTitle(const base::string16& title) {
|
||||
|
@ -97,8 +136,12 @@ void OffScreenWebContentsView::SetPageTitle(const base::string16& title) {
|
|||
|
||||
void OffScreenWebContentsView::RenderViewCreated(
|
||||
content::RenderViewHost* host) {
|
||||
if (view_)
|
||||
view_->InstallTransparency();
|
||||
if (GetView())
|
||||
GetView()->InstallTransparency();
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
host->Send(new AtomViewMsg_Offscreen(host->GetRoutingID()));
|
||||
#endif
|
||||
}
|
||||
|
||||
void OffScreenWebContentsView::RenderViewSwappedIn(
|
||||
|
@ -110,14 +153,22 @@ void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled) {
|
|||
|
||||
void OffScreenWebContentsView::GetScreenInfo(
|
||||
content::ScreenInfo* screen_info) const {
|
||||
screen_info->rect = gfx::Rect(view_->size());
|
||||
screen_info->available_rect = gfx::Rect(view_->size());
|
||||
screen_info->depth = 24;
|
||||
screen_info->depth_per_component = 8;
|
||||
screen_info->device_scale_factor = view_->scale_factor();
|
||||
screen_info->orientation_angle = 0;
|
||||
screen_info->device_scale_factor = 1.0;
|
||||
screen_info->orientation_type =
|
||||
content::SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY;
|
||||
|
||||
if (GetView()) {
|
||||
screen_info->rect = gfx::Rect(GetView()->size());
|
||||
screen_info->available_rect = gfx::Rect(GetView()->size());
|
||||
} else {
|
||||
const display::Display display =
|
||||
display::Screen::GetScreen()->GetPrimaryDisplay();
|
||||
screen_info->rect = display.bounds();
|
||||
screen_info->available_rect = display.work_area();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
|
@ -151,4 +202,12 @@ void OffScreenWebContentsView::UpdateDragCursor(
|
|||
blink::WebDragOperation operation) {
|
||||
}
|
||||
|
||||
OffScreenRenderWidgetHostView* OffScreenWebContentsView::GetView() const {
|
||||
if (web_contents_) {
|
||||
return static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents_->GetRenderViewHost()->GetWidget()->GetView());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -75,11 +75,12 @@ class OffScreenWebContentsView : public content::WebContentsView,
|
|||
void PlatformDestroy();
|
||||
#endif
|
||||
|
||||
OffScreenRenderWidgetHostView* GetView() const;
|
||||
|
||||
const bool transparent_;
|
||||
OnPaintCallback callback_;
|
||||
|
||||
// Weak refs.
|
||||
OffScreenRenderWidgetHostView* view_;
|
||||
content::WebContents* web_contents_;
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
<key>CFBundleIconFile</key>
|
||||
<string>electron.icns</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.6.8</string>
|
||||
<string>1.7.1</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.6.8</string>
|
||||
<string>1.7.1</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.developer-tools</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
|
|
|
@ -56,8 +56,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,6,8,0
|
||||
PRODUCTVERSION 1,6,8,0
|
||||
FILEVERSION 1,7,1,0
|
||||
PRODUCTVERSION 1,7,1,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -74,12 +74,12 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "GitHub, Inc."
|
||||
VALUE "FileDescription", "Electron"
|
||||
VALUE "FileVersion", "1.6.8"
|
||||
VALUE "FileVersion", "1.7.1"
|
||||
VALUE "InternalName", "electron.exe"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
|
||||
VALUE "OriginalFilename", "electron.exe"
|
||||
VALUE "ProductName", "Electron"
|
||||
VALUE "ProductVersion", "1.6.8"
|
||||
VALUE "ProductVersion", "1.7.1"
|
||||
VALUE "SquirrelAwareVersion", "1"
|
||||
END
|
||||
END
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
auto cert_db = net::CertDatabase::GetInstance();
|
||||
// This forces Chromium to reload the certificate since it might be trusted
|
||||
// now.
|
||||
cert_db->NotifyObserversCertDBChanged(cert_.get());
|
||||
cert_db->NotifyObserversCertDBChanged();
|
||||
|
||||
callback_.Run();
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ BOOL AddToTrustedRootStore(const PCCERT_CONTEXT cert_context,
|
|||
if (result) {
|
||||
// force Chromium to reload it's database for this certificate
|
||||
auto cert_db = net::CertDatabase::GetInstance();
|
||||
cert_db->NotifyObserversCertDBChanged(cert.get());
|
||||
cert_db->NotifyObserversCertDBChanged();
|
||||
}
|
||||
|
||||
CertCloseStore(root_cert_store, CERT_CLOSE_STORE_FORCE_FLAG);
|
||||
|
|
|
@ -41,7 +41,7 @@ class GtkMessageBox : public NativeWindowObserver {
|
|||
const gfx::ImageSkia& icon)
|
||||
: cancel_id_(cancel_id),
|
||||
checkbox_checked_(false),
|
||||
parent_(static_cast<NativeWindowViews*>(parent_window)) {
|
||||
parent_(static_cast<NativeWindow*>(parent_window)) {
|
||||
// Create dialog.
|
||||
dialog_ = gtk_message_dialog_new(
|
||||
nullptr, // parent
|
||||
|
@ -94,7 +94,7 @@ class GtkMessageBox : public NativeWindowObserver {
|
|||
// Parent window.
|
||||
if (parent_) {
|
||||
parent_->AddObserver(this);
|
||||
parent_->SetEnabled(false);
|
||||
static_cast<NativeWindowViews*>(parent_)->SetEnabled(false);
|
||||
libgtkui::SetGtkTransientForAura(dialog_, parent_->GetNativeWindow());
|
||||
gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE);
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ class GtkMessageBox : public NativeWindowObserver {
|
|||
gtk_widget_destroy(dialog_);
|
||||
if (parent_) {
|
||||
parent_->RemoveObserver(this);
|
||||
parent_->SetEnabled(true);
|
||||
static_cast<NativeWindowViews*>(parent_)->SetEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ class GtkMessageBox : public NativeWindowObserver {
|
|||
|
||||
bool checkbox_checked_;
|
||||
|
||||
NativeWindowViews* parent_;
|
||||
NativeWindow* parent_;
|
||||
GtkWidget* dialog_;
|
||||
MessageBoxCallback callback_;
|
||||
|
||||
|
|
|
@ -9,8 +9,10 @@
|
|||
// This conflicts with mate::Converter,
|
||||
#undef True
|
||||
#undef False
|
||||
// and V8.
|
||||
// and V8,
|
||||
#undef None
|
||||
// and url_request_status.h,
|
||||
#undef Status
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <glib-object.h>
|
||||
|
|
|
@ -36,7 +36,7 @@ SubmenuButton::SubmenuButton(const base::string16& title,
|
|||
|
||||
if (GetUnderlinePosition(title, &accelerator_, &underline_start_,
|
||||
&underline_end_))
|
||||
gfx::Canvas::SizeStringInt(GetText(), GetFontList(), &text_width_,
|
||||
gfx::Canvas::SizeStringInt(GetText(), gfx::FontList(), &text_width_,
|
||||
&text_height_, 0, 0);
|
||||
|
||||
SetInkDropMode(InkDropMode::ON);
|
||||
|
@ -107,8 +107,8 @@ bool SubmenuButton::GetUnderlinePosition(const base::string16& text,
|
|||
void SubmenuButton::GetCharacterPosition(
|
||||
const base::string16& text, int index, int* pos) {
|
||||
int height = 0;
|
||||
gfx::Canvas::SizeStringInt(text.substr(0, index), GetFontList(), pos, &height,
|
||||
0, 0);
|
||||
gfx::Canvas::SizeStringInt(text.substr(0, index), gfx::FontList(), pos,
|
||||
&height, 0, 0);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -33,9 +33,8 @@ void CreateResponseHeadersDictionary(const net::HttpResponseHeaders* headers,
|
|||
while (headers->EnumerateHeaderLines(&iter, &header_name, &header_value)) {
|
||||
base::Value* existing_value = nullptr;
|
||||
if (result->Get(header_name, &existing_value)) {
|
||||
base::StringValue* existing_string_value =
|
||||
static_cast<base::StringValue*>(existing_value);
|
||||
existing_string_value->GetString()->append(", ").append(header_value);
|
||||
std::string src = existing_value->GetString();
|
||||
result->SetString(header_name, src + ", " + header_value);
|
||||
} else {
|
||||
result->SetString(header_name, header_value);
|
||||
}
|
||||
|
@ -131,7 +130,7 @@ void PdfViewerHandler::GetDefaultZoom(const base::ListValue* args) {
|
|||
double zoom_level = host_zoom_map->GetDefaultZoomLevel();
|
||||
ResolveJavascriptCallback(
|
||||
*callback_id,
|
||||
base::FundamentalValue(content::ZoomLevelToZoomFactor(zoom_level)));
|
||||
base::Value(content::ZoomLevelToZoomFactor(zoom_level)));
|
||||
}
|
||||
|
||||
void PdfViewerHandler::GetInitialZoom(const base::ListValue* args) {
|
||||
|
@ -145,7 +144,7 @@ void PdfViewerHandler::GetInitialZoom(const base::ListValue* args) {
|
|||
content::HostZoomMap::GetZoomLevel(web_ui()->GetWebContents());
|
||||
ResolveJavascriptCallback(
|
||||
*callback_id,
|
||||
base::FundamentalValue(content::ZoomLevelToZoomFactor(zoom_level)));
|
||||
base::Value(content::ZoomLevelToZoomFactor(zoom_level)));
|
||||
}
|
||||
|
||||
void PdfViewerHandler::SetZoom(const base::ListValue* args) {
|
||||
|
@ -159,7 +158,7 @@ void PdfViewerHandler::SetZoom(const base::ListValue* args) {
|
|||
|
||||
content::HostZoomMap::SetZoomLevel(web_ui()->GetWebContents(),
|
||||
zoom_level);
|
||||
ResolveJavascriptCallback(*callback_id, base::FundamentalValue(zoom_level));
|
||||
ResolveJavascriptCallback(*callback_id, base::Value(zoom_level));
|
||||
}
|
||||
|
||||
void PdfViewerHandler::GetStrings(const base::ListValue* args) {
|
||||
|
@ -204,7 +203,7 @@ void PdfViewerHandler::OnZoomLevelChanged(
|
|||
if (change.host == kPdfViewerUIHost) {
|
||||
CallJavascriptFunction(
|
||||
"cr.webUIListenerCallback", base::StringValue("onZoomLevelChanged"),
|
||||
base::FundamentalValue(
|
||||
base::Value(
|
||||
content::ZoomLevelToZoomFactor(change.zoom_level)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,7 +134,8 @@ class PdfViewerUI::ResourceRequester
|
|||
content::ResourceDispatcherHostImpl::Get()->InitializeURLRequest(
|
||||
request.get(), content::Referrer(url, blink::WebReferrerPolicyDefault),
|
||||
false, // download.
|
||||
render_process_id, render_view_id, render_frame_id, resource_context);
|
||||
render_process_id, render_view_id, render_frame_id,
|
||||
content::PREVIEWS_OFF, resource_context);
|
||||
|
||||
content::ResourceRequestInfoImpl* info =
|
||||
content::ResourceRequestInfoImpl::ForRequest(request.get());
|
||||
|
@ -202,7 +203,8 @@ PdfViewerUI::PdfViewerUI(content::BrowserContext* browser_context,
|
|||
content::WebContentsObserver(web_ui->GetWebContents()),
|
||||
src_(src) {
|
||||
pdf_handler_ = new PdfViewerHandler(src);
|
||||
web_ui->AddMessageHandler(pdf_handler_);
|
||||
web_ui->AddMessageHandler(
|
||||
std::unique_ptr<content::WebUIMessageHandler>(pdf_handler_));
|
||||
content::URLDataSource::Add(browser_context, new BundledDataSource);
|
||||
}
|
||||
|
||||
|
|
|
@ -106,6 +106,8 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
|||
// integration.
|
||||
if (IsSandboxed(web_contents))
|
||||
command_line->AppendSwitch(switches::kEnableSandbox);
|
||||
if (web_preferences.GetBoolean("nativeWindowOpen", &b) && b)
|
||||
command_line->AppendSwitch(switches::kNativeWindowOpen);
|
||||
|
||||
// The preload script.
|
||||
base::FilePath::StringType preload;
|
||||
|
@ -212,6 +214,22 @@ bool WebContentsPreferences::IsSandboxed(content::WebContents* web_contents) {
|
|||
return sandboxed;
|
||||
}
|
||||
|
||||
bool WebContentsPreferences::UsesNativeWindowOpen(
|
||||
content::WebContents* web_contents) {
|
||||
WebContentsPreferences* self;
|
||||
if (!web_contents)
|
||||
return false;
|
||||
|
||||
self = FromWebContents(web_contents);
|
||||
if (!self)
|
||||
return false;
|
||||
|
||||
base::DictionaryValue& web_preferences = self->web_preferences_;
|
||||
bool use = false;
|
||||
web_preferences.GetBoolean("nativeWindowOpen", &use);
|
||||
return use;
|
||||
}
|
||||
|
||||
// static
|
||||
void WebContentsPreferences::OverrideWebkitPrefs(
|
||||
content::WebContents* web_contents, content::WebPreferences* prefs) {
|
||||
|
|
|
@ -38,6 +38,7 @@ class WebContentsPreferences
|
|||
content::WebContents* web_contents, base::CommandLine* command_line);
|
||||
|
||||
static bool IsSandboxed(content::WebContents* web_contents);
|
||||
static bool UsesNativeWindowOpen(content::WebContents* web_contents);
|
||||
|
||||
// Modify the WebPreferences according to |web_contents|'s preferences.
|
||||
static void OverrideWebkitPrefs(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue