Chromium Code Reviews| 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/metrics_names.h" | |
| 9 #include "apps/pref_names.h" | 10 #include "apps/pref_names.h" |
| 10 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
| 11 #include "base/bind.h" | 12 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 13 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
| 14 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
| 15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 16 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/values.h" | 19 #include "base/values.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 base::Unretained(this))); | 206 base::Unretained(this))); |
| 206 web_ui()->RegisterMessageCallback("generateAppForLink", | 207 web_ui()->RegisterMessageCallback("generateAppForLink", |
| 207 base::Bind(&AppLauncherHandler::HandleGenerateAppForLink, | 208 base::Bind(&AppLauncherHandler::HandleGenerateAppForLink, |
| 208 base::Unretained(this))); | 209 base::Unretained(this))); |
| 209 web_ui()->RegisterMessageCallback("recordAppLaunchByURL", | 210 web_ui()->RegisterMessageCallback("recordAppLaunchByURL", |
| 210 base::Bind(&AppLauncherHandler::HandleRecordAppLaunchByUrl, | 211 base::Bind(&AppLauncherHandler::HandleRecordAppLaunchByUrl, |
| 211 base::Unretained(this))); | 212 base::Unretained(this))); |
| 212 web_ui()->RegisterMessageCallback("stopShowingAppLauncherPromo", | 213 web_ui()->RegisterMessageCallback("stopShowingAppLauncherPromo", |
| 213 base::Bind(&AppLauncherHandler::StopShowingAppLauncherPromo, | 214 base::Bind(&AppLauncherHandler::StopShowingAppLauncherPromo, |
| 214 base::Unretained(this))); | 215 base::Unretained(this))); |
| 216 web_ui()->RegisterMessageCallback("onLearnMore", | |
| 217 base::Bind(&AppLauncherHandler::OnLearnMore, | |
| 218 base::Unretained(this))); | |
| 215 } | 219 } |
| 216 | 220 |
| 217 void AppLauncherHandler::Observe(int type, | 221 void AppLauncherHandler::Observe(int type, |
| 218 const content::NotificationSource& source, | 222 const content::NotificationSource& source, |
| 219 const content::NotificationDetails& details) { | 223 const content::NotificationDetails& details) { |
| 220 if (type == chrome::NOTIFICATION_APP_INSTALLED_TO_NTP) { | 224 if (type == chrome::NOTIFICATION_APP_INSTALLED_TO_NTP) { |
| 221 highlight_app_id_ = *content::Details<const std::string>(details).ptr(); | 225 highlight_app_id_ = *content::Details<const std::string>(details).ptr(); |
| 222 if (has_loaded_apps_) | 226 if (has_loaded_apps_) |
| 223 SetAppToBeHighlighted(); | 227 SetAppToBeHighlighted(); |
| 224 return; | 228 return; |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 687 static_cast<extension_misc::AppLaunchBucket>(static_cast<int>(source)); | 691 static_cast<extension_misc::AppLaunchBucket>(static_cast<int>(source)); |
| 688 CHECK(source < extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); | 692 CHECK(source < extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); |
| 689 | 693 |
| 690 RecordAppLaunchByUrl(Profile::FromWebUI(web_ui()), url, bucket); | 694 RecordAppLaunchByUrl(Profile::FromWebUI(web_ui()), url, bucket); |
| 691 } | 695 } |
| 692 | 696 |
| 693 void AppLauncherHandler::StopShowingAppLauncherPromo( | 697 void AppLauncherHandler::StopShowingAppLauncherPromo( |
| 694 const base::ListValue* args) { | 698 const base::ListValue* args) { |
| 695 g_browser_process->local_state()->SetBoolean( | 699 g_browser_process->local_state()->SetBoolean( |
| 696 apps::prefs::kShowAppLauncherPromo, false); | 700 apps::prefs::kShowAppLauncherPromo, false); |
| 701 UMA_HISTOGRAM_ENUMERATION(apps::kAppLauncherPromoHistogram, | |
| 702 apps::APP_LAUNCHER_PROMO_DISMISSED, | |
| 703 apps::APP_LAUNCHER_PROMO_MAX); | |
|
Ilya Sherman
2013/06/25 21:35:15
I'd strongly recommend creating a method like apps
MAD
2013/06/26 03:33:40
Done.
| |
| 704 | |
| 705 } | |
| 706 | |
| 707 void AppLauncherHandler::OnLearnMore( | |
| 708 const base::ListValue* args) { | |
| 709 UMA_HISTOGRAM_ENUMERATION(apps::kAppLauncherPromoHistogram, | |
| 710 apps::APP_LAUNCHER_PROMO_LEARN_MORE, | |
| 711 apps::APP_LAUNCHER_PROMO_MAX); | |
| 712 | |
| 697 } | 713 } |
| 698 | 714 |
| 699 void AppLauncherHandler::OnFaviconForApp( | 715 void AppLauncherHandler::OnFaviconForApp( |
| 700 scoped_ptr<AppInstallInfo> install_info, | 716 scoped_ptr<AppInstallInfo> install_info, |
| 701 const chrome::FaviconImageResult& image_result) { | 717 const chrome::FaviconImageResult& image_result) { |
| 702 scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo()); | 718 scoped_ptr<WebApplicationInfo> web_app(new WebApplicationInfo()); |
| 703 web_app->is_bookmark_app = install_info->is_bookmark_app; | 719 web_app->is_bookmark_app = install_info->is_bookmark_app; |
| 704 web_app->title = install_info->title; | 720 web_app->title = install_info->title; |
| 705 web_app->app_url = install_info->app_url; | 721 web_app->app_url = install_info->app_url; |
| 706 web_app->urls.push_back(install_info->app_url); | 722 web_app->urls.push_back(install_info->app_url); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 874 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() { | 890 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() { |
| 875 if (!extension_uninstall_dialog_.get()) { | 891 if (!extension_uninstall_dialog_.get()) { |
| 876 Browser* browser = chrome::FindBrowserWithWebContents( | 892 Browser* browser = chrome::FindBrowserWithWebContents( |
| 877 web_ui()->GetWebContents()); | 893 web_ui()->GetWebContents()); |
| 878 extension_uninstall_dialog_.reset( | 894 extension_uninstall_dialog_.reset( |
| 879 ExtensionUninstallDialog::Create(extension_service_->profile(), | 895 ExtensionUninstallDialog::Create(extension_service_->profile(), |
| 880 browser, this)); | 896 browser, this)); |
| 881 } | 897 } |
| 882 return extension_uninstall_dialog_.get(); | 898 return extension_uninstall_dialog_.get(); |
| 883 } | 899 } |
| OLD | NEW |