diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 8b46484b36e6..a189cc211b42 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -76,6 +76,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" @@ -1306,7 +1307,7 @@ void WebContents::SelectAll() { } void WebContents::Unselect() { - web_contents()->Unselect(); + web_contents()->CollapseSelection(); } void WebContents::Replace(const base::string16& word) { @@ -1396,7 +1397,10 @@ void WebContents::SendInputEvent(v8::Isolate* isolate, 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); return; @@ -1486,8 +1490,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; } @@ -1507,10 +1510,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) { diff --git a/atom/browser/api/frame_subscriber.cc b/atom/browser/api/frame_subscriber.cc index 652596af15f4..076ebde98268 100644 --- a/atom/browser/api/frame_subscriber.cc +++ b/atom/browser/api/frame_subscriber.cc @@ -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) { } @@ -63,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, diff --git a/atom/browser/api/frame_subscriber.h b/atom/browser/api/frame_subscriber.h index a32864c17749..3761f144d04b 100644 --- a/atom/browser/api/frame_subscriber.h +++ b/atom/browser/api/frame_subscriber.h @@ -32,6 +32,7 @@ class FrameSubscriber : public content::RenderWidgetHostViewFrameSubscriber { base::TimeTicks present_time, scoped_refptr* 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 weak_factory_; DISALLOW_COPY_AND_ASSIGN(FrameSubscriber); diff --git a/atom/browser/ui/webui/pdf_viewer_ui.cc b/atom/browser/ui/webui/pdf_viewer_ui.cc index c1b6dbfccfa8..b6073f8409af 100644 --- a/atom/browser/ui/webui/pdf_viewer_ui.cc +++ b/atom/browser/ui/webui/pdf_viewer_ui.cc @@ -203,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(pdf_handler_)); content::URLDataSource::Add(browser_context, new BundledDataSource); }