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 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 url_patterns.begin(); | 799 url_patterns.begin(); |
800 url_pattern != url_patterns.end(); ++url_pattern) { | 800 url_pattern != url_patterns.end(); ++url_pattern) { |
801 url_pattern_list->Append(new StringValue(url_pattern->GetAsString())); | 801 url_pattern_list->Append(new StringValue(url_pattern->GetAsString())); |
802 } | 802 } |
803 | 803 |
804 script_data->Set("matches", url_pattern_list); | 804 script_data->Set("matches", url_pattern_list); |
805 | 805 |
806 return script_data; | 806 return script_data; |
807 } | 807 } |
808 | 808 |
809 static bool ExtensionWantsFileAccess(const Extension* extension) { | |
810 for (UserScriptList::const_iterator it = extension->content_scripts().begin(); | |
811 it != extension->content_scripts().end(); ++it) { | |
812 for (UserScript::PatternList::const_iterator pattern = | |
813 it->url_patterns().begin(); | |
814 pattern != it->url_patterns().end(); ++pattern) { | |
815 if (pattern->MatchesScheme(chrome::kFileScheme)) | |
816 return true; | |
817 } | |
818 } | |
819 | |
820 return false; | |
821 } | |
822 | |
823 // Static | 809 // Static |
824 DictionaryValue* ExtensionsDOMHandler::CreateExtensionDetailValue( | 810 DictionaryValue* ExtensionsDOMHandler::CreateExtensionDetailValue( |
825 ExtensionService* service, const Extension* extension, | 811 ExtensionService* service, const Extension* extension, |
826 const std::vector<ExtensionPage>& pages, bool enabled, bool terminated) { | 812 const std::vector<ExtensionPage>& pages, bool enabled, bool terminated) { |
827 DictionaryValue* extension_data = new DictionaryValue(); | 813 DictionaryValue* extension_data = new DictionaryValue(); |
828 | 814 |
829 extension_data->SetString("id", extension->id()); | 815 extension_data->SetString("id", extension->id()); |
830 extension_data->SetString("name", extension->name()); | 816 extension_data->SetString("name", extension->name()); |
831 extension_data->SetString("description", extension->description()); | 817 extension_data->SetString("description", extension->description()); |
832 extension_data->SetString("version", extension->version()->GetString()); | 818 extension_data->SetString("version", extension->version()->GetString()); |
833 extension_data->SetBoolean("enabled", enabled); | 819 extension_data->SetBoolean("enabled", enabled); |
834 extension_data->SetBoolean("terminated", terminated); | 820 extension_data->SetBoolean("terminated", terminated); |
835 extension_data->SetBoolean("enabledIncognito", | 821 extension_data->SetBoolean("enabledIncognito", |
836 service ? service->IsIncognitoEnabled(extension) : false); | 822 service ? service->IsIncognitoEnabled(extension) : false); |
837 extension_data->SetBoolean("wantsFileAccess", | 823 extension_data->SetBoolean("wantsFileAccess", extension->wants_file_access()); |
838 ExtensionWantsFileAccess(extension)); | |
839 extension_data->SetBoolean("allowFileAccess", | 824 extension_data->SetBoolean("allowFileAccess", |
840 service ? service->AllowFileAccess(extension) : false); | 825 service ? service->AllowFileAccess(extension) : false); |
841 extension_data->SetBoolean("allow_reload", | 826 extension_data->SetBoolean("allow_reload", |
842 extension->location() == Extension::LOAD); | 827 extension->location() == Extension::LOAD); |
843 extension_data->SetBoolean("is_hosted_app", extension->is_hosted_app()); | 828 extension_data->SetBoolean("is_hosted_app", extension->is_hosted_app()); |
844 | 829 |
845 // Determine the sort order: Extensions loaded through --load-extensions show | 830 // Determine the sort order: Extensions loaded through --load-extensions show |
846 // up at the top. Disabled extensions show up at the bottom. | 831 // up at the top. Disabled extensions show up at the bottom. |
847 if (extension->location() == Extension::LOAD) | 832 if (extension->location() == Extension::LOAD) |
848 extension_data->SetInteger("order", 1); | 833 extension_data->SetInteger("order", 1); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 // static | 974 // static |
990 RefCountedMemory* ExtensionsUI::GetFaviconResourceBytes() { | 975 RefCountedMemory* ExtensionsUI::GetFaviconResourceBytes() { |
991 return ResourceBundle::GetSharedInstance(). | 976 return ResourceBundle::GetSharedInstance(). |
992 LoadDataResourceBytes(IDR_PLUGIN); | 977 LoadDataResourceBytes(IDR_PLUGIN); |
993 } | 978 } |
994 | 979 |
995 // static | 980 // static |
996 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) { | 981 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) { |
997 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, false); | 982 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, false); |
998 } | 983 } |
OLD | NEW |