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

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

Issue 2803923002: [Media Router] Unload the legacy Cast extension at install (Closed)
Patch Set: Unload instead of uninstall Created 3 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/scoped_observer.h"
14 #include "extensions/browser/extension_registry_observer.h"
13 15
14 class Browser; 16 class Browser;
15 class ExtensionService;
16 class Profile; 17 class Profile;
17 class ToolbarActionsBar; 18 class ToolbarActionsBar;
18 class ToolbarActionViewController; 19 class ToolbarActionViewController;
19 20
20 namespace extensions { 21 namespace extensions {
21 class ExtensionRegistry; 22 class ExtensionRegistry;
22 } 23 class ExtensionSystem;
24 } // namespace extensions
23 25
24 // The registry for all component toolbar actions. Component toolbar actions 26 // The registry for all component toolbar actions. Component toolbar actions
25 // are actions that live in the toolbar (like extension actions), but are for 27 // are actions that live in the toolbar (like extension actions), but are for
26 // components of Chrome, such as Media Router. 28 // components of Chrome, such as Media Router.
27 class ComponentToolbarActionsFactory { 29 class ComponentToolbarActionsFactory
30 : public extensions::ExtensionRegistryObserver {
28 public: 31 public:
29 // Extension and component action IDs. 32 // Extension and component action IDs.
30 static const char kCastBetaExtensionId[]; 33 static const char kCastBetaExtensionId[];
31 static const char kCastExtensionId[]; 34 static const char kCastExtensionId[];
32 static const char kMediaRouterActionId[]; 35 static const char kMediaRouterActionId[];
33 36
34 explicit ComponentToolbarActionsFactory(Profile* profile); 37 explicit ComponentToolbarActionsFactory(Profile* profile);
35 virtual ~ComponentToolbarActionsFactory(); 38 ~ComponentToolbarActionsFactory() override;
36 39
37 // Returns a set of IDs of the component actions that should be present when 40 // Returns a set of IDs of the component actions that should be present when
38 // the toolbar model is initialized. 41 // the toolbar model is initialized.
39 virtual std::set<std::string> GetInitialComponentIds(); 42 virtual std::set<std::string> GetInitialComponentIds();
40 43
41 // Called when component actions are added or removed before the toolbar model 44 // Called when component actions are added or removed before the toolbar model
42 // is initialized. Adds or removes |action_id| to/from |initial_ids_| as 45 // is initialized. Adds or removes |action_id| to/from |initial_ids_| as
43 // necessary. 46 // necessary.
44 void OnAddComponentActionBeforeInit(const std::string& action_id); 47 void OnAddComponentActionBeforeInit(const std::string& action_id);
45 void OnRemoveComponentActionBeforeInit(const std::string& action_id); 48 void OnRemoveComponentActionBeforeInit(const std::string& action_id);
46 49
47 // Returns the controller responsible for the component action associated with 50 // Returns the controller responsible for the component action associated with
48 // |action_id| in |bar|. Declared virtual for testing. 51 // |action_id| in |bar|. Declared virtual for testing.
49 virtual std::unique_ptr<ToolbarActionViewController> 52 virtual std::unique_ptr<ToolbarActionViewController>
50 GetComponentToolbarActionForId(const std::string& action_id, 53 GetComponentToolbarActionForId(const std::string& action_id,
51 Browser* browser, 54 Browser* browser,
52 ToolbarActionsBar* bar); 55 ToolbarActionsBar* bar);
53 56
54 // Unloads extensions that were migrated to component actions and therefore 57 // Unloads extensions that were migrated to component actions and therefore
55 // are no longer needed. 58 // are no longer needed.
56 void UnloadMigratedExtensions(ExtensionService* service, 59 void UnloadMigratedExtensions();
57 extensions::ExtensionRegistry* registry); 60
61 // extensions::ExtensionRegistryObserver:
62 void OnExtensionInstalled(content::BrowserContext* browser_context,
63 const extensions::Extension* extension,
64 bool is_update) override;
58 65
59 private: 66 private:
60 // Unloads an extension if it is active. 67 // Unloads an extension if it is installed.
61 void UnloadExtension(ExtensionService* service, 68 void UnloadExtension(const std::string& extension_id);
62 extensions::ExtensionRegistry* registry,
63 const std::string& extension_id);
64 69
65 Profile* profile_; 70 Profile* const profile_;
66 71
67 // IDs of component actions that should be added to the toolbar model when it 72 // IDs of component actions that should be added to the toolbar model when it
68 // gets initialized. 73 // gets initialized.
69 std::set<std::string> initial_ids_; 74 std::set<std::string> initial_ids_;
70 75
76 // The ExtensionRegistry and ExtensionSystem for the profile, used for
77 // detecting and unloading migrated extensions.
78 extensions::ExtensionRegistry* const extension_registry_;
79 extensions::ExtensionSystem* const extension_system_;
80
81 ScopedObserver<extensions::ExtensionRegistry, ExtensionRegistryObserver>
82 extension_registry_observer_;
83
71 DISALLOW_COPY_AND_ASSIGN(ComponentToolbarActionsFactory); 84 DISALLOW_COPY_AND_ASSIGN(ComponentToolbarActionsFactory);
72 }; 85 };
73 86
74 #endif // CHROME_BROWSER_UI_TOOLBAR_COMPONENT_TOOLBAR_ACTIONS_FACTORY_H_ 87 #endif // CHROME_BROWSER_UI_TOOLBAR_COMPONENT_TOOLBAR_ACTIONS_FACTORY_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698