OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_COCOA_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_COCOA_H_ |
6 #define CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_COCOA_H_ | 6 #define CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_COCOA_H_ |
7 | 7 |
8 #include "base/memory/scoped_nsobject.h" | 8 #include "base/memory/scoped_nsobject.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/prefs/public/pref_change_registrar.h" | 10 #include "base/prefs/public/pref_change_registrar.h" |
11 #include "base/prefs/public/pref_observer.h" | |
12 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
13 #include "chrome/browser/extensions/extension_keybinding_registry.h" | 12 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
14 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
15 #include "ui/base/ui_base_types.h" | 14 #include "ui/base/ui_base_types.h" |
16 | 15 |
17 class Browser; | 16 class Browser; |
18 @class BrowserWindowController; | 17 @class BrowserWindowController; |
19 @class FindBarCocoaController; | 18 @class FindBarCocoaController; |
20 @class NSEvent; | 19 @class NSEvent; |
21 @class NSMenu; | 20 @class NSMenu; |
22 @class NSWindow; | 21 @class NSWindow; |
23 | 22 |
24 namespace extensions { | 23 namespace extensions { |
25 class ActiveTabPermissionGranter; | 24 class ActiveTabPermissionGranter; |
26 class Extension; | 25 class Extension; |
27 } | 26 } |
28 | 27 |
29 // An implementation of BrowserWindow for Cocoa. Bridges between C++ and | 28 // An implementation of BrowserWindow for Cocoa. Bridges between C++ and |
30 // the Cocoa NSWindow. Cross-platform code will interact with this object when | 29 // the Cocoa NSWindow. Cross-platform code will interact with this object when |
31 // it needs to manipulate the window. | 30 // it needs to manipulate the window. |
32 | 31 |
33 class BrowserWindowCocoa : | 32 class BrowserWindowCocoa : |
34 public BrowserWindow, | 33 public BrowserWindow, |
35 public PrefObserver, | |
36 public extensions::ExtensionKeybindingRegistry::Delegate { | 34 public extensions::ExtensionKeybindingRegistry::Delegate { |
37 public: | 35 public: |
38 BrowserWindowCocoa(Browser* browser, | 36 BrowserWindowCocoa(Browser* browser, |
39 BrowserWindowController* controller); | 37 BrowserWindowController* controller); |
40 virtual ~BrowserWindowCocoa(); | 38 virtual ~BrowserWindowCocoa(); |
41 | 39 |
42 // Overridden from BrowserWindow | 40 // Overridden from BrowserWindow |
43 virtual void Show() OVERRIDE; | 41 virtual void Show() OVERRIDE; |
44 virtual void ShowInactive() OVERRIDE; | 42 virtual void ShowInactive() OVERRIDE; |
45 virtual void Hide() OVERRIDE; | 43 virtual void Hide() OVERRIDE; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 virtual gfx::Rect GetInstantBounds() OVERRIDE; | 137 virtual gfx::Rect GetInstantBounds() OVERRIDE; |
140 virtual bool IsInstantTabShowing() OVERRIDE; | 138 virtual bool IsInstantTabShowing() OVERRIDE; |
141 virtual WindowOpenDisposition GetDispositionForPopupBounds( | 139 virtual WindowOpenDisposition GetDispositionForPopupBounds( |
142 const gfx::Rect& bounds) OVERRIDE; | 140 const gfx::Rect& bounds) OVERRIDE; |
143 virtual FindBar* CreateFindBar() OVERRIDE; | 141 virtual FindBar* CreateFindBar() OVERRIDE; |
144 virtual bool GetConstrainedWindowTopY(int* top_y) OVERRIDE; | 142 virtual bool GetConstrainedWindowTopY(int* top_y) OVERRIDE; |
145 virtual void ShowAvatarBubble(content::WebContents* web_contents, | 143 virtual void ShowAvatarBubble(content::WebContents* web_contents, |
146 const gfx::Rect& rect) OVERRIDE; | 144 const gfx::Rect& rect) OVERRIDE; |
147 virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE; | 145 virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE; |
148 | 146 |
149 // Overridden from NotificationObserver | |
150 virtual void OnPreferenceChanged(PrefServiceBase* service, | |
151 const std::string& pref_name) OVERRIDE; | |
152 | |
153 // Overridden from ExtensionKeybindingRegistry::Delegate: | 147 // Overridden from ExtensionKeybindingRegistry::Delegate: |
154 virtual extensions::ActiveTabPermissionGranter* | 148 virtual extensions::ActiveTabPermissionGranter* |
155 GetActiveTabPermissionGranter() OVERRIDE; | 149 GetActiveTabPermissionGranter() OVERRIDE; |
156 | 150 |
157 // Adds the given FindBar cocoa controller to this browser window. | 151 // Adds the given FindBar cocoa controller to this browser window. |
158 void AddFindBar(FindBarCocoaController* find_bar_cocoa_controller); | 152 void AddFindBar(FindBarCocoaController* find_bar_cocoa_controller); |
159 | 153 |
160 // Returns the cocoa-world BrowserWindowController | 154 // Returns the cocoa-world BrowserWindowController |
161 BrowserWindowController* cocoa_controller() { return controller_; } | 155 BrowserWindowController* cocoa_controller() { return controller_; } |
162 | 156 |
163 protected: | 157 protected: |
164 virtual void DestroyBrowser() OVERRIDE; | 158 virtual void DestroyBrowser() OVERRIDE; |
165 | 159 |
166 private: | 160 private: |
| 161 virtual void OnShowBookmarkBarChanged(); |
167 NSWindow* window() const; // Accessor for the (current) |NSWindow|. | 162 NSWindow* window() const; // Accessor for the (current) |NSWindow|. |
168 | 163 |
169 PrefChangeRegistrar pref_change_registrar_; | 164 PrefChangeRegistrar pref_change_registrar_; |
170 Browser* browser_; // weak, owned by controller | 165 Browser* browser_; // weak, owned by controller |
171 BrowserWindowController* controller_; // weak, owns us | 166 BrowserWindowController* controller_; // weak, owns us |
172 base::WeakPtrFactory<Browser> confirm_close_factory_; | 167 base::WeakPtrFactory<Browser> confirm_close_factory_; |
173 scoped_nsobject<NSString> pending_window_title_; | 168 scoped_nsobject<NSString> pending_window_title_; |
174 ui::WindowShowState initial_show_state_; | 169 ui::WindowShowState initial_show_state_; |
175 NSInteger attention_request_id_; // identifier from requestUserAttention | 170 NSInteger attention_request_id_; // identifier from requestUserAttention |
176 }; | 171 }; |
177 | 172 |
178 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_COCOA_H_ | 173 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_COCOA_H_ |
OLD | NEW |