| 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 "chrome/browser/api/prefs/pref_change_registrar.h" | 10 #include "chrome/browser/api/prefs/pref_change_registrar.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 12 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
| 12 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
| 13 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 14 #include "ui/base/ui_base_types.h" | 15 #include "ui/base/ui_base_types.h" |
| 15 | 16 |
| 16 class Browser; | 17 class Browser; |
| 17 @class BrowserWindowController; | 18 @class BrowserWindowController; |
| 18 @class FindBarCocoaController; | 19 @class FindBarCocoaController; |
| 19 @class NSEvent; | 20 @class NSEvent; |
| 20 @class NSMenu; | 21 @class NSMenu; |
| 21 @class NSWindow; | 22 @class NSWindow; |
| 22 | 23 |
| 23 namespace extensions { | 24 namespace extensions { |
| 25 class ActiveTabPermissionGranter; |
| 24 class Extension; | 26 class Extension; |
| 25 } | 27 } |
| 26 | 28 |
| 27 // An implementation of BrowserWindow for Cocoa. Bridges between C++ and | 29 // An implementation of BrowserWindow for Cocoa. Bridges between C++ and |
| 28 // the Cocoa NSWindow. Cross-platform code will interact with this object when | 30 // the Cocoa NSWindow. Cross-platform code will interact with this object when |
| 29 // it needs to manipulate the window. | 31 // it needs to manipulate the window. |
| 30 | 32 |
| 31 class BrowserWindowCocoa : public BrowserWindow, | 33 class BrowserWindowCocoa : |
| 32 public content::NotificationObserver { | 34 public BrowserWindow, |
| 35 public content::NotificationObserver, |
| 36 public extensions::ExtensionKeybindingRegistry::Delegate { |
| 33 public: | 37 public: |
| 34 BrowserWindowCocoa(Browser* browser, | 38 BrowserWindowCocoa(Browser* browser, |
| 35 BrowserWindowController* controller); | 39 BrowserWindowController* controller); |
| 36 virtual ~BrowserWindowCocoa(); | 40 virtual ~BrowserWindowCocoa(); |
| 37 | 41 |
| 38 // Overridden from BrowserWindow | 42 // Overridden from BrowserWindow |
| 39 virtual void Show() OVERRIDE; | 43 virtual void Show() OVERRIDE; |
| 40 virtual void ShowInactive() OVERRIDE; | 44 virtual void ShowInactive() OVERRIDE; |
| 41 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | 45 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; |
| 42 virtual void Close() OVERRIDE; | 46 virtual void Close() OVERRIDE; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 virtual FindBar* CreateFindBar() OVERRIDE; | 147 virtual FindBar* CreateFindBar() OVERRIDE; |
| 144 virtual void ShowAvatarBubble(content::WebContents* web_contents, | 148 virtual void ShowAvatarBubble(content::WebContents* web_contents, |
| 145 const gfx::Rect& rect) OVERRIDE; | 149 const gfx::Rect& rect) OVERRIDE; |
| 146 virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE; | 150 virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE; |
| 147 | 151 |
| 148 // Overridden from NotificationObserver | 152 // Overridden from NotificationObserver |
| 149 virtual void Observe(int type, | 153 virtual void Observe(int type, |
| 150 const content::NotificationSource& source, | 154 const content::NotificationSource& source, |
| 151 const content::NotificationDetails& details) OVERRIDE; | 155 const content::NotificationDetails& details) OVERRIDE; |
| 152 | 156 |
| 157 // Overridden from ExtensionKeybindingRegistry::Delegate: |
| 158 virtual extensions::ActiveTabPermissionGranter* |
| 159 GetActiveTabPermissionGranter() OVERRIDE; |
| 160 |
| 153 // Adds the given FindBar cocoa controller to this browser window. | 161 // Adds the given FindBar cocoa controller to this browser window. |
| 154 void AddFindBar(FindBarCocoaController* find_bar_cocoa_controller); | 162 void AddFindBar(FindBarCocoaController* find_bar_cocoa_controller); |
| 155 | 163 |
| 156 // Returns the cocoa-world BrowserWindowController | 164 // Returns the cocoa-world BrowserWindowController |
| 157 BrowserWindowController* cocoa_controller() { return controller_; } | 165 BrowserWindowController* cocoa_controller() { return controller_; } |
| 158 | 166 |
| 159 protected: | 167 protected: |
| 160 virtual void DestroyBrowser() OVERRIDE; | 168 virtual void DestroyBrowser() OVERRIDE; |
| 161 | 169 |
| 162 private: | 170 private: |
| 163 NSWindow* window() const; // Accessor for the (current) |NSWindow|. | 171 NSWindow* window() const; // Accessor for the (current) |NSWindow|. |
| 164 | 172 |
| 165 content::NotificationRegistrar registrar_; | 173 content::NotificationRegistrar registrar_; |
| 166 PrefChangeRegistrar pref_change_registrar_; | 174 PrefChangeRegistrar pref_change_registrar_; |
| 167 Browser* browser_; // weak, owned by controller | 175 Browser* browser_; // weak, owned by controller |
| 168 BrowserWindowController* controller_; // weak, owns us | 176 BrowserWindowController* controller_; // weak, owns us |
| 169 base::WeakPtrFactory<Browser> confirm_close_factory_; | 177 base::WeakPtrFactory<Browser> confirm_close_factory_; |
| 170 scoped_nsobject<NSString> pending_window_title_; | 178 scoped_nsobject<NSString> pending_window_title_; |
| 171 ui::WindowShowState initial_show_state_; | 179 ui::WindowShowState initial_show_state_; |
| 172 NSInteger attention_request_id_; // identifier from requestUserAttention | 180 NSInteger attention_request_id_; // identifier from requestUserAttention |
| 173 }; | 181 }; |
| 174 | 182 |
| 175 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_COCOA_H_ | 183 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_COCOA_H_ |
| OLD | NEW |