[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "chrome/browser/extensions/extension_install_prompt.h" |
| 6 | |
| 7 | #include <map> |
| 8 | |
| 9 | #include "base/command_line.h" |
[email protected] | b19fe57 | 2013-07-18 04:54:26 | [diff] [blame] | 10 | #include "base/message_loop/message_loop.h" |
[email protected] | 3853a4c | 2013-02-11 17:15:57 | [diff] [blame] | 11 | #include "base/prefs/pref_service.h" |
[email protected] | 3ea1b18 | 2013-02-08 22:38:41 | [diff] [blame] | 12 | #include "base/strings/string_number_conversions.h" |
[email protected] | 00e7bef | 2013-06-10 20:35:17 | [diff] [blame] | 13 | #include "base/strings/string_util.h" |
| 14 | #include "base/strings/stringprintf.h" |
[email protected] | 112158af | 2013-06-07 23:46:18 | [diff] [blame] | 15 | #include "base/strings/utf_string_conversions.h" |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 16 | #include "chrome/browser/extensions/bundle_installer.h" |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 17 | #include "chrome/browser/extensions/extension_install_ui.h" |
[email protected] | 7eb20e3 | 2014-04-30 08:50:56 | [diff] [blame] | 18 | #include "chrome/browser/extensions/extension_util.h" |
[email protected] | ec7de0c5a | 2012-11-16 07:40:47 | [diff] [blame] | 19 | #include "chrome/browser/extensions/image_loader.h" |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 20 | #include "chrome/browser/profiles/profile.h" |
[email protected] | 4f3fb35 | 2013-07-17 04:07:01 | [diff] [blame] | 21 | #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
[email protected] | 32fc4ff7 | 2012-06-15 21:50:01 | [diff] [blame] | 22 | #include "chrome/browser/ui/browser.h" |
[email protected] | 619f8618 | 2012-07-03 21:30:18 | [diff] [blame] | 23 | #include "chrome/browser/ui/browser_window.h" |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 24 | #include "chrome/common/chrome_switches.h" |
[email protected] | 29e0c4e7 | 2013-02-01 04:42:56 | [diff] [blame] | 25 | #include "chrome/common/extensions/api/identity/oauth2_manifest_handler.h" |
[email protected] | fc507794 | 2012-08-15 21:37:59 | [diff] [blame] | 26 | #include "chrome/common/pref_names.h" |
[email protected] | 7274ef0 | 2014-03-24 22:43:40 | [diff] [blame] | 27 | #include "components/signin/core/browser/profile_oauth2_token_service.h" |
[email protected] | 91e51d61 | 2012-10-21 23:03:05 | [diff] [blame] | 28 | #include "content/public/browser/web_contents.h" |
[email protected] | 21db9ef | 2014-05-16 02:06:27 | [diff] [blame] | 29 | #include "extensions/browser/extension_prefs.h" |
[email protected] | 411f8ae | 2014-05-22 11:12:23 | [diff] [blame^] | 30 | #include "extensions/browser/extension_util.h" |
[email protected] | cda103d | 2014-04-04 16:22:39 | [diff] [blame] | 31 | #include "extensions/common/constants.h" |
[email protected] | e4452d3 | 2013-11-15 23:07:41 | [diff] [blame] | 32 | #include "extensions/common/extension.h" |
[email protected] | 4b790884 | 2014-04-07 23:50:22 | [diff] [blame] | 33 | #include "extensions/common/extension_icon_set.h" |
[email protected] | 993da5e | 2013-03-23 21:25:16 | [diff] [blame] | 34 | #include "extensions/common/extension_resource.h" |
[email protected] | 5ef835a | 2013-11-08 20:42:57 | [diff] [blame] | 35 | #include "extensions/common/feature_switch.h" |
[email protected] | d42c1115 | 2013-08-22 19:36:32 | [diff] [blame] | 36 | #include "extensions/common/manifest.h" |
[email protected] | 6bf9061 | 2013-08-15 00:36:27 | [diff] [blame] | 37 | #include "extensions/common/manifest_constants.h" |
[email protected] | 0db486f | 2014-04-09 19:32:22 | [diff] [blame] | 38 | #include "extensions/common/manifest_handlers/icons_handler.h" |
[email protected] | c4100347 | 2013-10-19 15:37:25 | [diff] [blame] | 39 | #include "extensions/common/permissions/permission_message_provider.h" |
[email protected] | 5a55f3f | 2013-10-29 01:08:29 | [diff] [blame] | 40 | #include "extensions/common/permissions/permission_set.h" |
[email protected] | e4452d3 | 2013-11-15 23:07:41 | [diff] [blame] | 41 | #include "extensions/common/permissions/permissions_data.h" |
[email protected] | 885c0e9 | 2012-11-13 20:27:42 | [diff] [blame] | 42 | #include "extensions/common/url_pattern.h" |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 43 | #include "grit/chromium_strings.h" |
| 44 | #include "grit/generated_resources.h" |
[email protected] | 2a28133 | 2012-07-11 22:20:23 | [diff] [blame] | 45 | #include "grit/theme_resources.h" |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 46 | #include "ui/base/l10n/l10n_util.h" |
| 47 | #include "ui/base/resource/resource_bundle.h" |
| 48 | #include "ui/gfx/image/image.h" |
| 49 | |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 50 | using extensions::BundleInstaller; |
| 51 | using extensions::Extension; |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 52 | using extensions::Manifest; |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 53 | using extensions::PermissionSet; |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 54 | |
[email protected] | 612a1cb1 | 2012-10-17 13:18:03 | [diff] [blame] | 55 | namespace { |
| 56 | |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 57 | static const int kTitleIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = { |
[email protected] | 21db9ef | 2014-05-16 02:06:27 | [diff] [blame] | 58 | 0, // The regular install prompt depends on what's being installed. |
| 59 | IDS_EXTENSION_INLINE_INSTALL_PROMPT_TITLE, |
| 60 | IDS_EXTENSION_INSTALL_PROMPT_TITLE, |
| 61 | IDS_EXTENSION_RE_ENABLE_PROMPT_TITLE, |
| 62 | IDS_EXTENSION_PERMISSIONS_PROMPT_TITLE, |
| 63 | IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_TITLE, |
| 64 | IDS_EXTENSION_POST_INSTALL_PERMISSIONS_PROMPT_TITLE, |
| 65 | IDS_EXTENSION_LAUNCH_APP_PROMPT_TITLE, |
| 66 | 0, // The remote install prompt depends on what's being installed. |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 67 | }; |
| 68 | static const int kHeadingIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = { |
[email protected] | 21db9ef | 2014-05-16 02:06:27 | [diff] [blame] | 69 | IDS_EXTENSION_INSTALL_PROMPT_HEADING, |
| 70 | 0, // Inline installs use the extension name. |
| 71 | 0, // Heading for bundle installs depends on the bundle contents. |
| 72 | IDS_EXTENSION_RE_ENABLE_PROMPT_HEADING, |
| 73 | IDS_EXTENSION_PERMISSIONS_PROMPT_HEADING, |
| 74 | 0, // External installs use different strings for extensions/apps. |
| 75 | IDS_EXTENSION_POST_INSTALL_PERMISSIONS_PROMPT_HEADING, |
| 76 | IDS_EXTENSION_LAUNCH_APP_PROMPT_HEADING, |
| 77 | IDS_EXTENSION_REMOTE_INSTALL_PROMPT_HEADING, |
[email protected] | 15d267b4 | 2013-02-14 23:43:32 | [diff] [blame] | 78 | }; |
| 79 | static const int kButtons[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = { |
[email protected] | 21db9ef | 2014-05-16 02:06:27 | [diff] [blame] | 80 | ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL, |
| 81 | ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL, |
| 82 | ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL, |
| 83 | ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL, |
| 84 | ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL, |
| 85 | ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL, |
| 86 | ui::DIALOG_BUTTON_CANCEL, |
| 87 | ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL, |
| 88 | ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL, |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 89 | }; |
| 90 | static const int kAcceptButtonIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = { |
[email protected] | 21db9ef | 2014-05-16 02:06:27 | [diff] [blame] | 91 | IDS_EXTENSION_PROMPT_INSTALL_BUTTON, |
| 92 | IDS_EXTENSION_PROMPT_INSTALL_BUTTON, |
| 93 | IDS_EXTENSION_PROMPT_INSTALL_BUTTON, |
| 94 | IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON, |
| 95 | IDS_EXTENSION_PROMPT_PERMISSIONS_BUTTON, |
| 96 | 0, // External installs use different strings for extensions/apps. |
| 97 | IDS_EXTENSION_PROMPT_PERMISSIONS_CLEAR_RETAINED_FILES_BUTTON, |
| 98 | IDS_EXTENSION_PROMPT_LAUNCH_BUTTON, |
| 99 | IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON, |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 100 | }; |
| 101 | static const int kAbortButtonIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = { |
[email protected] | 21db9ef | 2014-05-16 02:06:27 | [diff] [blame] | 102 | 0, // These all use the platform's default cancel label. |
| 103 | 0, |
| 104 | 0, |
| 105 | 0, |
| 106 | IDS_EXTENSION_PROMPT_PERMISSIONS_ABORT_BUTTON, |
| 107 | IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ABORT_BUTTON, |
| 108 | IDS_CLOSE, |
| 109 | 0, // Platform dependent cancel button. |
| 110 | 0, |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 111 | }; |
[email protected] | 21db9ef | 2014-05-16 02:06:27 | [diff] [blame] | 112 | static const int |
| 113 | kPermissionsHeaderIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = { |
| 114 | IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, |
| 115 | IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, |
| 116 | IDS_EXTENSION_PROMPT_THESE_WILL_HAVE_ACCESS_TO, |
| 117 | IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO, |
| 118 | IDS_EXTENSION_PROMPT_WANTS_ACCESS_TO, |
| 119 | IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, |
| 120 | IDS_EXTENSION_PROMPT_CAN_ACCESS, |
| 121 | IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, |
| 122 | IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 123 | }; |
[email protected] | 612a1cb1 | 2012-10-17 13:18:03 | [diff] [blame] | 124 | static const int kOAuthHeaderIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = { |
[email protected] | 21db9ef | 2014-05-16 02:06:27 | [diff] [blame] | 125 | IDS_EXTENSION_PROMPT_OAUTH_HEADER, |
| 126 | 0, // Inline installs don't show OAuth permissions. |
| 127 | 0, // Bundle installs don't show OAuth permissions. |
| 128 | IDS_EXTENSION_PROMPT_OAUTH_REENABLE_HEADER, |
| 129 | IDS_EXTENSION_PROMPT_OAUTH_PERMISSIONS_HEADER, |
| 130 | 0, |
| 131 | 0, |
| 132 | IDS_EXTENSION_PROMPT_OAUTH_HEADER, |
| 133 | IDS_EXTENSION_PROMPT_OAUTH_HEADER, |
[email protected] | fc507794 | 2012-08-15 21:37:59 | [diff] [blame] | 134 | }; |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 135 | |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 136 | // Size of extension icon in top left of dialog. |
| 137 | const int kIconSize = 69; |
| 138 | |
[email protected] | dd46a4ce | 2012-09-15 10:50:50 | [diff] [blame] | 139 | // Returns pixel size under maximal scale factor for the icon whose device |
| 140 | // independent size is |size_in_dip| |
| 141 | int GetSizeForMaxScaleFactor(int size_in_dip) { |
[email protected] | 50b6626 | 2013-09-24 03:25:48 | [diff] [blame] | 142 | return static_cast<int>(size_in_dip * gfx::ImageSkia::GetMaxSupportedScale()); |
[email protected] | dd46a4ce | 2012-09-15 10:50:50 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | // Returns bitmap for the default icon with size equal to the default icon's |
| 146 | // pixel size under maximal supported scale factor. |
| 147 | SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { |
[email protected] | 702d8b4 | 2013-02-27 20:55:50 | [diff] [blame] | 148 | const gfx::ImageSkia& image = is_app ? |
[email protected] | 7eb20e3 | 2014-04-30 08:50:56 | [diff] [blame] | 149 | extensions::util::GetDefaultAppIcon() : |
| 150 | extensions::util::GetDefaultExtensionIcon(); |
[email protected] | 50b6626 | 2013-09-24 03:25:48 | [diff] [blame] | 151 | return image.GetRepresentation( |
| 152 | gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap(); |
[email protected] | dd46a4ce | 2012-09-15 10:50:50 | [diff] [blame] | 153 | } |
| 154 | |
[email protected] | af6efb2 | 2012-10-12 02:23:05 | [diff] [blame] | 155 | // If auto confirm is enabled then posts a task to proceed with or cancel the |
| 156 | // install and returns true. Otherwise returns false. |
| 157 | bool AutoConfirmPrompt(ExtensionInstallPrompt::Delegate* delegate) { |
| 158 | const CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
| 159 | if (!cmdline->HasSwitch(switches::kAppsGalleryInstallAutoConfirmForTests)) |
| 160 | return false; |
| 161 | std::string value = cmdline->GetSwitchValueASCII( |
| 162 | switches::kAppsGalleryInstallAutoConfirmForTests); |
| 163 | |
| 164 | // We use PostTask instead of calling the delegate directly here, because in |
| 165 | // the real implementations it's highly likely the message loop will be |
| 166 | // pumping a few times before the user clicks accept or cancel. |
| 167 | if (value == "accept") { |
[email protected] | b3a2509 | 2013-05-28 22:08:16 | [diff] [blame] | 168 | base::MessageLoop::current()->PostTask( |
[email protected] | af6efb2 | 2012-10-12 02:23:05 | [diff] [blame] | 169 | FROM_HERE, |
| 170 | base::Bind(&ExtensionInstallPrompt::Delegate::InstallUIProceed, |
| 171 | base::Unretained(delegate))); |
| 172 | return true; |
| 173 | } |
| 174 | |
| 175 | if (value == "cancel") { |
[email protected] | b3a2509 | 2013-05-28 22:08:16 | [diff] [blame] | 176 | base::MessageLoop::current()->PostTask( |
[email protected] | af6efb2 | 2012-10-12 02:23:05 | [diff] [blame] | 177 | FROM_HERE, |
| 178 | base::Bind(&ExtensionInstallPrompt::Delegate::InstallUIAbort, |
| 179 | base::Unretained(delegate), |
| 180 | true)); |
| 181 | return true; |
| 182 | } |
| 183 | |
| 184 | NOTREACHED(); |
| 185 | return false; |
| 186 | } |
| 187 | |
[email protected] | 91e51d61 | 2012-10-21 23:03:05 | [diff] [blame] | 188 | Profile* ProfileForWebContents(content::WebContents* web_contents) { |
| 189 | if (!web_contents) |
| 190 | return NULL; |
| 191 | return Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 192 | } |
| 193 | |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 194 | gfx::NativeWindow NativeWindowForWebContents(content::WebContents* contents) { |
| 195 | if (!contents) |
| 196 | return NULL; |
| 197 | |
[email protected] | fc2b46b | 2014-05-03 16:33:45 | [diff] [blame] | 198 | return contents->GetTopLevelNativeWindow(); |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 199 | } |
| 200 | |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 201 | } // namespace |
| 202 | |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 203 | ExtensionInstallPrompt::Prompt::Prompt(PromptType type) |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 204 | : type_(type), |
[email protected] | 79a6f99a | 2013-08-29 00:32:58 | [diff] [blame] | 205 | is_showing_details_for_retained_files_(false), |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 206 | extension_(NULL), |
| 207 | bundle_(NULL), |
| 208 | average_rating_(0.0), |
[email protected] | dcde34b3 | 2013-07-31 02:28:45 | [diff] [blame] | 209 | rating_count_(0), |
[email protected] | 34b5f7f | 2014-01-29 02:48:11 | [diff] [blame] | 210 | show_user_count_(false), |
| 211 | has_webstore_data_(false) { |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | ExtensionInstallPrompt::Prompt::~Prompt() { |
| 215 | } |
| 216 | |
| 217 | void ExtensionInstallPrompt::Prompt::SetPermissions( |
[email protected] | d2065e06 | 2013-12-12 23:49:52 | [diff] [blame] | 218 | const std::vector<base::string16>& permissions) { |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 219 | permissions_ = permissions; |
| 220 | } |
| 221 | |
[email protected] | 8ab7e6c | 2013-07-11 21:15:03 | [diff] [blame] | 222 | void ExtensionInstallPrompt::Prompt::SetPermissionsDetails( |
[email protected] | d2065e06 | 2013-12-12 23:49:52 | [diff] [blame] | 223 | const std::vector<base::string16>& details) { |
[email protected] | 8ab7e6c | 2013-07-11 21:15:03 | [diff] [blame] | 224 | details_ = details; |
[email protected] | 79a6f99a | 2013-08-29 00:32:58 | [diff] [blame] | 225 | is_showing_details_for_permissions_.clear(); |
| 226 | for (size_t i = 0; i < details.size(); ++i) |
| 227 | is_showing_details_for_permissions_.push_back(false); |
| 228 | } |
| 229 | |
| 230 | void ExtensionInstallPrompt::Prompt::SetIsShowingDetails( |
| 231 | DetailsType type, |
| 232 | size_t index, |
| 233 | bool is_showing_details) { |
| 234 | switch (type) { |
| 235 | case PERMISSIONS_DETAILS: |
| 236 | is_showing_details_for_permissions_[index] = is_showing_details; |
| 237 | break; |
| 238 | case OAUTH_DETAILS: |
| 239 | is_showing_details_for_oauth_[index] = is_showing_details; |
| 240 | break; |
| 241 | case RETAINED_FILES_DETAILS: |
| 242 | is_showing_details_for_retained_files_ = is_showing_details; |
| 243 | break; |
| 244 | } |
[email protected] | 8ab7e6c | 2013-07-11 21:15:03 | [diff] [blame] | 245 | } |
| 246 | |
[email protected] | b70a2d9 | 2012-06-28 19:51:21 | [diff] [blame] | 247 | void ExtensionInstallPrompt::Prompt::SetOAuthIssueAdvice( |
| 248 | const IssueAdviceInfo& issue_advice) { |
[email protected] | 79a6f99a | 2013-08-29 00:32:58 | [diff] [blame] | 249 | is_showing_details_for_oauth_.clear(); |
| 250 | for (size_t i = 0; i < issue_advice.size(); ++i) |
| 251 | is_showing_details_for_oauth_.push_back(false); |
| 252 | |
[email protected] | b70a2d9 | 2012-06-28 19:51:21 | [diff] [blame] | 253 | oauth_issue_advice_ = issue_advice; |
| 254 | } |
| 255 | |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 256 | void ExtensionInstallPrompt::Prompt::SetUserNameFromProfile(Profile* profile) { |
| 257 | // |profile| can be NULL in unit tests. |
| 258 | if (profile) { |
[email protected] | 0433872 | 2013-12-24 23:18:05 | [diff] [blame] | 259 | oauth_user_name_ = base::UTF8ToUTF16(profile->GetPrefs()->GetString( |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 260 | prefs::kGoogleServicesUsername)); |
| 261 | } else { |
| 262 | oauth_user_name_.clear(); |
| 263 | } |
| 264 | } |
| 265 | |
[email protected] | 34b5f7f | 2014-01-29 02:48:11 | [diff] [blame] | 266 | void ExtensionInstallPrompt::Prompt::SetWebstoreData( |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 267 | const std::string& localized_user_count, |
[email protected] | dcde34b3 | 2013-07-31 02:28:45 | [diff] [blame] | 268 | bool show_user_count, |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 269 | double average_rating, |
| 270 | int rating_count) { |
[email protected] | 34b5f7f | 2014-01-29 02:48:11 | [diff] [blame] | 271 | CHECK(type_ == INLINE_INSTALL_PROMPT || type_ == EXTERNAL_INSTALL_PROMPT); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 272 | localized_user_count_ = localized_user_count; |
[email protected] | dcde34b3 | 2013-07-31 02:28:45 | [diff] [blame] | 273 | show_user_count_ = show_user_count; |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 274 | average_rating_ = average_rating; |
| 275 | rating_count_ = rating_count; |
[email protected] | 34b5f7f | 2014-01-29 02:48:11 | [diff] [blame] | 276 | has_webstore_data_ = true; |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 277 | } |
| 278 | |
[email protected] | 6a72a63 | 2013-12-12 22:22:00 | [diff] [blame] | 279 | base::string16 ExtensionInstallPrompt::Prompt::GetDialogTitle() const { |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 280 | int resource_id = kTitleIds[type_]; |
| 281 | |
| 282 | if (type_ == INSTALL_PROMPT) { |
| 283 | if (extension_->is_app()) |
| 284 | resource_id = IDS_EXTENSION_INSTALL_APP_PROMPT_TITLE; |
| 285 | else if (extension_->is_theme()) |
| 286 | resource_id = IDS_EXTENSION_INSTALL_THEME_PROMPT_TITLE; |
| 287 | else |
| 288 | resource_id = IDS_EXTENSION_INSTALL_EXTENSION_PROMPT_TITLE; |
[email protected] | 612a1cb1 | 2012-10-17 13:18:03 | [diff] [blame] | 289 | } else if (type_ == EXTERNAL_INSTALL_PROMPT) { |
| 290 | return l10n_util::GetStringFUTF16( |
[email protected] | 0433872 | 2013-12-24 23:18:05 | [diff] [blame] | 291 | resource_id, base::UTF8ToUTF16(extension_->name())); |
[email protected] | 21db9ef | 2014-05-16 02:06:27 | [diff] [blame] | 292 | } else if (type_ == REMOTE_INSTALL_PROMPT) { |
| 293 | if (extension_->is_app()) |
| 294 | resource_id = IDS_EXTENSION_REMOTE_INSTALL_APP_PROMPT_TITLE; |
| 295 | else |
| 296 | resource_id = IDS_EXTENSION_REMOTE_INSTALL_EXTENSION_PROMPT_TITLE; |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | return l10n_util::GetStringUTF16(resource_id); |
| 300 | } |
| 301 | |
[email protected] | 6a72a63 | 2013-12-12 22:22:00 | [diff] [blame] | 302 | base::string16 ExtensionInstallPrompt::Prompt::GetHeading() const { |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 303 | if (type_ == INLINE_INSTALL_PROMPT) { |
[email protected] | 0433872 | 2013-12-24 23:18:05 | [diff] [blame] | 304 | return base::UTF8ToUTF16(extension_->name()); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 305 | } else if (type_ == BUNDLE_INSTALL_PROMPT) { |
| 306 | return bundle_->GetHeadingTextFor(BundleInstaller::Item::STATE_PENDING); |
[email protected] | 612a1cb1 | 2012-10-17 13:18:03 | [diff] [blame] | 307 | } else if (type_ == EXTERNAL_INSTALL_PROMPT) { |
[email protected] | 84660601 | 2012-10-19 18:42:25 | [diff] [blame] | 308 | int resource_id = -1; |
| 309 | if (extension_->is_app()) |
| 310 | resource_id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_HEADING_APP; |
| 311 | else if (extension_->is_theme()) |
| 312 | resource_id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_HEADING_THEME; |
| 313 | else |
| 314 | resource_id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_HEADING_EXTENSION; |
| 315 | return l10n_util::GetStringUTF16(resource_id); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 316 | } else { |
| 317 | return l10n_util::GetStringFUTF16( |
[email protected] | 0433872 | 2013-12-24 23:18:05 | [diff] [blame] | 318 | kHeadingIds[type_], base::UTF8ToUTF16(extension_->name())); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 319 | } |
| 320 | } |
| 321 | |
[email protected] | 15d267b4 | 2013-02-14 23:43:32 | [diff] [blame] | 322 | int ExtensionInstallPrompt::Prompt::GetDialogButtons() const { |
[email protected] | a2886e8b | 2013-06-08 05:15:02 | [diff] [blame] | 323 | if (type_ == POST_INSTALL_PERMISSIONS_PROMPT && |
| 324 | ShouldDisplayRevokeFilesButton()) { |
| 325 | return kButtons[type_] | ui::DIALOG_BUTTON_OK; |
| 326 | } |
| 327 | |
[email protected] | 15d267b4 | 2013-02-14 23:43:32 | [diff] [blame] | 328 | return kButtons[type_]; |
| 329 | } |
| 330 | |
[email protected] | 62a28d7c | 2013-12-28 01:34:49 | [diff] [blame] | 331 | bool ExtensionInstallPrompt::Prompt::ShouldShowExplanationText() const { |
| 332 | return type_ == INSTALL_PROMPT && |
| 333 | extension_->is_extension() && experiment_ && experiment_->text_only(); |
| 334 | } |
| 335 | |
[email protected] | 15d267b4 | 2013-02-14 23:43:32 | [diff] [blame] | 336 | bool ExtensionInstallPrompt::Prompt::HasAcceptButtonLabel() const { |
[email protected] | a2886e8b | 2013-06-08 05:15:02 | [diff] [blame] | 337 | if (kAcceptButtonIds[type_] == 0) |
| 338 | return false; |
| 339 | |
| 340 | if (type_ == POST_INSTALL_PERMISSIONS_PROMPT) |
| 341 | return ShouldDisplayRevokeFilesButton(); |
| 342 | |
| 343 | return true; |
[email protected] | 15d267b4 | 2013-02-14 23:43:32 | [diff] [blame] | 344 | } |
| 345 | |
[email protected] | 6a72a63 | 2013-12-12 22:22:00 | [diff] [blame] | 346 | base::string16 ExtensionInstallPrompt::Prompt::GetAcceptButtonLabel() const { |
[email protected] | 84660601 | 2012-10-19 18:42:25 | [diff] [blame] | 347 | if (type_ == EXTERNAL_INSTALL_PROMPT) { |
| 348 | int id = -1; |
| 349 | if (extension_->is_app()) |
| 350 | id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_APP; |
| 351 | else if (extension_->is_theme()) |
| 352 | id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_THEME; |
| 353 | else |
| 354 | id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_EXTENSION; |
| 355 | return l10n_util::GetStringUTF16(id); |
| 356 | } |
[email protected] | 62a28d7c | 2013-12-28 01:34:49 | [diff] [blame] | 357 | if (ShouldShowExplanationText()) |
| 358 | return experiment_->GetOkButtonText(); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 359 | return l10n_util::GetStringUTF16(kAcceptButtonIds[type_]); |
| 360 | } |
| 361 | |
| 362 | bool ExtensionInstallPrompt::Prompt::HasAbortButtonLabel() const { |
[email protected] | 62a28d7c | 2013-12-28 01:34:49 | [diff] [blame] | 363 | if (ShouldShowExplanationText()) |
| 364 | return true; |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 365 | return kAbortButtonIds[type_] > 0; |
| 366 | } |
| 367 | |
[email protected] | 6a72a63 | 2013-12-12 22:22:00 | [diff] [blame] | 368 | base::string16 ExtensionInstallPrompt::Prompt::GetAbortButtonLabel() const { |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 369 | CHECK(HasAbortButtonLabel()); |
[email protected] | 62a28d7c | 2013-12-28 01:34:49 | [diff] [blame] | 370 | if (ShouldShowExplanationText()) |
| 371 | return experiment_->GetCancelButtonText(); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 372 | return l10n_util::GetStringUTF16(kAbortButtonIds[type_]); |
| 373 | } |
| 374 | |
[email protected] | 6a72a63 | 2013-12-12 22:22:00 | [diff] [blame] | 375 | base::string16 ExtensionInstallPrompt::Prompt::GetPermissionsHeading() const { |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 376 | return l10n_util::GetStringUTF16(kPermissionsHeaderIds[type_]); |
| 377 | } |
| 378 | |
[email protected] | 6a72a63 | 2013-12-12 22:22:00 | [diff] [blame] | 379 | base::string16 ExtensionInstallPrompt::Prompt::GetOAuthHeading() const { |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 380 | return l10n_util::GetStringFUTF16(kOAuthHeaderIds[type_], oauth_user_name_); |
[email protected] | 813475e | 2012-07-02 23:54:18 | [diff] [blame] | 381 | } |
| 382 | |
[email protected] | 6a72a63 | 2013-12-12 22:22:00 | [diff] [blame] | 383 | base::string16 ExtensionInstallPrompt::Prompt::GetRetainedFilesHeading() const { |
[email protected] | 4f1e108 | 2013-09-23 10:30:53 | [diff] [blame] | 384 | const int kRetainedFilesMessageIDs[6] = { |
| 385 | IDS_EXTENSION_PROMPT_RETAINED_FILES_DEFAULT, |
| 386 | IDS_EXTENSION_PROMPT_RETAINED_FILE_SINGULAR, |
| 387 | IDS_EXTENSION_PROMPT_RETAINED_FILES_ZERO, |
| 388 | IDS_EXTENSION_PROMPT_RETAINED_FILES_TWO, |
| 389 | IDS_EXTENSION_PROMPT_RETAINED_FILES_FEW, |
| 390 | IDS_EXTENSION_PROMPT_RETAINED_FILES_MANY, |
| 391 | }; |
| 392 | std::vector<int> message_ids; |
| 393 | for (size_t i = 0; i < arraysize(kRetainedFilesMessageIDs); i++) { |
| 394 | message_ids.push_back(kRetainedFilesMessageIDs[i]); |
| 395 | } |
| 396 | return l10n_util::GetPluralStringFUTF16(message_ids, GetRetainedFileCount()); |
[email protected] | 8ab7e6c | 2013-07-11 21:15:03 | [diff] [blame] | 397 | } |
| 398 | |
[email protected] | f2cd899 | 2013-06-11 17:30:18 | [diff] [blame] | 399 | bool ExtensionInstallPrompt::Prompt::ShouldShowPermissions() const { |
| 400 | return GetPermissionCount() > 0 || type_ == POST_INSTALL_PERMISSIONS_PROMPT; |
| 401 | } |
| 402 | |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 403 | void ExtensionInstallPrompt::Prompt::AppendRatingStars( |
| 404 | StarAppender appender, void* data) const { |
| 405 | CHECK(appender); |
[email protected] | 34b5f7f | 2014-01-29 02:48:11 | [diff] [blame] | 406 | CHECK(type_ == INLINE_INSTALL_PROMPT || type_ == EXTERNAL_INSTALL_PROMPT); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 407 | int rating_integer = floor(average_rating_); |
| 408 | double rating_fractional = average_rating_ - rating_integer; |
| 409 | |
| 410 | if (rating_fractional > 0.66) { |
| 411 | rating_integer++; |
| 412 | } |
| 413 | |
| 414 | if (rating_fractional < 0.33 || rating_fractional > 0.66) { |
| 415 | rating_fractional = 0; |
| 416 | } |
| 417 | |
| 418 | ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 419 | int i; |
| 420 | for (i = 0; i < rating_integer; i++) { |
| 421 | appender(rb.GetImageSkiaNamed(IDR_EXTENSIONS_RATING_STAR_ON), data); |
| 422 | } |
| 423 | if (rating_fractional) { |
| 424 | appender(rb.GetImageSkiaNamed(IDR_EXTENSIONS_RATING_STAR_HALF_LEFT), data); |
| 425 | i++; |
| 426 | } |
| 427 | for (; i < kMaxExtensionRating; i++) { |
| 428 | appender(rb.GetImageSkiaNamed(IDR_EXTENSIONS_RATING_STAR_OFF), data); |
| 429 | } |
| 430 | } |
| 431 | |
[email protected] | 6a72a63 | 2013-12-12 22:22:00 | [diff] [blame] | 432 | base::string16 ExtensionInstallPrompt::Prompt::GetRatingCount() const { |
[email protected] | 34b5f7f | 2014-01-29 02:48:11 | [diff] [blame] | 433 | CHECK(type_ == INLINE_INSTALL_PROMPT || type_ == EXTERNAL_INSTALL_PROMPT); |
[email protected] | 6725048e | 2013-10-24 21:47:14 | [diff] [blame] | 434 | return l10n_util::GetStringFUTF16(IDS_EXTENSION_RATING_COUNT, |
| 435 | base::IntToString16(rating_count_)); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 436 | } |
| 437 | |
[email protected] | 6a72a63 | 2013-12-12 22:22:00 | [diff] [blame] | 438 | base::string16 ExtensionInstallPrompt::Prompt::GetUserCount() const { |
[email protected] | 34b5f7f | 2014-01-29 02:48:11 | [diff] [blame] | 439 | CHECK(type_ == INLINE_INSTALL_PROMPT || type_ == EXTERNAL_INSTALL_PROMPT); |
[email protected] | dcde34b3 | 2013-07-31 02:28:45 | [diff] [blame] | 440 | |
| 441 | if (show_user_count_) { |
[email protected] | 6725048e | 2013-10-24 21:47:14 | [diff] [blame] | 442 | return l10n_util::GetStringFUTF16(IDS_EXTENSION_USER_COUNT, |
| 443 | base::UTF8ToUTF16(localized_user_count_)); |
[email protected] | dcde34b3 | 2013-07-31 02:28:45 | [diff] [blame] | 444 | } |
[email protected] | 6725048e | 2013-10-24 21:47:14 | [diff] [blame] | 445 | return base::string16(); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | size_t ExtensionInstallPrompt::Prompt::GetPermissionCount() const { |
| 449 | return permissions_.size(); |
| 450 | } |
| 451 | |
[email protected] | 8ab7e6c | 2013-07-11 21:15:03 | [diff] [blame] | 452 | size_t ExtensionInstallPrompt::Prompt::GetPermissionsDetailsCount() const { |
| 453 | return details_.size(); |
| 454 | } |
| 455 | |
[email protected] | 6a72a63 | 2013-12-12 22:22:00 | [diff] [blame] | 456 | base::string16 ExtensionInstallPrompt::Prompt::GetPermission(size_t index) |
| 457 | const { |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 458 | CHECK_LT(index, permissions_.size()); |
[email protected] | ef2654e4 | 2012-08-11 03:57:56 | [diff] [blame] | 459 | return permissions_[index]; |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 460 | } |
| 461 | |
[email protected] | 6a72a63 | 2013-12-12 22:22:00 | [diff] [blame] | 462 | base::string16 ExtensionInstallPrompt::Prompt::GetPermissionsDetails( |
[email protected] | 8ab7e6c | 2013-07-11 21:15:03 | [diff] [blame] | 463 | size_t index) const { |
| 464 | CHECK_LT(index, details_.size()); |
| 465 | return details_[index]; |
| 466 | } |
| 467 | |
[email protected] | 79a6f99a | 2013-08-29 00:32:58 | [diff] [blame] | 468 | bool ExtensionInstallPrompt::Prompt::GetIsShowingDetails( |
| 469 | DetailsType type, size_t index) const { |
| 470 | switch (type) { |
| 471 | case PERMISSIONS_DETAILS: |
| 472 | CHECK_LT(index, is_showing_details_for_permissions_.size()); |
| 473 | return is_showing_details_for_permissions_[index]; |
| 474 | case OAUTH_DETAILS: |
| 475 | CHECK_LT(index, is_showing_details_for_oauth_.size()); |
| 476 | return is_showing_details_for_oauth_[index]; |
| 477 | case RETAINED_FILES_DETAILS: |
| 478 | return is_showing_details_for_retained_files_; |
| 479 | } |
| 480 | return false; |
| 481 | } |
| 482 | |
[email protected] | b70a2d9 | 2012-06-28 19:51:21 | [diff] [blame] | 483 | size_t ExtensionInstallPrompt::Prompt::GetOAuthIssueCount() const { |
| 484 | return oauth_issue_advice_.size(); |
| 485 | } |
| 486 | |
| 487 | const IssueAdviceInfoEntry& ExtensionInstallPrompt::Prompt::GetOAuthIssue( |
| 488 | size_t index) const { |
| 489 | CHECK_LT(index, oauth_issue_advice_.size()); |
| 490 | return oauth_issue_advice_[index]; |
| 491 | } |
| 492 | |
[email protected] | a2886e8b | 2013-06-08 05:15:02 | [diff] [blame] | 493 | size_t ExtensionInstallPrompt::Prompt::GetRetainedFileCount() const { |
| 494 | return retained_files_.size(); |
| 495 | } |
| 496 | |
[email protected] | 6a72a63 | 2013-12-12 22:22:00 | [diff] [blame] | 497 | base::string16 ExtensionInstallPrompt::Prompt::GetRetainedFile(size_t index) |
| 498 | const { |
[email protected] | a2886e8b | 2013-06-08 05:15:02 | [diff] [blame] | 499 | CHECK_LT(index, retained_files_.size()); |
[email protected] | 6725048e | 2013-10-24 21:47:14 | [diff] [blame] | 500 | return retained_files_[index].AsUTF16Unsafe(); |
[email protected] | a2886e8b | 2013-06-08 05:15:02 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | bool ExtensionInstallPrompt::Prompt::ShouldDisplayRevokeFilesButton() const { |
| 504 | return !retained_files_.empty(); |
| 505 | } |
| 506 | |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 507 | ExtensionInstallPrompt::ShowParams::ShowParams(content::WebContents* contents) |
| 508 | : parent_web_contents(contents), |
| 509 | parent_window(NativeWindowForWebContents(contents)), |
| 510 | navigator(contents) { |
| 511 | } |
| 512 | |
| 513 | ExtensionInstallPrompt::ShowParams::ShowParams( |
| 514 | gfx::NativeWindow window, |
| 515 | content::PageNavigator* navigator) |
| 516 | : parent_web_contents(NULL), |
| 517 | parent_window(window), |
| 518 | navigator(navigator) { |
| 519 | } |
| 520 | |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 521 | // static |
| 522 | scoped_refptr<Extension> |
| 523 | ExtensionInstallPrompt::GetLocalizedExtensionForDisplay( |
[email protected] | 023b3d1 | 2013-12-23 18:46:49 | [diff] [blame] | 524 | const base::DictionaryValue* manifest, |
[email protected] | c422a86 | 2012-07-31 15:46:13 | [diff] [blame] | 525 | int flags, |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 526 | const std::string& id, |
| 527 | const std::string& localized_name, |
| 528 | const std::string& localized_description, |
| 529 | std::string* error) { |
[email protected] | 023b3d1 | 2013-12-23 18:46:49 | [diff] [blame] | 530 | scoped_ptr<base::DictionaryValue> localized_manifest; |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 531 | if (!localized_name.empty() || !localized_description.empty()) { |
| 532 | localized_manifest.reset(manifest->DeepCopy()); |
| 533 | if (!localized_name.empty()) { |
[email protected] | 6bf9061 | 2013-08-15 00:36:27 | [diff] [blame] | 534 | localized_manifest->SetString(extensions::manifest_keys::kName, |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 535 | localized_name); |
| 536 | } |
| 537 | if (!localized_description.empty()) { |
[email protected] | 6bf9061 | 2013-08-15 00:36:27 | [diff] [blame] | 538 | localized_manifest->SetString(extensions::manifest_keys::kDescription, |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 539 | localized_description); |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | return Extension::Create( |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 544 | base::FilePath(), |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 545 | Manifest::INTERNAL, |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 546 | localized_manifest.get() ? *localized_manifest.get() : *manifest, |
[email protected] | c422a86 | 2012-07-31 15:46:13 | [diff] [blame] | 547 | flags, |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 548 | id, |
| 549 | error); |
| 550 | } |
| 551 | |
[email protected] | 7f16534 | 2014-02-12 09:22:22 | [diff] [blame] | 552 | ExtensionInstallPrompt::ExtensionInstallPrompt(content::WebContents* contents) |
[email protected] | f1e9848 | 2013-12-27 00:45:59 | [diff] [blame] | 553 | : OAuth2TokenService::Consumer("extensions_install"), |
| 554 | record_oauth2_grant_(false), |
[email protected] | b3a2509 | 2013-05-28 22:08:16 | [diff] [blame] | 555 | ui_loop_(base::MessageLoop::current()), |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 556 | extension_(NULL), |
[email protected] | 7f16534 | 2014-02-12 09:22:22 | [diff] [blame] | 557 | bundle_(NULL), |
[email protected] | 91e51d61 | 2012-10-21 23:03:05 | [diff] [blame] | 558 | install_ui_(ExtensionInstallUI::Create(ProfileForWebContents(contents))), |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 559 | show_params_(contents), |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 560 | delegate_(NULL), |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 561 | prompt_(UNSET_PROMPT_TYPE) { |
| 562 | prompt_.SetUserNameFromProfile(install_ui_->profile()); |
| 563 | } |
| 564 | |
| 565 | ExtensionInstallPrompt::ExtensionInstallPrompt( |
| 566 | Profile* profile, |
| 567 | gfx::NativeWindow native_window, |
| 568 | content::PageNavigator* navigator) |
[email protected] | f1e9848 | 2013-12-27 00:45:59 | [diff] [blame] | 569 | : OAuth2TokenService::Consumer("extensions_install"), |
| 570 | record_oauth2_grant_(false), |
[email protected] | b3a2509 | 2013-05-28 22:08:16 | [diff] [blame] | 571 | ui_loop_(base::MessageLoop::current()), |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 572 | extension_(NULL), |
[email protected] | 7f16534 | 2014-02-12 09:22:22 | [diff] [blame] | 573 | bundle_(NULL), |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 574 | install_ui_(ExtensionInstallUI::Create(profile)), |
| 575 | show_params_(native_window, navigator), |
| 576 | delegate_(NULL), |
| 577 | prompt_(UNSET_PROMPT_TYPE) { |
| 578 | prompt_.SetUserNameFromProfile(install_ui_->profile()); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | ExtensionInstallPrompt::~ExtensionInstallPrompt() { |
| 582 | } |
| 583 | |
| 584 | void ExtensionInstallPrompt::ConfirmBundleInstall( |
| 585 | extensions::BundleInstaller* bundle, |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 586 | const PermissionSet* permissions) { |
[email protected] | b3a2509 | 2013-05-28 22:08:16 | [diff] [blame] | 587 | DCHECK(ui_loop_ == base::MessageLoop::current()); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 588 | bundle_ = bundle; |
| 589 | permissions_ = permissions; |
| 590 | delegate_ = bundle; |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 591 | prompt_.set_type(BUNDLE_INSTALL_PROMPT); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 592 | |
[email protected] | 4e49487 | 2013-09-06 09:13:54 | [diff] [blame] | 593 | ShowConfirmation(); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 594 | } |
| 595 | |
[email protected] | 734bcec | 2012-10-08 20:29:05 | [diff] [blame] | 596 | void ExtensionInstallPrompt::ConfirmStandaloneInstall( |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 597 | Delegate* delegate, |
| 598 | const Extension* extension, |
| 599 | SkBitmap* icon, |
| 600 | const ExtensionInstallPrompt::Prompt& prompt) { |
[email protected] | b3a2509 | 2013-05-28 22:08:16 | [diff] [blame] | 601 | DCHECK(ui_loop_ == base::MessageLoop::current()); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 602 | extension_ = extension; |
| 603 | permissions_ = extension->GetActivePermissions(); |
| 604 | delegate_ = delegate; |
| 605 | prompt_ = prompt; |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 606 | |
| 607 | SetIcon(icon); |
[email protected] | 4e49487 | 2013-09-06 09:13:54 | [diff] [blame] | 608 | ShowConfirmation(); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 609 | } |
| 610 | |
[email protected] | af6efb2 | 2012-10-12 02:23:05 | [diff] [blame] | 611 | void ExtensionInstallPrompt::ConfirmWebstoreInstall( |
| 612 | Delegate* delegate, |
| 613 | const Extension* extension, |
| 614 | const SkBitmap* icon, |
| 615 | const ShowDialogCallback& show_dialog_callback) { |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 616 | // SetIcon requires |extension_| to be set. ConfirmInstall will setup the |
| 617 | // remaining fields. |
| 618 | extension_ = extension; |
| 619 | SetIcon(icon); |
[email protected] | af6efb2 | 2012-10-12 02:23:05 | [diff] [blame] | 620 | ConfirmInstall(delegate, extension, show_dialog_callback); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 621 | } |
| 622 | |
[email protected] | af6efb2 | 2012-10-12 02:23:05 | [diff] [blame] | 623 | void ExtensionInstallPrompt::ConfirmInstall( |
| 624 | Delegate* delegate, |
| 625 | const Extension* extension, |
| 626 | const ShowDialogCallback& show_dialog_callback) { |
[email protected] | b3a2509 | 2013-05-28 22:08:16 | [diff] [blame] | 627 | DCHECK(ui_loop_ == base::MessageLoop::current()); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 628 | extension_ = extension; |
| 629 | permissions_ = extension->GetActivePermissions(); |
| 630 | delegate_ = delegate; |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 631 | prompt_.set_type(INSTALL_PROMPT); |
[email protected] | af6efb2 | 2012-10-12 02:23:05 | [diff] [blame] | 632 | show_dialog_callback_ = show_dialog_callback; |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 633 | |
| 634 | // We special-case themes to not show any confirm UI. Instead they are |
| 635 | // immediately installed, and then we show an infobar (see OnInstallSuccess) |
| 636 | // to allow the user to revert if they don't like it. |
| 637 | // |
| 638 | // We don't do this in the case where off-store extension installs are |
| 639 | // disabled because in that case, we don't show the dangerous download UI, so |
| 640 | // we need the UI confirmation. |
| 641 | if (extension->is_theme()) { |
| 642 | if (extension->from_webstore() || |
[email protected] | 544471a | 2012-10-13 05:27:09 | [diff] [blame] | 643 | extensions::FeatureSwitch::easy_off_store_install()->IsEnabled()) { |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 644 | delegate->InstallUIProceed(); |
| 645 | return; |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | LoadImageIfNeeded(); |
| 650 | } |
| 651 | |
| 652 | void ExtensionInstallPrompt::ConfirmReEnable(Delegate* delegate, |
| 653 | const Extension* extension) { |
[email protected] | b3a2509 | 2013-05-28 22:08:16 | [diff] [blame] | 654 | DCHECK(ui_loop_ == base::MessageLoop::current()); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 655 | extension_ = extension; |
| 656 | permissions_ = extension->GetActivePermissions(); |
| 657 | delegate_ = delegate; |
[email protected] | 21db9ef | 2014-05-16 02:06:27 | [diff] [blame] | 658 | bool is_remote_install = |
| 659 | install_ui_->profile() && |
| 660 | extensions::ExtensionPrefs::Get(install_ui_->profile())->HasDisableReason( |
| 661 | extension->id(), extensions::Extension::DISABLE_REMOTE_INSTALL); |
[email protected] | 411f8ae | 2014-05-22 11:12:23 | [diff] [blame^] | 662 | bool is_ephemeral = |
| 663 | extensions::util::IsEphemeralApp(extension->id(), install_ui_->profile()); |
| 664 | if (is_ephemeral) |
[email protected] | 21db9ef | 2014-05-16 02:06:27 | [diff] [blame] | 665 | prompt_.set_type(LAUNCH_PROMPT); |
| 666 | else if (is_remote_install) |
| 667 | prompt_.set_type(REMOTE_INSTALL_PROMPT); |
| 668 | else |
| 669 | prompt_.set_type(RE_ENABLE_PROMPT); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 670 | LoadImageIfNeeded(); |
| 671 | } |
| 672 | |
[email protected] | 612a1cb1 | 2012-10-17 13:18:03 | [diff] [blame] | 673 | void ExtensionInstallPrompt::ConfirmExternalInstall( |
[email protected] | c8ff7c9e | 2013-04-20 12:36:27 | [diff] [blame] | 674 | Delegate* delegate, |
| 675 | const Extension* extension, |
[email protected] | 34b5f7f | 2014-01-29 02:48:11 | [diff] [blame] | 676 | const ShowDialogCallback& show_dialog_callback, |
| 677 | const Prompt& prompt) { |
[email protected] | b3a2509 | 2013-05-28 22:08:16 | [diff] [blame] | 678 | DCHECK(ui_loop_ == base::MessageLoop::current()); |
[email protected] | 612a1cb1 | 2012-10-17 13:18:03 | [diff] [blame] | 679 | extension_ = extension; |
| 680 | permissions_ = extension->GetActivePermissions(); |
| 681 | delegate_ = delegate; |
[email protected] | 34b5f7f | 2014-01-29 02:48:11 | [diff] [blame] | 682 | prompt_ = prompt; |
[email protected] | c8ff7c9e | 2013-04-20 12:36:27 | [diff] [blame] | 683 | show_dialog_callback_ = show_dialog_callback; |
[email protected] | 612a1cb1 | 2012-10-17 13:18:03 | [diff] [blame] | 684 | |
| 685 | LoadImageIfNeeded(); |
| 686 | } |
| 687 | |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 688 | void ExtensionInstallPrompt::ConfirmPermissions( |
| 689 | Delegate* delegate, |
| 690 | const Extension* extension, |
[email protected] | c2e66e1 | 2012-06-27 06:27:06 | [diff] [blame] | 691 | const PermissionSet* permissions) { |
[email protected] | b3a2509 | 2013-05-28 22:08:16 | [diff] [blame] | 692 | DCHECK(ui_loop_ == base::MessageLoop::current()); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 693 | extension_ = extension; |
| 694 | permissions_ = permissions; |
| 695 | delegate_ = delegate; |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 696 | prompt_.set_type(PERMISSIONS_PROMPT); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 697 | |
| 698 | LoadImageIfNeeded(); |
| 699 | } |
| 700 | |
[email protected] | f746b3f | 2012-07-03 17:53:37 | [diff] [blame] | 701 | void ExtensionInstallPrompt::ConfirmIssueAdvice( |
| 702 | Delegate* delegate, |
| 703 | const Extension* extension, |
| 704 | const IssueAdviceInfo& issue_advice) { |
[email protected] | b3a2509 | 2013-05-28 22:08:16 | [diff] [blame] | 705 | DCHECK(ui_loop_ == base::MessageLoop::current()); |
[email protected] | f746b3f | 2012-07-03 17:53:37 | [diff] [blame] | 706 | extension_ = extension; |
| 707 | delegate_ = delegate; |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 708 | prompt_.set_type(PERMISSIONS_PROMPT); |
[email protected] | f746b3f | 2012-07-03 17:53:37 | [diff] [blame] | 709 | |
| 710 | record_oauth2_grant_ = true; |
| 711 | prompt_.SetOAuthIssueAdvice(issue_advice); |
| 712 | |
| 713 | LoadImageIfNeeded(); |
| 714 | } |
| 715 | |
[email protected] | a2886e8b | 2013-06-08 05:15:02 | [diff] [blame] | 716 | void ExtensionInstallPrompt::ReviewPermissions( |
| 717 | Delegate* delegate, |
| 718 | const Extension* extension, |
| 719 | const std::vector<base::FilePath>& retained_file_paths) { |
[email protected] | b3a2509 | 2013-05-28 22:08:16 | [diff] [blame] | 720 | DCHECK(ui_loop_ == base::MessageLoop::current()); |
[email protected] | 15d267b4 | 2013-02-14 23:43:32 | [diff] [blame] | 721 | extension_ = extension; |
| 722 | permissions_ = extension->GetActivePermissions(); |
[email protected] | a2886e8b | 2013-06-08 05:15:02 | [diff] [blame] | 723 | prompt_.set_retained_files(retained_file_paths); |
[email protected] | 15d267b4 | 2013-02-14 23:43:32 | [diff] [blame] | 724 | delegate_ = delegate; |
| 725 | prompt_.set_type(POST_INSTALL_PERMISSIONS_PROMPT); |
| 726 | |
| 727 | LoadImageIfNeeded(); |
| 728 | } |
| 729 | |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 730 | void ExtensionInstallPrompt::OnInstallSuccess(const Extension* extension, |
| 731 | SkBitmap* icon) { |
| 732 | extension_ = extension; |
| 733 | SetIcon(icon); |
| 734 | |
| 735 | install_ui_->OnInstallSuccess(extension, &icon_); |
| 736 | } |
| 737 | |
[email protected] | bf3d9df | 2012-07-24 23:20:27 | [diff] [blame] | 738 | void ExtensionInstallPrompt::OnInstallFailure( |
| 739 | const extensions::CrxInstallerError& error) { |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 740 | install_ui_->OnInstallFailure(error); |
| 741 | } |
| 742 | |
| 743 | void ExtensionInstallPrompt::SetIcon(const SkBitmap* image) { |
| 744 | if (image) |
| 745 | icon_ = *image; |
| 746 | else |
| 747 | icon_ = SkBitmap(); |
[email protected] | dd46a4ce | 2012-09-15 10:50:50 | [diff] [blame] | 748 | if (icon_.empty()) { |
| 749 | // Let's set default icon bitmap whose size is equal to the default icon's |
| 750 | // pixel size under maximal supported scale factor. If the bitmap is larger |
| 751 | // than the one we need, it will be scaled down by the ui code. |
| 752 | icon_ = GetDefaultIconBitmapForMaxScaleFactor(extension_->is_app()); |
| 753 | } |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 754 | } |
| 755 | |
[email protected] | ec7de0c5a | 2012-11-16 07:40:47 | [diff] [blame] | 756 | void ExtensionInstallPrompt::OnImageLoaded(const gfx::Image& image) { |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 757 | SetIcon(image.IsEmpty() ? NULL : image.ToSkBitmap()); |
[email protected] | 4e49487 | 2013-09-06 09:13:54 | [diff] [blame] | 758 | ShowConfirmation(); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 759 | } |
| 760 | |
| 761 | void ExtensionInstallPrompt::LoadImageIfNeeded() { |
| 762 | // Bundle install prompts do not have an icon. |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 763 | // Also |install_ui_.profile()| can be NULL in unit tests. |
| 764 | if (!icon_.empty() || !install_ui_->profile()) { |
[email protected] | 4e49487 | 2013-09-06 09:13:54 | [diff] [blame] | 765 | ShowConfirmation(); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 766 | return; |
| 767 | } |
| 768 | |
| 769 | // Load the image asynchronously. For the response, check OnImageLoaded. |
[email protected] | 993da5e | 2013-03-23 21:25:16 | [diff] [blame] | 770 | extensions::ExtensionResource image = extensions::IconsInfo::GetIconResource( |
[email protected] | 702d8b4 | 2013-02-27 20:55:50 | [diff] [blame] | 771 | extension_, |
| 772 | extension_misc::EXTENSION_ICON_LARGE, |
| 773 | ExtensionIconSet::MATCH_BIGGER); |
[email protected] | dd46a4ce | 2012-09-15 10:50:50 | [diff] [blame] | 774 | // Load the icon whose pixel size is large enough to be displayed under |
| 775 | // maximal supported scale factor. UI code will scale the icon down if needed. |
| 776 | // TODO(tbarzic): We should use IconImage here and load the required bitmap |
| 777 | // lazily. |
| 778 | int pixel_size = GetSizeForMaxScaleFactor(kIconSize); |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 779 | extensions::ImageLoader::Get(install_ui_->profile())->LoadImageAsync( |
[email protected] | ec7de0c5a | 2012-11-16 07:40:47 | [diff] [blame] | 780 | extension_, image, gfx::Size(pixel_size, pixel_size), |
| 781 | base::Bind(&ExtensionInstallPrompt::OnImageLoaded, AsWeakPtr())); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 782 | } |
| 783 | |
[email protected] | 4f3fb35 | 2013-07-17 04:07:01 | [diff] [blame] | 784 | void ExtensionInstallPrompt::OnGetTokenSuccess( |
| 785 | const OAuth2TokenService::Request* request, |
| 786 | const std::string& access_token, |
| 787 | const base::Time& expiration_time) { |
| 788 | DCHECK_EQ(login_token_request_.get(), request); |
| 789 | login_token_request_.reset(); |
| 790 | |
| 791 | const extensions::OAuth2Info& oauth2_info = |
| 792 | extensions::OAuth2Info::GetOAuth2Info(extension_); |
| 793 | |
[email protected] | b70a2d9 | 2012-06-28 19:51:21 | [diff] [blame] | 794 | token_flow_.reset(new OAuth2MintTokenFlow( |
[email protected] | 4f3fb35 | 2013-07-17 04:07:01 | [diff] [blame] | 795 | install_ui_->profile()->GetRequestContext(), |
[email protected] | b70a2d9 | 2012-06-28 19:51:21 | [diff] [blame] | 796 | this, |
| 797 | OAuth2MintTokenFlow::Parameters( |
[email protected] | 4f3fb35 | 2013-07-17 04:07:01 | [diff] [blame] | 798 | access_token, |
[email protected] | b70a2d9 | 2012-06-28 19:51:21 | [diff] [blame] | 799 | extension_->id(), |
| 800 | oauth2_info.client_id, |
[email protected] | d4a37f1c | 2012-07-09 21:36:13 | [diff] [blame] | 801 | oauth2_info.scopes, |
[email protected] | b70a2d9 | 2012-06-28 19:51:21 | [diff] [blame] | 802 | OAuth2MintTokenFlow::MODE_ISSUE_ADVICE))); |
| 803 | token_flow_->Start(); |
| 804 | } |
| 805 | |
[email protected] | 4f3fb35 | 2013-07-17 04:07:01 | [diff] [blame] | 806 | void ExtensionInstallPrompt::OnGetTokenFailure( |
| 807 | const OAuth2TokenService::Request* request, |
| 808 | const GoogleServiceAuthError& error) { |
| 809 | DCHECK_EQ(login_token_request_.get(), request); |
| 810 | login_token_request_.reset(); |
| 811 | ShowConfirmation(); |
| 812 | } |
| 813 | |
[email protected] | b70a2d9 | 2012-06-28 19:51:21 | [diff] [blame] | 814 | void ExtensionInstallPrompt::OnIssueAdviceSuccess( |
| 815 | const IssueAdviceInfo& advice_info) { |
| 816 | prompt_.SetOAuthIssueAdvice(advice_info); |
| 817 | record_oauth2_grant_ = true; |
| 818 | ShowConfirmation(); |
| 819 | } |
| 820 | |
| 821 | void ExtensionInstallPrompt::OnMintTokenFailure( |
| 822 | const GoogleServiceAuthError& error) { |
| 823 | ShowConfirmation(); |
| 824 | } |
| 825 | |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 826 | void ExtensionInstallPrompt::ShowConfirmation() { |
[email protected] | 62a28d7c | 2013-12-28 01:34:49 | [diff] [blame] | 827 | if (prompt_.type() == INSTALL_PROMPT) |
| 828 | prompt_.set_experiment(ExtensionInstallPromptExperiment::Find()); |
| 829 | else |
| 830 | prompt_.set_experiment(ExtensionInstallPromptExperiment::ControlGroup()); |
| 831 | |
[email protected] | dc24976f | 2013-06-02 21:15:09 | [diff] [blame] | 832 | if (permissions_.get() && |
[email protected] | 13c68b6 | 2013-05-17 11:29:05 | [diff] [blame] | 833 | (!extension_ || |
| 834 | !extensions::PermissionsData::ShouldSkipPermissionWarnings( |
| 835 | extension_))) { |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 836 | Manifest::Type extension_type = extension_ ? |
| 837 | extension_->GetType() : Manifest::TYPE_UNKNOWN; |
[email protected] | 8ab7e6c | 2013-07-11 21:15:03 | [diff] [blame] | 838 | prompt_.SetPermissions( |
[email protected] | c4100347 | 2013-10-19 15:37:25 | [diff] [blame] | 839 | extensions::PermissionMessageProvider::Get()-> |
| 840 | GetWarningMessages(permissions_, extension_type)); |
[email protected] | 8ab7e6c | 2013-07-11 21:15:03 | [diff] [blame] | 841 | prompt_.SetPermissionsDetails( |
[email protected] | c4100347 | 2013-10-19 15:37:25 | [diff] [blame] | 842 | extensions::PermissionMessageProvider::Get()-> |
| 843 | GetWarningMessagesDetails(permissions_, extension_type)); |
[email protected] | bebe1d0 | 2012-08-02 20:17:09 | [diff] [blame] | 844 | } |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 845 | |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 846 | switch (prompt_.type()) { |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 847 | case PERMISSIONS_PROMPT: |
| 848 | case RE_ENABLE_PROMPT: |
| 849 | case INLINE_INSTALL_PROMPT: |
[email protected] | 612a1cb1 | 2012-10-17 13:18:03 | [diff] [blame] | 850 | case EXTERNAL_INSTALL_PROMPT: |
[email protected] | 15d267b4 | 2013-02-14 23:43:32 | [diff] [blame] | 851 | case INSTALL_PROMPT: |
[email protected] | 1a93d8d | 2013-10-27 23:09:20 | [diff] [blame] | 852 | case LAUNCH_PROMPT: |
[email protected] | 21db9ef | 2014-05-16 02:06:27 | [diff] [blame] | 853 | case POST_INSTALL_PERMISSIONS_PROMPT: |
| 854 | case REMOTE_INSTALL_PROMPT: { |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 855 | prompt_.set_extension(extension_); |
[email protected] | 32e7a9b | 2013-01-23 23:00:19 | [diff] [blame] | 856 | prompt_.set_icon(gfx::Image::CreateFrom1xBitmap(icon_)); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 857 | break; |
| 858 | } |
| 859 | case BUNDLE_INSTALL_PROMPT: { |
| 860 | prompt_.set_bundle(bundle_); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 861 | break; |
| 862 | } |
| 863 | default: |
| 864 | NOTREACHED() << "Unknown message"; |
[email protected] | af6efb2 | 2012-10-12 02:23:05 | [diff] [blame] | 865 | return; |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 866 | } |
[email protected] | af6efb2 | 2012-10-12 02:23:05 | [diff] [blame] | 867 | |
| 868 | if (AutoConfirmPrompt(delegate_)) |
| 869 | return; |
| 870 | |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 871 | if (show_dialog_callback_.is_null()) |
| 872 | GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_); |
| 873 | else |
| 874 | show_dialog_callback_.Run(show_params_, delegate_, prompt_); |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 875 | } |