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

Side by Side Diff: chrome/browser/ui/toolbar/action_box_button_controller.h

Issue 12095023: Allow platform apps to add themselves to the Action Box. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 7 years, 10 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
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_UI_TOOLBAR_ACTION_BOX_BUTTON_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_ACTION_BOX_BUTTON_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_ACTION_BOX_BUTTON_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_TOOLBAR_ACTION_BOX_BUTTON_CONTROLLER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/ui/toolbar/action_box_menu_model.h"
13 #include "content/public/browser/notification_observer.h" 12 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 13 #include "content/public/browser/notification_registrar.h"
15 #include "ui/base/models/simple_menu_model.h" 14 #include "ui/base/models/simple_menu_model.h"
16 15
16 class ActionBoxMenuModel;
17 class Browser; 17 class Browser;
18 18
19 namespace extensions { 19 namespace extensions {
20 class Extension; 20 class Extension;
21 } 21 }
22 22
23 namespace ui { 23 namespace ui {
24 class MenuModel; 24 class MenuModel;
25 } 25 }
26 26
27 // Controller for the action box. 27 // Controller for the action box.
28 // 28 //
29 // This should have the same lifetime as the action box itself -- that is, more 29 // This should have the same lifetime as the action box itself -- that is, more
30 // or less the lifetime of the tab -- unlike ActionBoxMenuModel which is scoped 30 // or less the lifetime of the tab -- unlike ActionBoxMenuModel which is scoped
31 // to the menu being open. 31 // to the menu being open.
32 class ActionBoxButtonController : public ui::SimpleMenuModel::Delegate, 32 class ActionBoxButtonController : public ui::SimpleMenuModel::Delegate,
33 public content::NotificationObserver { 33 public content::NotificationObserver {
34 public: 34 public:
35 class Delegate { 35 class Delegate {
36 public: 36 public:
37 // Shows the menu with the given |menu_model|. 37 // Shows the menu with the given |menu_model|.
38 virtual void ShowMenu(scoped_ptr<ActionBoxMenuModel> menu_model) {} 38 virtual void ShowMenu(scoped_ptr<ActionBoxMenuModel> menu_model);
sky 2013/02/11 16:37:09 It's ok to inline virtual method that have no retu
Rune Fevang 2013/02/11 20:52:52 The reason I changed it is to allow forward declar
39 39
40 protected: 40 protected:
41 virtual ~Delegate() {} 41 virtual ~Delegate() {}
42 }; 42 };
43 43
44 ActionBoxButtonController(Browser* browser, Delegate* delegate); 44 ActionBoxButtonController(Browser* browser, Delegate* delegate);
45 virtual ~ActionBoxButtonController(); 45 virtual ~ActionBoxButtonController();
46 46
47 // Notifies this that the action box button has been clicked. 47 // Notifies this that the action box button has been clicked.
48 // Methods on the Delegate may be called re-entrantly. 48 // Methods on the Delegate may be called re-entrantly.
49 void OnButtonClicked(); 49 void OnButtonClicked();
50 50
51 // Overridden from ui::SimpleMenuModel::Delegate: 51 // Overridden from ui::SimpleMenuModel::Delegate:
52 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; 52 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
53 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; 53 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
54 virtual bool GetAcceleratorForCommandId( 54 virtual bool GetAcceleratorForCommandId(
55 int command_id, 55 int command_id,
56 ui::Accelerator* accelerator) OVERRIDE; 56 ui::Accelerator* accelerator) OVERRIDE;
57 virtual void ExecuteCommand(int command_id) OVERRIDE; 57 virtual void ExecuteCommand(int command_id) OVERRIDE;
58 58
59 private: 59 private:
60 // Gets the command ID for an extension, creating a new one if necessary. 60 // Gets the command ID for an extension, creating a new one if necessary.
61 int GetCommandIdForExtension(const extensions::Extension& extension); 61 int GetCommandIdForExtension(const extensions::Extension& extension);
62 62
63 // Gets the extension for a command ID, or NULL if there isn't one. 63 // Returns the next command ID to be used.
64 const extensions::Extension* GetExtensionForCommandId(int command_id); 64 int GetNextCommandId();
65 65
66 // content::NotificationObserver implementation. 66 // content::NotificationObserver implementation.
67 virtual void Observe(int type, 67 virtual void Observe(int type,
68 const content::NotificationSource& source, 68 const content::NotificationSource& source,
69 const content::NotificationDetails& details) OVERRIDE; 69 const content::NotificationDetails& details) OVERRIDE;
70 70
71 // Handles "share with X" commands.
72 void TriggerExplicitShareIntent(const GURL& share_service_url);
73
74 // Handles the "Find places to share" command. Navigates the browser to the
75 // web store to find extensions with share intents.
76 void NavigateToWebStoreShareIntentsList();
77
78 Browser* browser_; 71 Browser* browser_;
79 72
80 Delegate* delegate_; 73 Delegate* delegate_;
81 74
82 // The share service strings that have commands associated with them. 75 typedef std::map<int, std::string> ExtensionIdCommandMap;
83 typedef std::map<int, GURL> ShareIntentServiceCommandMap; 76 ExtensionIdCommandMap extension_command_ids_;
84 ShareIntentServiceCommandMap share_intent_service_ids_;
85 77
86 // The command ID to assign to the next extension that needs one. 78 // The command ID to assign to the next dynamic entry that needs one.
87 int next_extension_command_id_; 79 int next_command_id_;
88
89 // The extension IDs that have commands associated with them.
90 typedef std::map<std::string, int> ExtensionIdCommandMap;
91 ExtensionIdCommandMap extension_command_ids_;
92 80
93 content::NotificationRegistrar registrar_; 81 content::NotificationRegistrar registrar_;
94 82
95 DISALLOW_COPY_AND_ASSIGN(ActionBoxButtonController); 83 DISALLOW_COPY_AND_ASSIGN(ActionBoxButtonController);
96 }; 84 };
97 85
98 #endif // CHROME_BROWSER_UI_TOOLBAR_ACTION_BOX_BUTTON_CONTROLLER_H_ 86 #endif // CHROME_BROWSER_UI_TOOLBAR_ACTION_BOX_BUTTON_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698