| 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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 url_patterns.begin(); | 685 url_patterns.begin(); |
| 686 url_pattern != url_patterns.end(); ++url_pattern) { | 686 url_pattern != url_patterns.end(); ++url_pattern) { |
| 687 url_pattern_list->Append(new StringValue(url_pattern->GetAsString())); | 687 url_pattern_list->Append(new StringValue(url_pattern->GetAsString())); |
| 688 } | 688 } |
| 689 | 689 |
| 690 script_data->Set("matches", url_pattern_list); | 690 script_data->Set("matches", url_pattern_list); |
| 691 | 691 |
| 692 return script_data; | 692 return script_data; |
| 693 } | 693 } |
| 694 | 694 |
| 695 static bool ExtensionWantsFileAccess(const Extension* extension) { | |
| 696 for (UserScriptList::const_iterator it = extension->content_scripts().begin(); | |
| 697 it != extension->content_scripts().end(); ++it) { | |
| 698 for (UserScript::PatternList::const_iterator pattern = | |
| 699 it->url_patterns().begin(); | |
| 700 pattern != it->url_patterns().end(); ++pattern) { | |
| 701 if (pattern->MatchesScheme(chrome::kFileScheme)) | |
| 702 return true; | |
| 703 } | |
| 704 } | |
| 705 | |
| 706 return false; | |
| 707 } | |
| 708 | |
| 709 // Static | 695 // Static |
| 710 DictionaryValue* ExtensionsDOMHandler::CreateExtensionDetailValue( | 696 DictionaryValue* ExtensionsDOMHandler::CreateExtensionDetailValue( |
| 711 ExtensionService* service, const Extension* extension, | 697 ExtensionService* service, const Extension* extension, |
| 712 const std::vector<ExtensionPage>& pages, bool enabled, bool terminated) { | 698 const std::vector<ExtensionPage>& pages, bool enabled, bool terminated) { |
| 713 DictionaryValue* extension_data = new DictionaryValue(); | 699 DictionaryValue* extension_data = new DictionaryValue(); |
| 714 GURL icon = | 700 GURL icon = |
| 715 ExtensionIconSource::GetIconURL(extension, | 701 ExtensionIconSource::GetIconURL(extension, |
| 716 Extension::EXTENSION_ICON_MEDIUM, | 702 Extension::EXTENSION_ICON_MEDIUM, |
| 717 ExtensionIconSet::MATCH_BIGGER, | 703 ExtensionIconSet::MATCH_BIGGER, |
| 718 !enabled); | 704 !enabled); |
| 719 extension_data->SetString("id", extension->id()); | 705 extension_data->SetString("id", extension->id()); |
| 720 extension_data->SetString("name", extension->name()); | 706 extension_data->SetString("name", extension->name()); |
| 721 extension_data->SetString("description", extension->description()); | 707 extension_data->SetString("description", extension->description()); |
| 722 extension_data->SetString("version", extension->version()->GetString()); | 708 extension_data->SetString("version", extension->version()->GetString()); |
| 723 extension_data->SetString("icon", icon.spec()); | 709 extension_data->SetString("icon", icon.spec()); |
| 724 extension_data->SetBoolean("enabled", enabled); | 710 extension_data->SetBoolean("enabled", enabled); |
| 725 extension_data->SetBoolean("terminated", terminated); | 711 extension_data->SetBoolean("terminated", terminated); |
| 726 extension_data->SetBoolean("enabledIncognito", | 712 extension_data->SetBoolean("enabledIncognito", |
| 727 service ? service->IsIncognitoEnabled(extension) : false); | 713 service ? service->IsIncognitoEnabled(extension) : false); |
| 728 extension_data->SetBoolean("wantsFileAccess", | 714 extension_data->SetBoolean("wantsFileAccess", extension->wants_file_access()); |
| 729 ExtensionWantsFileAccess(extension)); | |
| 730 extension_data->SetBoolean("allowFileAccess", | 715 extension_data->SetBoolean("allowFileAccess", |
| 731 service ? service->AllowFileAccess(extension) : false); | 716 service ? service->AllowFileAccess(extension) : false); |
| 732 extension_data->SetBoolean("allow_reload", | 717 extension_data->SetBoolean("allow_reload", |
| 733 extension->location() == Extension::LOAD); | 718 extension->location() == Extension::LOAD); |
| 734 extension_data->SetBoolean("is_hosted_app", extension->is_hosted_app()); | 719 extension_data->SetBoolean("is_hosted_app", extension->is_hosted_app()); |
| 735 | 720 |
| 736 // Determine the sort order: Extensions loaded through --load-extensions show | 721 // Determine the sort order: Extensions loaded through --load-extensions show |
| 737 // up at the top. Disabled extensions show up at the bottom. | 722 // up at the top. Disabled extensions show up at the bottom. |
| 738 if (extension->location() == Extension::LOAD) | 723 if (extension->location() == Extension::LOAD) |
| 739 extension_data->SetInteger("order", 1); | 724 extension_data->SetInteger("order", 1); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 // static | 864 // static |
| 880 RefCountedMemory* ExtensionsUI::GetFaviconResourceBytes() { | 865 RefCountedMemory* ExtensionsUI::GetFaviconResourceBytes() { |
| 881 return ResourceBundle::GetSharedInstance(). | 866 return ResourceBundle::GetSharedInstance(). |
| 882 LoadDataResourceBytes(IDR_PLUGIN); | 867 LoadDataResourceBytes(IDR_PLUGIN); |
| 883 } | 868 } |
| 884 | 869 |
| 885 // static | 870 // static |
| 886 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) { | 871 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) { |
| 887 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, false); | 872 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, false); |
| 888 } | 873 } |
| OLD | NEW |