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

Unified Diff: chrome/browser/ui/webui/app_list/start_page_handler.cc

Issue 275503003: Remove deprecated extension notification and deprecated extension_service functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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/webui/app_list/start_page_handler.cc
diff --git a/chrome/browser/ui/webui/app_list/start_page_handler.cc b/chrome/browser/ui/webui/app_list/start_page_handler.cc
index 604797357880b2729621a8b9ab7a29347ec499ac..88dc23610a8620926f10650a3410ba4d36e92f9a 100644
--- a/chrome/browser/ui/webui/app_list/start_page_handler.cc
+++ b/chrome/browser/ui/webui/app_list/start_page_handler.cc
@@ -9,7 +9,6 @@
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_service.h"
Devlin 2014/05/19 16:04:11 Safe to remove this include, I think.
limasdf 2014/05/20 04:04:49 Done.
#include "chrome/browser/omaha_query_params/omaha_query_params.h"
#include "chrome/browser/profiles/profile.h"
@@ -21,9 +20,8 @@
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
#include "chrome/common/pref_names.h"
-#include "content/public/browser/notification_details.h"
-#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_ui.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_icon_set.h"
@@ -61,7 +59,9 @@ scoped_ptr<base::DictionaryValue> CreateAppInfo(
} // namespace
-StartPageHandler::StartPageHandler() : recommended_apps_(NULL) {}
+StartPageHandler::StartPageHandler()
+ : recommended_apps_(NULL), extension_registry_observer_(this) {
+}
StartPageHandler::~StartPageHandler() {
if (recommended_apps_)
@@ -89,31 +89,26 @@ void StartPageHandler::RegisterMessages() {
base::Unretained(this)));
}
-void StartPageHandler::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
+void StartPageHandler::OnExtensionLoaded(
+ content::BrowserContext* browser_context,
+ const extensions::Extension* extension) {
#if defined(OS_CHROMEOS)
DCHECK_EQ(Profile::FromWebUI(web_ui()),
- content::Source<Profile>(source).ptr());
- switch (type) {
- case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: {
- extensions::Extension* extension =
- content::Details<extensions::Extension>(details).ptr();
- if (extension->id() == extension_misc::kHotwordExtensionId)
- OnHotwordEnabledChanged();
- break;
- }
- case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
- extensions::UnloadedExtensionInfo* info =
- content::Details<extensions::UnloadedExtensionInfo>(details).ptr();
- if (info->extension->id() == extension_misc::kHotwordExtensionId)
- OnHotwordEnabledChanged();
- break;
- }
- default:
- NOTREACHED();
- break;
- }
+ Profile::FromBrowserContext(browser_context));
+ if (extension->id() == extension_misc::kHotwordExtensionId)
+ OnHotwordEnabledChanged();
+#endif
+}
+
+void StartPageHandler::OnExtensionUnloaded(
+ content::BrowserContext* browser_context,
+ const extensions::Extension* extension,
+ extensions::UnloadedExtensionInfo::Reason reason) {
+#if defined(OS_CHROMEOS)
+ DCHECK_EQ(Profile::FromWebUI(web_ui()),
+ Profile::FromBrowserContext(browser_context));
+ if (extension->id() == extension_misc::kHotwordExtensionId)
+ OnHotwordEnabledChanged();
#endif
}
@@ -139,15 +134,15 @@ void StartPageHandler::OnHotwordEnabledChanged() {
// hotwordPrivate API to provide the feature.
// TODO(mukai): remove this after everything gets stable.
Profile* profile = Profile::FromWebUI(web_ui());
- ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(profile)->extension_service();
- if (!extension_service)
- return;
- const extensions::Extension* hotword_extension =
- extension_service->GetExtensionById(
- extension_misc::kHotwordExtensionId, false /* include_disabled */);
- if (hotword_extension && hotword_extension->version()->CompareTo(
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(profile);
+ if (!registry)
Devlin 2014/05/19 16:04:11 ExtensionRegistry can never be NULL, unless someth
limasdf 2014/05/20 04:04:49 Done. I was a little worried about because of http
+ return;
+ const extensions::Extension& hotword_extension = registry->GetExtensionById(
Devlin 2014/05/19 16:04:11 ExtensionRegistry::GetExtensionById() returns a co
limasdf 2014/05/20 04:04:49 Done.
limasdf 2014/05/20 04:04:49 Done. shame on me :(
Devlin 2014/05/20 15:45:23 No worries :)
+ extension_misc::kHotwordExtensionId, false /* include_disabled */);
Devlin 2014/05/19 16:04:11 Hmm... does this compile? ExtensionRegistry::GetE
limasdf 2014/05/20 04:04:49 Done.
+ if (hotword_extension &&
+ hotword_extension.version()->CompareTo(
base::Version(kOldHotwordExtensionVersionString)) <= 0) {
StartPageService* service = StartPageService::Get(profile);
web_ui()->CallJavascriptFunction(
@@ -177,11 +172,9 @@ void StartPageHandler::HandleInitialize(const base::ListValue* args) {
prefs::kHotwordSearchEnabled,
base::Bind(&StartPageHandler::OnHotwordEnabledChanged,
base::Unretained(this)));
- registrar_.Add(this,
- chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
- content::Source<Profile>(profile));
- registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
- content::Source<Profile>(profile));
+
+ extension_registry_observer_.Add(
+ extensions::ExtensionRegistry::Get(profile));
}
#endif

Powered by Google App Engine
This is Rietveld 408576698