summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpaulmeyer <paulmeyer@chromium.org>2015-10-21 15:58:05 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-21 22:59:00 +0000
commitd7523c2b968283cfdcfe46cf2569b871ed2216f8 (patch)
tree455fcd013dbed35021ac2a0359b1ac94a058211b
parent03007d04e150b30cfe62ab26a7ed47f71c2a79c2 (diff)
downloadchromium_src-d7523c2b968283cfdcfe46cf2569b871ed2216f8.zip
chromium_src-d7523c2b968283cfdcfe46cf2569b871ed2216f8.tar.gz
chromium_src-d7523c2b968283cfdcfe46cf2569b871ed2216f8.tar.bz2
This patch reduces the public method footprint of GuestViewBase and derived types.
BUG=534320 Review URL: https://codereview.chromium.org/1392343002 Cr-Commit-Position: refs/heads/master@{#355420}
-rw-r--r--components/guest_view/browser/guest_view_base.cc17
-rw-r--r--components/guest_view/browser/guest_view_base.h311
-rw-r--r--content/browser/browser_plugin/browser_plugin_embedder.cc10
-rw-r--r--content/browser/browser_plugin/browser_plugin_guest.cc13
-rw-r--r--content/browser/browser_plugin/browser_plugin_guest.h8
-rw-r--r--content/public/browser/browser_plugin_guest_delegate.cc10
-rw-r--r--content/public/browser/browser_plugin_guest_delegate.h8
-rw-r--r--extensions/browser/api/guest_view/web_view/web_view_internal_api.cc4
-rw-r--r--extensions/browser/guest_view/app_view/app_view_guest.h36
-rw-r--r--extensions/browser/guest_view/extension_options/extension_options_guest.h39
-rw-r--r--extensions/browser/guest_view/extension_view/extension_view_guest.h27
-rw-r--r--extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h34
-rw-r--r--extensions/browser/guest_view/web_view/web_view_guest.cc4
-rw-r--r--extensions/browser/guest_view/web_view/web_view_guest.h228
14 files changed, 358 insertions, 391 deletions
diff --git a/components/guest_view/browser/guest_view_base.cc b/components/guest_view/browser/guest_view_base.cc
index 063850e..564ab65 100644
--- a/components/guest_view/browser/guest_view_base.cc
+++ b/components/guest_view/browser/guest_view_base.cc
@@ -159,6 +159,8 @@ GuestViewBase::GuestViewBase(WebContents* owner_web_contents)
owner_web_contents->GetLastCommittedURL().host() : std::string();
}
+GuestViewBase::~GuestViewBase() {}
+
void GuestViewBase::Init(const base::DictionaryValue& create_params,
const WebContentsCreatedCallback& callback) {
if (initialized_)
@@ -407,9 +409,10 @@ void GuestViewBase::DidDetach() {
element_instance_id_ = kInstanceIDNone;
}
-bool GuestViewBase::Find(int request_id,
- const base::string16& search_text,
- const blink::WebFindOptions& options) {
+bool GuestViewBase::HandleFindForEmbedder(
+ int request_id,
+ const base::string16& search_text,
+ const blink::WebFindOptions& options) {
if (ShouldHandleFindRequestsForEmbedder()) {
web_contents()->Find(request_id, search_text, options);
return true;
@@ -417,7 +420,8 @@ bool GuestViewBase::Find(int request_id,
return false;
}
-bool GuestViewBase::StopFinding(content::StopFindAction action) {
+bool GuestViewBase::HandleStopFindingForEmbedder(
+ content::StopFindAction action) {
if (ShouldHandleFindRequestsForEmbedder()) {
web_contents()->StopFinding(action);
return true;
@@ -701,9 +705,6 @@ void GuestViewBase::FindReply(WebContents* source,
}
}
-GuestViewBase::~GuestViewBase() {
-}
-
void GuestViewBase::OnZoomChanged(
const ui_zoom::ZoomController::ZoomChangedEventData& data) {
if (data.web_contents == embedder_web_contents()) {
@@ -717,8 +718,6 @@ void GuestViewBase::OnZoomChanged(
// When the embedder's zoom level doesn't match the guest's, then update the
// guest's zoom level to match.
guest_zoom_controller->SetZoomLevel(data.new_zoom_level);
-
- EmbedderZoomChanged(data.old_zoom_level, data.new_zoom_level);
return;
}
diff --git a/components/guest_view/browser/guest_view_base.h b/components/guest_view/browser/guest_view_base.h
index 0884fcd..588826f 100644
--- a/components/guest_view/browser/guest_view_base.h
+++ b/components/guest_view/browser/guest_view_base.h
@@ -82,123 +82,50 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate,
static bool IsGuest(content::WebContents* web_contents);
+ // Returns the name of the derived type of this GuestView.
virtual const char* GetViewType() const = 0;
- // This method is called after the guest has been attached to an embedder and
- // suspended resource loads have been resumed.
- //
- // This method can be overriden by subclasses. This gives the derived class
- // an opportunity to perform setup actions after attachment.
- virtual void DidAttachToEmbedder() {}
-
- // This method is called after this GuestViewBase has been initiated.
- //
- // This gives the derived class an opportunity to perform additional
- // initialization.
- virtual void DidInitialize(const base::DictionaryValue& create_params) {}
-
- // This method is called when the initial set of frames within the page have
- // completed loading.
- virtual void GuestViewDidStopLoading() {}
-
- // This method is called when the embedder's zoom changes.
- virtual void EmbedderZoomChanged(double old_zoom_level,
- double new_zoom_level) {}
-
- // This method is called when the guest WebContents has been destroyed. This
- // object will be destroyed after this call returns.
- //
- // This gives the derived class an opportunity to perform some cleanup.
- virtual void GuestDestroyed() {}
-
- // This method is invoked when the guest RenderView is ready, e.g. because we
- // recreated it after a crash or after reattachment.
- //
- // This gives the derived class an opportunity to perform some initialization
- // work.
- virtual void GuestReady() {}
-
- // This method is called when the guest's zoom changes.
- virtual void GuestZoomChanged(double old_zoom_level, double new_zoom_level) {}
-
- // This method is called when embedder WebContents's fullscreen is toggled.
- //
- // If the guest asked the embedder to enter fullscreen, the guest uses this
- // signal to exit fullscreen state.
- virtual void EmbedderFullscreenToggled(bool entered_fullscreen) {}
-
- // This method is invoked when the contents auto-resized to give the container
- // an opportunity to match it if it wishes.
- //
- // This gives the derived class an opportunity to inform its container element
- // or perform other actions.
- virtual void GuestSizeChangedDueToAutoSize(const gfx::Size& old_size,
- const gfx::Size& new_size) {}
-
// This method queries whether autosize is supported for this particular view.
// By default, autosize is not supported. Derived classes can override this
// behavior to support autosize.
virtual bool IsAutoSizeSupported() const;
- // This method is invoked when the contents preferred size changes. This will
- // only ever fire if IsPreferredSizeSupported returns true.
- virtual void OnPreferredSizeChanged(const gfx::Size& pref_size) {}
-
// This method queries whether preferred size events are enabled for this
// view. By default, preferred size events are disabled, since they add a
// small amount of overhead.
virtual bool IsPreferredSizeModeEnabled() const;
- // This method is called immediately before suspended resource loads have been
- // resumed on attachment to an embedder.
- //
- // This method can be overriden by subclasses. This gives the derived class
- // an opportunity to perform setup actions before attachment.
- virtual void WillAttachToEmbedder() {}
-
- // This method is called when the guest WebContents is about to be destroyed.
- //
- // This gives the derived class an opportunity to perform some cleanup prior
- // to destruction.
- virtual void WillDestroy() {}
-
- // This method is to be implemented by the derived class. This indicates
- // whether zoom should propagate from the embedder to the guest content.
+ // This indicates whether zoom should propagate from the embedder to the guest
+ // content.
virtual bool ZoomPropagatesFromEmbedderToGuest() const;
- // This method is to be implemented by the derived class. Access to guest
- // views are determined by the availability of the internal extension API
- // used to implement the guest view.
+ // Access to guest views are determined by the availability of the internal
+ // extension API used to implement the guest view.
//
// This should be the name of the API as it appears in the _api_features.json
// file.
virtual const char* GetAPINamespace() const = 0;
- // This method is to be implemented by the derived class. This method is the
- // task prefix to show for a task produced by this GuestViewBase's derived
- // type.
+ // This method is the task prefix to show for a task produced by this
+ // GuestViewBase's derived type.
virtual int GetTaskPrefix() const = 0;
- // This method is to be implemented by the derived class. Given a set of
- // initialization parameters, a concrete subclass of GuestViewBase can
- // create a specialized WebContents that it returns back to GuestViewBase.
- using WebContentsCreatedCallback =
- base::Callback<void(content::WebContents*)>;
- virtual void CreateWebContents(
- const base::DictionaryValue& create_params,
- const WebContentsCreatedCallback& callback) = 0;
+ // Dispatches an event to the guest proxy.
+ void DispatchEventToGuestProxy(GuestViewEvent* event);
+
+ // Dispatches an event to the view.
+ void DispatchEventToView(GuestViewEvent* event);
// This creates a WebContents and initializes |this| GuestViewBase to use the
// newly created WebContents.
+ using WebContentsCreatedCallback =
+ base::Callback<void(content::WebContents*)>;
void Init(const base::DictionaryValue& create_params,
const WebContentsCreatedCallback& callback);
void InitWithWebContents(const base::DictionaryValue& create_params,
content::WebContents* guest_web_contents);
- void LoadURLWithParams(
- const content::NavigationController::LoadURLParams& load_params);
-
bool IsViewType(const char* const view_type) const {
return !strcmp(GetViewType(), view_type);
}
@@ -271,36 +198,115 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate,
void SetAttachParams(const base::DictionaryValue& params);
void SetOpener(GuestViewBase* opener);
- content::WebContents* CreateNewGuestWindow(
- const content::WebContents::CreateParams& create_params) final;
- void DidAttach(int guest_proxy_routing_id) final;
- void DidDetach() final;
- content::WebContents* GetOwnerWebContents() const final;
- bool Find(int request_id,
- const base::string16& search_text,
- const blink::WebFindOptions& options) final;
- bool StopFinding(content::StopFindAction action) final;
- void GuestSizeChanged(const gfx::Size& new_size) final;
- void SetGuestHost(content::GuestHost* guest_host) final;
- void WillAttach(content::WebContents* embedder_web_contents,
- int browser_plugin_instance_id,
- bool is_full_page_plugin,
- const base::Closure& callback) final;
+ protected:
+ explicit GuestViewBase(content::WebContents* owner_web_contents);
- // ui_zoom::ZoomObserver implementation.
- void OnZoomChanged(
- const ui_zoom::ZoomController::ZoomChangedEventData& data) final;
+ ~GuestViewBase() override;
- // Dispatches an event to the guest proxy.
- void DispatchEventToGuestProxy(GuestViewEvent* event);
+ // BrowserPluginGuestDelegate implementation.
+ void SetContextMenuPosition(const gfx::Point& position) override;
- // Dispatches an event to the view.
- void DispatchEventToView(GuestViewEvent* event);
+ // WebContentsDelegate implementation.
+ void HandleKeyboardEvent(
+ content::WebContents* source,
+ const content::NativeWebKeyboardEvent& event) override;
+ bool PreHandleGestureEvent(content::WebContents* source,
+ const blink::WebGestureEvent& event) override;
+ void FindReply(content::WebContents* source,
+ int request_id,
+ int number_of_matches,
+ const gfx::Rect& selection_rect,
+ int active_match_ordinal,
+ bool final_update) override;
- protected:
- explicit GuestViewBase(content::WebContents* owner_web_contents);
+ // WebContentsObserver implementation.
+ void DidNavigateMainFrame(
+ const content::LoadCommittedDetails& details,
+ const content::FrameNavigateParams& params) override;
- ~GuestViewBase() override;
+ // Given a set of initialization parameters, a concrete subclass of
+ // GuestViewBase can create a specialized WebContents that it returns back to
+ // GuestViewBase.
+ virtual void CreateWebContents(
+ const base::DictionaryValue& create_params,
+ const WebContentsCreatedCallback& callback) = 0;
+
+ // This method is called after the guest has been attached to an embedder and
+ // suspended resource loads have been resumed.
+ //
+ // This method can be overriden by subclasses. This gives the derived class
+ // an opportunity to perform setup actions after attachment.
+ virtual void DidAttachToEmbedder() {}
+
+ // This method is called after this GuestViewBase has been initiated.
+ //
+ // This gives the derived class an opportunity to perform additional
+ // initialization.
+ virtual void DidInitialize(const base::DictionaryValue& create_params) {}
+
+ // This method is called when embedder WebContents's fullscreen is toggled.
+ //
+ // If the guest asked the embedder to enter fullscreen, the guest uses this
+ // signal to exit fullscreen state.
+ virtual void EmbedderFullscreenToggled(bool entered_fullscreen) {}
+
+ // This method is called when the initial set of frames within the page have
+ // completed loading.
+ virtual void GuestViewDidStopLoading() {}
+
+ // This method is called when the guest WebContents has been destroyed. This
+ // object will be destroyed after this call returns.
+ //
+ // This gives the derived class an opportunity to perform some cleanup.
+ virtual void GuestDestroyed() {}
+
+ // This method is invoked when the guest RenderView is ready, e.g. because we
+ // recreated it after a crash or after reattachment.
+ //
+ // This gives the derived class an opportunity to perform some initialization
+ // work.
+ virtual void GuestReady() {}
+
+ // This method is called when the guest's zoom changes.
+ virtual void GuestZoomChanged(double old_zoom_level, double new_zoom_level) {}
+
+ // This method is invoked when the contents auto-resized to give the container
+ // an opportunity to match it if it wishes.
+ //
+ // This gives the derived class an opportunity to inform its container element
+ // or perform other actions.
+ virtual void GuestSizeChangedDueToAutoSize(const gfx::Size& old_size,
+ const gfx::Size& new_size) {}
+
+ // This method is invoked when the contents preferred size changes. This will
+ // only ever fire if IsPreferredSizeSupported returns true.
+ virtual void OnPreferredSizeChanged(const gfx::Size& pref_size) {}
+
+ // Signals that the guest view is ready. The default implementation signals
+ // immediately, but derived class can override this if they need to do
+ // asynchronous setup.
+ virtual void SignalWhenReady(const base::Closure& callback);
+
+ // Returns true if this guest should handle find requests for its
+ // embedder. This should generally be true for guests that make up the
+ // entirety of the embedder's content.
+ virtual bool ShouldHandleFindRequestsForEmbedder() const;
+
+ // This method is called immediately before suspended resource loads have been
+ // resumed on attachment to an embedder.
+ //
+ // This method can be overriden by subclasses. This gives the derived class
+ // an opportunity to perform setup actions before attachment.
+ virtual void WillAttachToEmbedder() {}
+
+ // This method is called when the guest WebContents is about to be destroyed.
+ //
+ // This gives the derived class an opportunity to perform some cleanup prior
+ // to destruction.
+ virtual void WillDestroy() {}
+
+ void LoadURLWithParams(
+ const content::NavigationController::LoadURLParams& load_params);
// Convert sizes in pixels from logical to physical numbers of pixels.
// Note that a size can consist of a fractional number of logical pixels
@@ -316,66 +322,61 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate,
// is represented as an int).
double PhysicalPixelsToLogicalPixels(int physical_pixels) const;
- // WebContentsObserver implementation.
- void DidStopLoading() final;
- void RenderViewReady() final;
- void WebContentsDestroyed() final;
- void DidNavigateMainFrame(
- const content::LoadCommittedDetails& details,
- const content::FrameNavigateParams& params) override;
+ void SetGuestZoomLevelToMatchEmbedder();
+
+ private:
+ friend class GuestViewMessageFilter;
+
+ class OwnerContentsObserver;
+ class OpenerLifetimeObserver;
+
+ // BrowserPluginGuestDelegate implementation.
+ content::WebContents* CreateNewGuestWindow(
+ const content::WebContents::CreateParams& create_params) final;
+ void DidAttach(int guest_proxy_routing_id) final;
+ void DidDetach() final;
+ content::WebContents* GetOwnerWebContents() const final;
+ bool HandleFindForEmbedder(int request_id,
+ const base::string16& search_text,
+ const blink::WebFindOptions& options) final;
+ bool HandleStopFindingForEmbedder(content::StopFindAction action) final;
+ void GuestSizeChanged(const gfx::Size& new_size) final;
+ void SetGuestHost(content::GuestHost* guest_host) final;
+ void WillAttach(content::WebContents* embedder_web_contents,
+ int browser_plugin_instance_id,
+ bool is_full_page_plugin,
+ const base::Closure& callback) final;
// WebContentsDelegate implementation.
void ActivateContents(content::WebContents* contents) final;
void ContentsMouseEvent(content::WebContents* source,
const gfx::Point& location,
- bool motion) override;
- void ContentsZoomChange(bool zoom_in) override;
- void HandleKeyboardEvent(
- content::WebContents* source,
- const content::NativeWebKeyboardEvent& event) override;
+ bool motion) final;
+ void ContentsZoomChange(bool zoom_in) final;
void LoadingStateChanged(content::WebContents* source,
bool to_different_document) final;
content::ColorChooser* OpenColorChooser(
content::WebContents* web_contents,
SkColor color,
- const std::vector<content::ColorSuggestion>& suggestions) override;
+ const std::vector<content::ColorSuggestion>& suggestions) final;
void ResizeDueToAutoResize(content::WebContents* web_contents,
- const gfx::Size& new_size) override;
+ const gfx::Size& new_size) final;
void RunFileChooser(content::WebContents* web_contents,
- const content::FileChooserParams& params) override;
+ const content::FileChooserParams& params) final;
bool ShouldFocusPageAfterCrash() final;
- bool PreHandleGestureEvent(content::WebContents* source,
- const blink::WebGestureEvent& event) override;
void UpdatePreferredSize(content::WebContents* web_contents,
const gfx::Size& pref_size) final;
- void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
- bool ShouldResumeRequestsForCreatedWindow() override;
- void FindReply(content::WebContents* source,
- int request_id,
- int number_of_matches,
- const gfx::Rect& selection_rect,
- int active_match_ordinal,
- bool final_update) override;
+ void UpdateTargetURL(content::WebContents* source, const GURL& url) final;
+ bool ShouldResumeRequestsForCreatedWindow() final;
- void SetGuestZoomLevelToMatchEmbedder();
-
- // Signals that the guest view is ready. The default implementation signals
- // immediately, but derived class can override this if they need to do
- // asynchronous setup.
- virtual void SignalWhenReady(const base::Closure& callback);
-
- // Returns true if this guest should handle find requests for its
- // embedder. This should generally be true for guests that make up the
- // entirety of the embedder's content.
- virtual bool ShouldHandleFindRequestsForEmbedder() const;
-
- // BrowserPluginGuestDelegate implementation.
- void SetContextMenuPosition(const gfx::Point& position) override;
-
- private:
- class OwnerContentsObserver;
+ // WebContentsObserver implementation.
+ void DidStopLoading() final;
+ void RenderViewReady() final;
+ void WebContentsDestroyed() final;
- class OpenerLifetimeObserver;
+ // ui_zoom::ZoomObserver implementation.
+ void OnZoomChanged(
+ const ui_zoom::ZoomController::ZoomChangedEventData& data) final;
void SendQueuedEvents();
diff --git a/content/browser/browser_plugin/browser_plugin_embedder.cc b/content/browser/browser_plugin/browser_plugin_embedder.cc
index 04cd3ab..68899fa 100644
--- a/content/browser/browser_plugin/browser_plugin_embedder.cc
+++ b/content/browser/browser_plugin/browser_plugin_embedder.cc
@@ -237,8 +237,9 @@ bool BrowserPluginEmbedder::FindInGuest(int request_id,
const base::string16& search_text,
const blink::WebFindOptions& options,
WebContents* guest) {
- if (static_cast<WebContentsImpl*>(guest)->GetBrowserPluginGuest()->Find(
- request_id, search_text, options)) {
+ if (static_cast<WebContentsImpl*>(guest)
+ ->GetBrowserPluginGuest()
+ ->HandleFindForEmbedder(request_id, search_text, options)) {
// There can only ever currently be one browser plugin that handles find so
// we can break the iteration at this point.
return true;
@@ -249,8 +250,9 @@ bool BrowserPluginEmbedder::FindInGuest(int request_id,
// static
bool BrowserPluginEmbedder::StopFindingInGuest(StopFindAction action,
WebContents* guest) {
- if (static_cast<WebContentsImpl*>(guest)->GetBrowserPluginGuest()
- ->StopFinding(action)) {
+ if (static_cast<WebContentsImpl*>(guest)
+ ->GetBrowserPluginGuest()
+ ->HandleStopFindingForEmbedder(action)) {
// There can only ever currently be one browser plugin that handles find so
// we can break the iteration at this point.
return true;
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc
index 2c79731..cef0842 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest.cc
@@ -450,14 +450,15 @@ void BrowserPluginGuest::SetContentsOpaque(bool opaque) {
browser_plugin_instance_id(), opaque));
}
-bool BrowserPluginGuest::Find(int request_id,
- const base::string16& search_text,
- const blink::WebFindOptions& options) {
- return delegate_->Find(request_id, search_text, options);
+bool BrowserPluginGuest::HandleFindForEmbedder(
+ int request_id,
+ const base::string16& search_text,
+ const blink::WebFindOptions& options) {
+ return delegate_->HandleFindForEmbedder(request_id, search_text, options);
}
-bool BrowserPluginGuest::StopFinding(StopFindAction action) {
- return delegate_->StopFinding(action);
+bool BrowserPluginGuest::HandleStopFindingForEmbedder(StopFindAction action) {
+ return delegate_->HandleStopFindingForEmbedder(action);
}
void BrowserPluginGuest::ResendEventToEmbedder(
diff --git a/content/browser/browser_plugin/browser_plugin_guest.h b/content/browser/browser_plugin/browser_plugin_guest.h
index d739434..ca81988 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.h
+++ b/content/browser/browser_plugin/browser_plugin_guest.h
@@ -251,10 +251,10 @@ class CONTENT_EXPORT BrowserPluginGuest : public GuestHost,
// Find the given |search_text| in the page. Returns true if the find request
// is handled by this browser plugin guest.
- bool Find(int request_id,
- const base::string16& search_text,
- const blink::WebFindOptions& options);
- bool StopFinding(StopFindAction action);
+ bool HandleFindForEmbedder(int request_id,
+ const base::string16& search_text,
+ const blink::WebFindOptions& options);
+ bool HandleStopFindingForEmbedder(StopFindAction action);
void ResendEventToEmbedder(const blink::WebInputEvent& event);
diff --git a/content/public/browser/browser_plugin_guest_delegate.cc b/content/public/browser/browser_plugin_guest_delegate.cc
index fd7dec4..bfa19e4 100644
--- a/content/public/browser/browser_plugin_guest_delegate.cc
+++ b/content/public/browser/browser_plugin_guest_delegate.cc
@@ -20,13 +20,15 @@ WebContents* BrowserPluginGuestDelegate::GetOwnerWebContents() const {
return nullptr;
}
-bool BrowserPluginGuestDelegate::Find(int request_id,
- const base::string16& search_text,
- const blink::WebFindOptions& options) {
+bool BrowserPluginGuestDelegate::HandleFindForEmbedder(
+ int request_id,
+ const base::string16& search_text,
+ const blink::WebFindOptions& options) {
return false;
}
-bool BrowserPluginGuestDelegate::StopFinding(StopFindAction action) {
+bool BrowserPluginGuestDelegate::HandleStopFindingForEmbedder(
+ StopFindAction action) {
return false;
}
diff --git a/content/public/browser/browser_plugin_guest_delegate.h b/content/public/browser/browser_plugin_guest_delegate.h
index aabe27b..4dd1a4c 100644
--- a/content/public/browser/browser_plugin_guest_delegate.h
+++ b/content/public/browser/browser_plugin_guest_delegate.h
@@ -78,10 +78,10 @@ class CONTENT_EXPORT BrowserPluginGuestDelegate {
// Find the given |search_text| in the page. Returns true if the find request
// is handled by this browser plugin guest delegate.
- virtual bool Find(int request_id,
- const base::string16& search_text,
- const blink::WebFindOptions& options);
- virtual bool StopFinding(StopFindAction action);
+ virtual bool HandleFindForEmbedder(int request_id,
+ const base::string16& search_text,
+ const blink::WebFindOptions& options);
+ virtual bool HandleStopFindingForEmbedder(StopFindAction action);
// Provides the delegate with an interface with which to communicate with the
// content module.
diff --git a/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc b/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc
index cee2f5e..b6a8ab6 100644
--- a/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc
+++ b/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc
@@ -642,7 +642,7 @@ bool WebViewInternalFindFunction::RunAsyncSafe(WebViewGuest* guest) {
params->options->match_case ? *params->options->match_case : false;
}
- guest->StartFindInternal(search_text, options, this);
+ guest->StartFind(search_text, options, this);
return true;
}
@@ -673,7 +673,7 @@ bool WebViewInternalStopFindingFunction::RunAsyncSafe(WebViewGuest* guest) {
action = content::STOP_FIND_ACTION_KEEP_SELECTION;
}
- guest->StopFindingInternal(action);
+ guest->StopFinding(action);
return true;
}
diff --git a/extensions/browser/guest_view/app_view/app_view_guest.h b/extensions/browser/guest_view/app_view/app_view_guest.h
index d9f0901..c8959ca 100644
--- a/extensions/browser/guest_view/app_view/app_view_guest.h
+++ b/extensions/browser/guest_view/app_view/app_view_guest.h
@@ -41,24 +41,6 @@ class AppViewGuest : public guest_view::GuestView<AppViewGuest> {
static std::vector<int> GetAllRegisteredInstanceIdsForTesting();
- // content::WebContentsDelegate implementation.
- bool HandleContextMenu(const content::ContextMenuParams& params) override;
- void RequestMediaAccessPermission(
- content::WebContents* web_contents,
- const content::MediaStreamRequest& request,
- const content::MediaResponseCallback& callback) override;
- bool CheckMediaAccessPermission(content::WebContents* web_contents,
- const GURL& security_origin,
- content::MediaStreamType type) override;
-
- // GuestViewBase implementation.
- bool CanRunInDetachedState() const override;
- void CreateWebContents(const base::DictionaryValue& create_params,
- const WebContentsCreatedCallback& callback) override;
- void DidInitialize(const base::DictionaryValue& create_params) override;
- const char* GetAPINamespace() const override;
- int GetTaskPrefix() const override;
-
// Sets the AppDelegate for this guest.
void SetAppDelegateForTest(AppDelegate* delegate);
@@ -67,6 +49,24 @@ class AppViewGuest : public guest_view::GuestView<AppViewGuest> {
~AppViewGuest() override;
+ // GuestViewBase implementation.
+ bool CanRunInDetachedState() const final;
+ void CreateWebContents(const base::DictionaryValue& create_params,
+ const WebContentsCreatedCallback& callback) final;
+ void DidInitialize(const base::DictionaryValue& create_params) final;
+ const char* GetAPINamespace() const final;
+ int GetTaskPrefix() const final;
+
+ // content::WebContentsDelegate implementation.
+ bool HandleContextMenu(const content::ContextMenuParams& params) final;
+ void RequestMediaAccessPermission(
+ content::WebContents* web_contents,
+ const content::MediaStreamRequest& request,
+ const content::MediaResponseCallback& callback) final;
+ bool CheckMediaAccessPermission(content::WebContents* web_contents,
+ const GURL& security_origin,
+ content::MediaStreamType type) final;
+
void CompleteCreateWebContents(const GURL& url,
const Extension* guest_extension,
const WebContentsCreatedCallback& callback);
diff --git a/extensions/browser/guest_view/extension_options/extension_options_guest.h b/extensions/browser/guest_view/extension_options/extension_options_guest.h
index 9cf37d2..eaab6da 100644
--- a/extensions/browser/guest_view/extension_options/extension_options_guest.h
+++ b/extensions/browser/guest_view/extension_options/extension_options_guest.h
@@ -23,24 +23,28 @@ class ExtensionOptionsGuest
static guest_view::GuestViewBase* Create(
content::WebContents* owner_web_contents);
+ private:
+ explicit ExtensionOptionsGuest(content::WebContents* owner_web_contents);
+ ~ExtensionOptionsGuest() override;
+
// GuestViewBase implementation.
- bool CanRunInDetachedState() const override;
+ bool CanRunInDetachedState() const final;
void CreateWebContents(const base::DictionaryValue& create_params,
- const WebContentsCreatedCallback& callback) override;
- void DidInitialize(const base::DictionaryValue& create_params) override;
- void GuestViewDidStopLoading() override;
- const char* GetAPINamespace() const override;
- int GetTaskPrefix() const override;
- bool IsPreferredSizeModeEnabled() const override;
- void OnPreferredSizeChanged(const gfx::Size& pref_size) override;
- bool ShouldHandleFindRequestsForEmbedder() const override;
+ const WebContentsCreatedCallback& callback) final;
+ void DidInitialize(const base::DictionaryValue& create_params) final;
+ void GuestViewDidStopLoading() final;
+ const char* GetAPINamespace() const final;
+ int GetTaskPrefix() const final;
+ bool IsPreferredSizeModeEnabled() const final;
+ void OnPreferredSizeChanged(const gfx::Size& pref_size) final;
+ bool ShouldHandleFindRequestsForEmbedder() const final;
// content::WebContentsDelegate implementation.
content::WebContents* OpenURLFromTab(
content::WebContents* source,
- const content::OpenURLParams& params) override;
- void CloseContents(content::WebContents* source) override;
- bool HandleContextMenu(const content::ContextMenuParams& params) override;
+ const content::OpenURLParams& params) final;
+ void CloseContents(content::WebContents* source) final;
+ bool HandleContextMenu(const content::ContextMenuParams& params) final;
bool ShouldCreateWebContents(
content::WebContents* web_contents,
int route_id,
@@ -49,16 +53,11 @@ class ExtensionOptionsGuest
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) override;
+ content::SessionStorageNamespace* session_storage_namespace) final;
// content::WebContentsObserver implementation.
- void DidNavigateMainFrame(
- const content::LoadCommittedDetails& details,
- const content::FrameNavigateParams& params) override;
-
- private:
- explicit ExtensionOptionsGuest(content::WebContents* owner_web_contents);
- ~ExtensionOptionsGuest() override;
+ void DidNavigateMainFrame(const content::LoadCommittedDetails& details,
+ const content::FrameNavigateParams& params) final;
scoped_ptr<extensions::ExtensionOptionsGuestDelegate>
extension_options_guest_delegate_;
diff --git a/extensions/browser/guest_view/extension_view/extension_view_guest.h b/extensions/browser/guest_view/extension_view/extension_view_guest.h
index cc968a7..4a9e124 100644
--- a/extensions/browser/guest_view/extension_view/extension_view_guest.h
+++ b/extensions/browser/guest_view/extension_view/extension_view_guest.h
@@ -27,27 +27,26 @@ class ExtensionViewGuest
// Returns true if the navigation is successful.
bool NavigateGuest(const std::string& src, bool force_navigation);
+ private:
+ ExtensionViewGuest(content::WebContents* owner_web_contents);
+ ~ExtensionViewGuest() override;
+
// GuestViewBase implementation.
- bool CanRunInDetachedState() const override;
+ bool CanRunInDetachedState() const final;
void CreateWebContents(const base::DictionaryValue& create_params,
- const WebContentsCreatedCallback& callback) override;
- void DidInitialize(const base::DictionaryValue& create_params) override;
- void DidAttachToEmbedder() override;
- const char* GetAPINamespace() const override;
- int GetTaskPrefix() const override;
+ const WebContentsCreatedCallback& callback) final;
+ void DidInitialize(const base::DictionaryValue& create_params) final;
+ void DidAttachToEmbedder() final;
+ const char* GetAPINamespace() const final;
+ int GetTaskPrefix() const final;
// content::WebContentsObserver implementation.
void DidCommitProvisionalLoadForFrame(
content::RenderFrameHost* render_frame_host,
const GURL& url,
- ui::PageTransition transition_type) override;
- void DidNavigateMainFrame(
- const content::LoadCommittedDetails& details,
- const content::FrameNavigateParams& params) override;
-
- private:
- ExtensionViewGuest(content::WebContents* owner_web_contents);
- ~ExtensionViewGuest() override;
+ ui::PageTransition transition_type) final;
+ void DidNavigateMainFrame(const content::LoadCommittedDetails& details,
+ const content::FrameNavigateParams& params) final;
// Applies attributes to the extensionview.
void ApplyAttributes(const base::DictionaryValue& params);
diff --git a/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h b/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
index 26c0e11..d482430 100644
--- a/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
+++ b/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
@@ -57,38 +57,40 @@ class MimeHandlerViewGuest :
static const char Type[];
+ protected:
+ explicit MimeHandlerViewGuest(content::WebContents* owner_web_contents);
+ ~MimeHandlerViewGuest() override;
+
+ private:
+ friend class TestMimeHandlerViewGuest;
+
// GuestViewBase implementation.
- const char* GetAPINamespace() const override;
- int GetTaskPrefix() const override;
+ const char* GetAPINamespace() const final;
+ int GetTaskPrefix() const final;
void CreateWebContents(const base::DictionaryValue& create_params,
const WebContentsCreatedCallback& callback) override;
void DidAttachToEmbedder() override;
- void DidInitialize(const base::DictionaryValue& create_params) override;
- bool ShouldHandleFindRequestsForEmbedder() const override;
- bool ZoomPropagatesFromEmbedderToGuest() const override;
+ void DidInitialize(const base::DictionaryValue& create_params) final;
+ bool ShouldHandleFindRequestsForEmbedder() const final;
+ bool ZoomPropagatesFromEmbedderToGuest() const final;
// WebContentsDelegate implementation.
content::WebContents* OpenURLFromTab(
content::WebContents* source,
- const content::OpenURLParams& params) override;
- bool HandleContextMenu(const content::ContextMenuParams& params) override;
+ const content::OpenURLParams& params) final;
+ bool HandleContextMenu(const content::ContextMenuParams& params) final;
bool PreHandleGestureEvent(content::WebContents* source,
- const blink::WebGestureEvent& event) override;
+ const blink::WebGestureEvent& event) final;
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
- content::WebContents* source) override;
- bool SaveFrame(const GURL& url, const content::Referrer& referrer) override;
+ content::WebContents* source) final;
+ bool SaveFrame(const GURL& url, const content::Referrer& referrer) final;
// content::WebContentsObserver implementation.
- void DocumentOnLoadCompletedInMainFrame() override;
+ void DocumentOnLoadCompletedInMainFrame() final;
std::string view_id() const { return view_id_; }
base::WeakPtr<StreamContainer> GetStream() const;
- protected:
- explicit MimeHandlerViewGuest(content::WebContents* owner_web_contents);
- ~MimeHandlerViewGuest() override;
-
- private:
scoped_ptr<MimeHandlerViewGuestDelegate> delegate_;
scoped_ptr<StreamContainer> stream_;
std::string view_id_;
diff --git a/extensions/browser/guest_view/web_view/web_view_guest.cc b/extensions/browser/guest_view/web_view/web_view_guest.cc
index 6cf3d9f..4dedeee 100644
--- a/extensions/browser/guest_view/web_view/web_view_guest.cc
+++ b/extensions/browser/guest_view/web_view/web_view_guest.cc
@@ -673,14 +673,14 @@ void WebViewGuest::Observe(int type,
}
}
-void WebViewGuest::StartFindInternal(
+void WebViewGuest::StartFind(
const base::string16& search_text,
const blink::WebFindOptions& options,
scoped_refptr<WebViewInternalFindFunction> find_function) {
find_helper_.Find(web_contents(), search_text, options, find_function);
}
-void WebViewGuest::StopFindingInternal(content::StopFindAction action) {
+void WebViewGuest::StopFinding(content::StopFindAction action) {
find_helper_.CancelAllFindSessions();
web_contents()->StopFinding(action);
}
diff --git a/extensions/browser/guest_view/web_view/web_view_guest.h b/extensions/browser/guest_view/web_view/web_view_guest.h
index 1f1a1ad..cc76a67 100644
--- a/extensions/browser/guest_view/web_view/web_view_guest.h
+++ b/extensions/browser/guest_view/web_view/web_view_guest.h
@@ -114,100 +114,13 @@ class WebViewGuest : public guest_view::GuestView<WebViewGuest>,
const std::string& virtual_url,
std::string* error);
- // GuestViewBase implementation.
- bool CanRunInDetachedState() const override;
- void CreateWebContents(const base::DictionaryValue& create_params,
- const WebContentsCreatedCallback& callback) override;
- void DidAttachToEmbedder() override;
- void DidDropLink(const GURL& url) override;
- void DidInitialize(const base::DictionaryValue& create_params) override;
- void FindReply(content::WebContents* source,
- int request_id,
- int number_of_matches,
- const gfx::Rect& selection_rect,
- int active_match_ordinal,
- bool final_update) override;
- void GuestViewDidStopLoading() override;
- void EmbedderFullscreenToggled(bool entered_fullscreen) override;
- const char* GetAPINamespace() const override;
- int GetTaskPrefix() const override;
- void GuestDestroyed() override;
- void GuestReady() override;
- void GuestSizeChangedDueToAutoSize(const gfx::Size& old_size,
- const gfx::Size& new_size) override;
- void GuestZoomChanged(double old_zoom_level, double new_zoom_level) override;
- bool IsAutoSizeSupported() const override;
- void SignalWhenReady(const base::Closure& callback) override;
- bool ShouldHandleFindRequestsForEmbedder() const override;
- void WillAttachToEmbedder() override;
- void WillDestroy() override;
-
- // WebContentsDelegate implementation.
- bool AddMessageToConsole(content::WebContents* source,
- int32 level,
- const base::string16& message,
- int32 line_no,
- const base::string16& source_id) override;
- void LoadProgressChanged(content::WebContents* source,
- double progress) override;
- void CloseContents(content::WebContents* source) override;
- bool HandleContextMenu(const content::ContextMenuParams& params) override;
- void HandleKeyboardEvent(
- content::WebContents* source,
- const content::NativeWebKeyboardEvent& event) override;
- bool PreHandleGestureEvent(content::WebContents* source,
- const blink::WebGestureEvent& event) override;
- void RendererResponsive(content::WebContents* source) override;
- void RendererUnresponsive(content::WebContents* source) override;
- void RequestMediaAccessPermission(
- content::WebContents* source,
- const content::MediaStreamRequest& request,
- const content::MediaResponseCallback& callback) override;
- void RequestPointerLockPermission(
- bool user_gesture,
- bool last_unlocked_by_target,
- const base::Callback<void(bool)>& callback) override;
- bool CheckMediaAccessPermission(content::WebContents* source,
- const GURL& security_origin,
- content::MediaStreamType type) override;
- void CanDownload(const GURL& url,
- const std::string& request_method,
- const base::Callback<void(bool)>& callback) override;
- content::JavaScriptDialogManager* GetJavaScriptDialogManager(
- content::WebContents* source) override;
- void AddNewContents(content::WebContents* source,
- content::WebContents* new_contents,
- WindowOpenDisposition disposition,
- const gfx::Rect& initial_rect,
- bool user_gesture,
- bool* was_blocked) override;
- content::WebContents* OpenURLFromTab(
- content::WebContents* source,
- const content::OpenURLParams& params) override;
- void WebContentsCreated(content::WebContents* source_contents,
- int opener_render_frame_id,
- const std::string& frame_name,
- const GURL& target_url,
- content::WebContents* new_contents) override;
- void EnterFullscreenModeForTab(content::WebContents* web_contents,
- const GURL& origin) override;
- void ExitFullscreenModeForTab(content::WebContents* web_contents) override;
- bool IsFullscreenForTabOrPending(
- const content::WebContents* web_contents) const override;
-
- // NotificationObserver implementation.
- void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) override;
-
// Begin or continue a find request.
- void StartFindInternal(
- const base::string16& search_text,
- const blink::WebFindOptions& options,
- scoped_refptr<WebViewInternalFindFunction> find_function);
+ void StartFind(const base::string16& search_text,
+ const blink::WebFindOptions& options,
+ scoped_refptr<WebViewInternalFindFunction> find_function);
// Conclude a find request to clear highlighting.
- void StopFindingInternal(content::StopFindAction);
+ void StopFinding(content::StopFindAction);
// If possible, navigate the guest to |relative_index| entries away from the
// current navigation entry. Returns true on success.
@@ -216,34 +129,6 @@ class WebViewGuest : public guest_view::GuestView<WebViewGuest>,
// Reload the guest.
void Reload();
- using PermissionResponseCallback =
- base::Callback<void(bool /* allow */,
- const std::string& /* user_input */)>;
- int RequestPermission(
- WebViewPermissionType permission_type,
- const base::DictionaryValue& request_info,
- const PermissionResponseCallback& callback,
- bool allowed_by_default);
-
- // Requests Geolocation Permission from the embedder.
- void RequestGeolocationPermission(int bridge_id,
- const GURL& requesting_frame,
- bool user_gesture,
- const base::Callback<void(bool)>& callback);
- void CancelGeolocationPermissionRequest(int bridge_id);
-
- // Called when file system access is requested by the guest content using the
- // HTML5 file system API in main thread, or a worker thread.
- // The request is plumbed through the <webview> permission request API. The
- // request will be:
- // - Allowed if the embedder explicitly allowed it.
- // - Denied if the embedder explicitly denied.
- // - Determined by the guest's content settings if the embedder does not
- // perform an explicit action.
- void RequestFileSystemPermission(const GURL& url,
- bool allowed_by_default,
- const base::Callback<void(bool)>& callback);
-
// Overrides the user agent for this guest.
// This affects subsequent guest navigations.
void SetUserAgentOverride(const std::string& user_agent_override);
@@ -264,12 +149,6 @@ class WebViewGuest : public guest_view::GuestView<WebViewGuest>,
ScriptExecutor* script_executor() { return script_executor_.get(); }
- scoped_ptr<WebViewGuestDelegate> SetDelegateForTesting(
- scoped_ptr<WebViewGuestDelegate> delegate) {
- web_view_guest_delegate_.swap(delegate);
- return delegate.Pass();
- }
-
private:
friend class WebViewPermissionHelper;
@@ -290,25 +169,110 @@ class WebViewGuest : public guest_view::GuestView<WebViewGuest>,
bool GuestMadeEmbedderFullscreen() const;
void SetFullscreenState(bool is_fullscreen);
+ // GuestViewBase implementation.
+ bool CanRunInDetachedState() const final;
+ void CreateWebContents(const base::DictionaryValue& create_params,
+ const WebContentsCreatedCallback& callback) final;
+ void DidAttachToEmbedder() final;
+ void DidDropLink(const GURL& url) final;
+ void DidInitialize(const base::DictionaryValue& create_params) final;
+ void EmbedderFullscreenToggled(bool entered_fullscreen) final;
+ void FindReply(content::WebContents* source,
+ int request_id,
+ int number_of_matches,
+ const gfx::Rect& selection_rect,
+ int active_match_ordinal,
+ bool final_update) final;
+ const char* GetAPINamespace() const final;
+ int GetTaskPrefix() const final;
+ void GuestDestroyed() final;
+ void GuestReady() final;
+ void GuestSizeChangedDueToAutoSize(const gfx::Size& old_size,
+ const gfx::Size& new_size) final;
+ void GuestViewDidStopLoading() final;
+ void GuestZoomChanged(double old_zoom_level, double new_zoom_level) final;
+ bool IsAutoSizeSupported() const final;
+ void SetContextMenuPosition(const gfx::Point& position) final;
+ void SignalWhenReady(const base::Closure& callback) final;
+ bool ShouldHandleFindRequestsForEmbedder() const final;
+ void WillAttachToEmbedder() final;
+ void WillDestroy() final;
+
+ // NotificationObserver implementation.
+ void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) final;
+
+ // WebContentsDelegate implementation.
+ bool AddMessageToConsole(content::WebContents* source,
+ int32 level,
+ const base::string16& message,
+ int32 line_no,
+ const base::string16& source_id) final;
+ void CloseContents(content::WebContents* source) final;
+ bool HandleContextMenu(const content::ContextMenuParams& params) final;
+ void HandleKeyboardEvent(content::WebContents* source,
+ const content::NativeWebKeyboardEvent& event) final;
+ void LoadProgressChanged(content::WebContents* source, double progress) final;
+ bool PreHandleGestureEvent(content::WebContents* source,
+ const blink::WebGestureEvent& event) final;
+ void RendererResponsive(content::WebContents* source) final;
+ void RendererUnresponsive(content::WebContents* source) final;
+ void RequestMediaAccessPermission(
+ content::WebContents* source,
+ const content::MediaStreamRequest& request,
+ const content::MediaResponseCallback& callback) final;
+ void RequestPointerLockPermission(
+ bool user_gesture,
+ bool last_unlocked_by_target,
+ const base::Callback<void(bool)>& callback) final;
+ bool CheckMediaAccessPermission(content::WebContents* source,
+ const GURL& security_origin,
+ content::MediaStreamType type) final;
+ void CanDownload(const GURL& url,
+ const std::string& request_method,
+ const base::Callback<void(bool)>& callback) final;
+ content::JavaScriptDialogManager* GetJavaScriptDialogManager(
+ content::WebContents* source) final;
+ void AddNewContents(content::WebContents* source,
+ content::WebContents* new_contents,
+ WindowOpenDisposition disposition,
+ const gfx::Rect& initial_rect,
+ bool user_gesture,
+ bool* was_blocked) final;
+ content::WebContents* OpenURLFromTab(
+ content::WebContents* source,
+ const content::OpenURLParams& params) final;
+ void WebContentsCreated(content::WebContents* source_contents,
+ int opener_render_frame_id,
+ const std::string& frame_name,
+ const GURL& target_url,
+ content::WebContents* new_contents) final;
+ void EnterFullscreenModeForTab(content::WebContents* web_contents,
+ const GURL& origin) final;
+ void ExitFullscreenModeForTab(content::WebContents* web_contents) final;
+ bool IsFullscreenForTabOrPending(
+ const content::WebContents* web_contents) const final;
+
// WebContentsObserver implementation.
void DidCommitProvisionalLoadForFrame(
content::RenderFrameHost* render_frame_host,
const GURL& url,
- ui::PageTransition transition_type) override;
+ ui::PageTransition transition_type) final;
void DidFailProvisionalLoad(content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code,
const base::string16& error_description,
- bool was_ignored_by_handler) override;
+ bool was_ignored_by_handler) final;
void DidStartProvisionalLoadForFrame(
content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
bool is_error_page,
- bool is_iframe_srcdoc) override;
- void RenderProcessGone(base::TerminationStatus status) override;
- void UserAgentOverrideSet(const std::string& user_agent) override;
+ bool is_iframe_srcdoc) final;
+ void RenderProcessGone(base::TerminationStatus status) final;
+ void UserAgentOverrideSet(const std::string& user_agent) final;
void FrameNameChanged(content::RenderFrameHost* render_frame_host,
- const std::string& name) override;
+ const std::string& name) final;
// Informs the embedder of a frame name change.
void ReportFrameNameChange(const std::string& name);
@@ -360,8 +324,6 @@ class WebViewGuest : public guest_view::GuestView<WebViewGuest>,
void ApplyAttributes(const base::DictionaryValue& params);
- void SetContextMenuPosition(const gfx::Point& position) override;
-
// Identifies the set of rules registries belonging to this guest.
int rules_registry_id_;