diff options
author | fsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-17 01:43:40 +0000 |
---|---|---|
committer | fsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-17 01:43:40 +0000 |
commit | 70dd12cb27827697f7553fcbf4f8fd9860bfd32f (patch) | |
tree | 0a1e094b1b364c6d517d37fd33eb9cfbe8dd71cb /content/renderer | |
parent | f0a1e262bc0fafa221ec86bd53f20de596bd1bc2 (diff) | |
download | chromium_src-70dd12cb27827697f7553fcbf4f8fd9860bfd32f.zip chromium_src-70dd12cb27827697f7553fcbf4f8fd9860bfd32f.tar.gz chromium_src-70dd12cb27827697f7553fcbf4f8fd9860bfd32f.tar.bz2 |
Browser Plugin: Simplified Embedder Focus state tracking
BrowserPlugin should be grabbing the embedder's focus state straight from the render_view if it exists instead of caching the focus state in a member variable. This simplifies code a bit and is a prerequisite to the new way of allocating instance IDs and initializing state coming in a subsequent patch.
BUG=140316
Review URL: https://chromiumcodereview.appspot.com/11959016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177300 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer')
5 files changed, 8 insertions, 23 deletions
diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc index 59dd401..2b5e255 100644 --- a/content/renderer/browser_plugin/browser_plugin.cc +++ b/content/renderer/browser_plugin/browser_plugin.cc @@ -128,7 +128,6 @@ BrowserPlugin::BrowserPlugin( valid_partition_id_(true), content_window_routing_id_(MSG_ROUTING_NONE), plugin_focused_(false), - embedder_focused_(false), visible_(true), size_changed_in_flight_(false), browser_plugin_manager_(render_view->browser_plugin_manager()), @@ -777,17 +776,6 @@ void BrowserPlugin::Reload() { instance_id_)); } -void BrowserPlugin::SetEmbedderFocus(bool focused) { - if (embedder_focused_ == focused) - return; - - bool old_guest_focus_state = ShouldGuestBeFocused(); - embedder_focused_ = focused; - - if (ShouldGuestBeFocused() != old_guest_focus_state) - UpdateGuestFocusState(); -} - void BrowserPlugin::UpdateGuestFocusState() { if (!navigate_src_sent_) return; @@ -799,7 +787,10 @@ void BrowserPlugin::UpdateGuestFocusState() { } bool BrowserPlugin::ShouldGuestBeFocused() const { - return plugin_focused_ && embedder_focused_; + bool embedder_focused = false; + if (render_view_) + embedder_focused = render_view_->has_focus(); + return plugin_focused_ && embedder_focused; } WebKit::WebPluginContainer* BrowserPlugin::container() const { diff --git a/content/renderer/browser_plugin/browser_plugin.h b/content/renderer/browser_plugin/browser_plugin.h index 9680daf..cdc6be0 100644 --- a/content/renderer/browser_plugin/browser_plugin.h +++ b/content/renderer/browser_plugin/browser_plugin.h @@ -89,8 +89,6 @@ class CONTENT_EXPORT BrowserPlugin : bool SetPartitionAttribute(const std::string& partition_id, std::string* error_message); - // Inform the BrowserPlugin of the focus state of the embedder RenderView. - void SetEmbedderFocus(bool focused); // Informs the guest of an updated focus state. void UpdateGuestFocusState(); // Indicates whether the guest should be focused. @@ -306,7 +304,6 @@ class CONTENT_EXPORT BrowserPlugin : bool valid_partition_id_; int content_window_routing_id_; bool plugin_focused_; - bool embedder_focused_; // Tracks the visibility of the browser plugin regardless of the whole // embedder RenderView's visibility. bool visible_; diff --git a/content/renderer/browser_plugin/browser_plugin_manager.cc b/content/renderer/browser_plugin/browser_plugin_manager.cc index 4cc3426..a067c8a 100644 --- a/content/renderer/browser_plugin/browser_plugin_manager.cc +++ b/content/renderer/browser_plugin/browser_plugin_manager.cc @@ -46,13 +46,10 @@ BrowserPlugin* BrowserPluginManager::GetBrowserPlugin(int instance_id) const { return instances_.Lookup(instance_id); } -void BrowserPluginManager::SetEmbedderFocus(const RenderViewImpl* embedder, - bool focused) { +void BrowserPluginManager::UpdateFocusState() { IDMap<BrowserPlugin>::iterator iter(&instances_); while (!iter.IsAtEnd()) { - BrowserPlugin* browser_plugin = iter.GetCurrentValue(); - if (browser_plugin->render_view() == embedder) - browser_plugin->SetEmbedderFocus(focused); + iter.GetCurrentValue()->UpdateGuestFocusState(); iter.Advance(); } } diff --git a/content/renderer/browser_plugin/browser_plugin_manager.h b/content/renderer/browser_plugin/browser_plugin_manager.h index b6dab83..21f17fa 100644 --- a/content/renderer/browser_plugin/browser_plugin_manager.h +++ b/content/renderer/browser_plugin/browser_plugin_manager.h @@ -52,7 +52,7 @@ class CONTENT_EXPORT BrowserPluginManager void AddBrowserPlugin(int instance_id, BrowserPlugin* browser_plugin); void RemoveBrowserPlugin(int instance_id); BrowserPlugin* GetBrowserPlugin(int instance_id) const; - void SetEmbedderFocus(const RenderViewImpl* embedder, bool focused); + void UpdateFocusState(); RenderViewImpl* render_view() const { return render_view_; } // RenderViewObserver implementation. diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 8d75551..4f8f22c 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -5963,7 +5963,7 @@ void RenderViewImpl::OnSetFocus(bool enable) { pepper_helper_->OnSetFocus(enable); // Notify all BrowserPlugins of the RenderView's focus state. if (browser_plugin_manager_) - browser_plugin_manager()->SetEmbedderFocus(this, enable); + browser_plugin_manager()->UpdateFocusState(); } void RenderViewImpl::PpapiPluginFocusChanged() { |