Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Side by Side Diff: chrome/browser/extensions/extension_install_prompt.cc

Issue 2705733002: [Extensions] Deprecate old install prompt types (Closed)
Patch Set: lazyboy's Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/extensions/extension_install_prompt.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/extension_install_prompt.h" 5 #include "chrome/browser/extensions/extension_install_prompt.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 using extensions::PermissionSet; 53 using extensions::PermissionSet;
54 54
55 namespace { 55 namespace {
56 56
57 bool AllowWebstoreData(ExtensionInstallPrompt::PromptType type) { 57 bool AllowWebstoreData(ExtensionInstallPrompt::PromptType type) {
58 return type == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT || 58 return type == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT ||
59 type == ExtensionInstallPrompt::EXTERNAL_INSTALL_PROMPT || 59 type == ExtensionInstallPrompt::EXTERNAL_INSTALL_PROMPT ||
60 type == ExtensionInstallPrompt::REPAIR_PROMPT; 60 type == ExtensionInstallPrompt::REPAIR_PROMPT;
61 } 61 }
62 62
63 static const int kTitleIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
64 IDS_EXTENSION_INSTALL_PROMPT_TITLE,
65 IDS_EXTENSION_INSTALL_PROMPT_TITLE,
66 0, // Deprecated.
67 IDS_EXTENSION_RE_ENABLE_PROMPT_TITLE,
68 IDS_EXTENSION_PERMISSIONS_PROMPT_TITLE,
69 0, // External installs use different strings for extensions/apps/themes.
70 IDS_EXTENSION_POST_INSTALL_PERMISSIONS_PROMPT_TITLE,
71 IDS_EXTENSION_LAUNCH_APP_PROMPT_TITLE,
72 IDS_EXTENSION_REMOTE_INSTALL_PROMPT_TITLE,
73 IDS_EXTENSION_REPAIR_PROMPT_TITLE,
74 IDS_EXTENSION_DELEGATED_INSTALL_PROMPT_TITLE,
75 0, // Deprecated.
76 };
77 static 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 // The "OK" button in the post install permissions dialog allows revoking
85 // file/device access, and is only shown if such permissions exist; see
86 // ShouldDisplayRevokeButton().
87 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_OK | ui::DIALOG_BUTTON_CANCEL,
93 };
94 static const int kAcceptButtonIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
95 0, // Regular installs use different strings for extensions/apps/themes.
96 0, // Inline installs as well.
97 IDS_EXTENSION_PROMPT_INSTALL_BUTTON,
98 IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON,
99 IDS_EXTENSION_PROMPT_PERMISSIONS_BUTTON,
100 0, // External installs use different strings for extensions/apps/themes.
101 0, // Different strings depending on the files and devices retained.
102 IDS_EXTENSION_PROMPT_LAUNCH_BUTTON,
103 0, // Remote installs use different strings for extensions/apps.
104 0, // Repairs use different strings for extensions/apps.
105 IDS_EXTENSION_PROMPT_INSTALL_BUTTON,
106 IDS_EXTENSION_PROMPT_INSTALL_BUTTON,
107 };
108 static const int kAbortButtonIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
109 IDS_CANCEL,
110 IDS_CANCEL,
111 IDS_CANCEL,
112 IDS_CANCEL,
113 IDS_EXTENSION_PROMPT_PERMISSIONS_ABORT_BUTTON,
114 IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ABORT_BUTTON,
115 IDS_CLOSE,
116 IDS_CANCEL,
117 IDS_CANCEL,
118 IDS_CANCEL,
119 IDS_CANCEL,
120 IDS_CANCEL,
121 };
122 static const int
123 kPermissionsHeaderIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
124 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO,
125 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO,
126 IDS_EXTENSION_PROMPT_THESE_WILL_HAVE_ACCESS_TO,
127 IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO,
128 IDS_EXTENSION_PROMPT_WANTS_ACCESS_TO,
129 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO,
130 IDS_EXTENSION_PROMPT_CAN_ACCESS,
131 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO,
132 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO,
133 IDS_EXTENSION_PROMPT_CAN_ACCESS,
134 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO,
135 IDS_EXTENSION_PROMPT_THESE_WILL_HAVE_ACCESS_TO,
136 };
137
138 // Returns bitmap for the default icon with size equal to the default icon's 63 // Returns bitmap for the default icon with size equal to the default icon's
139 // pixel size under maximal supported scale factor. 64 // pixel size under maximal supported scale factor.
140 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { 65 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) {
141 const gfx::ImageSkia& image = is_app ? 66 const gfx::ImageSkia& image = is_app ?
142 extensions::util::GetDefaultAppIcon() : 67 extensions::util::GetDefaultAppIcon() :
143 extensions::util::GetDefaultExtensionIcon(); 68 extensions::util::GetDefaultExtensionIcon();
144 return image.GetRepresentation( 69 return image.GetRepresentation(
145 gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap(); 70 gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap();
146 } 71 }
147 72
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 ~InstallPromptPermissions() { 110 ~InstallPromptPermissions() {
186 } 111 }
187 112
188 ExtensionInstallPrompt::PromptType 113 ExtensionInstallPrompt::PromptType
189 ExtensionInstallPrompt::g_last_prompt_type_for_tests = 114 ExtensionInstallPrompt::g_last_prompt_type_for_tests =
190 ExtensionInstallPrompt::UNSET_PROMPT_TYPE; 115 ExtensionInstallPrompt::UNSET_PROMPT_TYPE;
191 116
192 // This should match the PromptType enum. 117 // This should match the PromptType enum.
193 std::string ExtensionInstallPrompt::PromptTypeToString(PromptType type) { 118 std::string ExtensionInstallPrompt::PromptTypeToString(PromptType type) {
194 switch (type) { 119 switch (type) {
195 case ExtensionInstallPrompt::INSTALL_PROMPT: 120 case INSTALL_PROMPT:
196 return "INSTALL_PROMPT"; 121 return "INSTALL_PROMPT";
197 case ExtensionInstallPrompt::INLINE_INSTALL_PROMPT: 122 case INLINE_INSTALL_PROMPT:
198 return "INLINE_INSTALL_PROMPT"; 123 return "INLINE_INSTALL_PROMPT";
199 case ExtensionInstallPrompt::RE_ENABLE_PROMPT: 124 case RE_ENABLE_PROMPT:
200 return "RE_ENABLE_PROMPT"; 125 return "RE_ENABLE_PROMPT";
201 case ExtensionInstallPrompt::PERMISSIONS_PROMPT: 126 case PERMISSIONS_PROMPT:
202 return "PERMISSIONS_PROMPT"; 127 return "PERMISSIONS_PROMPT";
203 case ExtensionInstallPrompt::EXTERNAL_INSTALL_PROMPT: 128 case EXTERNAL_INSTALL_PROMPT:
204 return "EXTERNAL_INSTALL_PROMPT"; 129 return "EXTERNAL_INSTALL_PROMPT";
205 case ExtensionInstallPrompt::POST_INSTALL_PERMISSIONS_PROMPT: 130 case POST_INSTALL_PERMISSIONS_PROMPT:
206 return "POST_INSTALL_PERMISSIONS_PROMPT"; 131 return "POST_INSTALL_PERMISSIONS_PROMPT";
207 case ExtensionInstallPrompt::REMOTE_INSTALL_PROMPT: 132 case REMOTE_INSTALL_PROMPT:
208 return "REMOTE_INSTALL_PROMPT"; 133 return "REMOTE_INSTALL_PROMPT";
209 case ExtensionInstallPrompt::REPAIR_PROMPT: 134 case REPAIR_PROMPT:
210 return "REPAIR_PROMPT"; 135 return "REPAIR_PROMPT";
211 case ExtensionInstallPrompt::DELEGATED_PERMISSIONS_PROMPT: 136 case DELEGATED_PERMISSIONS_PROMPT:
212 return "DELEGATED_PERMISSIONS_PROMPT"; 137 return "DELEGATED_PERMISSIONS_PROMPT";
213 case ExtensionInstallPrompt::LAUNCH_PROMPT_DEPRECATED: 138 case UNSET_PROMPT_TYPE:
214 case ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT_DEPRECATED: 139 case NUM_PROMPT_TYPES:
215 case ExtensionInstallPrompt::DELEGATED_BUNDLE_PERMISSIONS_PROMPT_DEPRECATED:
216 NOTREACHED(); 140 NOTREACHED();
217 // fall through:
218 case ExtensionInstallPrompt::UNSET_PROMPT_TYPE:
219 case ExtensionInstallPrompt::NUM_PROMPT_TYPES:
220 break; 141 break;
221 } 142 }
222 return "OTHER"; 143 return "OTHER";
223 } 144 }
224 145
225 ExtensionInstallPrompt::Prompt::Prompt(PromptType type) 146 ExtensionInstallPrompt::Prompt::Prompt(PromptType type)
226 : type_(type), 147 : type_(type),
227 is_showing_details_for_retained_files_(false), 148 is_showing_details_for_retained_files_(false),
228 is_showing_details_for_retained_devices_(false), 149 is_showing_details_for_retained_devices_(false),
229 extension_(NULL), 150 extension_(NULL),
230 average_rating_(0.0), 151 average_rating_(0.0),
231 rating_count_(0), 152 rating_count_(0),
232 show_user_count_(false), 153 show_user_count_(false),
233 has_webstore_data_(false) { 154 has_webstore_data_(false) {
155 DCHECK_NE(type_, UNSET_PROMPT_TYPE);
156 DCHECK_NE(type_, NUM_PROMPT_TYPES);
234 } 157 }
235 158
236 ExtensionInstallPrompt::Prompt::~Prompt() { 159 ExtensionInstallPrompt::Prompt::~Prompt() {
237 } 160 }
238 161
239 void ExtensionInstallPrompt::Prompt::SetPermissions( 162 void ExtensionInstallPrompt::Prompt::SetPermissions(
240 const PermissionMessages& permissions, 163 const PermissionMessages& permissions,
241 PermissionsType permissions_type) { 164 PermissionsType permissions_type) {
242 InstallPromptPermissions& install_permissions = 165 InstallPromptPermissions& install_permissions =
243 GetPermissionsForType(permissions_type); 166 GetPermissionsForType(permissions_type);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 int rating_count) { 216 int rating_count) {
294 CHECK(AllowWebstoreData(type_)); 217 CHECK(AllowWebstoreData(type_));
295 localized_user_count_ = localized_user_count; 218 localized_user_count_ = localized_user_count;
296 show_user_count_ = show_user_count; 219 show_user_count_ = show_user_count;
297 average_rating_ = average_rating; 220 average_rating_ = average_rating;
298 rating_count_ = rating_count; 221 rating_count_ = rating_count;
299 has_webstore_data_ = true; 222 has_webstore_data_ = true;
300 } 223 }
301 224
302 base::string16 ExtensionInstallPrompt::Prompt::GetDialogTitle() const { 225 base::string16 ExtensionInstallPrompt::Prompt::GetDialogTitle() const {
303 int id = kTitleIds[type_]; 226 int id = -1;
304 if (type_ == DELEGATED_PERMISSIONS_PROMPT) { 227 switch (type_) {
305 return l10n_util::GetStringFUTF16(id, base::UTF8ToUTF16(extension_->name()), 228 case INSTALL_PROMPT:
306 base::UTF8ToUTF16(delegated_username_)); 229 case INLINE_INSTALL_PROMPT:
230 id = IDS_EXTENSION_INSTALL_PROMPT_TITLE;
231 break;
232 case RE_ENABLE_PROMPT:
233 id = IDS_EXTENSION_RE_ENABLE_PROMPT_TITLE;
234 break;
235 case PERMISSIONS_PROMPT:
236 id = IDS_EXTENSION_PERMISSIONS_PROMPT_TITLE;
237 break;
238 case EXTERNAL_INSTALL_PROMPT:
239 if (extension_->is_app())
240 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_TITLE_APP;
241 else if (extension_->is_theme())
242 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_TITLE_THEME;
243 else
244 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_TITLE_EXTENSION;
245 break;
246 case POST_INSTALL_PERMISSIONS_PROMPT:
247 id = IDS_EXTENSION_POST_INSTALL_PERMISSIONS_PROMPT_TITLE;
248 break;
249 case REMOTE_INSTALL_PROMPT:
250 id = IDS_EXTENSION_REMOTE_INSTALL_PROMPT_TITLE;
251 break;
252 case REPAIR_PROMPT:
253 id = IDS_EXTENSION_REPAIR_PROMPT_TITLE;
254 break;
255 case DELEGATED_PERMISSIONS_PROMPT:
256 // Special case: need to include the delegated username.
257 return l10n_util::GetStringFUTF16(
258 IDS_EXTENSION_DELEGATED_INSTALL_PROMPT_TITLE,
259 base::UTF8ToUTF16(extension_->name()),
260 base::UTF8ToUTF16(delegated_username_));
261 case UNSET_PROMPT_TYPE:
262 case NUM_PROMPT_TYPES:
263 NOTREACHED();
307 } 264 }
308 if (type_ == EXTERNAL_INSTALL_PROMPT) { 265
309 if (extension_->is_app())
310 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_TITLE_APP;
311 else if (extension_->is_theme())
312 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_TITLE_THEME;
313 else
314 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_TITLE_EXTENSION;
315 }
316 return l10n_util::GetStringFUTF16(id, base::UTF8ToUTF16(extension_->name())); 266 return l10n_util::GetStringFUTF16(id, base::UTF8ToUTF16(extension_->name()));
317 } 267 }
318 268
319 int ExtensionInstallPrompt::Prompt::GetDialogButtons() const { 269 int ExtensionInstallPrompt::Prompt::GetDialogButtons() const {
320 if (type_ == POST_INSTALL_PERMISSIONS_PROMPT && ShouldDisplayRevokeButton()) { 270 // The "OK" button in the post install permissions dialog allows revoking
321 return kButtons[type_] | ui::DIALOG_BUTTON_OK; 271 // file/device access, and is only shown if such permissions exist; see
272 // ShouldDisplayRevokeButton().
273 if (type_ == POST_INSTALL_PERMISSIONS_PROMPT &&
274 !ShouldDisplayRevokeButton()) {
275 return ui::DIALOG_BUTTON_CANCEL;
322 } 276 }
323 277 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
324 return kButtons[type_];
325 } 278 }
326 279
327 base::string16 ExtensionInstallPrompt::Prompt::GetAcceptButtonLabel() const { 280 base::string16 ExtensionInstallPrompt::Prompt::GetAcceptButtonLabel() const {
328 int id = kAcceptButtonIds[type_]; 281 int id = -1;
282 switch (type_) {
283 case INSTALL_PROMPT:
284 case INLINE_INSTALL_PROMPT:
285 if (extension_->is_app())
286 id = IDS_EXTENSION_INSTALL_PROMPT_ACCEPT_BUTTON_APP;
287 else if (extension_->is_theme())
288 id = IDS_EXTENSION_INSTALL_PROMPT_ACCEPT_BUTTON_THEME;
289 else
290 id = IDS_EXTENSION_INSTALL_PROMPT_ACCEPT_BUTTON_EXTENSION;
291 break;
292 case RE_ENABLE_PROMPT:
293 id = IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON;
294 break;
295 case PERMISSIONS_PROMPT:
296 id = IDS_EXTENSION_PROMPT_PERMISSIONS_BUTTON;
297 break;
298 case EXTERNAL_INSTALL_PROMPT:
299 if (extension_->is_app())
300 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_APP;
301 else if (extension_->is_theme())
302 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_THEME;
303 else
304 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_EXTENSION;
305 break;
306 case POST_INSTALL_PERMISSIONS_PROMPT:
307 if (GetRetainedFileCount() && GetRetainedDeviceCount()) {
308 id =
309 IDS_EXTENSION_PROMPT_PERMISSIONS_CLEAR_RETAINED_FILES_AND_DEVICES_BU TTON;
310 } else if (GetRetainedFileCount()) {
311 id = IDS_EXTENSION_PROMPT_PERMISSIONS_CLEAR_RETAINED_FILES_BUTTON;
312 } else if (GetRetainedDeviceCount()) {
313 id = IDS_EXTENSION_PROMPT_PERMISSIONS_CLEAR_RETAINED_DEVICES_BUTTON;
314 }
315 // If there are neither retained files nor devices, leave id -1 so there
316 // will be no "accept" button.
317 break;
318 case REMOTE_INSTALL_PROMPT:
319 if (extension_->is_app())
320 id = IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON_APP;
321 else
322 id = IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON_EXTENSION;
323 break;
324 case REPAIR_PROMPT:
325 if (extension_->is_app())
326 id = IDS_EXTENSION_PROMPT_REPAIR_BUTTON_APP;
327 else
328 id = IDS_EXTENSION_PROMPT_REPAIR_BUTTON_EXTENSION;
329 break;
330 case DELEGATED_PERMISSIONS_PROMPT:
331 id = IDS_EXTENSION_PROMPT_INSTALL_BUTTON;
332 break;
333 case UNSET_PROMPT_TYPE:
334 case NUM_PROMPT_TYPES:
335 NOTREACHED();
336 }
329 337
330 if (type_ == INSTALL_PROMPT || type_ == INLINE_INSTALL_PROMPT) { 338 return id != -1 ? l10n_util::GetStringUTF16(id) : base::string16();
331 if (extension_->is_app())
332 id = IDS_EXTENSION_INSTALL_PROMPT_ACCEPT_BUTTON_APP;
333 else if (extension_->is_theme())
334 id = IDS_EXTENSION_INSTALL_PROMPT_ACCEPT_BUTTON_THEME;
335 else
336 id = IDS_EXTENSION_INSTALL_PROMPT_ACCEPT_BUTTON_EXTENSION;
337 } else if (type_ == EXTERNAL_INSTALL_PROMPT) {
338 if (extension_->is_app())
339 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_APP;
340 else if (extension_->is_theme())
341 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_THEME;
342 else
343 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_EXTENSION;
344 } else if (type_ == POST_INSTALL_PERMISSIONS_PROMPT) {
345 if (GetRetainedFileCount() && GetRetainedDeviceCount()) {
346 id =
347 IDS_EXTENSION_PROMPT_PERMISSIONS_CLEAR_RETAINED_FILES_AND_DEVICES_BUTT ON;
348 } else if (GetRetainedFileCount()) {
349 id = IDS_EXTENSION_PROMPT_PERMISSIONS_CLEAR_RETAINED_FILES_BUTTON;
350 } else if (GetRetainedDeviceCount()) {
351 id = IDS_EXTENSION_PROMPT_PERMISSIONS_CLEAR_RETAINED_DEVICES_BUTTON;
352 }
353 // If there are neither retained files nor devices, leave id 0 so there
354 // will be no "accept" button.
355 } else if (type_ == REMOTE_INSTALL_PROMPT) {
356 if (extension_->is_app())
357 id = IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON_APP;
358 else
359 id = IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON_EXTENSION;
360 } else if (type_ == REPAIR_PROMPT) {
361 if (extension_->is_app())
362 id = IDS_EXTENSION_PROMPT_REPAIR_BUTTON_APP;
363 else
364 id = IDS_EXTENSION_PROMPT_REPAIR_BUTTON_EXTENSION;
365 }
366 return id ? l10n_util::GetStringUTF16(id) : base::string16();
367 } 339 }
368 340
369 base::string16 ExtensionInstallPrompt::Prompt::GetAbortButtonLabel() const { 341 base::string16 ExtensionInstallPrompt::Prompt::GetAbortButtonLabel() const {
370 return l10n_util::GetStringUTF16(kAbortButtonIds[type_]); 342 int id = -1;
343 switch (type_) {
344 case INSTALL_PROMPT:
345 case INLINE_INSTALL_PROMPT:
346 case RE_ENABLE_PROMPT:
347 case REMOTE_INSTALL_PROMPT:
348 case REPAIR_PROMPT:
349 case DELEGATED_PERMISSIONS_PROMPT:
350 id = IDS_CANCEL;
351 break;
352 case PERMISSIONS_PROMPT:
353 id = IDS_EXTENSION_PROMPT_PERMISSIONS_ABORT_BUTTON;
354 break;
355 case EXTERNAL_INSTALL_PROMPT:
356 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ABORT_BUTTON;
357 break;
358 case POST_INSTALL_PERMISSIONS_PROMPT:
359 id = IDS_CLOSE;
360 break;
361 case UNSET_PROMPT_TYPE:
362 case NUM_PROMPT_TYPES:
363 NOTREACHED();
364 }
365
366 return l10n_util::GetStringUTF16(id);
371 } 367 }
372 368
373 base::string16 ExtensionInstallPrompt::Prompt::GetPermissionsHeading( 369 base::string16 ExtensionInstallPrompt::Prompt::GetPermissionsHeading(
374 PermissionsType permissions_type) const { 370 PermissionsType permissions_type) const {
375 switch (permissions_type) { 371 switch (permissions_type) {
376 case REGULAR_PERMISSIONS: 372 case REGULAR_PERMISSIONS: {
377 return l10n_util::GetStringUTF16(kPermissionsHeaderIds[type_]); 373 int id = -1;
374 switch (type_) {
375 case INSTALL_PROMPT:
376 case INLINE_INSTALL_PROMPT:
377 case EXTERNAL_INSTALL_PROMPT:
378 case REMOTE_INSTALL_PROMPT:
379 case DELEGATED_PERMISSIONS_PROMPT:
380 id = IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO;
381 break;
382 case RE_ENABLE_PROMPT:
383 id = IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO;
384 break;
385 case PERMISSIONS_PROMPT:
386 id = IDS_EXTENSION_PROMPT_WANTS_ACCESS_TO;
387 break;
388 case POST_INSTALL_PERMISSIONS_PROMPT:
389 case REPAIR_PROMPT:
390 id = IDS_EXTENSION_PROMPT_CAN_ACCESS;
391 break;
392 case UNSET_PROMPT_TYPE:
393 case NUM_PROMPT_TYPES:
394 NOTREACHED();
395 }
396 return l10n_util::GetStringUTF16(id);
397 }
378 case WITHHELD_PERMISSIONS: 398 case WITHHELD_PERMISSIONS:
379 return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WITHHELD); 399 return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WITHHELD);
380 case ALL_PERMISSIONS: 400 case ALL_PERMISSIONS:
381 default:
382 NOTREACHED(); 401 NOTREACHED();
383 return base::string16(); 402 return base::string16();
384 } 403 }
404 NOTREACHED();
405 return base::string16();
385 } 406 }
386 407
387 base::string16 ExtensionInstallPrompt::Prompt::GetRetainedFilesHeading() const { 408 base::string16 ExtensionInstallPrompt::Prompt::GetRetainedFilesHeading() const {
388 return l10n_util::GetPluralStringFUTF16( 409 return l10n_util::GetPluralStringFUTF16(
389 IDS_EXTENSION_PROMPT_RETAINED_FILES, GetRetainedFileCount()); 410 IDS_EXTENSION_PROMPT_RETAINED_FILES, GetRetainedFileCount());
390 } 411 }
391 412
392 base::string16 ExtensionInstallPrompt::Prompt::GetRetainedDevicesHeading() 413 base::string16 ExtensionInstallPrompt::Prompt::GetRetainedDevicesHeading()
393 const { 414 const {
394 return l10n_util::GetPluralStringFUTF16( 415 return l10n_util::GetPluralStringFUTF16(
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 extension_ ? &extension_->permissions_data()->withheld_permissions() 799 extension_ ? &extension_->permissions_data()->withheld_permissions()
779 : nullptr; 800 : nullptr;
780 if (withheld && !withheld->IsEmpty()) { 801 if (withheld && !withheld->IsEmpty()) {
781 prompt_->SetPermissions( 802 prompt_->SetPermissions(
782 message_provider->GetPermissionMessages( 803 message_provider->GetPermissionMessages(
783 message_provider->GetAllPermissionIDs(*withheld, type)), 804 message_provider->GetAllPermissionIDs(*withheld, type)),
784 WITHHELD_PERMISSIONS); 805 WITHHELD_PERMISSIONS);
785 } 806 }
786 } 807 }
787 808
788 switch (prompt_->type()) { 809 prompt_->set_extension(extension_);
789 case PERMISSIONS_PROMPT:
790 case RE_ENABLE_PROMPT:
791 case INLINE_INSTALL_PROMPT:
792 case EXTERNAL_INSTALL_PROMPT:
793 case INSTALL_PROMPT:
794 case POST_INSTALL_PERMISSIONS_PROMPT:
795 case REMOTE_INSTALL_PROMPT:
796 case REPAIR_PROMPT:
797 case DELEGATED_PERMISSIONS_PROMPT: {
798 prompt_->set_extension(extension_);
799 break;
800 }
801 case LAUNCH_PROMPT_DEPRECATED:
802 default:
803 NOTREACHED() << "Unknown message";
804 return;
805 }
806 prompt_->set_icon(gfx::Image::CreateFrom1xBitmap(icon_)); 810 prompt_->set_icon(gfx::Image::CreateFrom1xBitmap(icon_));
807 811
808 if (show_params_->WasParentDestroyed()) { 812 if (show_params_->WasParentDestroyed()) {
809 base::ResetAndReturn(&done_callback_).Run(Result::ABORTED); 813 base::ResetAndReturn(&done_callback_).Run(Result::ABORTED);
810 return; 814 return;
811 } 815 }
812 816
813 g_last_prompt_type_for_tests = prompt_->type(); 817 g_last_prompt_type_for_tests = prompt_->type();
814 did_call_show_dialog_ = true; 818 did_call_show_dialog_ = true;
815 819
816 if (AutoConfirmPrompt(&done_callback_)) 820 if (AutoConfirmPrompt(&done_callback_))
817 return; 821 return;
818 822
819 if (show_dialog_callback_.is_null()) 823 if (show_dialog_callback_.is_null())
820 show_dialog_callback_ = GetDefaultShowDialogCallback(); 824 show_dialog_callback_ = GetDefaultShowDialogCallback();
821 base::ResetAndReturn(&show_dialog_callback_) 825 base::ResetAndReturn(&show_dialog_callback_)
822 .Run(show_params_.get(), base::ResetAndReturn(&done_callback_), 826 .Run(show_params_.get(), base::ResetAndReturn(&done_callback_),
823 std::move(prompt_)); 827 std::move(prompt_));
824 } 828 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_prompt.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698