OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/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 Loading... | |
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 case ExtensionInstallPrompt::EXTERNAL_INSTALL_PROMPT: | 128 case ExtensionInstallPrompt::EXTERNAL_INSTALL_PROMPT: |
204 return "EXTERNAL_INSTALL_PROMPT"; | 129 return "EXTERNAL_INSTALL_PROMPT"; |
205 case ExtensionInstallPrompt::POST_INSTALL_PERMISSIONS_PROMPT: | 130 case ExtensionInstallPrompt::POST_INSTALL_PERMISSIONS_PROMPT: |
206 return "POST_INSTALL_PERMISSIONS_PROMPT"; | 131 return "POST_INSTALL_PERMISSIONS_PROMPT"; |
207 case ExtensionInstallPrompt::REMOTE_INSTALL_PROMPT: | 132 case ExtensionInstallPrompt::REMOTE_INSTALL_PROMPT: |
208 return "REMOTE_INSTALL_PROMPT"; | 133 return "REMOTE_INSTALL_PROMPT"; |
209 case ExtensionInstallPrompt::REPAIR_PROMPT: | 134 case ExtensionInstallPrompt::REPAIR_PROMPT: |
210 return "REPAIR_PROMPT"; | 135 return "REPAIR_PROMPT"; |
211 case ExtensionInstallPrompt::DELEGATED_PERMISSIONS_PROMPT: | 136 case ExtensionInstallPrompt::DELEGATED_PERMISSIONS_PROMPT: |
212 return "DELEGATED_PERMISSIONS_PROMPT"; | 137 return "DELEGATED_PERMISSIONS_PROMPT"; |
213 case ExtensionInstallPrompt::LAUNCH_PROMPT_DEPRECATED: | |
214 case ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT_DEPRECATED: | |
215 case ExtensionInstallPrompt::DELEGATED_BUNDLE_PERMISSIONS_PROMPT_DEPRECATED: | |
216 NOTREACHED(); | |
217 // fall through: | |
218 case ExtensionInstallPrompt::UNSET_PROMPT_TYPE: | 138 case ExtensionInstallPrompt::UNSET_PROMPT_TYPE: |
219 case ExtensionInstallPrompt::NUM_PROMPT_TYPES: | 139 case ExtensionInstallPrompt::NUM_PROMPT_TYPES: |
140 NOTREACHED(); | |
lazyboy
2017/02/21 21:43:05
Can types_ be ever set to these upon constructing
Devlin
2017/02/22 00:08:40
Done.
| |
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), |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 int rating_count) { | 214 int rating_count) { |
294 CHECK(AllowWebstoreData(type_)); | 215 CHECK(AllowWebstoreData(type_)); |
295 localized_user_count_ = localized_user_count; | 216 localized_user_count_ = localized_user_count; |
296 show_user_count_ = show_user_count; | 217 show_user_count_ = show_user_count; |
297 average_rating_ = average_rating; | 218 average_rating_ = average_rating; |
298 rating_count_ = rating_count; | 219 rating_count_ = rating_count; |
299 has_webstore_data_ = true; | 220 has_webstore_data_ = true; |
300 } | 221 } |
301 | 222 |
302 base::string16 ExtensionInstallPrompt::Prompt::GetDialogTitle() const { | 223 base::string16 ExtensionInstallPrompt::Prompt::GetDialogTitle() const { |
303 int id = kTitleIds[type_]; | 224 int id = -1; |
304 if (type_ == DELEGATED_PERMISSIONS_PROMPT) { | 225 switch (type_) { |
305 return l10n_util::GetStringFUTF16(id, base::UTF8ToUTF16(extension_->name()), | 226 case INSTALL_PROMPT: |
306 base::UTF8ToUTF16(delegated_username_)); | 227 case INLINE_INSTALL_PROMPT: |
228 id = IDS_EXTENSION_INSTALL_PROMPT_TITLE; | |
229 break; | |
230 case RE_ENABLE_PROMPT: | |
231 id = IDS_EXTENSION_RE_ENABLE_PROMPT_TITLE; | |
232 break; | |
233 case PERMISSIONS_PROMPT: | |
234 id = IDS_EXTENSION_PERMISSIONS_PROMPT_TITLE; | |
235 break; | |
236 case EXTERNAL_INSTALL_PROMPT: | |
237 if (extension_->is_app()) | |
238 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_TITLE_APP; | |
239 else if (extension_->is_theme()) | |
240 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_TITLE_THEME; | |
241 else | |
242 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_TITLE_EXTENSION; | |
243 break; | |
244 case POST_INSTALL_PERMISSIONS_PROMPT: | |
245 id = IDS_EXTENSION_POST_INSTALL_PERMISSIONS_PROMPT_TITLE; | |
246 break; | |
247 case REMOTE_INSTALL_PROMPT: | |
248 id = IDS_EXTENSION_REMOTE_INSTALL_PROMPT_TITLE; | |
249 break; | |
250 case REPAIR_PROMPT: | |
251 id = IDS_EXTENSION_REPAIR_PROMPT_TITLE; | |
252 break; | |
253 case DELEGATED_PERMISSIONS_PROMPT: | |
254 // Special case: need to include the delegated username. | |
255 return l10n_util::GetStringFUTF16( | |
256 IDS_EXTENSION_DELEGATED_INSTALL_PROMPT_TITLE, | |
257 base::UTF8ToUTF16(extension_->name()), | |
258 base::UTF8ToUTF16(delegated_username_)); | |
259 case UNSET_PROMPT_TYPE: | |
260 case NUM_PROMPT_TYPES: | |
261 NOTREACHED(); | |
307 } | 262 } |
308 if (type_ == EXTERNAL_INSTALL_PROMPT) { | 263 |
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())); | 264 return l10n_util::GetStringFUTF16(id, base::UTF8ToUTF16(extension_->name())); |
317 } | 265 } |
318 | 266 |
319 int ExtensionInstallPrompt::Prompt::GetDialogButtons() const { | 267 int ExtensionInstallPrompt::Prompt::GetDialogButtons() const { |
320 if (type_ == POST_INSTALL_PERMISSIONS_PROMPT && ShouldDisplayRevokeButton()) { | 268 int buttons = 0; |
321 return kButtons[type_] | ui::DIALOG_BUTTON_OK; | 269 switch (type_) { |
270 case INSTALL_PROMPT: | |
271 case INLINE_INSTALL_PROMPT: | |
272 case RE_ENABLE_PROMPT: | |
273 case PERMISSIONS_PROMPT: | |
274 case EXTERNAL_INSTALL_PROMPT: | |
275 case REMOTE_INSTALL_PROMPT: | |
276 case REPAIR_PROMPT: | |
277 case DELEGATED_PERMISSIONS_PROMPT: | |
278 buttons = ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; | |
279 break; | |
280 case POST_INSTALL_PERMISSIONS_PROMPT: | |
281 buttons = ui::DIALOG_BUTTON_CANCEL; | |
lazyboy
2017/02/21 21:43:05
Since there's only one special case, I think even
Devlin
2017/02/22 00:08:40
Done.
| |
282 // The "OK" button in the post install permissions dialog allows revoking | |
283 // file/device access, and is only shown if such permissions exist; see | |
284 // ShouldDisplayRevokeButton(). | |
285 if (ShouldDisplayRevokeButton()) | |
286 buttons |= ui::DIALOG_BUTTON_OK; | |
287 break; | |
288 case UNSET_PROMPT_TYPE: | |
289 case NUM_PROMPT_TYPES: | |
290 NOTREACHED(); | |
322 } | 291 } |
323 | 292 return buttons; |
324 return kButtons[type_]; | |
325 } | 293 } |
326 | 294 |
327 base::string16 ExtensionInstallPrompt::Prompt::GetAcceptButtonLabel() const { | 295 base::string16 ExtensionInstallPrompt::Prompt::GetAcceptButtonLabel() const { |
328 int id = kAcceptButtonIds[type_]; | 296 int id = -1; |
297 switch (type_) { | |
298 case INSTALL_PROMPT: | |
299 case INLINE_INSTALL_PROMPT: | |
300 if (extension_->is_app()) | |
301 id = IDS_EXTENSION_INSTALL_PROMPT_ACCEPT_BUTTON_APP; | |
302 else if (extension_->is_theme()) | |
303 id = IDS_EXTENSION_INSTALL_PROMPT_ACCEPT_BUTTON_THEME; | |
304 else | |
305 id = IDS_EXTENSION_INSTALL_PROMPT_ACCEPT_BUTTON_EXTENSION; | |
306 break; | |
307 case RE_ENABLE_PROMPT: | |
lazyboy
2017/02/21 21:43:05
RE_ENABLE_PROMPT used to return
IDS_EXTENSION_PROM
Devlin
2017/02/22 00:08:40
Good catch! Changed.
| |
308 case PERMISSIONS_PROMPT: | |
309 case EXTERNAL_INSTALL_PROMPT: | |
310 if (extension_->is_app()) | |
311 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_APP; | |
312 else if (extension_->is_theme()) | |
313 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_THEME; | |
314 else | |
315 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_EXTENSION; | |
316 break; | |
317 case POST_INSTALL_PERMISSIONS_PROMPT: | |
318 if (GetRetainedFileCount() && GetRetainedDeviceCount()) { | |
319 id = | |
320 IDS_EXTENSION_PROMPT_PERMISSIONS_CLEAR_RETAINED_FILES_AND_DEVICES_BU TTON; | |
321 } else if (GetRetainedFileCount()) { | |
322 id = IDS_EXTENSION_PROMPT_PERMISSIONS_CLEAR_RETAINED_FILES_BUTTON; | |
323 } else if (GetRetainedDeviceCount()) { | |
324 id = IDS_EXTENSION_PROMPT_PERMISSIONS_CLEAR_RETAINED_DEVICES_BUTTON; | |
325 } | |
326 // If there are neither retained files nor devices, leave id 0 so there | |
lazyboy
2017/02/21 21:43:05
"leave id to -1"
Devlin
2017/02/22 00:08:40
Done.
| |
327 // will be no "accept" button. | |
328 break; | |
329 case REMOTE_INSTALL_PROMPT: | |
330 if (extension_->is_app()) | |
331 id = IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON_APP; | |
332 else | |
333 id = IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON_EXTENSION; | |
334 break; | |
335 case REPAIR_PROMPT: | |
336 if (extension_->is_app()) | |
337 id = IDS_EXTENSION_PROMPT_REPAIR_BUTTON_APP; | |
338 else | |
339 id = IDS_EXTENSION_PROMPT_REPAIR_BUTTON_EXTENSION; | |
340 break; | |
341 case DELEGATED_PERMISSIONS_PROMPT: | |
342 id = IDS_EXTENSION_PROMPT_INSTALL_BUTTON; | |
343 break; | |
344 case UNSET_PROMPT_TYPE: | |
345 case NUM_PROMPT_TYPES: | |
346 NOTREACHED(); | |
347 } | |
329 | 348 |
330 if (type_ == INSTALL_PROMPT || type_ == INLINE_INSTALL_PROMPT) { | 349 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 } | 350 } |
368 | 351 |
369 base::string16 ExtensionInstallPrompt::Prompt::GetAbortButtonLabel() const { | 352 base::string16 ExtensionInstallPrompt::Prompt::GetAbortButtonLabel() const { |
370 return l10n_util::GetStringUTF16(kAbortButtonIds[type_]); | 353 int id = -1; |
354 switch (type_) { | |
355 case INSTALL_PROMPT: | |
356 case INLINE_INSTALL_PROMPT: | |
357 case RE_ENABLE_PROMPT: | |
358 case REMOTE_INSTALL_PROMPT: | |
359 case REPAIR_PROMPT: | |
360 case DELEGATED_PERMISSIONS_PROMPT: | |
361 id = IDS_CANCEL; | |
362 break; | |
363 case PERMISSIONS_PROMPT: | |
364 id = IDS_EXTENSION_PROMPT_PERMISSIONS_ABORT_BUTTON; | |
365 break; | |
366 case EXTERNAL_INSTALL_PROMPT: | |
367 id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ABORT_BUTTON; | |
368 break; | |
369 case POST_INSTALL_PERMISSIONS_PROMPT: | |
370 id = IDS_CLOSE; | |
371 break; | |
372 case UNSET_PROMPT_TYPE: | |
373 case NUM_PROMPT_TYPES: | |
374 NOTREACHED(); | |
375 } | |
376 | |
377 return l10n_util::GetStringUTF16(id); | |
371 } | 378 } |
372 | 379 |
373 base::string16 ExtensionInstallPrompt::Prompt::GetPermissionsHeading( | 380 base::string16 ExtensionInstallPrompt::Prompt::GetPermissionsHeading( |
374 PermissionsType permissions_type) const { | 381 PermissionsType permissions_type) const { |
375 switch (permissions_type) { | 382 switch (permissions_type) { |
376 case REGULAR_PERMISSIONS: | 383 case REGULAR_PERMISSIONS: { |
377 return l10n_util::GetStringUTF16(kPermissionsHeaderIds[type_]); | 384 int id = -1; |
385 switch (type_) { | |
386 case INSTALL_PROMPT: | |
387 case INLINE_INSTALL_PROMPT: | |
388 case EXTERNAL_INSTALL_PROMPT: | |
389 case REMOTE_INSTALL_PROMPT: | |
390 case DELEGATED_PERMISSIONS_PROMPT: | |
391 id = IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO; | |
392 break; | |
393 case RE_ENABLE_PROMPT: | |
394 id = IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO; | |
395 break; | |
396 case PERMISSIONS_PROMPT: | |
397 id = IDS_EXTENSION_PROMPT_WANTS_ACCESS_TO; | |
398 break; | |
399 case POST_INSTALL_PERMISSIONS_PROMPT: | |
400 case REPAIR_PROMPT: | |
401 id = IDS_EXTENSION_PROMPT_CAN_ACCESS; | |
402 break; | |
403 case UNSET_PROMPT_TYPE: | |
404 case NUM_PROMPT_TYPES: | |
405 NOTREACHED(); | |
406 } | |
407 return l10n_util::GetStringUTF16(id); | |
408 } | |
378 case WITHHELD_PERMISSIONS: | 409 case WITHHELD_PERMISSIONS: |
379 return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WITHHELD); | 410 return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WITHHELD); |
380 case ALL_PERMISSIONS: | 411 case ALL_PERMISSIONS: |
381 default: | |
382 NOTREACHED(); | 412 NOTREACHED(); |
383 return base::string16(); | 413 return base::string16(); |
384 } | 414 } |
415 NOTREACHED(); | |
416 return base::string16(); | |
385 } | 417 } |
386 | 418 |
387 base::string16 ExtensionInstallPrompt::Prompt::GetRetainedFilesHeading() const { | 419 base::string16 ExtensionInstallPrompt::Prompt::GetRetainedFilesHeading() const { |
388 return l10n_util::GetPluralStringFUTF16( | 420 return l10n_util::GetPluralStringFUTF16( |
389 IDS_EXTENSION_PROMPT_RETAINED_FILES, GetRetainedFileCount()); | 421 IDS_EXTENSION_PROMPT_RETAINED_FILES, GetRetainedFileCount()); |
390 } | 422 } |
391 | 423 |
392 base::string16 ExtensionInstallPrompt::Prompt::GetRetainedDevicesHeading() | 424 base::string16 ExtensionInstallPrompt::Prompt::GetRetainedDevicesHeading() |
393 const { | 425 const { |
394 return l10n_util::GetPluralStringFUTF16( | 426 return l10n_util::GetPluralStringFUTF16( |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
778 extension_ ? &extension_->permissions_data()->withheld_permissions() | 810 extension_ ? &extension_->permissions_data()->withheld_permissions() |
779 : nullptr; | 811 : nullptr; |
780 if (withheld && !withheld->IsEmpty()) { | 812 if (withheld && !withheld->IsEmpty()) { |
781 prompt_->SetPermissions( | 813 prompt_->SetPermissions( |
782 message_provider->GetPermissionMessages( | 814 message_provider->GetPermissionMessages( |
783 message_provider->GetAllPermissionIDs(*withheld, type)), | 815 message_provider->GetAllPermissionIDs(*withheld, type)), |
784 WITHHELD_PERMISSIONS); | 816 WITHHELD_PERMISSIONS); |
785 } | 817 } |
786 } | 818 } |
787 | 819 |
788 switch (prompt_->type()) { | 820 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_)); | 821 prompt_->set_icon(gfx::Image::CreateFrom1xBitmap(icon_)); |
807 | 822 |
808 if (show_params_->WasParentDestroyed()) { | 823 if (show_params_->WasParentDestroyed()) { |
809 base::ResetAndReturn(&done_callback_).Run(Result::ABORTED); | 824 base::ResetAndReturn(&done_callback_).Run(Result::ABORTED); |
810 return; | 825 return; |
811 } | 826 } |
812 | 827 |
813 g_last_prompt_type_for_tests = prompt_->type(); | 828 g_last_prompt_type_for_tests = prompt_->type(); |
814 did_call_show_dialog_ = true; | 829 did_call_show_dialog_ = true; |
815 | 830 |
816 if (AutoConfirmPrompt(&done_callback_)) | 831 if (AutoConfirmPrompt(&done_callback_)) |
817 return; | 832 return; |
818 | 833 |
819 if (show_dialog_callback_.is_null()) | 834 if (show_dialog_callback_.is_null()) |
820 show_dialog_callback_ = GetDefaultShowDialogCallback(); | 835 show_dialog_callback_ = GetDefaultShowDialogCallback(); |
821 base::ResetAndReturn(&show_dialog_callback_) | 836 base::ResetAndReturn(&show_dialog_callback_) |
822 .Run(show_params_.get(), base::ResetAndReturn(&done_callback_), | 837 .Run(show_params_.get(), base::ResetAndReturn(&done_callback_), |
823 std::move(prompt_)); | 838 std::move(prompt_)); |
824 } | 839 } |
OLD | NEW |