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_disabled_ui.h" | 5 #include "chrome/browser/extensions/extension_disabled_ui.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 base::UTF8ToUTF16(extension_->name())); | 208 base::UTF8ToUTF16(extension_->name())); |
209 } else { | 209 } else { |
210 return l10n_util::GetStringFUTF16(IDS_EXTENSION_DISABLED_ERROR_TITLE, | 210 return l10n_util::GetStringFUTF16(IDS_EXTENSION_DISABLED_ERROR_TITLE, |
211 base::UTF8ToUTF16(extension_->name())); | 211 base::UTF8ToUTF16(extension_->name())); |
212 } | 212 } |
213 } | 213 } |
214 | 214 |
215 std::vector<base::string16> | 215 std::vector<base::string16> |
216 ExtensionDisabledGlobalError::GetBubbleViewMessages() { | 216 ExtensionDisabledGlobalError::GetBubbleViewMessages() { |
217 std::vector<base::string16> messages; | 217 std::vector<base::string16> messages; |
218 | |
219 std::unique_ptr<const extensions::PermissionSet> granted = | |
Devlin
2017/04/19 19:18:33
no need for extensions:: prefix (this whole file)
catmullings
2017/04/20 02:01:59
Done.
| |
220 service_->extension_prefs()->GetGrantedPermissions(extension_->id()); | |
221 | |
222 const extensions::PermissionSet& active = | |
223 extension_->permissions_data()->active_permissions(); | |
224 | |
225 std::unique_ptr<const extensions::PermissionSet> requested_permissions = | |
226 extensions::PermissionSet::CreateDifference(active, *granted); | |
227 | |
218 PermissionMessages permission_warnings = | 228 PermissionMessages permission_warnings = |
219 extension_->permissions_data()->GetPermissionMessages(); | 229 extension_->permissions_data()->GetPermissionMessages( |
230 *requested_permissions); | |
231 | |
220 if (is_remote_install_) { | 232 if (is_remote_install_) { |
221 if (!permission_warnings.empty()) | 233 if (!permission_warnings.empty()) |
222 messages.push_back( | 234 messages.push_back( |
223 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO)); | 235 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO)); |
224 } else { | 236 } else { |
225 // TODO(treib): If NeedCustodianApprovalForPermissionIncrease, add an extra | 237 // TODO(treib): If NeedCustodianApprovalForPermissionIncrease, add an extra |
226 // message for supervised users. crbug.com/461261 | 238 // message for supervised users. crbug.com/461261 |
227 messages.push_back(l10n_util::GetStringFUTF16( | 239 messages.push_back(l10n_util::GetStringUTF16( |
228 extension_->is_app() ? IDS_APP_DISABLED_ERROR_LABEL | 240 extension_->is_app() ? IDS_APP_DISABLED_ERROR_LABEL |
229 : IDS_EXTENSION_DISABLED_ERROR_LABEL, | 241 : IDS_EXTENSION_DISABLED_ERROR_LABEL)); |
230 base::UTF8ToUTF16(extension_->name()))); | |
231 messages.push_back(l10n_util::GetStringUTF16( | |
232 IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO)); | |
233 } | 242 } |
234 for (const PermissionMessage& msg : permission_warnings) { | 243 for (const PermissionMessage& msg : permission_warnings) { |
235 messages.push_back(l10n_util::GetStringFUTF16(IDS_EXTENSION_PERMISSION_LINE, | 244 messages.push_back(l10n_util::GetStringFUTF16(IDS_EXTENSION_PERMISSION_LINE, |
236 msg.message())); | 245 msg.message())); |
237 } | 246 } |
238 return messages; | 247 return messages; |
239 } | 248 } |
240 | 249 |
241 base::string16 ExtensionDisabledGlobalError::GetBubbleViewAcceptButtonLabel() { | 250 base::string16 ExtensionDisabledGlobalError::GetBubbleViewAcceptButtonLabel() { |
242 if (extensions::util::IsExtensionSupervised(extension_, | 251 if (extensions::util::IsExtensionSupervised(extension_, |
243 service_->profile())) { | 252 service_->profile())) { |
244 // TODO(treib): Probably use a new string here once we get UX design. | 253 // TODO(treib): Probably use a new string here once we get UX design. |
245 // For now, just use "OK". crbug.com/461261 | 254 // For now, just use "OK". crbug.com/461261 |
246 return l10n_util::GetStringUTF16(IDS_OK); | 255 return l10n_util::GetStringUTF16(IDS_OK); |
247 } | 256 } |
248 if (is_remote_install_) { | 257 if (is_remote_install_) { |
249 return l10n_util::GetStringUTF16( | 258 return l10n_util::GetStringUTF16( |
250 extension_->is_app() | 259 extension_->is_app() |
251 ? IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON_APP | 260 ? IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON_APP |
252 : IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON_EXTENSION); | 261 : IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON_EXTENSION); |
253 } | 262 } |
254 return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON); | 263 return l10n_util::GetStringUTF16( |
264 IDS_EXTENSION_PROMPT_PERMISSIONS_ACCEPT_BUTTON); | |
255 } | 265 } |
256 | 266 |
257 base::string16 ExtensionDisabledGlobalError::GetBubbleViewCancelButtonLabel() { | 267 base::string16 ExtensionDisabledGlobalError::GetBubbleViewCancelButtonLabel() { |
258 if (extensions::util::IsExtensionSupervised(extension_, | 268 if (extensions::util::IsExtensionSupervised(extension_, |
259 service_->profile())) { | 269 service_->profile())) { |
260 // The supervised user can't approve the update, and hence there is no | 270 // The supervised user can't approve the update, and hence there is no |
261 // "cancel" button. Return an empty string such that the "cancel" button | 271 // "cancel" button. Return an empty string such that the "cancel" button |
262 // is not shown in the dialog. | 272 // is not shown in the dialog. |
263 return base::string16(); | 273 return base::string16(); |
264 } | 274 } |
265 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL); | 275 return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON); |
Devlin
2017/04/19 19:18:33
I'm a little worried to re-open this to bikesheddi
catmullings
2017/04/20 02:01:59
Sure, will look into it.
| |
266 } | 276 } |
267 | 277 |
268 void ExtensionDisabledGlobalError::OnBubbleViewDidClose(Browser* browser) { | 278 void ExtensionDisabledGlobalError::OnBubbleViewDidClose(Browser* browser) { |
269 // If the user takes an action, |user_response_| is set in | 279 // If the user takes an action, |user_response_| is set in |
270 // BubbleView[Cancel|Accept]Pressed(). Otherwise, the IGNORE value set in the | 280 // BubbleView[Cancel|Accept]Pressed(). Otherwise, the IGNORE value set in the |
271 // constructor is correct. | 281 // constructor is correct. |
272 UMA_HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponseRemoteInstall2", | 282 UMA_HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponseRemoteInstall2", |
273 user_response_, | 283 user_response_, |
274 EXTENSION_DISABLED_UI_BUCKET_BOUNDARY); | 284 EXTENSION_DISABLED_UI_BUCKET_BOUNDARY); |
275 UMA_HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponse2", | 285 UMA_HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponse2", |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 ->LoadImageAsync(extension, | 411 ->LoadImageAsync(extension, |
402 image, | 412 image, |
403 size, | 413 size, |
404 base::Bind(&AddExtensionDisabledErrorWithIcon, | 414 base::Bind(&AddExtensionDisabledErrorWithIcon, |
405 service->AsWeakPtr(), | 415 service->AsWeakPtr(), |
406 extension->id(), | 416 extension->id(), |
407 is_remote_install)); | 417 is_remote_install)); |
408 } | 418 } |
409 | 419 |
410 } // namespace extensions | 420 } // namespace extensions |
OLD | NEW |