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

Side by Side Diff: chrome/browser/ui/webui/ntp/app_launcher_handler.cc

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head for commit Created 8 years, 1 month 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 | Annotate | Revision Log
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 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" 5 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 HandleGetApps(NULL); 305 HandleGetApps(NULL);
306 } 306 }
307 break; 307 break;
308 } 308 }
309 // The promo may not load until a couple seconds after the first NTP view, 309 // The promo may not load until a couple seconds after the first NTP view,
310 // so we listen for the load notification and notify the NTP when ready. 310 // so we listen for the load notification and notify the NTP when ready.
311 case chrome::NOTIFICATION_WEB_STORE_PROMO_LOADED: 311 case chrome::NOTIFICATION_WEB_STORE_PROMO_LOADED:
312 // TODO(estade): Try to get rid of this inefficient operation. 312 // TODO(estade): Try to get rid of this inefficient operation.
313 HandleGetApps(NULL); 313 HandleGetApps(NULL);
314 break; 314 break;
315 case chrome::NOTIFICATION_PREF_CHANGED: {
316 DictionaryValue dictionary;
317 FillAppDictionary(&dictionary);
318 web_ui()->CallJavascriptFunction("ntp.appsPrefChangeCallback",
319 dictionary);
320 break;
321 }
322 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: { 315 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: {
323 CrxInstaller* crx_installer = content::Source<CrxInstaller>(source).ptr(); 316 CrxInstaller* crx_installer = content::Source<CrxInstaller>(source).ptr();
324 if (!Profile::FromWebUI(web_ui())->IsSameProfile( 317 if (!Profile::FromWebUI(web_ui())->IsSameProfile(
325 crx_installer->profile())) { 318 crx_installer->profile())) {
326 return; 319 return;
327 } 320 }
328 // Fall through. 321 // Fall through.
329 } 322 }
330 case chrome::NOTIFICATION_EXTENSION_LOAD_ERROR: { 323 case chrome::NOTIFICATION_EXTENSION_LOAD_ERROR: {
331 attempted_bookmark_app_install_ = false; 324 attempted_bookmark_app_install_ = false;
332 break; 325 break;
333 } 326 }
334 default: 327 default:
335 NOTREACHED(); 328 NOTREACHED();
336 } 329 }
337 } 330 }
338 331
332 void AppLauncherHandler::OnPreferenceChanged(PrefServiceBase* service,
333 const std::string& pref_name) {
334 DictionaryValue dictionary;
335 FillAppDictionary(&dictionary);
336 web_ui()->CallJavascriptFunction("ntp.appsPrefChangeCallback",
337 dictionary);
338 }
339
339 void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) { 340 void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) {
340 // CreateAppInfo and ClearOrdinals can change the extension prefs. 341 // CreateAppInfo and ClearOrdinals can change the extension prefs.
341 AutoReset<bool> auto_reset(&ignore_changes_, true); 342 AutoReset<bool> auto_reset(&ignore_changes_, true);
342 343
343 ListValue* list = new ListValue(); 344 ListValue* list = new ListValue();
344 345
345 for (std::set<std::string>::iterator it = visible_apps_.begin(); 346 for (std::set<std::string>::iterator it = visible_apps_.begin();
346 it != visible_apps_.end(); ++it) { 347 it != visible_apps_.end(); ++it) {
347 const Extension* extension = extension_service_->GetInstalledExtension(*it); 348 const Extension* extension = extension_service_->GetInstalledExtension(*it);
348 if (extension && extension->ShouldDisplayInLauncher()) { 349 if (extension && extension->ShouldDisplayInLauncher()) {
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 return extension_uninstall_dialog_.get(); 921 return extension_uninstall_dialog_.get();
921 } 922 }
922 923
923 ExtensionInstallPrompt* AppLauncherHandler::GetExtensionInstallPrompt() { 924 ExtensionInstallPrompt* AppLauncherHandler::GetExtensionInstallPrompt() {
924 if (!extension_install_ui_.get()) { 925 if (!extension_install_ui_.get()) {
925 extension_install_ui_.reset( 926 extension_install_ui_.reset(
926 new ExtensionInstallPrompt(web_ui()->GetWebContents())); 927 new ExtensionInstallPrompt(web_ui()->GetWebContents()));
927 } 928 }
928 return extension_install_ui_.get(); 929 return extension_install_ui_.get();
929 } 930 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/app_launcher_handler.h ('k') | chrome/browser/ui/webui/ntp/new_tab_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698