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

Side by Side Diff: chrome/browser/extensions/extension_service.h

Issue 2925973002: Migrate upgrade notifications to observer (Closed)
Patch Set: Clean up code Created 3 years, 6 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_EXTENSIONS_EXTENSION_SERVICE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "base/strings/string16.h" 20 #include "base/strings/string16.h"
21 #include "chrome/browser/extensions/blacklist.h" 21 #include "chrome/browser/extensions/blacklist.h"
22 #include "chrome/browser/extensions/extension_management.h" 22 #include "chrome/browser/extensions/extension_management.h"
23 #include "chrome/browser/extensions/install_gate.h" 23 #include "chrome/browser/extensions/install_gate.h"
24 #include "chrome/browser/extensions/pending_extension_manager.h" 24 #include "chrome/browser/extensions/pending_extension_manager.h"
25 #include "chrome/browser/upgrade_observer.h"
25 #include "components/sync/model/string_ordinal.h" 26 #include "components/sync/model/string_ordinal.h"
26 #include "content/public/browser/notification_observer.h" 27 #include "content/public/browser/notification_observer.h"
27 #include "content/public/browser/notification_registrar.h" 28 #include "content/public/browser/notification_registrar.h"
28 #include "extensions/browser/crx_file_info.h" 29 #include "extensions/browser/crx_file_info.h"
29 #include "extensions/browser/extension_prefs.h" 30 #include "extensions/browser/extension_prefs.h"
30 #include "extensions/browser/external_provider_interface.h" 31 #include "extensions/browser/external_provider_interface.h"
31 #include "extensions/browser/install_flag.h" 32 #include "extensions/browser/install_flag.h"
32 #include "extensions/browser/process_manager.h" 33 #include "extensions/browser/process_manager.h"
33 #include "extensions/browser/uninstall_reason.h" 34 #include "extensions/browser/uninstall_reason.h"
34 #include "extensions/common/extension.h" 35 #include "extensions/common/extension.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 virtual base::SequencedTaskRunner* GetFileTaskRunner() = 0; 174 virtual base::SequencedTaskRunner* GetFileTaskRunner() = 0;
174 }; 175 };
175 176
176 // Manages installed and running Chromium extensions. An instance is shared 177 // Manages installed and running Chromium extensions. An instance is shared
177 // between normal and incognito profiles. 178 // between normal and incognito profiles.
178 class ExtensionService 179 class ExtensionService
179 : public ExtensionServiceInterface, 180 : public ExtensionServiceInterface,
180 public extensions::ExternalProviderInterface::VisitorInterface, 181 public extensions::ExternalProviderInterface::VisitorInterface,
181 public content::NotificationObserver, 182 public content::NotificationObserver,
182 public extensions::Blacklist::Observer, 183 public extensions::Blacklist::Observer,
183 public extensions::ExtensionManagement::Observer { 184 public extensions::ExtensionManagement::Observer,
185 public UpgradeObserver {
184 public: 186 public:
185 // Attempts to uninstall an extension from a given ExtensionService. Returns 187 // Attempts to uninstall an extension from a given ExtensionService. Returns
186 // true iff the target extension exists. 188 // true iff the target extension exists.
187 static bool UninstallExtensionHelper(ExtensionService* extensions_service, 189 static bool UninstallExtensionHelper(ExtensionService* extensions_service,
188 const std::string& extension_id, 190 const std::string& extension_id,
189 extensions::UninstallReason reason); 191 extensions::UninstallReason reason);
190 192
191 // Constructor stores pointers to |profile| and |extension_prefs| but 193 // Constructor stores pointers to |profile| and |extension_prefs| but
192 // ownership remains at caller. 194 // ownership remains at caller.
193 ExtensionService(Profile* profile, 195 ExtensionService(Profile* profile,
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 void ReloadExtensionImpl(const std::string& extension_id, bool be_noisy); 457 void ReloadExtensionImpl(const std::string& extension_id, bool be_noisy);
456 458
457 // content::NotificationObserver implementation: 459 // content::NotificationObserver implementation:
458 void Observe(int type, 460 void Observe(int type,
459 const content::NotificationSource& source, 461 const content::NotificationSource& source,
460 const content::NotificationDetails& details) override; 462 const content::NotificationDetails& details) override;
461 463
462 // extensions::Blacklist::Observer implementation. 464 // extensions::Blacklist::Observer implementation.
463 void OnBlacklistUpdated() override; 465 void OnBlacklistUpdated() override;
464 466
467 // UpgradeObserver implementation.
468 void OnUpgradeRecommended() override;
469
465 // Similar to FinishInstallation, but first checks if there still is an update 470 // Similar to FinishInstallation, but first checks if there still is an update
466 // pending for the extension, and makes sure the extension is still idle. 471 // pending for the extension, and makes sure the extension is still idle.
467 void MaybeFinishDelayedInstallation(const std::string& extension_id); 472 void MaybeFinishDelayedInstallation(const std::string& extension_id);
468 473
469 // For the extension in |version_path| with |id|, check to see if it's an 474 // For the extension in |version_path| with |id|, check to see if it's an
470 // externally managed extension. If so, uninstall it. 475 // externally managed extension. If so, uninstall it.
471 void CheckExternalUninstall(const std::string& id); 476 void CheckExternalUninstall(const std::string& id);
472 477
473 // Attempt to enable all disabled extensions which the only disabled reason is 478 // Attempt to enable all disabled extensions which the only disabled reason is
474 // reloading. 479 // reloading.
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 GreylistUnknownDontChange); 750 GreylistUnknownDontChange);
746 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 751 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
747 ManagementPolicyProhibitsEnableOnInstalled); 752 ManagementPolicyProhibitsEnableOnInstalled);
748 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, 753 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
749 BlockAndUnblockBlacklistedExtension); 754 BlockAndUnblockBlacklistedExtension);
750 755
751 DISALLOW_COPY_AND_ASSIGN(ExtensionService); 756 DISALLOW_COPY_AND_ASSIGN(ExtensionService);
752 }; 757 };
753 758
754 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_ 759 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698