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 <bitset> | 7 #include <bitset> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 if (is_remote_install_) { | 299 if (is_remote_install_) { |
300 messages.push_back(l10n_util::GetStringFUTF16( | 300 messages.push_back(l10n_util::GetStringFUTF16( |
301 extension_->is_app() | 301 extension_->is_app() |
302 ? IDS_APP_DISABLED_REMOTE_INSTALL_ERROR_LABEL | 302 ? IDS_APP_DISABLED_REMOTE_INSTALL_ERROR_LABEL |
303 : IDS_EXTENSION_DISABLED_REMOTE_INSTALL_ERROR_LABEL, | 303 : IDS_EXTENSION_DISABLED_REMOTE_INSTALL_ERROR_LABEL, |
304 base::UTF8ToUTF16(extension_->name()))); | 304 base::UTF8ToUTF16(extension_->name()))); |
305 if (!permission_warnings.empty()) | 305 if (!permission_warnings.empty()) |
306 messages.push_back( | 306 messages.push_back( |
307 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO)); | 307 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO)); |
308 } else { | 308 } else { |
| 309 // TODO(treib): Add an extra message for supervised users. crbug.com/461261 |
309 messages.push_back(l10n_util::GetStringFUTF16( | 310 messages.push_back(l10n_util::GetStringFUTF16( |
310 extension_->is_app() ? IDS_APP_DISABLED_ERROR_LABEL | 311 extension_->is_app() ? IDS_APP_DISABLED_ERROR_LABEL |
311 : IDS_EXTENSION_DISABLED_ERROR_LABEL, | 312 : IDS_EXTENSION_DISABLED_ERROR_LABEL, |
312 base::UTF8ToUTF16(extension_->name()))); | 313 base::UTF8ToUTF16(extension_->name()))); |
313 messages.push_back(l10n_util::GetStringUTF16( | 314 messages.push_back(l10n_util::GetStringUTF16( |
314 IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO)); | 315 IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO)); |
315 } | 316 } |
316 for (size_t i = 0; i < permission_warnings.size(); ++i) { | 317 for (size_t i = 0; i < permission_warnings.size(); ++i) { |
317 messages.push_back(l10n_util::GetStringFUTF16( | 318 messages.push_back(l10n_util::GetStringFUTF16( |
318 IDS_EXTENSION_PERMISSION_LINE, permission_warnings[i])); | 319 IDS_EXTENSION_PERMISSION_LINE, permission_warnings[i])); |
319 } | 320 } |
320 return messages; | 321 return messages; |
321 } | 322 } |
322 | 323 |
323 base::string16 ExtensionDisabledGlobalError::GetBubbleViewAcceptButtonLabel() { | 324 base::string16 ExtensionDisabledGlobalError::GetBubbleViewAcceptButtonLabel() { |
| 325 if (extensions::util::IsExtensionSupervised(extension_, |
| 326 service_->profile())) { |
| 327 // TODO(treib): Probably use a new string here once we get UX design. |
| 328 // For now, just re-use an existing string that says "OK". crbug.com/461261 |
| 329 return l10n_util::GetStringUTF16(IDS_EXTENSION_ALERT_ITEM_OK); |
| 330 } |
324 if (is_remote_install_) { | 331 if (is_remote_install_) { |
325 return l10n_util::GetStringUTF16( | 332 return l10n_util::GetStringUTF16( |
326 IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON); | 333 IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON); |
327 } else { | |
328 return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON); | |
329 } | 334 } |
| 335 return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON); |
330 } | 336 } |
331 | 337 |
332 base::string16 ExtensionDisabledGlobalError::GetBubbleViewCancelButtonLabel() { | 338 base::string16 ExtensionDisabledGlobalError::GetBubbleViewCancelButtonLabel() { |
| 339 // For custodian-installed extensions, supervised users only get a single |
| 340 // "acknowledge" button. |
| 341 if (extensions::util::IsExtensionSupervised(extension_, service_->profile())) |
| 342 return base::string16(); |
333 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL); | 343 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL); |
334 } | 344 } |
335 | 345 |
336 void ExtensionDisabledGlobalError::OnBubbleViewDidClose(Browser* browser) { | 346 void ExtensionDisabledGlobalError::OnBubbleViewDidClose(Browser* browser) { |
337 } | 347 } |
338 | 348 |
339 void ExtensionDisabledGlobalError::BubbleViewAcceptButtonPressed( | 349 void ExtensionDisabledGlobalError::BubbleViewAcceptButtonPressed( |
340 Browser* browser) { | 350 Browser* browser) { |
| 351 // Supervised users can't re-enable custodian-installed extensions, just |
| 352 // acknowledge that they've been disabled. |
| 353 if (extensions::util::IsExtensionSupervised(extension_, service_->profile())) |
| 354 return; |
341 // Delay extension reenabling so this bubble closes properly. | 355 // Delay extension reenabling so this bubble closes properly. |
342 base::MessageLoop::current()->PostTask(FROM_HERE, | 356 base::MessageLoop::current()->PostTask(FROM_HERE, |
343 base::Bind(&ExtensionService::GrantPermissionsAndEnableExtension, | 357 base::Bind(&ExtensionService::GrantPermissionsAndEnableExtension, |
344 service_->AsWeakPtr(), extension_)); | 358 service_->AsWeakPtr(), extension_)); |
345 } | 359 } |
346 | 360 |
347 void ExtensionDisabledGlobalError::BubbleViewCancelButtonPressed( | 361 void ExtensionDisabledGlobalError::BubbleViewCancelButtonPressed( |
348 Browser* browser) { | 362 Browser* browser) { |
| 363 // This button shouldn't exist for custodian-installed extensions in a |
| 364 // supervised profile. |
| 365 DCHECK(!extensions::util::IsExtensionSupervised(extension_, |
| 366 service_->profile())); |
| 367 |
349 uninstall_dialog_.reset(extensions::ExtensionUninstallDialog::Create( | 368 uninstall_dialog_.reset(extensions::ExtensionUninstallDialog::Create( |
350 service_->profile(), browser->window()->GetNativeWindow(), this)); | 369 service_->profile(), browser->window()->GetNativeWindow(), this)); |
351 // Delay showing the uninstall dialog, so that this function returns | 370 // Delay showing the uninstall dialog, so that this function returns |
352 // immediately, to close the bubble properly. See crbug.com/121544. | 371 // immediately, to close the bubble properly. See crbug.com/121544. |
353 base::MessageLoop::current()->PostTask( | 372 base::MessageLoop::current()->PostTask( |
354 FROM_HERE, | 373 FROM_HERE, |
355 base::Bind(&extensions::ExtensionUninstallDialog::ConfirmUninstall, | 374 base::Bind(&extensions::ExtensionUninstallDialog::ConfirmUninstall, |
356 uninstall_dialog_->AsWeakPtr(), | 375 uninstall_dialog_->AsWeakPtr(), |
357 extension_)); | 376 extension_)); |
358 } | 377 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 void ShowExtensionDisabledDialog(ExtensionService* service, | 456 void ShowExtensionDisabledDialog(ExtensionService* service, |
438 content::WebContents* web_contents, | 457 content::WebContents* web_contents, |
439 const Extension* extension) { | 458 const Extension* extension) { |
440 scoped_ptr<ExtensionInstallPrompt> install_ui( | 459 scoped_ptr<ExtensionInstallPrompt> install_ui( |
441 new ExtensionInstallPrompt(web_contents)); | 460 new ExtensionInstallPrompt(web_contents)); |
442 // This object manages its own lifetime. | 461 // This object manages its own lifetime. |
443 new ExtensionDisabledDialogDelegate(service, install_ui.Pass(), extension); | 462 new ExtensionDisabledDialogDelegate(service, install_ui.Pass(), extension); |
444 } | 463 } |
445 | 464 |
446 } // namespace extensions | 465 } // namespace extensions |
OLD | NEW |