Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Unified Diff: chrome/browser/ui/panels/panel_window_controller_cocoa.mm

Issue 7945018: Notify the WebView when panels gain/lose key window status. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/panels/panel_window_controller_cocoa.mm
diff --git a/chrome/browser/ui/panels/panel_window_controller_cocoa.mm b/chrome/browser/ui/panels/panel_window_controller_cocoa.mm
index 167c9058abd1dd3b94900914e6eae57edc0647a7..5c3c69bb1854cfb4fa6d860f0965bfe73cc46e42 100644
--- a/chrome/browser/ui/panels/panel_window_controller_cocoa.mm
+++ b/chrome/browser/ui/panels/panel_window_controller_cocoa.mm
@@ -27,6 +27,7 @@
#import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h"
#include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
#include "chrome/common/chrome_notification_types.h"
+#include "content/browser/renderer_host/render_widget_host_view.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/common/notification_service.h"
@@ -412,6 +413,38 @@ static BOOL g_reportAnimationStatus = NO;
NSView* titlebar = [self titlebarView];
return NSHeight([titlebar convertRect:[titlebar bounds] toView:nil]);
}
+
+// TODO(dcheng): These two selectors are almost copy-and-paste from
+// BrowserWindowController. Figure out the appropriate way of code sharing,
+// whether it's refactoring more things into BrowserWindowUtils or making a
+// common base controller for browser windows.
+- (void)windowDidBecomeKey:(NSNotification*)notification {
+ // We need to activate the controls (in the "WebView"). To do this, get the
+ // selected TabContents's RenderWidgetHostViewMac and tell it to activate.
+ if (TabContents* contents =
+ windowShim_->browser()->GetSelectedTabContents()) {
+ if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
+ rwhv->SetActive(true);
+ }
+}
+
+- (void)windowDidResignKey:(NSNotification*)notification {
+ // If our app is still active and we're still the key window, ignore this
+ // message, since it just means that a menu extra (on the "system status bar")
+ // was activated; we'll get another |-windowDidResignKey| if we ever really
+ // lose key window status.
+ if ([NSApp isActive] && ([NSApp keyWindow] == [self window]))
+ return;
+
+ // We need to deactivate the controls (in the "WebView"). To do this, get the
+ // selected TabContents's RenderWidgetHostView and tell it to deactivate.
+ if (TabContents* contents =
+ windowShim_->browser()->GetSelectedTabContents()) {
+ if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
+ rwhv->SetActive(false);
+ }
+}
+
// TestingAPI interface implementation
+ (void)enableBoundsAnimationNotifications {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698