diff options
author | calamity <calamity@chromium.org> | 2015-04-09 20:59:37 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-10 04:00:05 +0000 |
commit | 7fe55ce204b5fe66d6a1bea89046de98598f01a8 (patch) | |
tree | fb685b2f85a6e6a15e360d86ba6001d7de8bd1d1 /ui | |
parent | 16ca320592ce7ef6cd36500da6e670cc645781cd (diff) | |
download | chromium_src-7fe55ce204b5fe66d6a1bea89046de98598f01a8.zip chromium_src-7fe55ce204b5fe66d6a1bea89046de98598f01a8.tar.gz chromium_src-7fe55ce204b5fe66d6a1bea89046de98598f01a8.tar.bz2 |
Allow WebView to directly observe focus change of its WebContents.
Currently WebContentsDelegate::WebContentsFocused exists, but not
WebContentsObserver::WebContentsFocused. WebContentsDelegate::WebContentsFocused
exists only to allow views::WebView to call View::RequestFocus. Unfortunately,
views::WebView is only a delegate of the WebContentses that it creates itself
(it only *observes* the WebContentses that it owns via SetWebContents). However,
this makes every delegate responsible for forwarding focus events to the
views::WebView, which is not robust.
This CL resolves a TODO in WebView to allow the views::WebView to *observe* the
focus change of its WebContents and eliminates
WebContentsDelegate::WebContentsFocused.
This fixes an issue in the app list where no delegate was forwarding focus
changes to the custom launcher page's WebView.
BUG=458371
Review URL: https://codereview.chromium.org/959613002
Cr-Commit-Position: refs/heads/master@{#324584}
Diffstat (limited to 'ui')
-rw-r--r-- | ui/views/controls/webview/webview.cc | 18 | ||||
-rw-r--r-- | ui/views/controls/webview/webview.h | 8 |
2 files changed, 7 insertions, 19 deletions
diff --git a/ui/views/controls/webview/webview.cc b/ui/views/controls/webview/webview.cc index be33f1d..a131905 100644 --- a/ui/views/controls/webview/webview.cc +++ b/ui/views/controls/webview/webview.cc @@ -98,12 +98,6 @@ void WebView::SetResizeBackgroundColor(SkColor resize_background_color) { holder_->set_resize_background_color(resize_background_color); } -void WebView::OnWebContentsFocused(content::WebContents* web_contents) { - FocusManager* focus_manager = GetFocusManager(); - if (focus_manager) - focus_manager->SetFocusedView(this); -} - void WebView::SetPreferredSize(const gfx::Size& preferred_size) { preferred_size_ = preferred_size; PreferredSizeChanged(); @@ -275,12 +269,6 @@ void WebView::RenderProcessHostDestroyed(content::RenderProcessHost* host) { //////////////////////////////////////////////////////////////////////////////// // WebView, content::WebContentsDelegate implementation: -void WebView::WebContentsFocused(content::WebContents* web_contents) { - DCHECK(wc_owner_.get()); - // The WebView is only the delegate of WebContentses it creates itself. - OnWebContentsFocused(wc_owner_.get()); -} - bool WebView::EmbedsFullscreenWidget() const { DCHECK(wc_owner_.get()); return embed_fullscreen_widget_mode_enabled_; @@ -336,6 +324,12 @@ void WebView::DidDetachInterstitialPage() { NotifyMaybeTextInputClientAndAccessibilityChanged(); } +void WebView::OnWebContentsFocused() { + FocusManager* focus_manager = GetFocusManager(); + if (focus_manager) + focus_manager->SetFocusedView(this); +} + //////////////////////////////////////////////////////////////////////////////// // WebView, private: diff --git a/ui/views/controls/webview/webview.h b/ui/views/controls/webview/webview.h index f97449b..8ae132e 100644 --- a/ui/views/controls/webview/webview.h +++ b/ui/views/controls/webview/webview.h @@ -78,12 +78,6 @@ class WEBVIEW_EXPORT WebView : public View, // by default. void SetResizeBackgroundColor(SkColor resize_background_color); - // Called when the WebContents is focused. - // TODO(beng): This view should become a WebContentsViewObserver when a - // WebContents is attached, and not rely on the delegate to - // forward this notification. - void OnWebContentsFocused(content::WebContents* web_contents); - // When used to host UI, we need to explicitly allow accelerators to be // processed. Default is false. void set_allow_accelerators(bool allow_accelerators) { @@ -123,7 +117,6 @@ class WEBVIEW_EXPORT WebView : public View, void RenderProcessHostDestroyed(content::RenderProcessHost* host) override; // Overridden from content::WebContentsDelegate: - void WebContentsFocused(content::WebContents* web_contents) override; bool EmbedsFullscreenWidget() const override; // Overridden from content::WebContentsObserver: @@ -142,6 +135,7 @@ class WEBVIEW_EXPORT WebView : public View, void OnChannelConnected(int32 peer_id) override {} void OnChannelError() override {} void OnBadMessageReceived(const IPC::Message& message) override {} + void OnWebContentsFocused() override; private: friend class WebViewUnitTest; |