Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / command_observer_bridge.h
blob155cb999d7d936ab0bb3d45524d0830c24510e19
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_COCOA_COMMAND_OBSERVER_BRIDGE
6 #define CHROME_BROWSER_UI_COCOA_COMMAND_OBSERVER_BRIDGE
8 #import <Cocoa/Cocoa.h>
10 #include "base/compiler_specific.h"
11 #include "chrome/browser/command_observer.h"
13 @protocol CommandObserverProtocol;
15 class CommandUpdater;
17 // A C++ bridge class that handles listening for updates to commands and
18 // passing them back to an object that supports the protocol delcared below.
19 // The observer will create one of these bridges, call ObserveCommand() on the
20 // command ids it cares about, and then wait for update notifications,
21 // delivered via -enabledStateChangedForCommand:enabled:. Destroying this
22 // bridge will handle automatically unregistering for updates, so there's no
23 // need to do that manually.
25 class CommandObserverBridge : public CommandObserver {
26 public:
27 CommandObserverBridge(id<CommandObserverProtocol> observer,
28 CommandUpdater* commands);
29 ~CommandObserverBridge() override;
31 // Register for updates about |command|.
32 void ObserveCommand(int command);
34 protected:
35 // Overridden from CommandObserver
36 void EnabledStateChangedForCommand(int command, bool enabled) override;
38 private:
39 id<CommandObserverProtocol> observer_; // weak, owns me
40 CommandUpdater* commands_; // weak
43 // Implemented by the observing Objective-C object, called when there is a
44 // state change for the given command.
45 @protocol CommandObserverProtocol
46 - (void)enabledStateChangedForCommand:(NSInteger)command enabled:(BOOL)enabled;
47 @end
49 #endif // CHROME_BROWSER_UI_COCOA_COMMAND_OBSERVER_BRIDGE