Fix API changes of FrameSubscriber

This commit is contained in:
Cheng Zhao 2017-04-13 19:21:30 +09:00
parent 6da696b6f2
commit d85b58fdb5
4 changed files with 21 additions and 9 deletions

View file

@ -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) {

View file

@ -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,

View file

@ -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);

View file

@ -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<content::WebUIMessageHandler>(pdf_handler_));
content::URLDataSource::Add(browser_context, new BundledDataSource);
}