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

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

Issue 2613713005: Make ToolbarActionsModel own ComponentToolbarActionsFactory (Closed)
Patch Set: Created 3 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_COMPONENT_TOOLBAR_ACTIONS_FACTORY_H_ 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_COMPONENT_TOOLBAR_ACTIONS_FACTORY_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_COMPONENT_TOOLBAR_ACTIONS_FACTORY_H_ 6 #define CHROME_BROWSER_UI_TOOLBAR_COMPONENT_TOOLBAR_ACTIONS_FACTORY_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" 13 #include "chrome/browser/extensions/component_migration_helper.h"
14 14
15 class Browser; 15 class Browser;
16 class Profile; 16 class Profile;
17 class ToolbarActionsBar;
17 class ToolbarActionViewController; 18 class ToolbarActionViewController;
18 19
19 namespace extensions { 20 namespace extensions {
20 class ComponentMigrationHelper; 21 class ComponentMigrationHelper;
msw 2017/01/10 23:23:59 nit: remove
takumif 2017/02/17 03:22:51 Removed migration-related code.
21 } // extensions 22 } // extensions
22 23
23 // The registry for all component toolbar actions. Component toolbar actions 24 // The registry for all component toolbar actions. Component toolbar actions
24 // are actions that live in the toolbar (like extension actions), but are 25 // are actions that live in the toolbar (like extension actions), but are
25 // components of chrome, such as ChromeCast. 26 // components of chrome, such as Media Router.
26 class ComponentToolbarActionsFactory { 27 class ComponentToolbarActionsFactory {
27 public: 28 public:
28 // Component action IDs. 29 // Component action IDs.
29 static const char kMediaRouterActionId[]; 30 static const char kMediaRouterActionId[];
30 31
31 ComponentToolbarActionsFactory(); 32 ComponentToolbarActionsFactory(
msw 2017/01/10 23:23:59 nit: comment (explain params, especially the actio
takumif 2017/02/17 03:22:51 This class no longer needs a reference to the acti
33 Profile* profile,
34 extensions::ComponentMigrationHelper::ComponentActionDelegate*
35 action_delegate);
32 virtual ~ComponentToolbarActionsFactory(); 36 virtual ~ComponentToolbarActionsFactory();
33 37
34 static ComponentToolbarActionsFactory* GetInstance(); 38 // Returns a vector of IDs of the component actions.
39 virtual std::set<std::string> GetInitialComponentIds();
35 40
36 // Returns a vector of IDs of the component actions. 41 // Called when component actions are added or removed before the toolbar model
37 virtual std::set<std::string> GetInitialComponentIds(Profile* profile); 42 // is initialized. Adds or removes |action_id| to/from |initial_ids_| as
43 // necessary.
44 void OnAddComponentActionBeforeInit(const std::string& action_id);
45 void OnRemoveComponentActionBeforeInit(const std::string& action_id);
38 46
39 // Returns a collection of controllers for component actions. Declared 47 // Returns a collection of controllers for component actions. Declared
Devlin 2017/01/10 23:07:11 not this patch, but this is out of date (it's not
takumif 2017/02/17 03:22:51 Updated the comment.
40 // virtual for testing. 48 // virtual for testing.
41 virtual std::unique_ptr<ToolbarActionViewController> 49 virtual std::unique_ptr<ToolbarActionViewController>
42 GetComponentToolbarActionForId(const std::string& id, 50 GetComponentToolbarActionForId(const std::string& action_id,
43 Browser* browser, 51 Browser* browser,
44 ToolbarActionsBar* bar); 52 ToolbarActionsBar* bar);
45 53
46 // Registers component actions that are migrating from extensions. 54 // Registers component actions that are migrating from extensions.
47 virtual void RegisterComponentMigrations( 55 virtual void RegisterComponentMigrations();
48 extensions::ComponentMigrationHelper* helper) const;
49 56
50 // Synchronizes component action visibility and extension install status. 57 // Synchronizes component action visibility and extension install status.
51 virtual void HandleComponentMigrations( 58 virtual void HandleComponentMigrations();
52 extensions::ComponentMigrationHelper* helper,
53 Profile* profile) const;
54 59
55 // Sets the factory to use for testing purposes. 60 extensions::ComponentMigrationHelper* migration_helper() {
56 // Ownership remains with the caller. 61 return &migration_helper_;
57 static void SetTestingFactory(ComponentToolbarActionsFactory* factory); 62 }
63
64 protected:
65 extensions::ComponentMigrationHelper migration_helper_;
Devlin 2017/01/10 23:07:11 If we have the accessor above, why does this need
msw 2017/01/10 23:23:59 Why is this protected if there's a public accessor
takumif 2017/02/17 03:22:51 Removed migration-related code.
takumif 2017/02/17 03:22:51 Removed migration-related code.
58 66
59 private: 67 private:
68 Profile* profile_;
69
70 // IDs of component actions that should be added to the toolbar model when it
71 // gets initialized.
72 std::set<std::string> initial_ids_;
73
60 DISALLOW_COPY_AND_ASSIGN(ComponentToolbarActionsFactory); 74 DISALLOW_COPY_AND_ASSIGN(ComponentToolbarActionsFactory);
61 }; 75 };
62 76
63 #endif // CHROME_BROWSER_UI_TOOLBAR_COMPONENT_TOOLBAR_ACTIONS_FACTORY_H_ 77 #endif // CHROME_BROWSER_UI_TOOLBAR_COMPONENT_TOOLBAR_ACTIONS_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698