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

Unified Diff: chrome/browser/ui/cocoa/constrained_window_mac.mm

Issue 10823176: Cocoa: Support constrained windows for platform apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix print preview test Created 8 years, 4 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
Index: chrome/browser/ui/cocoa/constrained_window_mac.mm
diff --git a/chrome/browser/ui/cocoa/constrained_window_mac.mm b/chrome/browser/ui/cocoa/constrained_window_mac.mm
index 1d018f160838b2dc24cbd176e3f4a787908aaef2..d826dc3d0b36054ec1ba316c04d44a64d1ff3030 100644
--- a/chrome/browser/ui/cocoa/constrained_window_mac.mm
+++ b/chrome/browser/ui/cocoa/constrained_window_mac.mm
@@ -4,7 +4,6 @@
#include "chrome/browser/ui/cocoa/constrained_window_mac.h"
-#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#include "chrome/browser/ui/constrained_window_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "content/public/browser/web_contents.h"
@@ -105,12 +104,26 @@ void ConstrainedWindowMac::ShowConstrainedWindow() {
// The WebContents only has a native window if it is currently visible. In
// this case, open the sheet now. Else, Realize() will be called later, when
// our tab becomes visible.
- NSWindow* browserWindow =
+ NSWindow* window =
tab_contents_->web_contents()->GetView()->GetTopLevelNativeWindow();
- BrowserWindowController* browser_controller =
- [BrowserWindowController browserWindowControllerForWindow:browserWindow];
- if ([browser_controller canAttachConstrainedWindow])
- Realize(browser_controller);
+ NSWindowController<ConstrainedWindowSupport>* window_controller = nil;
+ while (window) {
+ if ([[window windowController] conformsToProtocol:
+ @protocol(ConstrainedWindowSupport)]) {
+ window_controller = [window windowController];
+ break;
+ }
+ window = [window parentWindow];
+ }
+
+ // It's valid for the window to be nil. For example, background tabs don't
+ // have a window set. However, if a window exists then there should always
+ // be a window controller that implements the ConstrainedWindowSupport
+ // protocol.
+ DCHECK(!window || window_controller);
+
+ if ([window_controller canAttachConstrainedWindow])
+ Realize(window_controller);
}
void ConstrainedWindowMac::CloseConstrainedWindow() {
@@ -131,7 +144,8 @@ void ConstrainedWindowMac::CloseConstrainedWindow() {
delete this;
}
-void ConstrainedWindowMac::Realize(BrowserWindowController* controller) {
+void ConstrainedWindowMac::Realize(
+ NSWindowController<ConstrainedWindowSupport>* controller) {
if (!should_be_visible_)
return;
« no previous file with comments | « chrome/browser/ui/cocoa/constrained_window_mac.h ('k') | chrome/browser/ui/cocoa/extensions/shell_window_cocoa.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698