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