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

Side by Side Diff: chrome/browser/ui/cocoa/command_observer_bridge.h

Issue 10677009: Move command handling and updating off Browser and onto a helper object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 months 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_COMMAND_OBSERVER_BRIDGE 5 #ifndef CHROME_BROWSER_UI_COCOA_COMMAND_OBSERVER_BRIDGE
6 #define CHROME_BROWSER_UI_COCOA_COMMAND_OBSERVER_BRIDGE 6 #define CHROME_BROWSER_UI_COCOA_COMMAND_OBSERVER_BRIDGE
7 #pragma once 7 #pragma once
8 8
9 #import <Cocoa/Cocoa.h> 9 #import <Cocoa/Cocoa.h>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "chrome/browser/command_updater.h" 12 #include "chrome/browser/command_observer.h"
13 13
14 @protocol CommandObserverProtocol; 14 @protocol CommandObserverProtocol;
15 15
16 class CommandUpdater;
17
16 // A C++ bridge class that handles listening for updates to commands and 18 // A C++ bridge class that handles listening for updates to commands and
17 // passing them back to an object that supports the protocol delcared below. 19 // passing them back to an object that supports the protocol delcared below.
18 // The observer will create one of these bridges, call ObserveCommand() on the 20 // The observer will create one of these bridges, call ObserveCommand() on the
19 // command ids it cares about, and then wait for update notifications, 21 // command ids it cares about, and then wait for update notifications,
20 // delivered via -enabledStateChangedForCommand:enabled:. Destroying this 22 // delivered via -enabledStateChangedForCommand:enabled:. Destroying this
21 // bridge will handle automatically unregistering for updates, so there's no 23 // bridge will handle automatically unregistering for updates, so there's no
22 // need to do that manually. 24 // need to do that manually.
23 25
24 class CommandObserverBridge : public CommandUpdater::CommandObserver { 26 class CommandObserverBridge : public CommandObserver {
25 public: 27 public:
26 CommandObserverBridge(id<CommandObserverProtocol> observer, 28 CommandObserverBridge(id<CommandObserverProtocol> observer,
27 CommandUpdater* commands); 29 CommandUpdater* commands);
28 virtual ~CommandObserverBridge(); 30 virtual ~CommandObserverBridge();
29 31
30 // Register for updates about |command|. 32 // Register for updates about |command|.
31 void ObserveCommand(int command); 33 void ObserveCommand(int command);
32 34
33 protected: 35 protected:
34 // Overridden from CommandUpdater::CommandObserver 36 // Overridden from CommandObserver
35 virtual void EnabledStateChangedForCommand(int command, 37 virtual void EnabledStateChangedForCommand(int command,
36 bool enabled) OVERRIDE; 38 bool enabled) OVERRIDE;
37 39
38 private: 40 private:
39 id<CommandObserverProtocol> observer_; // weak, owns me 41 id<CommandObserverProtocol> observer_; // weak, owns me
40 CommandUpdater* commands_; // weak 42 CommandUpdater* commands_; // weak
41 }; 43 };
42 44
43 // Implemented by the observing Objective-C object, called when there is a 45 // Implemented by the observing Objective-C object, called when there is a
44 // state change for the given command. 46 // state change for the given command.
45 @protocol CommandObserverProtocol 47 @protocol CommandObserverProtocol
46 - (void)enabledStateChangedForCommand:(NSInteger)command enabled:(BOOL)enabled; 48 - (void)enabledStateChangedForCommand:(NSInteger)command enabled:(BOOL)enabled;
47 @end 49 @end
48 50
49 #endif // CHROME_BROWSER_UI_COCOA_COMMAND_OBSERVER_BRIDGE 51 #endif // CHROME_BROWSER_UI_COCOA_COMMAND_OBSERVER_BRIDGE
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_utils.mm ('k') | chrome/browser/ui/cocoa/command_observer_bridge.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698