blob: b786a55f9bb75d54d39484b7456a66642e05c641 [file] [log] [blame]
[email protected]c82da8c42012-06-08 19:49:111// 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]b19fe572013-07-18 04:54:2610#include "base/message_loop/message_loop.h"
[email protected]3853a4c2013-02-11 17:15:5711#include "base/prefs/pref_service.h"
[email protected]3ea1b182013-02-08 22:38:4112#include "base/strings/string_number_conversions.h"
[email protected]00e7bef2013-06-10 20:35:1713#include "base/strings/string_util.h"
14#include "base/strings/stringprintf.h"
[email protected]112158af2013-06-07 23:46:1815#include "base/strings/utf_string_conversions.h"
[email protected]c82da8c42012-06-08 19:49:1116#include "chrome/browser/extensions/bundle_installer.h"
[email protected]c82da8c42012-06-08 19:49:1117#include "chrome/browser/extensions/extension_install_ui.h"
[email protected]ec7de0c5a2012-11-16 07:40:4718#include "chrome/browser/extensions/image_loader.h"
[email protected]c82da8c42012-06-08 19:49:1119#include "chrome/browser/profiles/profile.h"
[email protected]4f3fb352013-07-17 04:07:0120#include "chrome/browser/signin/profile_oauth2_token_service.h"
21#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
[email protected]32fc4ff72012-06-15 21:50:0122#include "chrome/browser/ui/browser.h"
[email protected]619f86182012-07-03 21:30:1823#include "chrome/browser/ui/browser_window.h"
[email protected]c82da8c42012-06-08 19:49:1124#include "chrome/common/chrome_switches.h"
[email protected]29e0c4e72013-02-01 04:42:5625#include "chrome/common/extensions/api/identity/oauth2_manifest_handler.h"
[email protected]c82da8c42012-06-08 19:49:1126#include "chrome/common/extensions/extension.h"
[email protected]faf87192012-08-17 00:07:5927#include "chrome/common/extensions/extension_constants.h"
[email protected]c82da8c42012-06-08 19:49:1128#include "chrome/common/extensions/extension_icon_set.h"
[email protected]544471a2012-10-13 05:27:0929#include "chrome/common/extensions/feature_switch.h"
[email protected]abe720c02013-04-12 04:00:1030#include "chrome/common/extensions/manifest_handlers/icons_handler.h"
[email protected]bebe1d02012-08-02 20:17:0931#include "chrome/common/extensions/permissions/permission_set.h"
[email protected]13c68b62013-05-17 11:29:0532#include "chrome/common/extensions/permissions/permissions_data.h"
[email protected]fc5077942012-08-15 21:37:5933#include "chrome/common/pref_names.h"
[email protected]91e51d612012-10-21 23:03:0534#include "content/public/browser/web_contents.h"
[email protected]5db2e882012-12-20 10:17:2635#include "content/public/browser/web_contents_view.h"
[email protected]993da5e2013-03-23 21:25:1636#include "extensions/common/extension_resource.h"
[email protected]d42c11152013-08-22 19:36:3237#include "extensions/common/manifest.h"
[email protected]6bf90612013-08-15 00:36:2738#include "extensions/common/manifest_constants.h"
[email protected]c41003472013-10-19 15:37:2539#include "extensions/common/permissions/permission_message_provider.h"
[email protected]885c0e92012-11-13 20:27:4240#include "extensions/common/url_pattern.h"
[email protected]c82da8c42012-06-08 19:49:1141#include "grit/chromium_strings.h"
42#include "grit/generated_resources.h"
[email protected]2a281332012-07-11 22:20:2343#include "grit/theme_resources.h"
[email protected]c82da8c42012-06-08 19:49:1144#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]c82da8c42012-06-08 19:49:1148using extensions::BundleInstaller;
49using extensions::Extension;
[email protected]1d5e58b2013-01-31 08:41:4050using extensions::Manifest;
[email protected]c2e66e12012-06-27 06:27:0651using extensions::PermissionSet;
[email protected]c82da8c42012-06-08 19:49:1152
[email protected]612a1cb12012-10-17 13:18:0353namespace {
54
[email protected]c82da8c42012-06-08 19:49:1155static const int kTitleIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
56 0, // The regular install prompt depends on what's being installed.
57 IDS_EXTENSION_INLINE_INSTALL_PROMPT_TITLE,
58 IDS_EXTENSION_INSTALL_PROMPT_TITLE,
59 IDS_EXTENSION_RE_ENABLE_PROMPT_TITLE,
[email protected]612a1cb12012-10-17 13:18:0360 IDS_EXTENSION_PERMISSIONS_PROMPT_TITLE,
61 IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_TITLE,
[email protected]15d267b42013-02-14 23:43:3262 IDS_EXTENSION_POST_INSTALL_PERMISSIONS_PROMPT_TITLE,
[email protected]bc123c02013-10-15 06:41:1363 IDS_EXTENSION_FIRST_RUN_PROMPT_TITLE,
[email protected]1a93d8d2013-10-27 23:09:2064 IDS_EXTENSION_LAUNCH_APP_PROMPT_TITLE,
[email protected]c82da8c42012-06-08 19:49:1165};
66static const int kHeadingIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
67 IDS_EXTENSION_INSTALL_PROMPT_HEADING,
68 0, // Inline installs use the extension name.
69 0, // Heading for bundle installs depends on the bundle contents.
70 IDS_EXTENSION_RE_ENABLE_PROMPT_HEADING,
[email protected]612a1cb12012-10-17 13:18:0371 IDS_EXTENSION_PERMISSIONS_PROMPT_HEADING,
[email protected]846606012012-10-19 18:42:2572 0, // External installs use different strings for extensions/apps.
[email protected]15d267b42013-02-14 23:43:3273 IDS_EXTENSION_POST_INSTALL_PERMISSIONS_PROMPT_HEADING,
[email protected]bc123c02013-10-15 06:41:1374 IDS_EXTENSION_FIRST_RUN_PROMPT_HEADING,
[email protected]1a93d8d2013-10-27 23:09:2075 IDS_EXTENSION_LAUNCH_APP_PROMPT_HEADING,
[email protected]15d267b42013-02-14 23:43:3276};
77static const int kButtons[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
78 ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL,
79 ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL,
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_CANCEL,
[email protected]aa5a5472013-10-04 03:41:0485 ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL,
[email protected]1a93d8d2013-10-27 23:09:2086 ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL,
[email protected]c82da8c42012-06-08 19:49:1187};
88static const int kAcceptButtonIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
89 IDS_EXTENSION_PROMPT_INSTALL_BUTTON,
90 IDS_EXTENSION_PROMPT_INSTALL_BUTTON,
91 IDS_EXTENSION_PROMPT_INSTALL_BUTTON,
92 IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON,
[email protected]612a1cb12012-10-17 13:18:0393 IDS_EXTENSION_PROMPT_PERMISSIONS_BUTTON,
[email protected]846606012012-10-19 18:42:2594 0, // External installs use different strings for extensions/apps.
[email protected]a2886e8b2013-06-08 05:15:0295 IDS_EXTENSION_PROMPT_PERMISSIONS_CLEAR_RETAINED_FILES_BUTTON,
[email protected]1a93d8d2013-10-27 23:09:2096 IDS_EXTENSION_PROMPT_FIRST_RUN_ACCEPT_BUTTON,
97 IDS_EXTENSION_PROMPT_LAUNCH_BUTTON,
[email protected]c82da8c42012-06-08 19:49:1198};
99static const int kAbortButtonIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
100 0, // These all use the platform's default cancel label.
101 0,
102 0,
103 0,
[email protected]612a1cb12012-10-17 13:18:03104 IDS_EXTENSION_PROMPT_PERMISSIONS_ABORT_BUTTON,
105 IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ABORT_BUTTON,
[email protected]15d267b42013-02-14 23:43:32106 IDS_CLOSE,
[email protected]bc123c02013-10-15 06:41:13107 0, // Platform dependent cancel button.
[email protected]1a93d8d2013-10-27 23:09:20108 0,
[email protected]c82da8c42012-06-08 19:49:11109};
110static const int kPermissionsHeaderIds[
111 ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
112 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO,
113 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO,
114 IDS_EXTENSION_PROMPT_THESE_WILL_HAVE_ACCESS_TO,
115 IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO,
116 IDS_EXTENSION_PROMPT_WANTS_ACCESS_TO,
[email protected]612a1cb12012-10-17 13:18:03117 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO,
[email protected]15d267b42013-02-14 23:43:32118 IDS_EXTENSION_PROMPT_CAN_ACCESS,
[email protected]aa5a5472013-10-04 03:41:04119 IDS_EXTENSION_PROMPT_CAN_ACCESS,
[email protected]1a93d8d2013-10-27 23:09:20120 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO,
[email protected]c82da8c42012-06-08 19:49:11121};
[email protected]612a1cb12012-10-17 13:18:03122static const int kOAuthHeaderIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
[email protected]fc5077942012-08-15 21:37:59123 IDS_EXTENSION_PROMPT_OAUTH_HEADER,
124 0, // Inline installs don't show OAuth permissions.
125 0, // Bundle installs don't show OAuth permissions.
126 IDS_EXTENSION_PROMPT_OAUTH_REENABLE_HEADER,
127 IDS_EXTENSION_PROMPT_OAUTH_PERMISSIONS_HEADER,
[email protected]612a1cb12012-10-17 13:18:03128 0,
[email protected]15d267b42013-02-14 23:43:32129 0,
[email protected]aa5a5472013-10-04 03:41:04130 IDS_EXTENSION_PROMPT_OAUTH_HEADER,
[email protected]1a93d8d2013-10-27 23:09:20131 IDS_EXTENSION_PROMPT_OAUTH_HEADER,
[email protected]fc5077942012-08-15 21:37:59132};
[email protected]c82da8c42012-06-08 19:49:11133
[email protected]c82da8c42012-06-08 19:49:11134// Size of extension icon in top left of dialog.
135const int kIconSize = 69;
136
[email protected]dd46a4ce2012-09-15 10:50:50137// Returns pixel size under maximal scale factor for the icon whose device
138// independent size is |size_in_dip|
139int GetSizeForMaxScaleFactor(int size_in_dip) {
[email protected]50b66262013-09-24 03:25:48140 return static_cast<int>(size_in_dip * gfx::ImageSkia::GetMaxSupportedScale());
[email protected]dd46a4ce2012-09-15 10:50:50141}
142
143// Returns bitmap for the default icon with size equal to the default icon's
144// pixel size under maximal supported scale factor.
145SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) {
[email protected]702d8b42013-02-27 20:55:50146 const gfx::ImageSkia& image = is_app ?
147 extensions::IconsInfo::GetDefaultAppIcon() :
148 extensions::IconsInfo::GetDefaultExtensionIcon();
[email protected]50b66262013-09-24 03:25:48149 return image.GetRepresentation(
150 gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap();
[email protected]dd46a4ce2012-09-15 10:50:50151}
152
[email protected]af6efb22012-10-12 02:23:05153// If auto confirm is enabled then posts a task to proceed with or cancel the
154// install and returns true. Otherwise returns false.
155bool AutoConfirmPrompt(ExtensionInstallPrompt::Delegate* delegate) {
156 const CommandLine* cmdline = CommandLine::ForCurrentProcess();
157 if (!cmdline->HasSwitch(switches::kAppsGalleryInstallAutoConfirmForTests))
158 return false;
159 std::string value = cmdline->GetSwitchValueASCII(
160 switches::kAppsGalleryInstallAutoConfirmForTests);
161
162 // We use PostTask instead of calling the delegate directly here, because in
163 // the real implementations it's highly likely the message loop will be
164 // pumping a few times before the user clicks accept or cancel.
165 if (value == "accept") {
[email protected]b3a25092013-05-28 22:08:16166 base::MessageLoop::current()->PostTask(
[email protected]af6efb22012-10-12 02:23:05167 FROM_HERE,
168 base::Bind(&ExtensionInstallPrompt::Delegate::InstallUIProceed,
169 base::Unretained(delegate)));
170 return true;
171 }
172
173 if (value == "cancel") {
[email protected]b3a25092013-05-28 22:08:16174 base::MessageLoop::current()->PostTask(
[email protected]af6efb22012-10-12 02:23:05175 FROM_HERE,
176 base::Bind(&ExtensionInstallPrompt::Delegate::InstallUIAbort,
177 base::Unretained(delegate),
178 true));
179 return true;
180 }
181
182 NOTREACHED();
183 return false;
184}
185
[email protected]91e51d612012-10-21 23:03:05186Profile* ProfileForWebContents(content::WebContents* web_contents) {
187 if (!web_contents)
188 return NULL;
189 return Profile::FromBrowserContext(web_contents->GetBrowserContext());
190}
191
[email protected]5db2e882012-12-20 10:17:26192gfx::NativeWindow NativeWindowForWebContents(content::WebContents* contents) {
193 if (!contents)
194 return NULL;
195
196 return contents->GetView()->GetTopLevelNativeWindow();
197}
198
[email protected]c82da8c42012-06-08 19:49:11199} // namespace
200
[email protected]5db2e882012-12-20 10:17:26201ExtensionInstallPrompt::Prompt::Prompt(PromptType type)
[email protected]c82da8c42012-06-08 19:49:11202 : type_(type),
[email protected]79a6f99a2013-08-29 00:32:58203 is_showing_details_for_retained_files_(false),
[email protected]c82da8c42012-06-08 19:49:11204 extension_(NULL),
205 bundle_(NULL),
206 average_rating_(0.0),
[email protected]dcde34b32013-07-31 02:28:45207 rating_count_(0),
208 show_user_count_(false) {
[email protected]c82da8c42012-06-08 19:49:11209}
210
211ExtensionInstallPrompt::Prompt::~Prompt() {
212}
213
214void ExtensionInstallPrompt::Prompt::SetPermissions(
215 const std::vector<string16>& permissions) {
216 permissions_ = permissions;
217}
218
[email protected]8ab7e6c2013-07-11 21:15:03219void ExtensionInstallPrompt::Prompt::SetPermissionsDetails(
220 const std::vector<string16>& details) {
221 details_ = details;
[email protected]79a6f99a2013-08-29 00:32:58222 is_showing_details_for_permissions_.clear();
223 for (size_t i = 0; i < details.size(); ++i)
224 is_showing_details_for_permissions_.push_back(false);
225}
226
227void ExtensionInstallPrompt::Prompt::SetIsShowingDetails(
228 DetailsType type,
229 size_t index,
230 bool is_showing_details) {
231 switch (type) {
232 case PERMISSIONS_DETAILS:
233 is_showing_details_for_permissions_[index] = is_showing_details;
234 break;
235 case OAUTH_DETAILS:
236 is_showing_details_for_oauth_[index] = is_showing_details;
237 break;
238 case RETAINED_FILES_DETAILS:
239 is_showing_details_for_retained_files_ = is_showing_details;
240 break;
241 }
[email protected]8ab7e6c2013-07-11 21:15:03242}
243
[email protected]b70a2d92012-06-28 19:51:21244void ExtensionInstallPrompt::Prompt::SetOAuthIssueAdvice(
245 const IssueAdviceInfo& issue_advice) {
[email protected]79a6f99a2013-08-29 00:32:58246 is_showing_details_for_oauth_.clear();
247 for (size_t i = 0; i < issue_advice.size(); ++i)
248 is_showing_details_for_oauth_.push_back(false);
249
[email protected]b70a2d92012-06-28 19:51:21250 oauth_issue_advice_ = issue_advice;
251}
252
[email protected]5db2e882012-12-20 10:17:26253void ExtensionInstallPrompt::Prompt::SetUserNameFromProfile(Profile* profile) {
254 // |profile| can be NULL in unit tests.
255 if (profile) {
256 oauth_user_name_ = UTF8ToUTF16(profile->GetPrefs()->GetString(
257 prefs::kGoogleServicesUsername));
258 } else {
259 oauth_user_name_.clear();
260 }
261}
262
[email protected]c82da8c42012-06-08 19:49:11263void ExtensionInstallPrompt::Prompt::SetInlineInstallWebstoreData(
264 const std::string& localized_user_count,
[email protected]dcde34b32013-07-31 02:28:45265 bool show_user_count,
[email protected]c82da8c42012-06-08 19:49:11266 double average_rating,
267 int rating_count) {
268 CHECK_EQ(INLINE_INSTALL_PROMPT, type_);
269 localized_user_count_ = localized_user_count;
[email protected]dcde34b32013-07-31 02:28:45270 show_user_count_ = show_user_count;
[email protected]c82da8c42012-06-08 19:49:11271 average_rating_ = average_rating;
272 rating_count_ = rating_count;
273}
274
275string16 ExtensionInstallPrompt::Prompt::GetDialogTitle() const {
[email protected]c82da8c42012-06-08 19:49:11276 int resource_id = kTitleIds[type_];
277
278 if (type_ == INSTALL_PROMPT) {
279 if (extension_->is_app())
280 resource_id = IDS_EXTENSION_INSTALL_APP_PROMPT_TITLE;
281 else if (extension_->is_theme())
282 resource_id = IDS_EXTENSION_INSTALL_THEME_PROMPT_TITLE;
283 else
284 resource_id = IDS_EXTENSION_INSTALL_EXTENSION_PROMPT_TITLE;
[email protected]612a1cb12012-10-17 13:18:03285 } else if (type_ == EXTERNAL_INSTALL_PROMPT) {
286 return l10n_util::GetStringFUTF16(
287 resource_id, UTF8ToUTF16(extension_->name()));
[email protected]c82da8c42012-06-08 19:49:11288 }
289
290 return l10n_util::GetStringUTF16(resource_id);
291}
292
293string16 ExtensionInstallPrompt::Prompt::GetHeading() const {
294 if (type_ == INLINE_INSTALL_PROMPT) {
295 return UTF8ToUTF16(extension_->name());
296 } else if (type_ == BUNDLE_INSTALL_PROMPT) {
297 return bundle_->GetHeadingTextFor(BundleInstaller::Item::STATE_PENDING);
[email protected]612a1cb12012-10-17 13:18:03298 } else if (type_ == EXTERNAL_INSTALL_PROMPT) {
[email protected]846606012012-10-19 18:42:25299 int resource_id = -1;
300 if (extension_->is_app())
301 resource_id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_HEADING_APP;
302 else if (extension_->is_theme())
303 resource_id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_HEADING_THEME;
304 else
305 resource_id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_HEADING_EXTENSION;
306 return l10n_util::GetStringUTF16(resource_id);
[email protected]c82da8c42012-06-08 19:49:11307 } else {
308 return l10n_util::GetStringFUTF16(
309 kHeadingIds[type_], UTF8ToUTF16(extension_->name()));
310 }
311}
312
[email protected]15d267b42013-02-14 23:43:32313int ExtensionInstallPrompt::Prompt::GetDialogButtons() const {
[email protected]a2886e8b2013-06-08 05:15:02314 if (type_ == POST_INSTALL_PERMISSIONS_PROMPT &&
315 ShouldDisplayRevokeFilesButton()) {
316 return kButtons[type_] | ui::DIALOG_BUTTON_OK;
317 }
318
[email protected]15d267b42013-02-14 23:43:32319 return kButtons[type_];
320}
321
322bool ExtensionInstallPrompt::Prompt::HasAcceptButtonLabel() const {
[email protected]a2886e8b2013-06-08 05:15:02323 if (kAcceptButtonIds[type_] == 0)
324 return false;
325
326 if (type_ == POST_INSTALL_PERMISSIONS_PROMPT)
327 return ShouldDisplayRevokeFilesButton();
328
329 return true;
[email protected]15d267b42013-02-14 23:43:32330}
331
[email protected]c82da8c42012-06-08 19:49:11332string16 ExtensionInstallPrompt::Prompt::GetAcceptButtonLabel() const {
[email protected]846606012012-10-19 18:42:25333 if (type_ == EXTERNAL_INSTALL_PROMPT) {
334 int id = -1;
335 if (extension_->is_app())
336 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_APP;
337 else if (extension_->is_theme())
338 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_THEME;
339 else
340 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_EXTENSION;
341 return l10n_util::GetStringUTF16(id);
342 }
[email protected]c82da8c42012-06-08 19:49:11343 return l10n_util::GetStringUTF16(kAcceptButtonIds[type_]);
344}
345
346bool ExtensionInstallPrompt::Prompt::HasAbortButtonLabel() const {
347 return kAbortButtonIds[type_] > 0;
348}
349
350string16 ExtensionInstallPrompt::Prompt::GetAbortButtonLabel() const {
351 CHECK(HasAbortButtonLabel());
352 return l10n_util::GetStringUTF16(kAbortButtonIds[type_]);
353}
354
355string16 ExtensionInstallPrompt::Prompt::GetPermissionsHeading() const {
356 return l10n_util::GetStringUTF16(kPermissionsHeaderIds[type_]);
357}
358
[email protected]813475e2012-07-02 23:54:18359string16 ExtensionInstallPrompt::Prompt::GetOAuthHeading() const {
[email protected]5db2e882012-12-20 10:17:26360 return l10n_util::GetStringFUTF16(kOAuthHeaderIds[type_], oauth_user_name_);
[email protected]813475e2012-07-02 23:54:18361}
362
[email protected]a2886e8b2013-06-08 05:15:02363string16 ExtensionInstallPrompt::Prompt::GetRetainedFilesHeading() const {
[email protected]4f1e1082013-09-23 10:30:53364 const int kRetainedFilesMessageIDs[6] = {
365 IDS_EXTENSION_PROMPT_RETAINED_FILES_DEFAULT,
366 IDS_EXTENSION_PROMPT_RETAINED_FILE_SINGULAR,
367 IDS_EXTENSION_PROMPT_RETAINED_FILES_ZERO,
368 IDS_EXTENSION_PROMPT_RETAINED_FILES_TWO,
369 IDS_EXTENSION_PROMPT_RETAINED_FILES_FEW,
370 IDS_EXTENSION_PROMPT_RETAINED_FILES_MANY,
371 };
372 std::vector<int> message_ids;
373 for (size_t i = 0; i < arraysize(kRetainedFilesMessageIDs); i++) {
374 message_ids.push_back(kRetainedFilesMessageIDs[i]);
375 }
376 return l10n_util::GetPluralStringFUTF16(message_ids, GetRetainedFileCount());
[email protected]8ab7e6c2013-07-11 21:15:03377}
378
[email protected]f2cd8992013-06-11 17:30:18379bool ExtensionInstallPrompt::Prompt::ShouldShowPermissions() const {
380 return GetPermissionCount() > 0 || type_ == POST_INSTALL_PERMISSIONS_PROMPT;
381}
382
[email protected]c82da8c42012-06-08 19:49:11383void ExtensionInstallPrompt::Prompt::AppendRatingStars(
384 StarAppender appender, void* data) const {
385 CHECK(appender);
386 CHECK_EQ(INLINE_INSTALL_PROMPT, type_);
387 int rating_integer = floor(average_rating_);
388 double rating_fractional = average_rating_ - rating_integer;
389
390 if (rating_fractional > 0.66) {
391 rating_integer++;
392 }
393
394 if (rating_fractional < 0.33 || rating_fractional > 0.66) {
395 rating_fractional = 0;
396 }
397
398 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
399 int i;
400 for (i = 0; i < rating_integer; i++) {
401 appender(rb.GetImageSkiaNamed(IDR_EXTENSIONS_RATING_STAR_ON), data);
402 }
403 if (rating_fractional) {
404 appender(rb.GetImageSkiaNamed(IDR_EXTENSIONS_RATING_STAR_HALF_LEFT), data);
405 i++;
406 }
407 for (; i < kMaxExtensionRating; i++) {
408 appender(rb.GetImageSkiaNamed(IDR_EXTENSIONS_RATING_STAR_OFF), data);
409 }
410}
411
412string16 ExtensionInstallPrompt::Prompt::GetRatingCount() const {
413 CHECK_EQ(INLINE_INSTALL_PROMPT, type_);
[email protected]6725048e2013-10-24 21:47:14414 return l10n_util::GetStringFUTF16(IDS_EXTENSION_RATING_COUNT,
415 base::IntToString16(rating_count_));
[email protected]c82da8c42012-06-08 19:49:11416}
417
418string16 ExtensionInstallPrompt::Prompt::GetUserCount() const {
419 CHECK_EQ(INLINE_INSTALL_PROMPT, type_);
[email protected]dcde34b32013-07-31 02:28:45420
421 if (show_user_count_) {
[email protected]6725048e2013-10-24 21:47:14422 return l10n_util::GetStringFUTF16(IDS_EXTENSION_USER_COUNT,
423 base::UTF8ToUTF16(localized_user_count_));
[email protected]dcde34b32013-07-31 02:28:45424 }
[email protected]6725048e2013-10-24 21:47:14425 return base::string16();
[email protected]c82da8c42012-06-08 19:49:11426}
427
428size_t ExtensionInstallPrompt::Prompt::GetPermissionCount() const {
429 return permissions_.size();
430}
431
[email protected]8ab7e6c2013-07-11 21:15:03432size_t ExtensionInstallPrompt::Prompt::GetPermissionsDetailsCount() const {
433 return details_.size();
434}
435
[email protected]c82da8c42012-06-08 19:49:11436string16 ExtensionInstallPrompt::Prompt::GetPermission(size_t index) const {
437 CHECK_LT(index, permissions_.size());
[email protected]ef2654e42012-08-11 03:57:56438 return permissions_[index];
[email protected]c82da8c42012-06-08 19:49:11439}
440
[email protected]8ab7e6c2013-07-11 21:15:03441string16 ExtensionInstallPrompt::Prompt::GetPermissionsDetails(
442 size_t index) const {
443 CHECK_LT(index, details_.size());
444 return details_[index];
445}
446
[email protected]79a6f99a2013-08-29 00:32:58447bool ExtensionInstallPrompt::Prompt::GetIsShowingDetails(
448 DetailsType type, size_t index) const {
449 switch (type) {
450 case PERMISSIONS_DETAILS:
451 CHECK_LT(index, is_showing_details_for_permissions_.size());
452 return is_showing_details_for_permissions_[index];
453 case OAUTH_DETAILS:
454 CHECK_LT(index, is_showing_details_for_oauth_.size());
455 return is_showing_details_for_oauth_[index];
456 case RETAINED_FILES_DETAILS:
457 return is_showing_details_for_retained_files_;
458 }
459 return false;
460}
461
[email protected]b70a2d92012-06-28 19:51:21462size_t ExtensionInstallPrompt::Prompt::GetOAuthIssueCount() const {
463 return oauth_issue_advice_.size();
464}
465
466const IssueAdviceInfoEntry& ExtensionInstallPrompt::Prompt::GetOAuthIssue(
467 size_t index) const {
468 CHECK_LT(index, oauth_issue_advice_.size());
469 return oauth_issue_advice_[index];
470}
471
[email protected]a2886e8b2013-06-08 05:15:02472size_t ExtensionInstallPrompt::Prompt::GetRetainedFileCount() const {
473 return retained_files_.size();
474}
475
476string16 ExtensionInstallPrompt::Prompt::GetRetainedFile(size_t index) const {
477 CHECK_LT(index, retained_files_.size());
[email protected]6725048e2013-10-24 21:47:14478 return retained_files_[index].AsUTF16Unsafe();
[email protected]a2886e8b2013-06-08 05:15:02479}
480
481bool ExtensionInstallPrompt::Prompt::ShouldDisplayRevokeFilesButton() const {
482 return !retained_files_.empty();
483}
484
[email protected]5db2e882012-12-20 10:17:26485ExtensionInstallPrompt::ShowParams::ShowParams(content::WebContents* contents)
486 : parent_web_contents(contents),
487 parent_window(NativeWindowForWebContents(contents)),
488 navigator(contents) {
489}
490
491ExtensionInstallPrompt::ShowParams::ShowParams(
492 gfx::NativeWindow window,
493 content::PageNavigator* navigator)
494 : parent_web_contents(NULL),
495 parent_window(window),
496 navigator(navigator) {
497}
498
[email protected]c82da8c42012-06-08 19:49:11499// static
500scoped_refptr<Extension>
501 ExtensionInstallPrompt::GetLocalizedExtensionForDisplay(
502 const DictionaryValue* manifest,
[email protected]c422a862012-07-31 15:46:13503 int flags,
[email protected]c82da8c42012-06-08 19:49:11504 const std::string& id,
505 const std::string& localized_name,
506 const std::string& localized_description,
507 std::string* error) {
508 scoped_ptr<DictionaryValue> localized_manifest;
509 if (!localized_name.empty() || !localized_description.empty()) {
510 localized_manifest.reset(manifest->DeepCopy());
511 if (!localized_name.empty()) {
[email protected]6bf90612013-08-15 00:36:27512 localized_manifest->SetString(extensions::manifest_keys::kName,
[email protected]c82da8c42012-06-08 19:49:11513 localized_name);
514 }
515 if (!localized_description.empty()) {
[email protected]6bf90612013-08-15 00:36:27516 localized_manifest->SetString(extensions::manifest_keys::kDescription,
[email protected]c82da8c42012-06-08 19:49:11517 localized_description);
518 }
519 }
520
521 return Extension::Create(
[email protected]650b2d52013-02-10 03:41:45522 base::FilePath(),
[email protected]1d5e58b2013-01-31 08:41:40523 Manifest::INTERNAL,
[email protected]c82da8c42012-06-08 19:49:11524 localized_manifest.get() ? *localized_manifest.get() : *manifest,
[email protected]c422a862012-07-31 15:46:13525 flags,
[email protected]c82da8c42012-06-08 19:49:11526 id,
527 error);
528}
529
[email protected]619f86182012-07-03 21:30:18530ExtensionInstallPrompt::ExtensionInstallPrompt(
[email protected]91e51d612012-10-21 23:03:05531 content::WebContents* contents)
[email protected]16798da832012-08-30 20:46:04532 : record_oauth2_grant_(false),
[email protected]b3a25092013-05-28 22:08:16533 ui_loop_(base::MessageLoop::current()),
[email protected]c82da8c42012-06-08 19:49:11534 extension_(NULL),
[email protected]91e51d612012-10-21 23:03:05535 install_ui_(ExtensionInstallUI::Create(ProfileForWebContents(contents))),
[email protected]5db2e882012-12-20 10:17:26536 show_params_(contents),
[email protected]c82da8c42012-06-08 19:49:11537 delegate_(NULL),
[email protected]5db2e882012-12-20 10:17:26538 prompt_(UNSET_PROMPT_TYPE) {
539 prompt_.SetUserNameFromProfile(install_ui_->profile());
540}
541
542ExtensionInstallPrompt::ExtensionInstallPrompt(
543 Profile* profile,
544 gfx::NativeWindow native_window,
545 content::PageNavigator* navigator)
546 : record_oauth2_grant_(false),
[email protected]b3a25092013-05-28 22:08:16547 ui_loop_(base::MessageLoop::current()),
[email protected]5db2e882012-12-20 10:17:26548 extension_(NULL),
549 install_ui_(ExtensionInstallUI::Create(profile)),
550 show_params_(native_window, navigator),
551 delegate_(NULL),
552 prompt_(UNSET_PROMPT_TYPE) {
553 prompt_.SetUserNameFromProfile(install_ui_->profile());
[email protected]c82da8c42012-06-08 19:49:11554}
555
556ExtensionInstallPrompt::~ExtensionInstallPrompt() {
557}
558
559void ExtensionInstallPrompt::ConfirmBundleInstall(
560 extensions::BundleInstaller* bundle,
[email protected]c2e66e12012-06-27 06:27:06561 const PermissionSet* permissions) {
[email protected]b3a25092013-05-28 22:08:16562 DCHECK(ui_loop_ == base::MessageLoop::current());
[email protected]c82da8c42012-06-08 19:49:11563 bundle_ = bundle;
564 permissions_ = permissions;
565 delegate_ = bundle;
[email protected]5db2e882012-12-20 10:17:26566 prompt_.set_type(BUNDLE_INSTALL_PROMPT);
[email protected]c82da8c42012-06-08 19:49:11567
[email protected]4e494872013-09-06 09:13:54568 ShowConfirmation();
[email protected]c82da8c42012-06-08 19:49:11569}
570
[email protected]734bcec2012-10-08 20:29:05571void ExtensionInstallPrompt::ConfirmStandaloneInstall(
[email protected]c82da8c42012-06-08 19:49:11572 Delegate* delegate,
573 const Extension* extension,
574 SkBitmap* icon,
575 const ExtensionInstallPrompt::Prompt& prompt) {
[email protected]b3a25092013-05-28 22:08:16576 DCHECK(ui_loop_ == base::MessageLoop::current());
[email protected]c82da8c42012-06-08 19:49:11577 extension_ = extension;
578 permissions_ = extension->GetActivePermissions();
579 delegate_ = delegate;
580 prompt_ = prompt;
[email protected]c82da8c42012-06-08 19:49:11581
582 SetIcon(icon);
[email protected]4e494872013-09-06 09:13:54583 ShowConfirmation();
[email protected]c82da8c42012-06-08 19:49:11584}
585
[email protected]af6efb22012-10-12 02:23:05586void ExtensionInstallPrompt::ConfirmWebstoreInstall(
587 Delegate* delegate,
588 const Extension* extension,
589 const SkBitmap* icon,
590 const ShowDialogCallback& show_dialog_callback) {
[email protected]c82da8c42012-06-08 19:49:11591 // SetIcon requires |extension_| to be set. ConfirmInstall will setup the
592 // remaining fields.
593 extension_ = extension;
594 SetIcon(icon);
[email protected]af6efb22012-10-12 02:23:05595 ConfirmInstall(delegate, extension, show_dialog_callback);
[email protected]c82da8c42012-06-08 19:49:11596}
597
[email protected]af6efb22012-10-12 02:23:05598void ExtensionInstallPrompt::ConfirmInstall(
599 Delegate* delegate,
600 const Extension* extension,
601 const ShowDialogCallback& show_dialog_callback) {
[email protected]b3a25092013-05-28 22:08:16602 DCHECK(ui_loop_ == base::MessageLoop::current());
[email protected]c82da8c42012-06-08 19:49:11603 extension_ = extension;
604 permissions_ = extension->GetActivePermissions();
605 delegate_ = delegate;
[email protected]5db2e882012-12-20 10:17:26606 prompt_.set_type(INSTALL_PROMPT);
[email protected]af6efb22012-10-12 02:23:05607 show_dialog_callback_ = show_dialog_callback;
[email protected]c82da8c42012-06-08 19:49:11608
609 // We special-case themes to not show any confirm UI. Instead they are
610 // immediately installed, and then we show an infobar (see OnInstallSuccess)
611 // to allow the user to revert if they don't like it.
612 //
613 // We don't do this in the case where off-store extension installs are
614 // disabled because in that case, we don't show the dangerous download UI, so
615 // we need the UI confirmation.
616 if (extension->is_theme()) {
617 if (extension->from_webstore() ||
[email protected]544471a2012-10-13 05:27:09618 extensions::FeatureSwitch::easy_off_store_install()->IsEnabled()) {
[email protected]c82da8c42012-06-08 19:49:11619 delegate->InstallUIProceed();
620 return;
621 }
622 }
623
624 LoadImageIfNeeded();
625}
626
627void ExtensionInstallPrompt::ConfirmReEnable(Delegate* delegate,
628 const Extension* extension) {
[email protected]b3a25092013-05-28 22:08:16629 DCHECK(ui_loop_ == base::MessageLoop::current());
[email protected]c82da8c42012-06-08 19:49:11630 extension_ = extension;
631 permissions_ = extension->GetActivePermissions();
632 delegate_ = delegate;
[email protected]5db2e882012-12-20 10:17:26633 prompt_.set_type(RE_ENABLE_PROMPT);
[email protected]c82da8c42012-06-08 19:49:11634
635 LoadImageIfNeeded();
636}
637
[email protected]aa5a5472013-10-04 03:41:04638void ExtensionInstallPrompt::ConfirmDefaultInstallFirstRun(
639 Delegate* delegate,
640 const Extension* extension) {
641 DCHECK(ui_loop_ == base::MessageLoop::current());
642 extension_ = extension;
643 permissions_ = extension->GetActivePermissions();
644 delegate_ = delegate;
645 prompt_.set_type(DEFAULT_INSTALL_FIRST_RUN_PROMPT);
646 LoadImageIfNeeded();
647}
648
[email protected]612a1cb12012-10-17 13:18:03649void ExtensionInstallPrompt::ConfirmExternalInstall(
[email protected]c8ff7c9e2013-04-20 12:36:27650 Delegate* delegate,
651 const Extension* extension,
652 const ShowDialogCallback& show_dialog_callback) {
[email protected]b3a25092013-05-28 22:08:16653 DCHECK(ui_loop_ == base::MessageLoop::current());
[email protected]612a1cb12012-10-17 13:18:03654 extension_ = extension;
655 permissions_ = extension->GetActivePermissions();
656 delegate_ = delegate;
[email protected]5db2e882012-12-20 10:17:26657 prompt_.set_type(EXTERNAL_INSTALL_PROMPT);
[email protected]c8ff7c9e2013-04-20 12:36:27658 show_dialog_callback_ = show_dialog_callback;
[email protected]612a1cb12012-10-17 13:18:03659
660 LoadImageIfNeeded();
661}
662
[email protected]c82da8c42012-06-08 19:49:11663void ExtensionInstallPrompt::ConfirmPermissions(
664 Delegate* delegate,
665 const Extension* extension,
[email protected]c2e66e12012-06-27 06:27:06666 const PermissionSet* permissions) {
[email protected]b3a25092013-05-28 22:08:16667 DCHECK(ui_loop_ == base::MessageLoop::current());
[email protected]c82da8c42012-06-08 19:49:11668 extension_ = extension;
669 permissions_ = permissions;
670 delegate_ = delegate;
[email protected]5db2e882012-12-20 10:17:26671 prompt_.set_type(PERMISSIONS_PROMPT);
[email protected]c82da8c42012-06-08 19:49:11672
673 LoadImageIfNeeded();
674}
675
[email protected]f746b3f2012-07-03 17:53:37676void ExtensionInstallPrompt::ConfirmIssueAdvice(
677 Delegate* delegate,
678 const Extension* extension,
679 const IssueAdviceInfo& issue_advice) {
[email protected]b3a25092013-05-28 22:08:16680 DCHECK(ui_loop_ == base::MessageLoop::current());
[email protected]f746b3f2012-07-03 17:53:37681 extension_ = extension;
682 delegate_ = delegate;
[email protected]5db2e882012-12-20 10:17:26683 prompt_.set_type(PERMISSIONS_PROMPT);
[email protected]f746b3f2012-07-03 17:53:37684
685 record_oauth2_grant_ = true;
686 prompt_.SetOAuthIssueAdvice(issue_advice);
687
688 LoadImageIfNeeded();
689}
690
[email protected]a2886e8b2013-06-08 05:15:02691void ExtensionInstallPrompt::ReviewPermissions(
692 Delegate* delegate,
693 const Extension* extension,
694 const std::vector<base::FilePath>& retained_file_paths) {
[email protected]b3a25092013-05-28 22:08:16695 DCHECK(ui_loop_ == base::MessageLoop::current());
[email protected]15d267b42013-02-14 23:43:32696 extension_ = extension;
697 permissions_ = extension->GetActivePermissions();
[email protected]a2886e8b2013-06-08 05:15:02698 prompt_.set_retained_files(retained_file_paths);
[email protected]15d267b42013-02-14 23:43:32699 delegate_ = delegate;
700 prompt_.set_type(POST_INSTALL_PERMISSIONS_PROMPT);
701
702 LoadImageIfNeeded();
703}
704
[email protected]c82da8c42012-06-08 19:49:11705void ExtensionInstallPrompt::OnInstallSuccess(const Extension* extension,
706 SkBitmap* icon) {
707 extension_ = extension;
708 SetIcon(icon);
709
710 install_ui_->OnInstallSuccess(extension, &icon_);
711}
712
[email protected]bf3d9df2012-07-24 23:20:27713void ExtensionInstallPrompt::OnInstallFailure(
714 const extensions::CrxInstallerError& error) {
[email protected]c82da8c42012-06-08 19:49:11715 install_ui_->OnInstallFailure(error);
716}
717
718void ExtensionInstallPrompt::SetIcon(const SkBitmap* image) {
719 if (image)
720 icon_ = *image;
721 else
722 icon_ = SkBitmap();
[email protected]dd46a4ce2012-09-15 10:50:50723 if (icon_.empty()) {
724 // Let's set default icon bitmap whose size is equal to the default icon's
725 // pixel size under maximal supported scale factor. If the bitmap is larger
726 // than the one we need, it will be scaled down by the ui code.
727 icon_ = GetDefaultIconBitmapForMaxScaleFactor(extension_->is_app());
728 }
[email protected]c82da8c42012-06-08 19:49:11729}
730
[email protected]ec7de0c5a2012-11-16 07:40:47731void ExtensionInstallPrompt::OnImageLoaded(const gfx::Image& image) {
[email protected]c82da8c42012-06-08 19:49:11732 SetIcon(image.IsEmpty() ? NULL : image.ToSkBitmap());
[email protected]4e494872013-09-06 09:13:54733 ShowConfirmation();
[email protected]c82da8c42012-06-08 19:49:11734}
735
736void ExtensionInstallPrompt::LoadImageIfNeeded() {
737 // Bundle install prompts do not have an icon.
[email protected]5db2e882012-12-20 10:17:26738 // Also |install_ui_.profile()| can be NULL in unit tests.
739 if (!icon_.empty() || !install_ui_->profile()) {
[email protected]4e494872013-09-06 09:13:54740 ShowConfirmation();
[email protected]c82da8c42012-06-08 19:49:11741 return;
742 }
743
744 // Load the image asynchronously. For the response, check OnImageLoaded.
[email protected]993da5e2013-03-23 21:25:16745 extensions::ExtensionResource image = extensions::IconsInfo::GetIconResource(
[email protected]702d8b42013-02-27 20:55:50746 extension_,
747 extension_misc::EXTENSION_ICON_LARGE,
748 ExtensionIconSet::MATCH_BIGGER);
[email protected]dd46a4ce2012-09-15 10:50:50749 // Load the icon whose pixel size is large enough to be displayed under
750 // maximal supported scale factor. UI code will scale the icon down if needed.
751 // TODO(tbarzic): We should use IconImage here and load the required bitmap
752 // lazily.
753 int pixel_size = GetSizeForMaxScaleFactor(kIconSize);
[email protected]5db2e882012-12-20 10:17:26754 extensions::ImageLoader::Get(install_ui_->profile())->LoadImageAsync(
[email protected]ec7de0c5a2012-11-16 07:40:47755 extension_, image, gfx::Size(pixel_size, pixel_size),
756 base::Bind(&ExtensionInstallPrompt::OnImageLoaded, AsWeakPtr()));
[email protected]c82da8c42012-06-08 19:49:11757}
758
[email protected]4f3fb352013-07-17 04:07:01759void ExtensionInstallPrompt::OnGetTokenSuccess(
760 const OAuth2TokenService::Request* request,
761 const std::string& access_token,
762 const base::Time& expiration_time) {
763 DCHECK_EQ(login_token_request_.get(), request);
764 login_token_request_.reset();
765
766 const extensions::OAuth2Info& oauth2_info =
767 extensions::OAuth2Info::GetOAuth2Info(extension_);
768
[email protected]b70a2d92012-06-28 19:51:21769 token_flow_.reset(new OAuth2MintTokenFlow(
[email protected]4f3fb352013-07-17 04:07:01770 install_ui_->profile()->GetRequestContext(),
[email protected]b70a2d92012-06-28 19:51:21771 this,
772 OAuth2MintTokenFlow::Parameters(
[email protected]4f3fb352013-07-17 04:07:01773 access_token,
[email protected]b70a2d92012-06-28 19:51:21774 extension_->id(),
775 oauth2_info.client_id,
[email protected]d4a37f1c2012-07-09 21:36:13776 oauth2_info.scopes,
[email protected]b70a2d92012-06-28 19:51:21777 OAuth2MintTokenFlow::MODE_ISSUE_ADVICE)));
778 token_flow_->Start();
779}
780
[email protected]4f3fb352013-07-17 04:07:01781void ExtensionInstallPrompt::OnGetTokenFailure(
782 const OAuth2TokenService::Request* request,
783 const GoogleServiceAuthError& error) {
784 DCHECK_EQ(login_token_request_.get(), request);
785 login_token_request_.reset();
786 ShowConfirmation();
787}
788
[email protected]b70a2d92012-06-28 19:51:21789void ExtensionInstallPrompt::OnIssueAdviceSuccess(
790 const IssueAdviceInfo& advice_info) {
791 prompt_.SetOAuthIssueAdvice(advice_info);
792 record_oauth2_grant_ = true;
793 ShowConfirmation();
794}
795
796void ExtensionInstallPrompt::OnMintTokenFailure(
797 const GoogleServiceAuthError& error) {
798 ShowConfirmation();
799}
800
[email protected]c82da8c42012-06-08 19:49:11801void ExtensionInstallPrompt::ShowConfirmation() {
[email protected]dc24976f2013-06-02 21:15:09802 if (permissions_.get() &&
[email protected]13c68b62013-05-17 11:29:05803 (!extension_ ||
804 !extensions::PermissionsData::ShouldSkipPermissionWarnings(
805 extension_))) {
[email protected]1d5e58b2013-01-31 08:41:40806 Manifest::Type extension_type = extension_ ?
807 extension_->GetType() : Manifest::TYPE_UNKNOWN;
[email protected]8ab7e6c2013-07-11 21:15:03808 prompt_.SetPermissions(
[email protected]c41003472013-10-19 15:37:25809 extensions::PermissionMessageProvider::Get()->
810 GetWarningMessages(permissions_, extension_type));
[email protected]8ab7e6c2013-07-11 21:15:03811 prompt_.SetPermissionsDetails(
[email protected]c41003472013-10-19 15:37:25812 extensions::PermissionMessageProvider::Get()->
813 GetWarningMessagesDetails(permissions_, extension_type));
[email protected]bebe1d02012-08-02 20:17:09814 }
[email protected]c82da8c42012-06-08 19:49:11815
[email protected]5db2e882012-12-20 10:17:26816 switch (prompt_.type()) {
[email protected]c82da8c42012-06-08 19:49:11817 case PERMISSIONS_PROMPT:
818 case RE_ENABLE_PROMPT:
[email protected]aa5a5472013-10-04 03:41:04819 case DEFAULT_INSTALL_FIRST_RUN_PROMPT:
[email protected]c82da8c42012-06-08 19:49:11820 case INLINE_INSTALL_PROMPT:
[email protected]612a1cb12012-10-17 13:18:03821 case EXTERNAL_INSTALL_PROMPT:
[email protected]15d267b42013-02-14 23:43:32822 case INSTALL_PROMPT:
[email protected]1a93d8d2013-10-27 23:09:20823 case LAUNCH_PROMPT:
[email protected]15d267b42013-02-14 23:43:32824 case POST_INSTALL_PERMISSIONS_PROMPT: {
[email protected]c82da8c42012-06-08 19:49:11825 prompt_.set_extension(extension_);
[email protected]32e7a9b2013-01-23 23:00:19826 prompt_.set_icon(gfx::Image::CreateFrom1xBitmap(icon_));
[email protected]c82da8c42012-06-08 19:49:11827 break;
828 }
829 case BUNDLE_INSTALL_PROMPT: {
830 prompt_.set_bundle(bundle_);
[email protected]c82da8c42012-06-08 19:49:11831 break;
832 }
833 default:
834 NOTREACHED() << "Unknown message";
[email protected]af6efb22012-10-12 02:23:05835 return;
[email protected]c82da8c42012-06-08 19:49:11836 }
[email protected]af6efb22012-10-12 02:23:05837
838 if (AutoConfirmPrompt(delegate_))
839 return;
840
[email protected]5db2e882012-12-20 10:17:26841 if (show_dialog_callback_.is_null())
842 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_);
843 else
844 show_dialog_callback_.Run(show_params_, delegate_, prompt_);
[email protected]c82da8c42012-06-08 19:49:11845}