| 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" | |
| 17 #include "base/string_split.h" | |
| 18 #include "base/string_util.h" | |
| 19 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 20 #include "base/values.h" | 17 #include "base/values.h" |
| 21 #include "chrome/browser/extensions/app_notification.h" | 18 #include "chrome/browser/extensions/app_notification.h" |
| 22 #include "chrome/browser/extensions/app_notification_manager.h" | 19 #include "chrome/browser/extensions/app_notification_manager.h" |
| 23 #include "chrome/browser/extensions/crx_installer.h" | 20 #include "chrome/browser/extensions/crx_installer.h" |
| 24 #include "chrome/browser/extensions/extension_prefs.h" | 21 #include "chrome/browser/extensions/extension_prefs.h" |
| 25 #include "chrome/browser/extensions/extension_service.h" | 22 #include "chrome/browser/extensions/extension_service.h" |
| 26 #include "chrome/browser/extensions/extension_sorting.h" | 23 #include "chrome/browser/extensions/extension_sorting.h" |
| 27 #include "chrome/browser/extensions/extension_system.h" | 24 #include "chrome/browser/extensions/extension_system.h" |
| 28 #include "chrome/browser/favicon/favicon_service_factory.h" | 25 #include "chrome/browser/favicon/favicon_service_factory.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 44 #include "chrome/common/favicon_url.h" | 41 #include "chrome/common/favicon_url.h" |
| 45 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
| 46 #include "chrome/common/url_constants.h" | 43 #include "chrome/common/url_constants.h" |
| 47 #include "chrome/common/web_apps.h" | 44 #include "chrome/common/web_apps.h" |
| 48 #include "content/public/browser/notification_service.h" | 45 #include "content/public/browser/notification_service.h" |
| 49 #include "content/public/browser/web_ui.h" | 46 #include "content/public/browser/web_ui.h" |
| 50 #include "googleurl/src/gurl.h" | 47 #include "googleurl/src/gurl.h" |
| 51 #include "grit/browser_resources.h" | 48 #include "grit/browser_resources.h" |
| 52 #include "grit/generated_resources.h" | 49 #include "grit/generated_resources.h" |
| 53 #include "net/base/escape.h" | 50 #include "net/base/escape.h" |
| 54 #include "ui/base/animation/animation.h" | |
| 55 #include "ui/base/l10n/l10n_util.h" | 51 #include "ui/base/l10n/l10n_util.h" |
| 56 #include "ui/gfx/codec/png_codec.h" | |
| 57 #include "ui/gfx/favicon_size.h" | 52 #include "ui/gfx/favicon_size.h" |
| 58 | 53 |
| 59 using application_launch::LaunchParams; | 54 using application_launch::LaunchParams; |
| 60 using application_launch::OpenApplication; | 55 using application_launch::OpenApplication; |
| 61 using content::WebContents; | 56 using content::WebContents; |
| 62 using extensions::CrxInstaller; | 57 using extensions::CrxInstaller; |
| 63 using extensions::Extension; | 58 using extensions::Extension; |
| 64 using extensions::ExtensionPrefs; | 59 using extensions::ExtensionPrefs; |
| 65 | 60 |
| 66 namespace { | |
| 67 | |
| 68 const net::UnescapeRule::Type kUnescapeRules = | 61 const net::UnescapeRule::Type kUnescapeRules = |
| 69 net::UnescapeRule::NORMAL | net::UnescapeRule::URL_SPECIAL_CHARS; | 62 net::UnescapeRule::NORMAL | net::UnescapeRule::URL_SPECIAL_CHARS; |
| 70 | 63 |
| 71 extension_misc::AppLaunchBucket ParseLaunchSource( | |
| 72 const std::string& launch_source) { | |
| 73 int bucket_num = extension_misc::APP_LAUNCH_BUCKET_INVALID; | |
| 74 base::StringToInt(launch_source, &bucket_num); | |
| 75 extension_misc::AppLaunchBucket bucket = | |
| 76 static_cast<extension_misc::AppLaunchBucket>(bucket_num); | |
| 77 CHECK(bucket < extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); | |
| 78 return bucket; | |
| 79 } | |
| 80 | |
| 81 } // namespace | |
| 82 | |
| 83 AppLauncherHandler::AppInstallInfo::AppInstallInfo() {} | 64 AppLauncherHandler::AppInstallInfo::AppInstallInfo() {} |
| 84 | 65 |
| 85 AppLauncherHandler::AppInstallInfo::~AppInstallInfo() {} | 66 AppLauncherHandler::AppInstallInfo::~AppInstallInfo() {} |
| 86 | 67 |
| 87 AppLauncherHandler::AppLauncherHandler(ExtensionService* extension_service) | 68 AppLauncherHandler::AppLauncherHandler(ExtensionService* extension_service) |
| 88 : extension_service_(extension_service), | 69 : extension_service_(extension_service), |
| 89 ignore_changes_(false), | 70 ignore_changes_(false), |
| 90 attempted_bookmark_app_install_(false), | 71 attempted_bookmark_app_install_(false), |
| 91 has_loaded_apps_(false) { | 72 has_loaded_apps_(false) { |
| 92 } | 73 } |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 | 922 |
| 942 ExtensionInstallPrompt* AppLauncherHandler::GetExtensionInstallPrompt() { | 923 ExtensionInstallPrompt* AppLauncherHandler::GetExtensionInstallPrompt() { |
| 943 if (!extension_install_ui_.get()) { | 924 if (!extension_install_ui_.get()) { |
| 944 Browser* browser = browser::FindBrowserWithWebContents( | 925 Browser* browser = browser::FindBrowserWithWebContents( |
| 945 web_ui()->GetWebContents()); | 926 web_ui()->GetWebContents()); |
| 946 extension_install_ui_.reset( | 927 extension_install_ui_.reset( |
| 947 chrome::CreateExtensionInstallPromptWithBrowser(browser)); | 928 chrome::CreateExtensionInstallPromptWithBrowser(browser)); |
| 948 } | 929 } |
| 949 return extension_install_ui_.get(); | 930 return extension_install_ui_.get(); |
| 950 } | 931 } |
| OLD | NEW |