OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions_ui.h" | 5 #include "chrome/browser/extensions/extensions_ui.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 NotificationType::EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, | 427 NotificationType::EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, |
428 NotificationService::AllSources()); | 428 NotificationService::AllSources()); |
429 } | 429 } |
430 | 430 |
431 ExtensionResource ExtensionsDOMHandler::PickExtensionIcon( | 431 ExtensionResource ExtensionsDOMHandler::PickExtensionIcon( |
432 const Extension* extension) { | 432 const Extension* extension) { |
433 return extension->GetIconResource(Extension::EXTENSION_ICON_MEDIUM, | 433 return extension->GetIconResource(Extension::EXTENSION_ICON_MEDIUM, |
434 ExtensionIconSet::MATCH_BIGGER); | 434 ExtensionIconSet::MATCH_BIGGER); |
435 } | 435 } |
436 | 436 |
437 ExtensionInstallUI* ExtensionsDOMHandler::GetExtensionInstallUI() { | 437 ExtensionUninstallDialog* ExtensionsDOMHandler::GetExtensionUninstallDialog() { |
438 if (!install_ui_.get()) | 438 if (!extension_uninstall_dialog_.get()) { |
439 install_ui_.reset(new ExtensionInstallUI(web_ui_->GetProfile())); | 439 extension_uninstall_dialog_.reset( |
440 return install_ui_.get(); | 440 new ExtensionUninstallDialog(web_ui_->GetProfile())); |
| 441 } |
| 442 return extension_uninstall_dialog_.get(); |
441 } | 443 } |
442 | 444 |
443 void ExtensionsDOMHandler::HandleToggleDeveloperMode(const ListValue* args) { | 445 void ExtensionsDOMHandler::HandleToggleDeveloperMode(const ListValue* args) { |
444 bool developer_mode = web_ui_->GetProfile()->GetPrefs() | 446 bool developer_mode = web_ui_->GetProfile()->GetPrefs() |
445 ->GetBoolean(prefs::kExtensionsUIDeveloperMode); | 447 ->GetBoolean(prefs::kExtensionsUIDeveloperMode); |
446 web_ui_->GetProfile()->GetPrefs()->SetBoolean( | 448 web_ui_->GetProfile()->GetPrefs()->SetBoolean( |
447 prefs::kExtensionsUIDeveloperMode, !developer_mode); | 449 prefs::kExtensionsUIDeveloperMode, !developer_mode); |
448 } | 450 } |
449 | 451 |
450 void ExtensionsDOMHandler::HandleInspectMessage(const ListValue* args) { | 452 void ExtensionsDOMHandler::HandleInspectMessage(const ListValue* args) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 if (!extension) | 540 if (!extension) |
539 extension = extensions_service_->GetTerminatedExtension(extension_id); | 541 extension = extensions_service_->GetTerminatedExtension(extension_id); |
540 if (!extension) | 542 if (!extension) |
541 return; | 543 return; |
542 | 544 |
543 if (!extension_id_prompting_.empty()) | 545 if (!extension_id_prompting_.empty()) |
544 return; // Only one prompt at a time. | 546 return; // Only one prompt at a time. |
545 | 547 |
546 extension_id_prompting_ = extension_id; | 548 extension_id_prompting_ = extension_id; |
547 | 549 |
548 GetExtensionInstallUI()->ConfirmUninstall(this, extension); | 550 GetExtensionUninstallDialog()->ConfirmUninstall(this, extension); |
549 } | 551 } |
550 | 552 |
551 void ExtensionsDOMHandler::InstallUIProceed() { | 553 void ExtensionsDOMHandler::ExtensionDialogAccepted() { |
552 DCHECK(!extension_id_prompting_.empty()); | 554 DCHECK(!extension_id_prompting_.empty()); |
553 | 555 |
554 bool was_terminated = false; | 556 bool was_terminated = false; |
555 | 557 |
556 // The extension can be uninstalled in another window while the UI was | 558 // The extension can be uninstalled in another window while the UI was |
557 // showing. Do nothing in that case. | 559 // showing. Do nothing in that case. |
558 const Extension* extension = | 560 const Extension* extension = |
559 extensions_service_->GetExtensionById(extension_id_prompting_, true); | 561 extensions_service_->GetExtensionById(extension_id_prompting_, true); |
560 if (!extension) { | 562 if (!extension) { |
561 extension = extensions_service_->GetTerminatedExtension( | 563 extension = extensions_service_->GetTerminatedExtension( |
562 extension_id_prompting_); | 564 extension_id_prompting_); |
563 was_terminated = true; | 565 was_terminated = true; |
564 } | 566 } |
565 if (!extension) | 567 if (!extension) |
566 return; | 568 return; |
567 | 569 |
568 extensions_service_->UninstallExtension(extension_id_prompting_, | 570 extensions_service_->UninstallExtension(extension_id_prompting_, |
569 false /* external_uninstall */); | 571 false /* external_uninstall */); |
570 extension_id_prompting_ = ""; | 572 extension_id_prompting_ = ""; |
571 | 573 |
572 // There will be no EXTENSION_UNLOADED notification for terminated | 574 // There will be no EXTENSION_UNLOADED notification for terminated |
573 // extensions as they were already unloaded. | 575 // extensions as they were already unloaded. |
574 if (was_terminated) | 576 if (was_terminated) |
575 HandleRequestExtensionsData(NULL); | 577 HandleRequestExtensionsData(NULL); |
576 } | 578 } |
577 | 579 |
578 void ExtensionsDOMHandler::InstallUIAbort() { | 580 void ExtensionsDOMHandler::ExtensionDialogCanceled() { |
579 extension_id_prompting_ = ""; | 581 extension_id_prompting_ = ""; |
580 } | 582 } |
581 | 583 |
582 void ExtensionsDOMHandler::HandleOptionsMessage(const ListValue* args) { | 584 void ExtensionsDOMHandler::HandleOptionsMessage(const ListValue* args) { |
583 const Extension* extension = GetExtension(args); | 585 const Extension* extension = GetExtension(args); |
584 if (!extension || extension->options_url().is_empty()) | 586 if (!extension || extension->options_url().is_empty()) |
585 return; | 587 return; |
586 web_ui_->GetProfile()->GetExtensionProcessManager()->OpenOptionsPage( | 588 web_ui_->GetProfile()->GetExtensionProcessManager()->OpenOptionsPage( |
587 extension, NULL); | 589 extension, NULL); |
588 } | 590 } |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 // static | 983 // static |
982 RefCountedMemory* ExtensionsUI::GetFaviconResourceBytes() { | 984 RefCountedMemory* ExtensionsUI::GetFaviconResourceBytes() { |
983 return ResourceBundle::GetSharedInstance(). | 985 return ResourceBundle::GetSharedInstance(). |
984 LoadDataResourceBytes(IDR_PLUGIN); | 986 LoadDataResourceBytes(IDR_PLUGIN); |
985 } | 987 } |
986 | 988 |
987 // static | 989 // static |
988 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) { | 990 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) { |
989 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, false); | 991 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, false); |
990 } | 992 } |
OLD | NEW |