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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/toolbar/component_toolbar_actions_factory.h
diff --git a/chrome/browser/ui/toolbar/component_toolbar_actions_factory.h b/chrome/browser/ui/toolbar/component_toolbar_actions_factory.h
index 3f00ca9c1d0f53b37bf12b5b59da8bfb5deabfdb..538ec02f10688e98fc10ed6bdfffefd240730d81 100644
--- a/chrome/browser/ui/toolbar/component_toolbar_actions_factory.h
+++ b/chrome/browser/ui/toolbar/component_toolbar_actions_factory.h
@@ -10,10 +10,11 @@
#include <string>
#include "base/macros.h"
-#include "chrome/browser/ui/toolbar/toolbar_actions_bar.h"
+#include "chrome/browser/extensions/component_migration_helper.h"
class Browser;
class Profile;
+class ToolbarActionsBar;
class ToolbarActionViewController;
namespace extensions {
@@ -22,41 +23,54 @@ class ComponentMigrationHelper;
// The registry for all component toolbar actions. Component toolbar actions
// are actions that live in the toolbar (like extension actions), but are
-// components of chrome, such as ChromeCast.
+// components of chrome, such as Media Router.
class ComponentToolbarActionsFactory {
public:
// Component action IDs.
static const char kMediaRouterActionId[];
- ComponentToolbarActionsFactory();
+ 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
+ Profile* profile,
+ extensions::ComponentMigrationHelper::ComponentActionDelegate*
+ action_delegate);
virtual ~ComponentToolbarActionsFactory();
- static ComponentToolbarActionsFactory* GetInstance();
-
// Returns a vector of IDs of the component actions.
- virtual std::set<std::string> GetInitialComponentIds(Profile* profile);
+ virtual std::set<std::string> GetInitialComponentIds();
+
+ // Called when component actions are added or removed before the toolbar model
+ // is initialized. Adds or removes |action_id| to/from |initial_ids_| as
+ // necessary.
+ void OnAddComponentActionBeforeInit(const std::string& action_id);
+ void OnRemoveComponentActionBeforeInit(const std::string& action_id);
// 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.
// virtual for testing.
virtual std::unique_ptr<ToolbarActionViewController>
- GetComponentToolbarActionForId(const std::string& id,
+ GetComponentToolbarActionForId(const std::string& action_id,
Browser* browser,
ToolbarActionsBar* bar);
// Registers component actions that are migrating from extensions.
- virtual void RegisterComponentMigrations(
- extensions::ComponentMigrationHelper* helper) const;
+ virtual void RegisterComponentMigrations();
// Synchronizes component action visibility and extension install status.
- virtual void HandleComponentMigrations(
- extensions::ComponentMigrationHelper* helper,
- Profile* profile) const;
+ virtual void HandleComponentMigrations();
+
+ extensions::ComponentMigrationHelper* migration_helper() {
+ return &migration_helper_;
+ }
- // Sets the factory to use for testing purposes.
- // Ownership remains with the caller.
- static void SetTestingFactory(ComponentToolbarActionsFactory* factory);
+ protected:
+ 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.
private:
+ Profile* profile_;
+
+ // IDs of component actions that should be added to the toolbar model when it
+ // gets initialized.
+ std::set<std::string> initial_ids_;
+
DISALLOW_COPY_AND_ASSIGN(ComponentToolbarActionsFactory);
};

Powered by Google App Engine
This is Rietveld 408576698