summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-21 16:47:08 +0000
committerstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-21 16:47:08 +0000
commit2f2ba980e92c4fe49e3eddbfcf28bc52ae4ed590 (patch)
tree7a4ce421608e72d0f44604911a5537cd9818a702
parentb7b2cefeb858fe1586cd70aead60ed2b48708ed7 (diff)
downloadchromium_src-2f2ba980e92c4fe49e3eddbfcf28bc52ae4ed590.zip
chromium_src-2f2ba980e92c4fe49e3eddbfcf28bc52ae4ed590.tar.gz
chromium_src-2f2ba980e92c4fe49e3eddbfcf28bc52ae4ed590.tar.bz2
Send Cocoa NPAPI plugins an initial window activation event
Until we have real window activation status, just send a window focus event so that Cocoa plugins always think their window is active (as is currently the case with Carbon plugins). Also wire up the Carbon interposing on window activation checks to talk to the delegate, so once the delegate has correct information Carbon will Just Work. BUG=31847 TEST=Flash 10.1 should track the mouse when the plugin is loaded, without having to click in it first. Review URL: http://codereview.chromium.org/552067 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36754 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/framework.order1
-rw-r--r--chrome/browser/plugin_carbon_interpose_mac.cc5
-rw-r--r--chrome/plugin/plugin_interpose_util_mac.h3
-rw-r--r--chrome/plugin/plugin_interpose_util_mac.mm5
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.h6
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_mac.mm19
6 files changed, 35 insertions, 4 deletions
diff --git a/chrome/app/framework.order b/chrome/app/framework.order
index 814cecc..7ef7343 100644
--- a/chrome/app/framework.order
+++ b/chrome/app/framework.order
@@ -28,6 +28,7 @@ __ZN22mac_plugin_interposing33NotifyBrowserOfPluginSelectWindowEj6CGRectb
__ZN22mac_plugin_interposing31NotifyBrowserOfPluginShowWindowEj6CGRectb
__ZN22mac_plugin_interposing31NotifyBrowserOfPluginHideWindowEj6CGRect
__ZN22mac_plugin_interposing28NotifyPluginOfSetThemeCursorEP21WebPluginDelegateImplm
+__ZN22mac_plugin_interposing23GetPluginWindowHasFocusEPK21WebPluginDelegateImpl
__ZN23FakePluginWindowTrackerC1Ev
__ZN23FakePluginWindowTrackerC2Ev
__ZN23FakePluginWindowTracker14SharedInstanceEv
diff --git a/chrome/browser/plugin_carbon_interpose_mac.cc b/chrome/browser/plugin_carbon_interpose_mac.cc
index adbba7e..def2515 100644
--- a/chrome/browser/plugin_carbon_interpose_mac.cc
+++ b/chrome/browser/plugin_carbon_interpose_mac.cc
@@ -19,10 +19,7 @@ static bool IsModalWindow(WindowRef window) {
}
static bool IsContainingWindowActive(const WebPluginDelegateImpl* delegate) {
- // TODO(stuartmorgan): We need a way to find out if the delegate is in the
- // active window; for now we just lie and always say yes so plugins don't
- // throw events away.
- return true;
+ return mac_plugin_interposing::GetPluginWindowHasFocus(delegate);
}
static CGRect CGRectForWindow(WindowRef window) {
diff --git a/chrome/plugin/plugin_interpose_util_mac.h b/chrome/plugin/plugin_interpose_util_mac.h
index deabe6c..4942bb6 100644
--- a/chrome/plugin/plugin_interpose_util_mac.h
+++ b/chrome/plugin/plugin_interpose_util_mac.h
@@ -42,6 +42,9 @@ void NotifyBrowserOfPluginHideWindow(uint32 window_id, CGRect bounds);
void NotifyPluginOfSetThemeCursor(WebPluginDelegateImpl* delegate,
ThemeCursor cursor);
+// Returns true if the window containing the given plugin delegate is focused.
+bool GetPluginWindowHasFocus(const WebPluginDelegateImpl* delegate);
+
} // namespace MacPluginInterpose
#endif // CHROME_PLUGIN_PLUGIN_INTERPOSE_UTIL_MAC_H_
diff --git a/chrome/plugin/plugin_interpose_util_mac.mm b/chrome/plugin/plugin_interpose_util_mac.mm
index f919c2b..801efbe 100644
--- a/chrome/plugin/plugin_interpose_util_mac.mm
+++ b/chrome/plugin/plugin_interpose_util_mac.mm
@@ -75,6 +75,11 @@ void NotifyPluginOfSetThemeCursor(WebPluginDelegateImpl* delegate,
delegate->SetThemeCursor(cursor);
}
+__attribute__((visibility("default")))
+bool GetPluginWindowHasFocus(const WebPluginDelegateImpl* delegate) {
+ return delegate->GetWindowHasFocus();
+}
+
} // namespace mac_plugin_interposing
#pragma mark -
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h
index a246f60..209a38a 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.h
+++ b/webkit/glue/plugins/webplugin_delegate_impl.h
@@ -133,6 +133,10 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
void SetFocusNotifier(void (*notifier)(WebPluginDelegateImpl*)) {
focus_notifier_ = notifier;
}
+ // Informs the plugin that the window it is in has gained or lost focus.
+ void SetWindowHasFocus(bool has_focus);
+ // Returns whether or not the window the plugin is in has focus.
+ bool GetWindowHasFocus() const { return containing_window_has_focus_; }
// Informs the delegate that the plugin set a Carbon ThemeCursor.
void SetThemeCursor(ThemeCursor cursor);
// Informs the delegate that the plugin set a Cocoa NSCursor.
@@ -355,6 +359,8 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
bool have_focus_;
// A function to call when we want to accept keyboard focus
void (*focus_notifier_)(WebPluginDelegateImpl* notifier);
+
+ bool containing_window_has_focus_;
#endif
// Called by the message filter hook when the plugin enters a modal loop.
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
index 2d6fdc6..b469ac7 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
@@ -102,6 +102,7 @@ WebPluginDelegateImpl::WebPluginDelegateImpl(
last_mouse_y_(0),
have_focus_(false),
focus_notifier_(NULL),
+ containing_window_has_focus_(false),
handle_event_depth_(0),
user_gesture_message_posted_(this),
user_gesture_msg_factory_(this) {
@@ -387,6 +388,11 @@ void WebPluginDelegateImpl::WindowlessSetWindow(bool force_set_window) {
NPError err = instance()->NPP_SetWindow(&window_);
+ // TODO(stuartmorgan): Once we are getting window information via IPC, use
+ // that to set the right value. For now, just pretend plugins are always in
+ // active windows so they don't throw away events.
+ SetWindowHasFocus(true);
+
DCHECK(err == NPERR_NO_ERROR);
}
@@ -436,6 +442,19 @@ void WebPluginDelegateImpl::SetFocus() {
FocusNotify(this);
}
+void WebPluginDelegateImpl::SetWindowHasFocus(bool has_focus) {
+ containing_window_has_focus_ = has_focus;
+
+ if (instance()->event_model() == NPEventModelCocoa) {
+ ScopedActiveDelegate active_delegate(this);
+ NPCocoaEvent focus_event;
+ memset(&focus_event, 0, sizeof(focus_event));
+ focus_event.type = NPCocoaEventWindowFocusChanged;
+ focus_event.data.focus.hasFocus = has_focus;
+ instance()->NPP_HandleEvent(reinterpret_cast<NPEvent*>(&focus_event));
+ }
+}
+
void WebPluginDelegateImpl::SetThemeCursor(ThemeCursor cursor) {
current_windowless_cursor_.InitFromThemeCursor(cursor);
}