| OLD | NEW |
| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "apps/app_launcher.h" | 9 #include "apps/app_launcher.h" |
| 10 #include "apps/metrics_names.h" | 10 #include "apps/metrics_names.h" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 DictionaryValue app_info; | 310 DictionaryValue app_info; |
| 311 CreateAppInfo(extension, | 311 CreateAppInfo(extension, |
| 312 extension_service_, | 312 extension_service_, |
| 313 &app_info); | 313 &app_info); |
| 314 web_ui()->CallJavascriptFunction("ntp.appMoved", app_info); | 314 web_ui()->CallJavascriptFunction("ntp.appMoved", app_info); |
| 315 } else { | 315 } else { |
| 316 HandleGetApps(NULL); | 316 HandleGetApps(NULL); |
| 317 } | 317 } |
| 318 break; | 318 break; |
| 319 } | 319 } |
| 320 // The promo may not load until a couple seconds after the first NTP view, | |
| 321 // so we listen for the load notification and notify the NTP when ready. | |
| 322 case chrome::NOTIFICATION_WEB_STORE_PROMO_LOADED: | |
| 323 // TODO(estade): Try to get rid of this inefficient operation. | |
| 324 HandleGetApps(NULL); | |
| 325 break; | |
| 326 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: { | 320 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: { |
| 327 CrxInstaller* crx_installer = content::Source<CrxInstaller>(source).ptr(); | 321 CrxInstaller* crx_installer = content::Source<CrxInstaller>(source).ptr(); |
| 328 if (!Profile::FromWebUI(web_ui())->IsSameProfile( | 322 if (!Profile::FromWebUI(web_ui())->IsSameProfile( |
| 329 crx_installer->profile())) { | 323 crx_installer->profile())) { |
| 330 return; | 324 return; |
| 331 } | 325 } |
| 332 // Fall through. | 326 // Fall through. |
| 333 } | 327 } |
| 334 case chrome::NOTIFICATION_EXTENSION_LOAD_ERROR: { | 328 case chrome::NOTIFICATION_EXTENSION_LOAD_ERROR: { |
| 335 attempted_bookmark_app_install_ = false; | 329 attempted_bookmark_app_install_ = false; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 callback); | 441 callback); |
| 448 extension_pref_change_registrar_.Add(prefs::kNtpAppPageNames, callback); | 442 extension_pref_change_registrar_.Add(prefs::kNtpAppPageNames, callback); |
| 449 | 443 |
| 450 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 444 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 451 content::Source<Profile>(profile)); | 445 content::Source<Profile>(profile)); |
| 452 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 446 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 453 content::Source<Profile>(profile)); | 447 content::Source<Profile>(profile)); |
| 454 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, | 448 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, |
| 455 content::Source<ExtensionSorting>( | 449 content::Source<ExtensionSorting>( |
| 456 extension_service_->extension_prefs()->extension_sorting())); | 450 extension_service_->extension_prefs()->extension_sorting())); |
| 457 registrar_.Add(this, chrome::NOTIFICATION_WEB_STORE_PROMO_LOADED, | |
| 458 content::Source<Profile>(profile)); | |
| 459 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, | 451 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, |
| 460 content::Source<CrxInstaller>(NULL)); | 452 content::Source<CrxInstaller>(NULL)); |
| 461 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOAD_ERROR, | 453 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOAD_ERROR, |
| 462 content::Source<Profile>(profile)); | 454 content::Source<Profile>(profile)); |
| 463 } | 455 } |
| 464 | 456 |
| 465 has_loaded_apps_ = true; | 457 has_loaded_apps_ = true; |
| 466 } | 458 } |
| 467 | 459 |
| 468 void AppLauncherHandler::HandleLaunchApp(const ListValue* args) { | 460 void AppLauncherHandler::HandleLaunchApp(const ListValue* args) { |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() { | 816 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() { |
| 825 if (!extension_uninstall_dialog_.get()) { | 817 if (!extension_uninstall_dialog_.get()) { |
| 826 Browser* browser = chrome::FindBrowserWithWebContents( | 818 Browser* browser = chrome::FindBrowserWithWebContents( |
| 827 web_ui()->GetWebContents()); | 819 web_ui()->GetWebContents()); |
| 828 extension_uninstall_dialog_.reset( | 820 extension_uninstall_dialog_.reset( |
| 829 ExtensionUninstallDialog::Create(extension_service_->profile(), | 821 ExtensionUninstallDialog::Create(extension_service_->profile(), |
| 830 browser, this)); | 822 browser, this)); |
| 831 } | 823 } |
| 832 return extension_uninstall_dialog_.get(); | 824 return extension_uninstall_dialog_.get(); |
| 833 } | 825 } |
| OLD | NEW |