| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_COCOA_BROWSER_WINDOW_COCOA_H_ | 5 #ifndef CHROME_BROWSER_COCOA_BROWSER_WINDOW_COCOA_H_ |
| 6 #define CHROME_BROWSER_COCOA_BROWSER_WINDOW_COCOA_H_ | 6 #define CHROME_BROWSER_COCOA_BROWSER_WINDOW_COCOA_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "app/menus/simple_menu_model.h" |
| 9 #include "base/task.h" | 10 #include "base/task.h" |
| 10 #include "chrome/browser/browser_window.h" | 11 #include "chrome/browser/browser_window.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_model.h" | 12 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 12 #include "chrome/common/notification_registrar.h" | 13 #include "chrome/common/notification_registrar.h" |
| 13 | 14 |
| 14 class Browser; | 15 class Browser; |
| 15 @class BrowserWindowController; | 16 @class BrowserWindowController; |
| 16 @class FindBarCocoaController; | 17 @class FindBarCocoaController; |
| 17 @class NSEvent; | 18 @class NSEvent; |
| 18 @class NSMenu; | 19 @class NSMenu; |
| 19 @class NSWindow; | 20 @class NSWindow; |
| 20 | 21 |
| 21 // An implementation of BrowserWindow for Cocoa. Bridges between C++ and | 22 // An implementation of BrowserWindow for Cocoa. Bridges between C++ and |
| 22 // the Cocoa NSWindow. Cross-platform code will interact with this object when | 23 // the Cocoa NSWindow. Cross-platform code will interact with this object when |
| 23 // it needs to manipulate the window. | 24 // it needs to manipulate the window. |
| 24 | 25 |
| 25 class BrowserWindowCocoa : public BrowserWindow, | 26 class BrowserWindowCocoa : public BrowserWindow, |
| 26 public NotificationObserver { | 27 public NotificationObserver, |
| 28 public menus::SimpleMenuModel::Delegate { |
| 27 public: | 29 public: |
| 28 BrowserWindowCocoa(Browser* browser, | 30 BrowserWindowCocoa(Browser* browser, |
| 29 BrowserWindowController* controller, | 31 BrowserWindowController* controller, |
| 30 NSWindow* window); | 32 NSWindow* window); |
| 31 virtual ~BrowserWindowCocoa(); | 33 virtual ~BrowserWindowCocoa(); |
| 32 | 34 |
| 33 // Overridden from BrowserWindow | 35 // Overridden from BrowserWindow |
| 34 virtual void Show(); | 36 virtual void Show(); |
| 35 virtual void SetBounds(const gfx::Rect& bounds); | 37 virtual void SetBounds(const gfx::Rect& bounds); |
| 36 virtual void Close(); | 38 virtual void Close(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 virtual void Copy(); | 107 virtual void Copy(); |
| 106 virtual void Paste(); | 108 virtual void Paste(); |
| 107 virtual void ToggleTabStripMode(); | 109 virtual void ToggleTabStripMode(); |
| 108 virtual void OpenTabpose(); | 110 virtual void OpenTabpose(); |
| 109 | 111 |
| 110 // Overridden from NotificationObserver | 112 // Overridden from NotificationObserver |
| 111 virtual void Observe(NotificationType type, | 113 virtual void Observe(NotificationType type, |
| 112 const NotificationSource& source, | 114 const NotificationSource& source, |
| 113 const NotificationDetails& details); | 115 const NotificationDetails& details); |
| 114 | 116 |
| 117 // Overriden SimpleMenuModel::Delegate |
| 118 virtual bool IsCommandIdChecked(int command_id) const; |
| 119 virtual bool IsCommandIdEnabled(int command_id) const; |
| 120 virtual bool GetAcceleratorForCommandId( |
| 121 int command_id, |
| 122 menus::Accelerator* accelerator); |
| 123 virtual void ExecuteCommand(int command_id); |
| 124 |
| 115 // Adds the given FindBar cocoa controller to this browser window. | 125 // Adds the given FindBar cocoa controller to this browser window. |
| 116 void AddFindBar(FindBarCocoaController* find_bar_cocoa_controller); | 126 void AddFindBar(FindBarCocoaController* find_bar_cocoa_controller); |
| 117 | 127 |
| 118 // Returns the cocoa-world BrowserWindowController | 128 // Returns the cocoa-world BrowserWindowController |
| 119 BrowserWindowController* cocoa_controller() { return controller_; } | 129 BrowserWindowController* cocoa_controller() { return controller_; } |
| 120 | 130 |
| 121 protected: | 131 protected: |
| 122 virtual void DestroyBrowser(); | 132 virtual void DestroyBrowser(); |
| 123 | 133 |
| 124 private: | 134 private: |
| 125 int GetCommandId(const NativeWebKeyboardEvent& event); | 135 int GetCommandId(const NativeWebKeyboardEvent& event); |
| 126 bool HandleKeyboardEventInternal(NSEvent* event); | 136 bool HandleKeyboardEventInternal(NSEvent* event); |
| 127 NSWindow* window() const; // Accessor for the (current) |NSWindow|. | 137 NSWindow* window() const; // Accessor for the (current) |NSWindow|. |
| 128 | 138 |
| 129 NotificationRegistrar registrar_; | 139 NotificationRegistrar registrar_; |
| 130 Browser* browser_; // weak, owned by controller | 140 Browser* browser_; // weak, owned by controller |
| 131 BrowserWindowController* controller_; // weak, owns us | 141 BrowserWindowController* controller_; // weak, owns us |
| 132 ScopedRunnableMethodFactory<Browser> confirm_close_factory_; | 142 ScopedRunnableMethodFactory<Browser> confirm_close_factory_; |
| 133 }; | 143 }; |
| 134 | 144 |
| 135 #endif // CHROME_BROWSER_COCOA_BROWSER_WINDOW_COCOA_H_ | 145 #endif // CHROME_BROWSER_COCOA_BROWSER_WINDOW_COCOA_H_ |
| OLD | NEW |