| 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/ui/webui/extensions/extension_settings_handler.h" | 5 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/base64.h" | 8 #include "base/base64.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 DictionaryValue* ExtensionSettingsHandler::CreateExtensionDetailValue( | 88 DictionaryValue* ExtensionSettingsHandler::CreateExtensionDetailValue( |
| 89 const Extension* extension, | 89 const Extension* extension, |
| 90 const std::vector<ExtensionPage>& pages, | 90 const std::vector<ExtensionPage>& pages, |
| 91 const ExtensionWarningSet* warnings_set) { | 91 const ExtensionWarningSet* warnings_set) { |
| 92 DictionaryValue* extension_data = new DictionaryValue(); | 92 DictionaryValue* extension_data = new DictionaryValue(); |
| 93 bool enabled = extension_service_ ? | 93 bool enabled = extension_service_ ? |
| 94 extension_service_->IsExtensionEnabled(extension->id()) : | 94 extension_service_->IsExtensionEnabled(extension->id()) : |
| 95 true; | 95 true; |
| 96 extension->GetBasicInfo(enabled, extension_data); | 96 extension->GetBasicInfo(enabled, extension_data); |
| 97 | 97 |
| 98 if (extension_service_) { |
| 99 extension_data->SetBoolean("mayModifyStatus", extension_service_-> |
| 100 extension_management_policy()->UserMayModifyStatus(extension, NULL)); |
| 101 extension_data->SetBoolean("mayModifyUsage", extension_service_-> |
| 102 extension_management_policy()->UserMayModifyUsage(extension, NULL)); |
| 103 } else { |
| 104 // This should only happen in testing. |
| 105 extension_data->SetBoolean("mayModifyStatus", true); |
| 106 extension_data->SetBoolean("mayModifyUsage", true); |
| 107 } |
| 108 |
| 98 GURL icon = | 109 GURL icon = |
| 99 ExtensionIconSource::GetIconURL(extension, | 110 ExtensionIconSource::GetIconURL(extension, |
| 100 ExtensionIconSet::EXTENSION_ICON_MEDIUM, | 111 ExtensionIconSet::EXTENSION_ICON_MEDIUM, |
| 101 ExtensionIconSet::MATCH_BIGGER, | 112 ExtensionIconSet::MATCH_BIGGER, |
| 102 !enabled, NULL); | 113 !enabled, NULL); |
| 103 if (extension->location() == Extension::LOAD) | 114 if (extension->location() == Extension::LOAD) |
| 104 extension_data->SetString("path", extension->path().value()); | 115 extension_data->SetString("path", extension->path().value()); |
| 105 extension_data->SetString("icon", icon.spec()); | 116 extension_data->SetString("icon", icon.spec()); |
| 106 extension_data->SetBoolean("isUnpacked", | 117 extension_data->SetBoolean("isUnpacked", |
| 107 extension->location() == Extension::LOAD); | 118 extension->location() == Extension::LOAD); |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 } | 567 } |
| 557 | 568 |
| 558 void ExtensionSettingsHandler::HandleEnableMessage(const ListValue* args) { | 569 void ExtensionSettingsHandler::HandleEnableMessage(const ListValue* args) { |
| 559 CHECK_EQ(2U, args->GetSize()); | 570 CHECK_EQ(2U, args->GetSize()); |
| 560 std::string extension_id, enable_str; | 571 std::string extension_id, enable_str; |
| 561 CHECK(args->GetString(0, &extension_id)); | 572 CHECK(args->GetString(0, &extension_id)); |
| 562 CHECK(args->GetString(1, &enable_str)); | 573 CHECK(args->GetString(1, &enable_str)); |
| 563 | 574 |
| 564 const Extension* extension = | 575 const Extension* extension = |
| 565 extension_service_->GetInstalledExtension(extension_id); | 576 extension_service_->GetInstalledExtension(extension_id); |
| 566 if (!extension || !Extension::UserMayDisable(extension->location())) { | 577 if (!extension || |
| 578 !extension_service_->extension_management_policy()-> |
| 579 UserMayModifyStatus(extension, NULL)) { |
| 567 LOG(ERROR) << "Attempt to enable an extension that is non-usermanagable was" | 580 LOG(ERROR) << "Attempt to enable an extension that is non-usermanagable was" |
| 568 << "made. Extension id: " << extension->id(); | 581 << "made. Extension id: " << extension->id(); |
| 569 return; | 582 return; |
| 570 } | 583 } |
| 571 | 584 |
| 572 if (enable_str == "true") { | 585 if (enable_str == "true") { |
| 573 ExtensionPrefs* prefs = extension_service_->extension_prefs(); | 586 ExtensionPrefs* prefs = extension_service_->extension_prefs(); |
| 574 if (prefs->DidExtensionEscalatePermissions(extension_id)) { | 587 if (prefs->DidExtensionEscalatePermissions(extension_id)) { |
| 575 extensions::ShowExtensionDisabledDialog( | 588 extensions::ShowExtensionDisabledDialog( |
| 576 extension_service_, Profile::FromWebUI(web_ui()), extension); | 589 extension_service_, Profile::FromWebUI(web_ui()), extension); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 const ListValue* args) { | 627 const ListValue* args) { |
| 615 CHECK_EQ(2U, args->GetSize()); | 628 CHECK_EQ(2U, args->GetSize()); |
| 616 std::string extension_id, allow_str; | 629 std::string extension_id, allow_str; |
| 617 CHECK(args->GetString(0, &extension_id)); | 630 CHECK(args->GetString(0, &extension_id)); |
| 618 CHECK(args->GetString(1, &allow_str)); | 631 CHECK(args->GetString(1, &allow_str)); |
| 619 const Extension* extension = | 632 const Extension* extension = |
| 620 extension_service_->GetInstalledExtension(extension_id); | 633 extension_service_->GetInstalledExtension(extension_id); |
| 621 if (!extension) | 634 if (!extension) |
| 622 return; | 635 return; |
| 623 | 636 |
| 624 if (!Extension::UserMayDisable(extension->location())) { | 637 if (!extension_service_->extension_management_policy()-> |
| 638 UserMayModifyUsage(extension, NULL)) { |
| 625 LOG(ERROR) << "Attempt to change allow file access of an extension that is " | 639 LOG(ERROR) << "Attempt to change allow file access of an extension that is " |
| 626 << "non-usermanagable was made. Extension id : " | 640 << "non-usermanagable was made. Extension id : " |
| 627 << extension->id(); | 641 << extension->id(); |
| 628 return; | 642 return; |
| 629 } | 643 } |
| 630 | 644 |
| 631 extension_service_->SetAllowFileAccess(extension, allow_str == "true"); | 645 extension_service_->SetAllowFileAccess(extension, allow_str == "true"); |
| 632 } | 646 } |
| 633 | 647 |
| 634 void ExtensionSettingsHandler::HandleUninstallMessage(const ListValue* args) { | 648 void ExtensionSettingsHandler::HandleUninstallMessage(const ListValue* args) { |
| 635 CHECK_EQ(1U, args->GetSize()); | 649 CHECK_EQ(1U, args->GetSize()); |
| 636 std::string extension_id; | 650 std::string extension_id; |
| 637 CHECK(args->GetString(0, &extension_id)); | 651 CHECK(args->GetString(0, &extension_id)); |
| 638 const Extension* extension = | 652 const Extension* extension = |
| 639 extension_service_->GetInstalledExtension(extension_id); | 653 extension_service_->GetInstalledExtension(extension_id); |
| 640 if (!extension) | 654 if (!extension) |
| 641 return; | 655 return; |
| 642 | 656 |
| 643 if (!Extension::UserMayDisable(extension->location())) { | 657 if (!extension_service_->extension_management_policy()-> |
| 658 UserMayModifyStatus(extension, NULL)) { |
| 644 LOG(ERROR) << "Attempt to uninstall an extension that is non-usermanagable " | 659 LOG(ERROR) << "Attempt to uninstall an extension that is non-usermanagable " |
| 645 << "was made. Extension id : " << extension->id(); | 660 << "was made. Extension id : " << extension->id(); |
| 646 return; | 661 return; |
| 647 } | 662 } |
| 648 | 663 |
| 649 if (!extension_id_prompting_.empty()) | 664 if (!extension_id_prompting_.empty()) |
| 650 return; // Only one prompt at a time. | 665 return; // Only one prompt at a time. |
| 651 | 666 |
| 652 extension_id_prompting_ = extension_id; | 667 extension_id_prompting_ = extension_id; |
| 653 | 668 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 return extension_uninstall_dialog_.get(); | 835 return extension_uninstall_dialog_.get(); |
| 821 #else | 836 #else |
| 822 return NULL; | 837 return NULL; |
| 823 #endif // !defined(OS_ANDROID) | 838 #endif // !defined(OS_ANDROID) |
| 824 } | 839 } |
| 825 | 840 |
| 826 void ExtensionSettingsHandler::InspectExtensionHost(ExtensionHost* host) { | 841 void ExtensionSettingsHandler::InspectExtensionHost(ExtensionHost* host) { |
| 827 if (host) | 842 if (host) |
| 828 DevToolsWindow::OpenDevToolsWindow(host->render_view_host()); | 843 DevToolsWindow::OpenDevToolsWindow(host->render_view_host()); |
| 829 } | 844 } |
| OLD | NEW |