| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
| 14 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
| 17 #include "base/string_split.h" | 17 #include "base/string_split.h" |
| 18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 20 #include "base/values.h" | 20 #include "base/values.h" |
| 21 #include "chrome/browser/extensions/app_notification.h" | 21 #include "chrome/browser/extensions/app_notification.h" |
| 22 #include "chrome/browser/extensions/app_notification_manager.h" | 22 #include "chrome/browser/extensions/app_notification_manager.h" |
| 23 #include "chrome/browser/extensions/crx_installer.h" | 23 #include "chrome/browser/extensions/crx_installer.h" |
| 24 #include "chrome/browser/extensions/extension_prefs.h" | 24 #include "chrome/browser/extensions/extension_prefs.h" |
| 25 #include "chrome/browser/extensions/extension_service.h" | 25 #include "chrome/browser/extensions/extension_service.h" |
| 26 #include "chrome/browser/extensions/extension_sorting.h" | 26 #include "chrome/browser/extensions/extension_sorting.h" |
| 27 #include "chrome/browser/extensions/extension_system.h" | 27 #include "chrome/browser/extensions/extension_system.h" |
| 28 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 28 #include "chrome/browser/prefs/pref_service.h" | 29 #include "chrome/browser/prefs/pref_service.h" |
| 29 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 30 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 30 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
| 31 #include "chrome/browser/ui/browser_finder.h" | 32 #include "chrome/browser/ui/browser_finder.h" |
| 32 #include "chrome/browser/ui/browser_tabstrip.h" | 33 #include "chrome/browser/ui/browser_tabstrip.h" |
| 33 #include "chrome/browser/ui/browser_window.h" | 34 #include "chrome/browser/ui/browser_window.h" |
| 34 #include "chrome/browser/ui/extensions/application_launch.h" | 35 #include "chrome/browser/ui/extensions/application_launch.h" |
| 35 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 36 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 36 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 37 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 37 #include "chrome/browser/ui/webui/web_ui_util.h" | 38 #include "chrome/browser/ui/webui/web_ui_util.h" |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 double page_index; | 685 double page_index; |
| 685 CHECK(args->GetDouble(2, &page_index)); | 686 CHECK(args->GetDouble(2, &page_index)); |
| 686 ExtensionSorting* extension_sorting = | 687 ExtensionSorting* extension_sorting = |
| 687 extension_service_->extension_prefs()->extension_sorting(); | 688 extension_service_->extension_prefs()->extension_sorting(); |
| 688 const StringOrdinal& page_ordinal = | 689 const StringOrdinal& page_ordinal = |
| 689 extension_sorting->PageIntegerAsStringOrdinal( | 690 extension_sorting->PageIntegerAsStringOrdinal( |
| 690 static_cast<size_t>(page_index)); | 691 static_cast<size_t>(page_index)); |
| 691 | 692 |
| 692 Profile* profile = Profile::FromWebUI(web_ui()); | 693 Profile* profile = Profile::FromWebUI(web_ui()); |
| 693 FaviconService* favicon_service = | 694 FaviconService* favicon_service = |
| 694 profile->GetFaviconService(Profile::EXPLICIT_ACCESS); | 695 FaviconServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); |
| 695 if (!favicon_service) { | 696 if (!favicon_service) { |
| 696 LOG(ERROR) << "No favicon service"; | 697 LOG(ERROR) << "No favicon service"; |
| 697 return; | 698 return; |
| 698 } | 699 } |
| 699 | 700 |
| 700 scoped_ptr<AppInstallInfo> install_info(new AppInstallInfo()); | 701 scoped_ptr<AppInstallInfo> install_info(new AppInstallInfo()); |
| 701 install_info->is_bookmark_app = true; | 702 install_info->is_bookmark_app = true; |
| 702 install_info->title = title; | 703 install_info->title = title; |
| 703 install_info->app_url = launch_url; | 704 install_info->app_url = launch_url; |
| 704 install_info->page_ordinal = page_ordinal; | 705 install_info->page_ordinal = page_ordinal; |
| 705 | 706 |
| 706 FaviconService::Handle h = favicon_service->GetFaviconForURL( | 707 FaviconService::Handle h = favicon_service->GetFaviconForURL( |
| 707 launch_url, history::FAVICON, &favicon_consumer_, | 708 profile, launch_url, history::FAVICON, &favicon_consumer_, |
| 708 base::Bind(&AppLauncherHandler::OnFaviconForApp, base::Unretained(this))); | 709 base::Bind(&AppLauncherHandler::OnFaviconForApp, base::Unretained(this))); |
| 709 favicon_consumer_.SetClientData(favicon_service, h, install_info.release()); | 710 favicon_consumer_.SetClientData(favicon_service, h, install_info.release()); |
| 710 } | 711 } |
| 711 | 712 |
| 712 void AppLauncherHandler::HandleRecordAppLaunchByUrl( | 713 void AppLauncherHandler::HandleRecordAppLaunchByUrl( |
| 713 const base::ListValue* args) { | 714 const base::ListValue* args) { |
| 714 std::string url; | 715 std::string url; |
| 715 CHECK(args->GetString(0, &url)); | 716 CHECK(args->GetString(0, &url)); |
| 716 double source; | 717 double source; |
| 717 CHECK(args->GetDouble(1, &source)); | 718 CHECK(args->GetDouble(1, &source)); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 | 941 |
| 941 ExtensionInstallPrompt* AppLauncherHandler::GetExtensionInstallPrompt() { | 942 ExtensionInstallPrompt* AppLauncherHandler::GetExtensionInstallPrompt() { |
| 942 if (!extension_install_ui_.get()) { | 943 if (!extension_install_ui_.get()) { |
| 943 Browser* browser = browser::FindBrowserWithWebContents( | 944 Browser* browser = browser::FindBrowserWithWebContents( |
| 944 web_ui()->GetWebContents()); | 945 web_ui()->GetWebContents()); |
| 945 extension_install_ui_.reset( | 946 extension_install_ui_.reset( |
| 946 chrome::CreateExtensionInstallPromptWithBrowser(browser)); | 947 chrome::CreateExtensionInstallPromptWithBrowser(browser)); |
| 947 } | 948 } |
| 948 return extension_install_ui_.get(); | 949 return extension_install_ui_.get(); |
| 949 } | 950 } |
| OLD | NEW |