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

Side by Side Diff: chrome/browser/command_updater.h

Issue 11308259: chrome: Extract CommandUpdaterDelegate into its own header file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: FakeCommandObserver Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/command_observer.h ('k') | chrome/browser/command_updater.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_COMMAND_UPDATER_H_ 5 #ifndef CHROME_BROWSER_COMMAND_UPDATER_H_
6 #define CHROME_BROWSER_COMMAND_UPDATER_H_ 6 #define CHROME_BROWSER_COMMAND_UPDATER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/hash_tables.h" 9 #include "base/hash_tables.h"
10 #include "webkit/glue/window_open_disposition.h" 10 #include "webkit/glue/window_open_disposition.h"
11 11
12 class CommandObserver; 12 class CommandObserver;
13 class CommandUpdaterDelegate;
13 14
14 //////////////////////////////////////////////////////////////////////////////// 15 ////////////////////////////////////////////////////////////////////////////////
15 // 16 //
16 // CommandUpdater class 17 // CommandUpdater class
17 // 18 //
18 // This object manages the enabled state of a set of commands. Observers 19 // This object manages the enabled state of a set of commands. Observers
19 // register to listen to changes in this state so they can update their 20 // register to listen to changes in this state so they can update their
20 // presentation. 21 // presentation.
21 // 22 //
22 class CommandUpdater { 23 class CommandUpdater {
23 public: 24 public:
24 // A Delegate object implements this interface so that it can execute commands 25 // Create a CommandUpdater with |delegate| to handle the execution of specific
25 // when needed. 26 // commands.
26 class CommandUpdaterDelegate { 27 explicit CommandUpdater(CommandUpdaterDelegate* delegate);
27 public: 28 ~CommandUpdater();
sky 2012/12/06 01:38:08 In general if there are subclasses we make the des
tfarina 2012/12/06 01:41:40 If I understand you, and you are concerned about t
28 // Performs the action associated with the command with the specified ID and
29 // using the given disposition.
30 virtual void ExecuteCommandWithDisposition(
31 int id,
32 WindowOpenDisposition disposition) = 0;
33
34 protected:
35 virtual ~CommandUpdaterDelegate();
36 };
37
38 // Create a CommandUpdater with a CommandUpdaterDelegate to handle execution
39 // of specific commands.
40 explicit CommandUpdater(CommandUpdaterDelegate* handler);
41 virtual ~CommandUpdater();
42 29
43 // Returns true if the specified command ID is supported. 30 // Returns true if the specified command ID is supported.
44 bool SupportsCommand(int id) const; 31 bool SupportsCommand(int id) const;
45 32
46 // Returns true if the specified command ID is enabled. The command ID must be 33 // Returns true if the specified command ID is enabled. The command ID must be
47 // supported by this updater. 34 // supported by this updater.
48 bool IsCommandEnabled(int id) const; 35 bool IsCommandEnabled(int id) const;
49 36
50 // Performs the action associated with this command ID using CURRENT_TAB 37 // Performs the action associated with this command ID using CURRENT_TAB
51 // disposition. 38 // disposition.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // exist if desired. 71 // exist if desired.
85 Command* GetCommand(int id, bool create); 72 Command* GetCommand(int id, bool create);
86 73
87 // The delegate is responsible for executing commands. 74 // The delegate is responsible for executing commands.
88 CommandUpdaterDelegate* delegate_; 75 CommandUpdaterDelegate* delegate_;
89 76
90 // This is a map of command IDs to states and observer lists 77 // This is a map of command IDs to states and observer lists
91 typedef base::hash_map<int, Command*> CommandMap; 78 typedef base::hash_map<int, Command*> CommandMap;
92 CommandMap commands_; 79 CommandMap commands_;
93 80
94 CommandUpdater();
95 DISALLOW_COPY_AND_ASSIGN(CommandUpdater); 81 DISALLOW_COPY_AND_ASSIGN(CommandUpdater);
96 }; 82 };
97 83
98 #endif // CHROME_BROWSER_COMMAND_UPDATER_H_ 84 #endif // CHROME_BROWSER_COMMAND_UPDATER_H_
OLDNEW
« no previous file with comments | « chrome/browser/command_observer.h ('k') | chrome/browser/command_updater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698