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

Unified Diff: chrome/browser/cocoa/constrained_window_mac.h

Issue 164547: Mac: make save/open dialogs operate as tab-modal sheets.... Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Painfully (but hopefully correctly) merged ToT. Created 11 years, 2 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 | « chrome/browser/cocoa/browser_window_controller.mm ('k') | chrome/browser/cocoa/constrained_window_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/constrained_window_mac.h
diff --git a/chrome/browser/cocoa/constrained_window_mac.h b/chrome/browser/cocoa/constrained_window_mac.h
index 519a42ad01db4f77110ed2977537b2ce7b8d957f..9bfb1b2c9cb5854e1e4aeddf33e15a632945e84a 100644
--- a/chrome/browser/cocoa/constrained_window_mac.h
+++ b/chrome/browser/cocoa/constrained_window_mac.h
@@ -30,10 +30,24 @@ class ConstrainedWindowMacDelegate {
// in this method.
virtual void DeleteDelegate() = 0;
+ // Responds to things done by the parent tab. Called by
+ // |ConstrainedWindowMac::ParentWillDo()|. Returns |true| if it did something
+ // in response, |false| if it did not and if
+ // |ConstrainedWindowMac::ParentWillDo()| should run its default handler. The
+ // default implementation just returns |false|.
+ virtual bool ParentWillDo(ConstrainedWindow::Event event) { return false; }
+
+ // Gives the modality level of the constrained window. The default
+ // implementation just specifies "content-modality".
+ virtual ConstrainedWindow::ModalityLevel GetModalityLevel()
+ { return ConstrainedWindow::kModalForContent; }
+
// Called by the tab controller, you do not need to do anything yourself
// with this method.
virtual void RunSheet(GTMWindowSheetController* sheetController,
- NSView* view) = 0;
+ NSView* view,
+ SEL frameSelector,
+ SEL positionSelector) = 0;
protected:
// Returns true if this delegate's sheet is currently showing.
bool is_sheet_open() { return is_sheet_open_; }
@@ -45,23 +59,47 @@ class ConstrainedWindowMacDelegate {
};
// Subclass this for a dialog delegate that displays a system sheet such as
-// an NSAlert, an open or save file panel, etc.
-class ConstrainedWindowMacDelegateSystemSheet
+// an NSSavePanel, NSOpenPanel, etc. This can handle any system sheet that GTM
+// supports (if in a somewhat ugly way).
+class ConstrainedWindowMacDelegateSystemSheetParams
: public ConstrainedWindowMacDelegate {
public:
- ConstrainedWindowMacDelegateSystemSheet(id delegate, SEL didEndSelector)
+ // See third_party/GTM/AppKit/GTMWindowSheetController.h for the format of
+ // |params|.
+ explicit ConstrainedWindowMacDelegateSystemSheetParams(NSArray* params)
: systemSheet_(nil),
- delegate_([delegate retain]),
- didEndSelector_(didEndSelector) { }
+ params_([params retain]) { }
protected:
void set_sheet(id sheet) { systemSheet_.reset([sheet retain]); }
id sheet() { return systemSheet_; }
+ void set_params(NSArray* params) { params_.reset([params retain]); }
+ NSArray* params() { return static_cast<NSArray*>(params_); }
+ virtual void RunSheet(GTMWindowSheetController* sheetController,
+ NSView* view,
+ SEL frameSelector,
+ SEL positionSelector);
private:
- virtual void RunSheet(GTMWindowSheetController* sheetController,
- NSView* view);
scoped_nsobject<id> systemSheet_;
+ scoped_nsobject<id> params_;
+};
+
+// Subclass this for a dialog delegate that displays a system sheet such as
+// an NSAlert or other simple panel.
+class ConstrainedWindowMacDelegateSystemSheet
+ : public ConstrainedWindowMacDelegateSystemSheetParams {
+ public:
+ ConstrainedWindowMacDelegateSystemSheet(id delegate, SEL didEndSelector)
+ : ConstrainedWindowMacDelegateSystemSheetParams(nil),
+ delegate_([delegate retain]),
+ didEndSelector_(didEndSelector) { }
+
+ private:
+ virtual void RunSheet(GTMWindowSheetController* sheetController,
+ NSView* view,
+ SEL frameSelector,
+ SEL positionSelector);
scoped_nsobject<id> delegate_;
SEL didEndSelector_;
};
@@ -97,7 +135,9 @@ class ConstrainedWindowMacDelegateCustomSheet
private:
virtual void RunSheet(GTMWindowSheetController* sheetController,
- NSView* view);
+ NSView* view,
+ SEL frameSelector,
+ SEL positionSelector);
scoped_nsobject<NSWindow> customSheet_;
scoped_nsobject<id> delegate_;
SEL didEndSelector_;
@@ -117,6 +157,12 @@ class ConstrainedWindowMac : public ConstrainedWindow {
// Overridden from ConstrainedWindow:
virtual void CloseConstrainedWindow();
+ virtual bool ParentWillDo(ConstrainedWindow::Event event);
+
+ // This returns a cached result from the delegate. It can't just get the
+ // delegate to answer because we may outlive the delegate.
+ virtual ConstrainedWindow::ModalityLevel GetModalityLevel()
+ { return modality_level_; }
// Returns the TabContents that constrains this Constrained Window.
TabContents* owner() const { return owner_; }
@@ -142,8 +188,10 @@ class ConstrainedWindowMac : public ConstrainedWindow {
// Controller of the window that contains this sheet.
BrowserWindowController* controller_;
+ // Level of modality (cached result from delegate).
+ ConstrainedWindow::ModalityLevel modality_level_;
+
DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowMac);
};
#endif // CHROME_BROWSER_COCOA_CONSTRAINED_WINDOW_MAC_H_
-
« no previous file with comments | « chrome/browser/cocoa/browser_window_controller.mm ('k') | chrome/browser/cocoa/constrained_window_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698