Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: chrome/browser/extensions/extension.cc

Issue 12876: Introduce ExtensionsService. Load extensions on startup from a directory in... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/extension.h" 5 #include "chrome/browser/extensions/extension.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 9
10 const std::wstring Extension::kFormatVersionKey(L"format_version"); 10 const FilePath::CharType* Extension::kManifestFilename =
11 const std::wstring Extension::kIdKey(L"id"); 11 FILE_PATH_LITERAL("manifest");
12 const std::wstring Extension::kNameKey(L"name");
13 const std::wstring Extension::kDescriptionKey(L"description");
14 const std::wstring Extension::kContentScriptsKey(L"content_scripts");
15 12
16 const std::wstring Extension::kInvalidFormatVersionError( 13 const wchar_t* Extension::kFormatVersionKey = L"format_version";
14 const wchar_t* Extension::kIdKey = L"id";
15 const wchar_t* Extension::kNameKey = L"name";
16 const wchar_t* Extension::kDescriptionKey = L"description";
17 const wchar_t* Extension::kContentScriptsKey = L"content_scripts";
18
19 const wchar_t* Extension::kInvalidManifestError =
20 L"Manifest is missing or invalid.";
21 const wchar_t* Extension::kInvalidFormatVersionError =
17 StringPrintf(L"Required key '%ls' is missing or invalid", 22 StringPrintf(L"Required key '%ls' is missing or invalid",
18 kFormatVersionKey.c_str())); 23 kFormatVersionKey).c_str();
19 const std::wstring Extension::kInvalidIdError( 24 const wchar_t* Extension::kInvalidIdError =
20 StringPrintf(L"Required key '%ls' is missing or invalid.", 25 StringPrintf(L"Required key '%ls' is missing or invalid.",
21 kIdKey.c_str())); 26 kIdKey).c_str();
22 const std::wstring Extension::kInvalidNameError( 27 const wchar_t* Extension::kInvalidNameError =
23 StringPrintf(L"Required key '%ls' is missing or has invalid type.", 28 StringPrintf(L"Required key '%ls' is missing or has invalid type.",
24 kNameKey.c_str())); 29 kNameKey).c_str();
25 const std::wstring Extension::kInvalidDescriptionError( 30 const wchar_t* Extension::kInvalidDescriptionError =
26 StringPrintf(L"Invalid type for '%ls' key.", 31 StringPrintf(L"Invalid type for '%ls' key.",
27 kDescriptionKey.c_str())); 32 kDescriptionKey).c_str();
28 const std::wstring Extension::kInvalidContentScriptsListError( 33 const wchar_t* Extension::kInvalidContentScriptsListError =
29 StringPrintf(L"Invalid type for '%ls' key.", 34 StringPrintf(L"Invalid type for '%ls' key.",
30 kContentScriptsKey.c_str())); 35 kContentScriptsKey).c_str();
31 const std::wstring Extension::kInvalidContentScriptError( 36 const wchar_t* Extension::kInvalidContentScriptError =
32 StringPrintf(L"Invalid type for %ls at index ", 37 StringPrintf(L"Invalid type for %ls at index ",
33 kContentScriptsKey.c_str())); 38 kContentScriptsKey).c_str();
34 39
35 bool Extension::InitFromValue(const DictionaryValue& source, 40 bool Extension::InitFromValue(const DictionaryValue& source,
36 std::wstring* error) { 41 std::wstring* error) {
37 // Check format version. 42 // Check format version.
38 int format_version = 0; 43 int format_version = 0;
39 if (!source.GetInteger(kFormatVersionKey, &format_version) || 44 if (!source.GetInteger(kFormatVersionKey, &format_version) ||
40 format_version != kExpectedFormatVersion) { 45 format_version != kExpectedFormatVersion) {
41 *error = kInvalidFormatVersionError; 46 *error = kInvalidFormatVersionError;
42 return false; 47 return false;
43 } 48 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // Copy content scripts (optional). 111 // Copy content scripts (optional).
107 if (content_scripts_.size() > 0) { 112 if (content_scripts_.size() > 0) {
108 ListValue* list_value = new ListValue(); 113 ListValue* list_value = new ListValue();
109 destination->Set(kContentScriptsKey, list_value); 114 destination->Set(kContentScriptsKey, list_value);
110 115
111 for (size_t i = 0; i < content_scripts_.size(); ++i) { 116 for (size_t i = 0; i < content_scripts_.size(); ++i) {
112 list_value->Set(i, Value::CreateStringValue(content_scripts_[i])); 117 list_value->Set(i, Value::CreateStringValue(content_scripts_[i]));
113 } 118 }
114 } 119 }
115 } 120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698