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 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 url_patterns.begin(); | 708 url_patterns.begin(); |
709 url_pattern != url_patterns.end(); ++url_pattern) { | 709 url_pattern != url_patterns.end(); ++url_pattern) { |
710 url_pattern_list->Append(new StringValue(url_pattern->GetAsString())); | 710 url_pattern_list->Append(new StringValue(url_pattern->GetAsString())); |
711 } | 711 } |
712 | 712 |
713 script_data->Set("matches", url_pattern_list); | 713 script_data->Set("matches", url_pattern_list); |
714 | 714 |
715 return script_data; | 715 return script_data; |
716 } | 716 } |
717 | 717 |
718 static bool ExtensionWantsFileAccess(const Extension* extension) { | |
719 for (UserScriptList::const_iterator it = extension->content_scripts().begin(); | |
720 it != extension->content_scripts().end(); ++it) { | |
721 for (UserScript::PatternList::const_iterator pattern = | |
722 it->url_patterns().begin(); | |
723 pattern != it->url_patterns().end(); ++pattern) { | |
724 if (pattern->MatchesScheme(chrome::kFileScheme)) | |
725 return true; | |
726 } | |
727 } | |
728 | |
729 return false; | |
730 } | |
731 | |
732 // Static | 718 // Static |
733 DictionaryValue* ExtensionsDOMHandler::CreateExtensionDetailValue( | 719 DictionaryValue* ExtensionsDOMHandler::CreateExtensionDetailValue( |
734 ExtensionService* service, const Extension* extension, | 720 ExtensionService* service, const Extension* extension, |
735 const std::vector<ExtensionPage>& pages, bool enabled, bool terminated) { | 721 const std::vector<ExtensionPage>& pages, bool enabled, bool terminated) { |
736 DictionaryValue* extension_data = new DictionaryValue(); | 722 DictionaryValue* extension_data = new DictionaryValue(); |
737 GURL icon = | 723 GURL icon = |
738 ExtensionIconSource::GetIconURL(extension, | 724 ExtensionIconSource::GetIconURL(extension, |
739 Extension::EXTENSION_ICON_MEDIUM, | 725 Extension::EXTENSION_ICON_MEDIUM, |
740 ExtensionIconSet::MATCH_BIGGER, | 726 ExtensionIconSet::MATCH_BIGGER, |
741 !enabled); | 727 !enabled); |
742 extension_data->SetString("id", extension->id()); | 728 extension_data->SetString("id", extension->id()); |
743 extension_data->SetString("name", extension->name()); | 729 extension_data->SetString("name", extension->name()); |
744 extension_data->SetString("description", extension->description()); | 730 extension_data->SetString("description", extension->description()); |
745 if (extension->location() == Extension::LOAD) | 731 if (extension->location() == Extension::LOAD) |
746 extension_data->SetString("path", extension->path().value()); | 732 extension_data->SetString("path", extension->path().value()); |
747 extension_data->SetString("version", extension->version()->GetString()); | 733 extension_data->SetString("version", extension->version()->GetString()); |
748 extension_data->SetString("icon", icon.spec()); | 734 extension_data->SetString("icon", icon.spec()); |
749 extension_data->SetBoolean("isUnpacked", | 735 extension_data->SetBoolean("isUnpacked", |
750 extension->location() == Extension::LOAD); | 736 extension->location() == Extension::LOAD); |
751 extension_data->SetBoolean("mayDisable", | 737 extension_data->SetBoolean("mayDisable", |
752 Extension::UserMayDisable(extension->location())); | 738 Extension::UserMayDisable(extension->location())); |
753 extension_data->SetBoolean("enabled", enabled); | 739 extension_data->SetBoolean("enabled", enabled); |
754 extension_data->SetBoolean("terminated", terminated); | 740 extension_data->SetBoolean("terminated", terminated); |
755 extension_data->SetBoolean("enabledIncognito", | 741 extension_data->SetBoolean("enabledIncognito", |
756 service ? service->IsIncognitoEnabled(extension) : false); | 742 service ? service->IsIncognitoEnabled(extension) : false); |
757 extension_data->SetBoolean("wantsFileAccess", | 743 extension_data->SetBoolean("wantsFileAccess", extension->wants_file_access()); |
758 ExtensionWantsFileAccess(extension)); | |
759 extension_data->SetBoolean("allowFileAccess", | 744 extension_data->SetBoolean("allowFileAccess", |
760 service ? service->AllowFileAccess(extension) : false); | 745 service ? service->AllowFileAccess(extension) : false); |
761 extension_data->SetBoolean("allow_reload", | 746 extension_data->SetBoolean("allow_reload", |
762 extension->location() == Extension::LOAD); | 747 extension->location() == Extension::LOAD); |
763 extension_data->SetBoolean("is_hosted_app", extension->is_hosted_app()); | 748 extension_data->SetBoolean("is_hosted_app", extension->is_hosted_app()); |
764 | 749 |
765 // Determine the sort order: Extensions loaded through --load-extensions show | 750 // Determine the sort order: Extensions loaded through --load-extensions show |
766 // up at the top. Disabled extensions show up at the bottom. | 751 // up at the top. Disabled extensions show up at the bottom. |
767 if (extension->location() == Extension::LOAD) | 752 if (extension->location() == Extension::LOAD) |
768 extension_data->SetInteger("order", 1); | 753 extension_data->SetInteger("order", 1); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 // static | 893 // static |
909 RefCountedMemory* ExtensionsUI::GetFaviconResourceBytes() { | 894 RefCountedMemory* ExtensionsUI::GetFaviconResourceBytes() { |
910 return ResourceBundle::GetSharedInstance(). | 895 return ResourceBundle::GetSharedInstance(). |
911 LoadDataResourceBytes(IDR_PLUGIN); | 896 LoadDataResourceBytes(IDR_PLUGIN); |
912 } | 897 } |
913 | 898 |
914 // static | 899 // static |
915 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) { | 900 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) { |
916 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, false); | 901 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, false); |
917 } | 902 } |
OLD | NEW |