| 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_BROWSER_COMMAND_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_BROWSER_COMMAND_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_BROWSER_COMMAND_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_BROWSER_COMMAND_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/prefs/pref_change_registrar.h" | 10 #include "base/prefs/pref_change_registrar.h" |
| 11 #include "base/prefs/pref_member.h" | 11 #include "base/prefs/pref_member.h" |
| 12 #include "chrome/browser/command_updater.h" | 12 #include "chrome/browser/command_updater.h" |
| 13 #include "chrome/browser/command_updater_delegate.h" | 13 #include "chrome/browser/command_updater_delegate.h" |
| 14 #include "chrome/browser/profiles/profile_info_cache_observer.h" | |
| 15 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 14 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
| 16 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| 17 #include "ui/base/window_open_disposition.h" | 16 #include "ui/base/window_open_disposition.h" |
| 18 | 17 |
| 19 class Browser; | 18 class Browser; |
| 20 class BrowserWindow; | 19 class BrowserWindow; |
| 21 class Profile; | 20 class Profile; |
| 22 class ProfileManager; | |
| 23 | 21 |
| 24 namespace content { | 22 namespace content { |
| 25 struct NativeWebKeyboardEvent; | 23 struct NativeWebKeyboardEvent; |
| 26 } | 24 } |
| 27 | 25 |
| 28 namespace chrome { | 26 namespace chrome { |
| 29 | 27 |
| 30 class BrowserCommandController : public CommandUpdaterDelegate, | 28 class BrowserCommandController : public CommandUpdaterDelegate, |
| 31 public ProfileInfoCacheObserver, | |
| 32 public TabStripModelObserver, | 29 public TabStripModelObserver, |
| 33 public TabRestoreServiceObserver { | 30 public TabRestoreServiceObserver { |
| 34 public: | 31 public: |
| 35 BrowserCommandController(Browser* browser, ProfileManager* profile_manager); | 32 explicit BrowserCommandController(Browser* browser); |
| 36 virtual ~BrowserCommandController(); | 33 virtual ~BrowserCommandController(); |
| 37 | 34 |
| 38 CommandUpdater* command_updater() { return &command_updater_; } | 35 CommandUpdater* command_updater() { return &command_updater_; } |
| 39 bool block_command_execution() const { return block_command_execution_; } | 36 bool block_command_execution() const { return block_command_execution_; } |
| 40 | 37 |
| 41 // Returns true if |command_id| is a reserved command whose keyboard shortcuts | 38 // Returns true if |command_id| is a reserved command whose keyboard shortcuts |
| 42 // should not be sent to the renderer or |event| was triggered by a key that | 39 // should not be sent to the renderer or |event| was triggered by a key that |
| 43 // we never want to send to the renderer. | 40 // we never want to send to the renderer. |
| 44 bool IsReservedCommandOrKey(int command_id, | 41 bool IsReservedCommandOrKey(int command_id, |
| 45 const content::NativeWebKeyboardEvent& event); | 42 const content::NativeWebKeyboardEvent& event); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 Profile* profile); | 74 Profile* profile); |
| 78 | 75 |
| 79 private: | 76 private: |
| 80 class InterstitialObserver; | 77 class InterstitialObserver; |
| 81 | 78 |
| 82 // Overridden from CommandUpdaterDelegate: | 79 // Overridden from CommandUpdaterDelegate: |
| 83 virtual void ExecuteCommandWithDisposition( | 80 virtual void ExecuteCommandWithDisposition( |
| 84 int id, | 81 int id, |
| 85 WindowOpenDisposition disposition) OVERRIDE; | 82 WindowOpenDisposition disposition) OVERRIDE; |
| 86 | 83 |
| 87 // Overridden from ProfileInfoCacheObserver: | |
| 88 virtual void OnProfileAdded(const base::FilePath& profile_path) OVERRIDE; | |
| 89 virtual void OnProfileWasRemoved(const base::FilePath& profile_path, | |
| 90 const base::string16& profile_name) OVERRIDE; | |
| 91 | |
| 92 // Overridden from TabStripModelObserver: | 84 // Overridden from TabStripModelObserver: |
| 93 virtual void TabInsertedAt(content::WebContents* contents, | 85 virtual void TabInsertedAt(content::WebContents* contents, |
| 94 int index, | 86 int index, |
| 95 bool foreground) OVERRIDE; | 87 bool foreground) OVERRIDE; |
| 96 virtual void TabDetachedAt(content::WebContents* contents, | 88 virtual void TabDetachedAt(content::WebContents* contents, |
| 97 int index) OVERRIDE; | 89 int index) OVERRIDE; |
| 98 virtual void TabReplacedAt(TabStripModel* tab_strip_model, | 90 virtual void TabReplacedAt(TabStripModel* tab_strip_model, |
| 99 content::WebContents* old_contents, | 91 content::WebContents* old_contents, |
| 100 content::WebContents* new_contents, | 92 content::WebContents* new_contents, |
| 101 int index) OVERRIDE; | 93 int index) OVERRIDE; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 void UpdateCommandsForBookmarkBar(); | 126 void UpdateCommandsForBookmarkBar(); |
| 135 | 127 |
| 136 // Updates commands that affect file selection dialogs in aggregate, | 128 // Updates commands that affect file selection dialogs in aggregate, |
| 137 // namely the save-page-as state and the open-file state. | 129 // namely the save-page-as state and the open-file state. |
| 138 void UpdateCommandsForFileSelectionDialogs(); | 130 void UpdateCommandsForFileSelectionDialogs(); |
| 139 | 131 |
| 140 // Update commands whose state depends on the type of fullscreen mode the | 132 // Update commands whose state depends on the type of fullscreen mode the |
| 141 // window is in. | 133 // window is in. |
| 142 void UpdateCommandsForFullscreenMode(); | 134 void UpdateCommandsForFullscreenMode(); |
| 143 | 135 |
| 144 // Update commands whose state depends on whether multiple profiles are | |
| 145 // allowed. | |
| 146 void UpdateCommandsForMultipleProfiles(); | |
| 147 | |
| 148 // Updates the printing command state. | 136 // Updates the printing command state. |
| 149 void UpdatePrintingState(); | 137 void UpdatePrintingState(); |
| 150 | 138 |
| 151 // Updates the SHOW_SYNC_SETUP menu entry. | 139 // Updates the SHOW_SYNC_SETUP menu entry. |
| 152 void OnSigninAllowedPrefChange(); | 140 void OnSigninAllowedPrefChange(); |
| 153 | 141 |
| 154 // Updates the save-page-as command state. | 142 // Updates the save-page-as command state. |
| 155 void UpdateSaveAsState(); | 143 void UpdateSaveAsState(); |
| 156 | 144 |
| 157 // Updates the show-sync command state. | 145 // Updates the show-sync command state. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 168 // Add/remove observers for interstitial attachment/detachment from | 156 // Add/remove observers for interstitial attachment/detachment from |
| 169 // |contents|. | 157 // |contents|. |
| 170 void AddInterstitialObservers(content::WebContents* contents); | 158 void AddInterstitialObservers(content::WebContents* contents); |
| 171 void RemoveInterstitialObservers(content::WebContents* contents); | 159 void RemoveInterstitialObservers(content::WebContents* contents); |
| 172 | 160 |
| 173 inline BrowserWindow* window(); | 161 inline BrowserWindow* window(); |
| 174 inline Profile* profile(); | 162 inline Profile* profile(); |
| 175 | 163 |
| 176 Browser* browser_; | 164 Browser* browser_; |
| 177 | 165 |
| 178 ProfileManager* profile_manager_; | |
| 179 | |
| 180 // The CommandUpdater that manages the browser window commands. | 166 // The CommandUpdater that manages the browser window commands. |
| 181 CommandUpdater command_updater_; | 167 CommandUpdater command_updater_; |
| 182 | 168 |
| 183 // Indicates if command execution is blocked. | 169 // Indicates if command execution is blocked. |
| 184 bool block_command_execution_; | 170 bool block_command_execution_; |
| 185 | 171 |
| 186 // Stores the last blocked command id when |block_command_execution_| is true. | 172 // Stores the last blocked command id when |block_command_execution_| is true. |
| 187 int last_blocked_command_id_; | 173 int last_blocked_command_id_; |
| 188 | 174 |
| 189 // Stores the disposition type of the last blocked command. | 175 // Stores the disposition type of the last blocked command. |
| 190 WindowOpenDisposition last_blocked_command_disposition_; | 176 WindowOpenDisposition last_blocked_command_disposition_; |
| 191 | 177 |
| 192 std::vector<InterstitialObserver*> interstitial_observers_; | 178 std::vector<InterstitialObserver*> interstitial_observers_; |
| 193 | 179 |
| 194 PrefChangeRegistrar profile_pref_registrar_; | 180 PrefChangeRegistrar profile_pref_registrar_; |
| 195 PrefChangeRegistrar local_pref_registrar_; | 181 PrefChangeRegistrar local_pref_registrar_; |
| 196 BooleanPrefMember pref_signin_allowed_; | 182 BooleanPrefMember pref_signin_allowed_; |
| 197 | 183 |
| 198 DISALLOW_COPY_AND_ASSIGN(BrowserCommandController); | 184 DISALLOW_COPY_AND_ASSIGN(BrowserCommandController); |
| 199 }; | 185 }; |
| 200 | 186 |
| 201 } // namespace chrome | 187 } // namespace chrome |
| 202 | 188 |
| 203 #endif // CHROME_BROWSER_UI_BROWSER_COMMAND_CONTROLLER_H_ | 189 #endif // CHROME_BROWSER_UI_BROWSER_COMMAND_CONTROLLER_H_ |
| OLD | NEW |