diff options
Diffstat (limited to 'chrome/browser')
33 files changed, 29 insertions, 1534 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 618fb4a..7c0f84d 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -19,7 +19,6 @@ #include "chrome/browser/debugger/debugger_host.h" #include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/download/download_manager.h" -#include "chrome/browser/extensions/extension.h" #include "chrome/browser/find_bar.h" #include "chrome/browser/find_bar_controller.h" #include "chrome/browser/location_bar.h" @@ -39,6 +38,7 @@ #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/notification_service.h" #include "chrome/common/page_transition_types.h" #include "chrome/common/pref_names.h" diff --git a/chrome/browser/browser.vcproj b/chrome/browser/browser.vcproj index a1c1fdc..5d5404c 100644 --- a/chrome/browser/browser.vcproj +++ b/chrome/browser/browser.vcproj @@ -2012,14 +2012,6 @@ Name="Extensions" > <File - RelativePath=".\extensions\extension.cc" - > - </File> - <File - RelativePath=".\extensions\extension.h" - > - </File> - <File RelativePath=".\extensions\extension_bookmarks_module.cc" > </File> @@ -2044,22 +2036,6 @@ > </File> <File - RelativePath=".\extensions\extension_error_reporter.cc" - > - </File> - <File - RelativePath=".\extensions\extension_error_reporter.h" - > - </File> - <File - RelativePath=".\extensions\extension_error_utils.cc" - > - </File> - <File - RelativePath=".\extensions\extension_error_utils.h" - > - </File> - <File RelativePath=".\extensions\extension_event_names.cc" > </File> diff --git a/chrome/browser/browser_theme_provider.cc b/chrome/browser/browser_theme_provider.cc index 6c80bbc..f881ae7 100644 --- a/chrome/browser/browser_theme_provider.cc +++ b/chrome/browser/browser_theme_provider.cc @@ -8,10 +8,10 @@ #include "base/string_util.h" #include "base/values.h" #include "chrome/browser/browser_list.h" -#include "chrome/browser/extensions/extension.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/profile.h" #include "chrome/browser/theme_resources_util.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "grit/app_resources.h" diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc index a037fa01..4fa4de3 100644 --- a/chrome/browser/download/download_manager.cc +++ b/chrome/browser/download/download_manager.cc @@ -20,7 +20,6 @@ #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/download/download_file.h" -#include "chrome/browser/extensions/extension.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_process_host.h" @@ -31,6 +30,7 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/platform_util.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" diff --git a/chrome/browser/extensions/extension.cc b/chrome/browser/extensions/extension.cc deleted file mode 100644 index fcfdbb0..0000000 --- a/chrome/browser/extensions/extension.cc +++ /dev/null @@ -1,673 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/extensions/extension.h" - -#include "app/resource_bundle.h" -#include "base/file_path.h" -#include "base/file_util.h" -#include "base/logging.h" -#include "base/string_util.h" -#include "net/base/net_util.h" -#include "chrome/browser/extensions/extension_error_reporter.h" -#include "chrome/browser/extensions/extension_error_utils.h" -#include "chrome/common/extensions/user_script.h" -#include "chrome/common/url_constants.h" - -const char Extension::kManifestFilename[] = "manifest.json"; - -const wchar_t* Extension::kContentScriptsKey = L"content_scripts"; -const wchar_t* Extension::kCssKey = L"css"; -const wchar_t* Extension::kDescriptionKey = L"description"; -const wchar_t* Extension::kIconPathKey = L"icon"; -const wchar_t* Extension::kIdKey = L"id"; -const wchar_t* Extension::kJsKey = L"js"; -const wchar_t* Extension::kMatchesKey = L"matches"; -const wchar_t* Extension::kNameKey = L"name"; -const wchar_t* Extension::kPageActionsKey = L"page_actions"; -const wchar_t* Extension::kPermissionsKey = L"permissions"; -const wchar_t* Extension::kPluginsDirKey = L"plugins_dir"; -const wchar_t* Extension::kBackgroundKey = L"background_page"; -const wchar_t* Extension::kRunAtKey = L"run_at"; -const wchar_t* Extension::kThemeKey = L"theme"; -const wchar_t* Extension::kThemeImagesKey = L"images"; -const wchar_t* Extension::kThemeColorsKey = L"colors"; -const wchar_t* Extension::kThemeTintsKey = L"tints"; -const wchar_t* Extension::kToolstripsKey = L"toolstrips"; -const wchar_t* Extension::kTooltipKey = L"tooltip"; -const wchar_t* Extension::kTypeKey = L"type"; -const wchar_t* Extension::kVersionKey = L"version"; -const wchar_t* Extension::kZipHashKey = L"zip_hash"; - -const char* Extension::kRunAtDocumentStartValue = "document_start"; -const char* Extension::kRunAtDocumentEndValue = "document_end"; -const char* Extension::kPageActionTypeTab = "tab"; -const char* Extension::kPageActionTypePermanent = "permanent"; - - -// Extension-related error messages. Some of these are simple patterns, where a -// '*' is replaced at runtime with a specific value. This is used instead of -// printf because we want to unit test them and scanf is hard to make -// cross-platform. -const char* Extension::kInvalidContentScriptError = - "Invalid value for 'content_scripts[*]'."; -const char* Extension::kInvalidContentScriptsListError = - "Invalid value for 'content_scripts'."; -const char* Extension::kInvalidCssError = - "Invalid value for 'content_scripts[*].css[*]'."; -const char* Extension::kInvalidCssListError = - "Required value 'content_scripts[*].css is invalid."; -const char* Extension::kInvalidDescriptionError = - "Invalid value for 'description'."; -const char* Extension::kInvalidIdError = - "Required value 'id' is missing or invalid."; -const char* Extension::kInvalidJsError = - "Invalid value for 'content_scripts[*].js[*]'."; -const char* Extension::kInvalidJsListError = - "Required value 'content_scripts[*].js is invalid."; -const char* Extension::kInvalidManifestError = - "Manifest is missing or invalid."; -const char* Extension::kInvalidMatchCountError = - "Invalid value for 'content_scripts[*].matches. There must be at least one " - "match specified."; -const char* Extension::kInvalidMatchError = - "Invalid value for 'content_scripts[*].matches[*]'."; -const char* Extension::kInvalidMatchesError = - "Required value 'content_scripts[*].matches' is missing or invalid."; -const char* Extension::kInvalidNameError = - "Required value 'name' is missing or invalid."; -const char* Extension::kInvalidPageActionError = - "Invalid value for 'page_actions[*]'."; -const char* Extension::kInvalidPageActionsListError = - "Invalid value for 'page_actions'."; -const char* Extension::kInvalidPageActionIconPathError = - "Invalid value for 'page_actions[*].icon'."; -const char* Extension::kInvalidPageActionTooltipError = - "Invalid value for 'page_actions[*].tooltip'."; -const char* Extension::kInvalidPageActionTypeValueError = - "Invalid value for 'page_actions[*].type', expected 'tab' or 'permanent'."; -const char* Extension::kInvalidPermissionsError = - "Required value 'permissions' is missing or invalid."; -const char* Extension::kInvalidPermissionCountWarning = - "Warning, 'permissions' key found, but array is empty."; -const char* Extension::kInvalidPermissionError = - "Invalid value for 'permissions[*]'."; -const char* Extension::kInvalidPermissionSchemeError = - "Invalid scheme for 'permissions[*]'. Only 'http' and 'https' are " - "allowed."; -const char* Extension::kInvalidPluginsDirError = - "Invalid value for 'plugins_dir'."; -const char* Extension::kInvalidBackgroundError = - "Invalid value for 'background'."; -const char* Extension::kInvalidRunAtError = - "Invalid value for 'content_scripts[*].run_at'."; -const char* Extension::kInvalidToolstripError = - "Invalid value for 'toolstrips[*]'"; -const char* Extension::kInvalidToolstripsError = - "Invalid value for 'toolstrips'."; -const char* Extension::kInvalidVersionError = - "Required value 'version' is missing or invalid."; -const char* Extension::kInvalidZipHashError = - "Required key 'zip_hash' is missing or invalid."; -const char* Extension::kMissingFileError = - "At least one js or css file is required for 'content_scripts[*]'."; -const char* Extension::kInvalidThemeError = - "Invalid value for 'theme'."; -const char* Extension::kInvalidThemeImagesError = - "Invalid value for theme images - images must be strings."; -const char* Extension::kInvalidThemeImagesMissingError = - "Am image specified in the theme is missing."; -const char* Extension::kInvalidThemeColorsError = - "Invalid value for theme colors - colors must be integers"; -const char* Extension::kInvalidThemeTintsError = - "Invalid value for theme images - tints must be decimal numbers."; - -const size_t Extension::kIdSize = 20; // SHA1 (160 bits) == 20 bytes - -Extension::~Extension() { - for (PageActionMap::iterator i = page_actions_.begin(); - i != page_actions_.end(); ++i) - delete i->second; -} - -const std::string Extension::VersionString() const { - return version_->GetString(); -} - -// static -GURL Extension::GetResourceURL(const GURL& extension_url, - const std::string& relative_path) { - DCHECK(extension_url.SchemeIs(chrome::kExtensionScheme)); - DCHECK(extension_url.path() == "/"); - - GURL ret_val = GURL(extension_url.spec() + relative_path); - DCHECK(StartsWithASCII(ret_val.spec(), extension_url.spec(), false)); - - return ret_val; -} - -const PageAction* Extension::GetPageAction(std::string id) const { - PageActionMap::const_iterator it = page_actions_.find(id); - if (it == page_actions_.end()) - return NULL; - - return it->second; -} - -// static -FilePath Extension::GetResourcePath(const FilePath& extension_path, - const std::string& relative_path) { - // Build up a file:// URL and convert that back to a FilePath. This avoids - // URL encoding and path separator issues. - - // Convert the extension's root to a file:// URL. - GURL extension_url = net::FilePathToFileURL(extension_path); - if (!extension_url.is_valid()) - return FilePath(); - - // Append the requested path. - GURL::Replacements replacements; - std::string new_path(extension_url.path()); - new_path += "/"; - new_path += relative_path; - replacements.SetPathStr(new_path); - GURL file_url = extension_url.ReplaceComponents(replacements); - if (!file_url.is_valid()) - return FilePath(); - - // Convert the result back to a FilePath. - FilePath ret_val; - if (!net::FileURLToFilePath(file_url, &ret_val)) - return FilePath(); - - // Double-check that the path we ended up with is actually inside the - // extension root. We can do this with a simple prefix match because: - // a) We control the prefix on both sides, and they should match. - // b) GURL normalizes things like "../" and "//" before it gets to us. - if (ret_val.value().find(extension_path.value() + - FilePath::kSeparators[0]) != 0) - return FilePath(); - - return ret_val; -} - -Extension::Extension(const FilePath& path) { - DCHECK(path.IsAbsolute()); - location_ = INVALID; - -#if defined(OS_WIN) - // Normalize any drive letter to upper-case. We do this for consistency with - // net_utils::FilePathToFileURL(), which does the same thing, to make string - // comparisons simpler. - std::wstring path_str = path.value(); - if (path_str.size() >= 2 && path_str[0] >= L'a' && path_str[0] <= L'z' && - path_str[1] == ':') - path_str[0] += ('A' - 'a'); - - path_ = FilePath(path_str); -#else - path_ = path; -#endif -} - -// Helper method that loads a UserScript object from a dictionary in the -// content_script list of the manifest. -bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script, - int definition_index, std::string* error, - UserScript* result) { - // run_at - if (content_script->HasKey(kRunAtKey)) { - std::string run_location; - if (!content_script->GetString(kRunAtKey, &run_location)) { - *error = ExtensionErrorUtils::FormatErrorMessage(kInvalidRunAtError, - IntToString(definition_index)); - return false; - } - - if (run_location == kRunAtDocumentStartValue) { - result->set_run_location(UserScript::DOCUMENT_START); - } else if (run_location == kRunAtDocumentEndValue) { - result->set_run_location(UserScript::DOCUMENT_END); - } else { - *error = ExtensionErrorUtils::FormatErrorMessage(kInvalidRunAtError, - IntToString(definition_index)); - return false; - } - } - - // matches - ListValue* matches = NULL; - if (!content_script->GetList(kMatchesKey, &matches)) { - *error = ExtensionErrorUtils::FormatErrorMessage(kInvalidMatchesError, - IntToString(definition_index)); - return false; - } - - if (matches->GetSize() == 0) { - *error = ExtensionErrorUtils::FormatErrorMessage(kInvalidMatchCountError, - IntToString(definition_index)); - return false; - } - for (size_t j = 0; j < matches->GetSize(); ++j) { - std::string match_str; - if (!matches->GetString(j, &match_str)) { - *error = ExtensionErrorUtils::FormatErrorMessage(kInvalidMatchError, - IntToString(definition_index), IntToString(j)); - return false; - } - - URLPattern pattern; - if (!pattern.Parse(match_str)) { - *error = ExtensionErrorUtils::FormatErrorMessage(kInvalidMatchError, - IntToString(definition_index), IntToString(j)); - return false; - } - - result->add_url_pattern(pattern); - } - - // js and css keys - ListValue* js = NULL; - if (content_script->HasKey(kJsKey) && - !content_script->GetList(kJsKey, &js)) { - *error = ExtensionErrorUtils::FormatErrorMessage(kInvalidJsListError, - IntToString(definition_index)); - return false; - } - - ListValue* css = NULL; - if (content_script->HasKey(kCssKey) && - !content_script->GetList(kCssKey, &css)) { - *error = ExtensionErrorUtils::FormatErrorMessage(kInvalidCssListError, - IntToString(definition_index)); - return false; - } - - // The manifest needs to have at least one js or css user script definition. - if (((js ? js->GetSize() : 0) + (css ? css->GetSize() : 0)) == 0) { - *error = ExtensionErrorUtils::FormatErrorMessage(kMissingFileError, - IntToString(definition_index)); - return false; - } - - if (js) { - for (size_t script_index = 0; script_index < js->GetSize(); - ++script_index) { - Value* value; - std::wstring relative; - if (!js->Get(script_index, &value) || !value->GetAsString(&relative)) { - *error = ExtensionErrorUtils::FormatErrorMessage(kInvalidJsError, - IntToString(definition_index), IntToString(script_index)); - return false; - } - // TODO(georged): Make GetResourceURL accept wstring too - GURL url = GetResourceURL(WideToUTF8(relative)); - FilePath path = GetResourcePath(WideToUTF8(relative)); - result->js_scripts().push_back(UserScript::File(path, url)); - } - } - - if (css) { - for (size_t script_index = 0; script_index < css->GetSize(); - ++script_index) { - Value* value; - std::wstring relative; - if (!css->Get(script_index, &value) || !value->GetAsString(&relative)) { - *error = ExtensionErrorUtils::FormatErrorMessage(kInvalidCssError, - IntToString(definition_index), IntToString(script_index)); - return false; - } - // TODO(georged): Make GetResourceURL accept wstring too - GURL url = GetResourceURL(WideToUTF8(relative)); - FilePath path = GetResourcePath(WideToUTF8(relative)); - result->css_scripts().push_back(UserScript::File(path, url)); - } - } - - return true; -} - -// Helper method that loads a PageAction object from a dictionary in the -// page_action list of the manifest. -PageAction* Extension::LoadPageActionHelper( - const DictionaryValue* page_action, int definition_index, - std::string* error) { - scoped_ptr<PageAction> result(new PageAction()); - result->set_extension_id(id()); - - // Read the page action |icon|. - std::string icon; - if (!page_action->GetString(kIconPathKey, &icon)) { - *error = ExtensionErrorUtils::FormatErrorMessage( - kInvalidPageActionIconPathError, IntToString(definition_index)); - return NULL; - } - FilePath icon_path = path_.AppendASCII(icon); - result->set_icon_path(icon_path); - - // Read the page action |id|. - std::string id; - if (!page_action->GetString(kIdKey, &id)) { - *error = ExtensionErrorUtils::FormatErrorMessage(kInvalidIdError, - IntToString(definition_index)); - return NULL; - } - result->set_id(id); - - // Read the page action |name|. - std::string name; - if (!page_action->GetString(kNameKey, &name)) { - *error = ExtensionErrorUtils::FormatErrorMessage(kInvalidNameError, - IntToString(definition_index)); - return NULL; - } - result->set_name(name); - - // Read the page action |tooltip|. - std::string tooltip; - if (!page_action->GetString(kTooltipKey, &tooltip)) { - *error = ExtensionErrorUtils::FormatErrorMessage( - kInvalidPageActionTooltipError, IntToString(definition_index)); - return NULL; - } - result->set_tooltip(tooltip); - - // Read the page action |type|. It is optional and set to permanent if - // missing. - std::string type; - if (!page_action->GetString(kTypeKey, &type)) { - result->set_type(PageAction::PERMANENT); - } else if (!LowerCaseEqualsASCII(type, kPageActionTypeTab) && - !LowerCaseEqualsASCII(type, kPageActionTypePermanent)) { - *error = ExtensionErrorUtils::FormatErrorMessage( - kInvalidPageActionTypeValueError, IntToString(definition_index)); - return NULL; - } else { - if (LowerCaseEqualsASCII(type, kPageActionTypeTab)) - result->set_type(PageAction::TAB); - else - result->set_type(PageAction::PERMANENT); - } - - return result.release(); -} - -bool Extension::InitFromValue(const DictionaryValue& source, bool require_id, - std::string* error) { - // Initialize id. - if (source.HasKey(kIdKey)) { - if (!source.GetString(kIdKey, &id_)) { - *error = kInvalidIdError; - return false; - } - - // Normalize the string to lowercase, so it can be used as an URL component - // (where GURL will lowercase it). - StringToLowerASCII(&id_); - - // Verify that the id is legal. The id is a hex string of the SHA-1 hash of - // the public key. - std::vector<uint8> id_bytes; - if (!HexStringToBytes(id_, &id_bytes) || id_bytes.size() != kIdSize) { - *error = kInvalidIdError; - return false; - } - } else if (require_id) { - *error = kInvalidIdError; - return false; - } else { - // Generate a random ID - static int counter = 0; - id_ = StringPrintf("%x", counter); - ++counter; - - // pad the string out to 40 chars with zeroes. - id_.insert(0, 40 - id_.length(), '0'); - } - - // Initialize the URL. - extension_url_ = GURL(std::string(chrome::kExtensionScheme) + - chrome::kStandardSchemeSeparator + id_ + "/"); - - // Initialize version. - std::string version_str; - if (!source.GetString(kVersionKey, &version_str)) { - *error = kInvalidVersionError; - return false; - } - version_.reset(Version::GetVersionFromString(version_str)); - if (!version_.get()) { - *error = kInvalidVersionError; - return false; - } - - // Initialize name. - if (!source.GetString(kNameKey, &name_)) { - *error = kInvalidNameError; - return false; - } - - // Initialize description (optional). - if (source.HasKey(kDescriptionKey)) { - if (!source.GetString(kDescriptionKey, &description_)) { - *error = kInvalidDescriptionError; - return false; - } - } - - // Initialize zip hash (only present in zip) - // There's no need to verify it at this point. If it's in a bogus format - // it won't pass the hash verify step. - if (source.HasKey(kZipHashKey)) { - if (!source.GetString(kZipHashKey, &zip_hash_)) { - *error = kInvalidZipHashError; - return false; - } - } - - // Initialize themes. If a theme is included, no other items may be processed - // (we currently don't want people bundling themes and extension stuff - // together). - // - // TODO(glen): Error if other items *are* included. - is_theme_ = false; - if (source.HasKey(kThemeKey)) { - DictionaryValue* theme_value; - if (!source.GetDictionary(kThemeKey, &theme_value)) { - *error = kInvalidThemeError; - return false; - } - is_theme_ = true; - - DictionaryValue* images_value; - if (theme_value->GetDictionary(kThemeImagesKey, &images_value)) { - // Validate that the images are all strings - DictionaryValue::key_iterator iter = images_value->begin_keys(); - while (iter != images_value->end_keys()) { - std::string val; - if (!images_value->GetString(*iter, &val)) { - *error = kInvalidThemeImagesError; - return false; - } - ++iter; - } - theme_images_.reset( - static_cast<DictionaryValue*>(images_value->DeepCopy())); - } - - DictionaryValue* colors_value; - if (theme_value->GetDictionary(kThemeColorsKey, &colors_value)) { - // Validate that the colors are all three-item lists - DictionaryValue::key_iterator iter = colors_value->begin_keys(); - while (iter != colors_value->end_keys()) { - std::string val; - int color = 0; - ListValue* color_list; - if (!colors_value->GetList(*iter, &color_list) || - color_list->GetSize() != 3 || - !color_list->GetInteger(0, &color) || - !color_list->GetInteger(1, &color) || - !color_list->GetInteger(2, &color)) { - *error = kInvalidThemeColorsError; - return false; - } - ++iter; - } - theme_colors_.reset( - static_cast<DictionaryValue*>(colors_value->DeepCopy())); - } - - DictionaryValue* tints_value; - if (theme_value->GetDictionary(kThemeTintsKey, &tints_value)) { - // Validate that the tints are all reals. - DictionaryValue::key_iterator iter = tints_value->begin_keys(); - while (iter != tints_value->end_keys()) { - ListValue* tint_list; - double hue = 0; - if (!tints_value->GetList(*iter, &tint_list) || - tint_list->GetSize() != 3 || - !tint_list->GetReal(0, &hue) || - !tint_list->GetReal(1, &hue) || - !tint_list->GetReal(2, &hue)) { - *error = kInvalidThemeTintsError; - return false; - } - ++iter; - } - theme_tints_.reset( - static_cast<DictionaryValue*>(tints_value->DeepCopy())); - } - return true; - } - - // Initialize plugins dir (optional). - if (source.HasKey(kPluginsDirKey)) { - std::string plugins_dir; - if (!source.GetString(kPluginsDirKey, &plugins_dir)) { - *error = kInvalidPluginsDirError; - return false; - } - plugins_dir_ = path_.AppendASCII(plugins_dir); - } - - // Initialize background url (optional). - if (source.HasKey(kBackgroundKey)) { - std::string background_str; - if (!source.GetString(kBackgroundKey, &background_str)) { - *error = kInvalidBackgroundError; - return false; - } - background_url_ = GetResourceURL(background_str); - } - - // Initialize toolstrips (optional). - if (source.HasKey(kToolstripsKey)) { - ListValue* list_value; - if (!source.GetList(kToolstripsKey, &list_value)) { - *error = kInvalidToolstripsError; - return false; - } - - for (size_t i = 0; i < list_value->GetSize(); ++i) { - std::string toolstrip; - if (!list_value->GetString(i, &toolstrip)) { - *error = ExtensionErrorUtils::FormatErrorMessage(kInvalidToolstripError, - IntToString(i)); - return false; - } - toolstrips_.push_back(toolstrip); - } - } - - // Initialize content scripts (optional). - if (source.HasKey(kContentScriptsKey)) { - ListValue* list_value; - if (!source.GetList(kContentScriptsKey, &list_value)) { - *error = kInvalidContentScriptsListError; - return false; - } - - for (size_t i = 0; i < list_value->GetSize(); ++i) { - DictionaryValue* content_script; - if (!list_value->GetDictionary(i, &content_script)) { - *error = ExtensionErrorUtils::FormatErrorMessage( - kInvalidContentScriptError, IntToString(i)); - return false; - } - - UserScript script; - if (!LoadUserScriptHelper(content_script, i, error, &script)) - return false; // Failed to parse script context definition - script.set_extension_id(id()); - content_scripts_.push_back(script); - } - } - - // Initialize page actions (optional). - if (source.HasKey(kPageActionsKey)) { - ListValue* list_value; - if (!source.GetList(kPageActionsKey, &list_value)) { - *error = kInvalidPageActionsListError; - return false; - } - - for (size_t i = 0; i < list_value->GetSize(); ++i) { - DictionaryValue* page_action_value; - if (!list_value->GetDictionary(i, &page_action_value)) { - *error = ExtensionErrorUtils::FormatErrorMessage( - kInvalidPageActionError, IntToString(i)); - return false; - } - - PageAction* page_action = - LoadPageActionHelper(page_action_value, i, error); - if (!page_action) - return false; // Failed to parse page action definition. - page_actions_[page_action->id()] = page_action; - } - } - - // Initialize the permissions (optional). - if (source.HasKey(kPermissionsKey)) { - ListValue* hosts = NULL; - if (!source.GetList(kPermissionsKey, &hosts)) { - *error = ExtensionErrorUtils::FormatErrorMessage( - kInvalidPermissionsError, ""); - return false; - } - - if (hosts->GetSize() == 0) { - ExtensionErrorReporter::GetInstance()->ReportError( - kInvalidPermissionCountWarning, false); - } - - for (size_t i = 0; i < hosts->GetSize(); ++i) { - std::string host_str; - if (!hosts->GetString(i, &host_str)) { - *error = ExtensionErrorUtils::FormatErrorMessage( - kInvalidPermissionError, IntToString(i)); - return false; - } - - URLPattern pattern; - if (!pattern.Parse(host_str)) { - *error = ExtensionErrorUtils::FormatErrorMessage( - kInvalidPermissionError, IntToString(i)); - return false; - } - - // Only accept http/https persmissions at the moment. - if ((pattern.scheme() != chrome::kHttpScheme) && - (pattern.scheme() != chrome::kHttpsScheme)) { - *error = ExtensionErrorUtils::FormatErrorMessage( - kInvalidPermissionSchemeError, IntToString(i)); - return false; - } - - permissions_.push_back(pattern); - } - } - - return true; -} diff --git a/chrome/browser/extensions/extension.h b/chrome/browser/extensions/extension.h deleted file mode 100644 index 0160abd..0000000 --- a/chrome/browser/extensions/extension.h +++ /dev/null @@ -1,247 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_H_ -#define CHROME_BROWSER_EXTENSIONS_EXTENSION_H_ - -#include <string> -#include <vector> -#include <map> - -#include "base/file_path.h" -#include "base/scoped_ptr.h" -#include "base/string16.h" -#include "base/values.h" -#include "base/version.h" -#include "chrome/browser/extensions/user_script_master.h" -#include "chrome/common/extensions/url_pattern.h" -#include "chrome/common/page_action.h" -#include "googleurl/src/gurl.h" -#include "third_party/skia/include/core/SkColor.h" - -// Represents a Chromium extension. -class Extension { - public: - // What an extension was loaded from. - enum Location { - INVALID, - INTERNAL, // A crx file from the internal Extensions directory. - EXTERNAL, // A crx file from an external directory (via eg the registry - // on Windows). - LOAD // --load-extension. - }; - - // The name of the manifest inside an extension. - static const char kManifestFilename[]; - - // Keys used in JSON representation of extensions. - static const wchar_t* kContentScriptsKey; - static const wchar_t* kCssKey; - static const wchar_t* kDescriptionKey; - static const wchar_t* kIconPathKey; - static const wchar_t* kIdKey; - static const wchar_t* kJsKey; - static const wchar_t* kMatchesKey; - static const wchar_t* kNameKey; - static const wchar_t* kPageActionsKey; - static const wchar_t* kPermissionsKey; - static const wchar_t* kPluginsDirKey; - static const wchar_t* kBackgroundKey; - static const wchar_t* kRunAtKey; - static const wchar_t* kThemeKey; - static const wchar_t* kThemeImagesKey; - static const wchar_t* kThemeColorsKey; - static const wchar_t* kThemeTintsKey; - static const wchar_t* kToolstripsKey; - static const wchar_t* kTooltipKey; - static const wchar_t* kTypeKey; - static const wchar_t* kVersionKey; - static const wchar_t* kZipHashKey; - - // Some values expected in manifests. - static const char* kRunAtDocumentStartValue; - static const char* kRunAtDocumentEndValue; - static const char* kPageActionTypeTab; - static const char* kPageActionTypePermanent; - - // Error messages returned from InitFromValue(). - static const char* kInvalidContentScriptError; - static const char* kInvalidContentScriptsListError; - static const char* kInvalidCssError; - static const char* kInvalidCssListError; - static const char* kInvalidDescriptionError; - static const char* kInvalidIdError; - static const char* kInvalidJsError; - static const char* kInvalidJsListError; - static const char* kInvalidManifestError; - static const char* kInvalidMatchCountError; - static const char* kInvalidMatchError; - static const char* kInvalidMatchesError; - static const char* kInvalidNameError; - static const char* kInvalidPluginsDirError; - static const char* kInvalidBackgroundError; - static const char* kInvalidRunAtError; - static const char* kInvalidToolstripError; - static const char* kInvalidToolstripsError; - static const char* kInvalidVersionError; - static const char* kInvalidPageActionError; - static const char* kInvalidPageActionsListError; - static const char* kInvalidPageActionIconPathError; - static const char* kInvalidPageActionTooltipError; - static const char* kInvalidPageActionTypeValueError; - static const char* kInvalidPermissionsError; - static const char* kInvalidPermissionCountWarning; - static const char* kInvalidPermissionError; - static const char* kInvalidPermissionSchemeError; - static const char* kInvalidZipHashError; - static const char* kInvalidThemeError; - static const char* kInvalidThemeImagesMissingError; - static const char* kInvalidThemeImagesError; - static const char* kInvalidThemeColorsError; - static const char* kInvalidThemeTintsError; - static const char* kMissingFileError; - - // The number of bytes in a legal id. - static const size_t kIdSize; - - Extension() : location_(INVALID) {} - explicit Extension(const FilePath& path); - virtual ~Extension(); - - // Returns an absolute url to a resource inside of an extension. The - // |extension_url| argument should be the url() from an Extension object. The - // |relative_path| can be untrusted user input. The returned URL will either - // be invalid() or a child of |extension_url|. - // NOTE: Static so that it can be used from multiple threads. - static GURL GetResourceURL(const GURL& extension_url, - const std::string& relative_path); - GURL GetResourceURL(const std::string& relative_path) { - return GetResourceURL(url(), relative_path); - } - - // Returns an absolute path to a resource inside of an extension. The - // |extension_path| argument should be the path() from an Extension object. - // The |relative_path| can be untrusted user input. The returned path will - // either be empty or a child of extension_path. - // NOTE: Static so that it can be used from multiple threads. - static FilePath GetResourcePath(const FilePath& extension_path, - const std::string& relative_path); - FilePath GetResourcePath(const std::string& relative_path) { - return GetResourcePath(path(), relative_path); - } - - // Initialize the extension from a parsed manifest. - // If |require_id| is true, will return an error if the "id" key is missing - // from the value. - bool InitFromValue(const DictionaryValue& value, bool require_id, - std::string* error); - - const FilePath& path() const { return path_; } - const GURL& url() const { return extension_url_; } - const Location location() const { return location_; } - void set_location(Location location) { location_ = location; } - const std::string& id() const { return id_; } - const Version* version() const { return version_.get(); } - // String representation of the version number. - const std::string VersionString() const; - const std::string& name() const { return name_; } - const std::string& description() const { return description_; } - const UserScriptList& content_scripts() const { return content_scripts_; } - const PageActionMap& page_actions() const { return page_actions_; } - const FilePath& plugins_dir() const { return plugins_dir_; } - const GURL& background_url() const { return background_url_; } - const std::vector<std::string>& toolstrips() const { return toolstrips_; } - const std::vector<URLPattern>& permissions() const { - return permissions_; } - - // Retrieves a page action by |id|. - const PageAction* GetPageAction(std::string id) const; - - // Theme-related - DictionaryValue* GetThemeImages() const { return theme_images_.get(); } - DictionaryValue* GetThemeColors() const { return theme_colors_.get(); } - DictionaryValue* GetThemeTints() const { return theme_tints_.get(); } - bool IsTheme() { return is_theme_; } - - private: - // Helper method that loads a UserScript object from a - // dictionary in the content_script list of the manifest. - bool LoadUserScriptHelper(const DictionaryValue* content_script, - int definition_index, - std::string* error, - UserScript* result); - - // Helper method that loads a PageAction object from a - // dictionary in the page_action list of the manifest. - PageAction* LoadPageActionHelper(const DictionaryValue* page_action, - int definition_index, - std::string* error); - - // The absolute path to the directory the extension is stored in. - FilePath path_; - - // The base extension url for the extension. - GURL extension_url_; - - // The location the extension was loaded from. - Location location_; - - // A human-readable ID for the extension. The convention is to use something - // like 'com.example.myextension', but this is not currently enforced. An - // extension's ID is used in things like directory structures and URLs, and - // is expected to not change across versions. In the case of conflicts, - // updates will only be allowed if the extension can be validated using the - // previous version's update key. - std::string id_; - - // The extension's version. - scoped_ptr<Version> version_; - - // The extension's human-readable name. - std::string name_; - - // An optional longer description of the extension. - std::string description_; - - // Paths to the content scripts the extension contains. - UserScriptList content_scripts_; - - // A list of page actions. - PageActionMap page_actions_; - - // Optional absolute path to the directory of NPAPI plugins that the extension - // contains. - FilePath plugins_dir_; - - // Optional URL to a master page of which a single instance should be always - // loaded in the background. - GURL background_url_; - - // Paths to HTML files to be displayed in the toolbar. - std::vector<std::string> toolstrips_; - - // A SHA1 hash of the contents of the zip file. Note that this key is only - // present in the manifest that's prepended to the zip. The inner manifest - // will not have this key. - std::string zip_hash_; - - // A map of resource id's to relative file paths. - scoped_ptr<DictionaryValue> theme_images_; - - // A map of color names to colors. - scoped_ptr<DictionaryValue> theme_colors_; - - // A map of color names to colors. - scoped_ptr<DictionaryValue> theme_tints_; - - // Whether the extension is a theme - if it is, certain things are disabled. - bool is_theme_; - - // The sites this extension has permission to talk to (using XHR, etc). - std::vector<URLPattern> permissions_; - - DISALLOW_COPY_AND_ASSIGN(Extension); -}; - -#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_H_ diff --git a/chrome/browser/extensions/extension_browser_event_router.cc b/chrome/browser/extensions/extension_browser_event_router.cc index 30699f5..b3f81ca 100644 --- a/chrome/browser/extensions/extension_browser_event_router.cc +++ b/chrome/browser/extensions/extension_browser_event_router.cc @@ -8,11 +8,11 @@ #include "base/values.h" #include "chrome/browser/browser.h" #include "chrome/browser/profile.h" -#include "chrome/browser/extensions/extension.h" #include "chrome/browser/extensions/extension_event_names.h" #include "chrome/browser/extensions/extension_message_service.h" #include "chrome/browser/extensions/extension_tabs_module_constants.h" #include "chrome/browser/tab_contents/navigation_entry.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/notification_service.h" namespace events = extension_event_names; diff --git a/chrome/browser/extensions/extension_error_reporter.cc b/chrome/browser/extensions/extension_error_reporter.cc deleted file mode 100644 index c3a028c..0000000 --- a/chrome/browser/extensions/extension_error_reporter.cc +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/extensions/extension_error_reporter.h" - -#if defined(OS_WIN) -#include "app/win_util.h" -#endif -#include "base/string_util.h" - -// No AddRef required when using ExtensionErrorReporter with RunnableMethod. -// This is okay since the ExtensionErrorReporter is a singleton that lives until -// the end of the process. -template <> struct RunnableMethodTraits<ExtensionErrorReporter> { - static void RetainCallee(ExtensionErrorReporter*) {} - static void ReleaseCallee(ExtensionErrorReporter*) {} -}; - -ExtensionErrorReporter* ExtensionErrorReporter::instance_ = NULL; - -// static -void ExtensionErrorReporter::Init(bool enable_noisy_errors) { - if (!instance_) { - instance_ = new ExtensionErrorReporter(enable_noisy_errors); - } -} - -// static -ExtensionErrorReporter* ExtensionErrorReporter::GetInstance() { - CHECK(instance_) << "Init() was never called"; - return instance_; -} - -ExtensionErrorReporter::ExtensionErrorReporter(bool enable_noisy_errors) - : ui_loop_(MessageLoop::current()), - enable_noisy_errors_(enable_noisy_errors) { -} - -void ExtensionErrorReporter::ReportError(const std::string& message, - bool be_noisy) { - // NOTE: There won't be a ui_loop_ in the unit test environment. - if (ui_loop_ && MessageLoop::current() != ui_loop_) { - ui_loop_->PostTask(FROM_HERE, - NewRunnableMethod(this, &ExtensionErrorReporter::ReportError, message, - be_noisy)); - return; - } - - errors_.push_back(message); - - // TODO(aa): Print the error message out somewhere better. I think we are - // going to need some sort of 'extension inspector'. - LOG(WARNING) << message; - - if (enable_noisy_errors_ && be_noisy) { -#if defined(OS_WIN) - win_util::MessageBox(NULL, UTF8ToWide(message), L"Extension error", - MB_OK | MB_SETFOREGROUND); -#else - // TODO(port) -#endif - } -} - -const std::vector<std::string>* ExtensionErrorReporter::GetErrors() { - return &errors_; -} - -void ExtensionErrorReporter::ClearErrors() { - errors_.clear(); -} diff --git a/chrome/browser/extensions/extension_error_reporter.h b/chrome/browser/extensions/extension_error_reporter.h deleted file mode 100644 index b85927f..0000000 --- a/chrome/browser/extensions/extension_error_reporter.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_EXTENSIONS_ERROR_REPORTER_H_ -#define CHROME_BROWSER_EXTENSIONS_ERROR_REPORTER_H_ - -#include <string> -#include <vector> - -#include "base/message_loop.h" - -// Exposes an easy way for the various components of the extension system to -// report errors. This is a singleton that lives on the UI thread, with the -// exception of ReportError() which may be called from any thread. -// TODO(aa): Hook this up to about:extensions, when we have about:extensions. -// TODO(aa): Consider exposing directly, or via a helper, to the renderer -// process and plumbing the errors out to the browser. -// TODO(aa): Add ReportError(extension_id, message, be_noisy), so that we can -// report errors that are specific to a particular extension. -class ExtensionErrorReporter { - public: - // Initializes the error reporter. Must be called before any other methods - // and on the UI thread. - static void Init(bool enable_noisy_errors); - - // Get the singleton instance. - static ExtensionErrorReporter* GetInstance(); - - // Report an error. Errors always go to LOG(INFO). Optionally, they can also - // cause a noisy alert box. This method can be called from any thread. - void ReportError(const std::string& message, bool be_noisy); - - // Get the errors that have been reported so far. - const std::vector<std::string>* GetErrors(); - - // Clear the list of errors reported so far. - void ClearErrors(); - - private: - static ExtensionErrorReporter* instance_; - - ExtensionErrorReporter(bool enable_noisy_errors); - - MessageLoop* ui_loop_; - std::vector<std::string> errors_; - bool enable_noisy_errors_; -}; - -#endif // CHROME_BROWSER_EXTENSIONS_ERROR_REPORTER_H_ diff --git a/chrome/browser/extensions/extension_error_utils.cc b/chrome/browser/extensions/extension_error_utils.cc deleted file mode 100755 index c43587b..0000000 --- a/chrome/browser/extensions/extension_error_utils.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/extensions/extension_error_utils.h" - -#include "base/string_util.h" - -std::string ExtensionErrorUtils::FormatErrorMessage( - const std::string& format, - const std::string s1) { - std::string ret_val = format; - ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1); - return ret_val; -} - -std::string ExtensionErrorUtils::FormatErrorMessage( - const std::string& format, - const std::string s1, - const std::string s2) { - std::string ret_val = format; - ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1); - ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2); - return ret_val; -} diff --git a/chrome/browser/extensions/extension_error_utils.h b/chrome/browser/extensions/extension_error_utils.h deleted file mode 100755 index 1d7283a..0000000 --- a/chrome/browser/extensions/extension_error_utils.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_UTILS_H_ -#define CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_UTILS_H_ - -#include <string> - -class ExtensionErrorUtils { -public: - // Creates an error messages from a pattern. Places first instance if "*" - // with |s1|. - static std::string FormatErrorMessage(const std::string& format, - const std::string s1); - - // Creates an error messages from a pattern. Places first instance if "*" - // with |s1| and second instance of "*" with |s2|. - static std::string FormatErrorMessage(const std::string& format, - const std::string s1, - const std::string s2); -}; - -#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FORMAT_MESSAGE_UTILS_H_ diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 61f7a41..e1e87fe 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -9,7 +9,6 @@ #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/debugger/devtools_manager.h" -#include "chrome/browser/extensions/extension.h" #include "chrome/browser/extensions/extension_message_service.h" #include "chrome/browser/extensions/extension_view.h" #include "chrome/browser/profile.h" @@ -20,6 +19,7 @@ #include "chrome/browser/tab_contents/site_instance.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" diff --git a/chrome/browser/extensions/extension_message_service.cc b/chrome/browser/extensions/extension_message_service.cc index 86371e0..9096e0a 100644 --- a/chrome/browser/extensions/extension_message_service.cc +++ b/chrome/browser/extensions/extension_message_service.cc @@ -9,13 +9,13 @@ #include "base/stl_util-inl.h" #include "base/values.h" #include "chrome/browser/chrome_thread.h" -#include "chrome/browser/extensions/extension.h" #include "chrome/browser/extensions/extension_tabs_module.h" #include "chrome/browser/extensions/extension_view.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/renderer_host/resource_message_filter.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_util.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/notification_service.h" #include "chrome/common/render_messages.h" diff --git a/chrome/browser/extensions/extension_page_actions_module.cc b/chrome/browser/extensions/extension_page_actions_module.cc index fb686d8..ab943e0 100644 --- a/chrome/browser/extensions/extension_page_actions_module.cc +++ b/chrome/browser/extensions/extension_page_actions_module.cc @@ -7,12 +7,12 @@ #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/profile.h" -#include "chrome/browser/extensions/extension.h" -#include "chrome/browser/extensions/extension_error_utils.h" #include "chrome/browser/extensions/extension_page_actions_module_constants.h" #include "chrome/browser/extensions/extension_tabs_module.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/tab_contents/navigation_entry.h" +#include "chrome/common/extensions/extension.h" +#include "chrome/common/extensions/extension_error_utils.h" namespace keys = extension_page_actions_module_constants; diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc index ac79d16..e8f7de6 100644 --- a/chrome/browser/extensions/extension_process_manager.cc +++ b/chrome/browser/extensions/extension_process_manager.cc @@ -5,12 +5,12 @@ #include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/browsing_instance.h" -#include "chrome/browser/extensions/extension.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_view.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/site_instance.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/notification_service.h" static void CreateBackgroundHosts( diff --git a/chrome/browser/extensions/extension_process_manager_unittest.cc b/chrome/browser/extensions/extension_process_manager_unittest.cc index a72ac26..43d3048 100644 --- a/chrome/browser/extensions/extension_process_manager_unittest.cc +++ b/chrome/browser/extensions/extension_process_manager_unittest.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/extensions/extension_error_reporter.h" #include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/tab_contents/site_instance.h" +#include "chrome/common/extensions/extension_error_reporter.h" #include "chrome/test/testing_profile.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" diff --git a/chrome/browser/extensions/extension_protocols.cc b/chrome/browser/extensions/extension_protocols.cc index 5cf75f5..3a31b0e 100644 --- a/chrome/browser/extensions/extension_protocols.cc +++ b/chrome/browser/extensions/extension_protocols.cc @@ -5,8 +5,8 @@ #include "chrome/browser/extensions/extension_protocols.h" #include "base/string_util.h" -#include "chrome/browser/extensions/extension.h" #include "chrome/browser/net/chrome_url_request_context.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/url_constants.h" #include "googleurl/src/url_util.h" #include "net/base/net_util.h" diff --git a/chrome/browser/extensions/extension_shelf.cc b/chrome/browser/extensions/extension_shelf.cc index 445f181e..0c56833 100644 --- a/chrome/browser/extensions/extension_shelf.cc +++ b/chrome/browser/extensions/extension_shelf.cc @@ -8,11 +8,11 @@ #include "base/logging.h" #include "base/string_util.h" #include "chrome/browser/browser.h" -#include "chrome/browser/extensions/extension.h" #include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_view.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/profile.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/notification_service.h" #include "skia/ext/skia_utils.h" #include "views/controls/label.h" diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index c7bb630..5533ff5 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -7,13 +7,13 @@ #include "base/string_util.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" -#include "chrome/browser/extensions/extension.h" -#include "chrome/browser/extensions/extension_error_utils.h" #include "chrome/browser/extensions/extension_function_dispatcher.h" #include "chrome/browser/extensions/extension_tabs_module_constants.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "chrome/browser/tab_contents/navigation_entry.h" +#include "chrome/common/extensions/extension.h" +#include "chrome/common/extensions/extension_error_utils.h" // TODO(port): Port these files. #if defined(OS_WIN) || defined(OS_MACOSX) diff --git a/chrome/browser/extensions/extension_ui_unittest.cc b/chrome/browser/extensions/extension_ui_unittest.cc index 0449e2a..2b1115b 100644 --- a/chrome/browser/extensions/extension_ui_unittest.cc +++ b/chrome/browser/extensions/extension_ui_unittest.cc @@ -4,9 +4,9 @@ #include "base/path_service.h" #include "base/string_util.h" -#include "chrome/browser/extensions/extension.h" #include "chrome/browser/extensions/extensions_ui.h" #include "chrome/common/chrome_paths.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/json_value_serializer.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/extensions/extension_unittest.cc b/chrome/browser/extensions/extension_unittest.cc deleted file mode 100644 index 0607186..0000000 --- a/chrome/browser/extensions/extension_unittest.cc +++ /dev/null @@ -1,256 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/file_path.h" -#include "base/string_util.h" -#include "base/path_service.h" -#include "chrome/browser/extensions/extension.h" -#include "chrome/browser/extensions/extension_error_reporter.h" -#include "chrome/common/chrome_paths.h" -#include "chrome/common/json_value_serializer.h" -#include "testing/gtest/include/gtest/gtest.h" - -class ExtensionTest : public testing::Test { -}; - -TEST(ExtensionTest, InitFromValueInvalid) { -#if defined(OS_WIN) - FilePath path(FILE_PATH_LITERAL("c:\\foo")); -#elif defined(OS_POSIX) - FilePath path(FILE_PATH_LITERAL("/foo")); -#endif - Extension extension(path); - std::string error; - ExtensionErrorReporter::Init(false); - - // Start with a valid extension manifest - FilePath extensions_path; - ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); - extensions_path = extensions_path.AppendASCII("extensions") - .AppendASCII("good") - .AppendASCII("extension1") - .AppendASCII("1") - .AppendASCII(Extension::kManifestFilename); - - JSONFileValueSerializer serializer(extensions_path); - scoped_ptr<DictionaryValue> valid_value( - static_cast<DictionaryValue*>(serializer.Deserialize(&error))); - ASSERT_TRUE(valid_value.get()); - ASSERT_EQ("", error); - ASSERT_TRUE(extension.InitFromValue(*valid_value, true, &error)); - ASSERT_EQ("", error); - - scoped_ptr<DictionaryValue> input_value; - - // Test missing and invalid ids - input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->Remove(Extension::kIdKey, NULL); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_EQ(Extension::kInvalidIdError, error); - - input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->SetInteger(Extension::kIdKey, 42); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_EQ(Extension::kInvalidIdError, error); - - // Test missing and invalid versions - input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->Remove(Extension::kVersionKey, NULL); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_EQ(Extension::kInvalidVersionError, error); - - input_value->SetInteger(Extension::kVersionKey, 42); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_EQ(Extension::kInvalidVersionError, error); - - // Test missing and invalid names - input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->Remove(Extension::kNameKey, NULL); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_EQ(Extension::kInvalidNameError, error); - - input_value->SetInteger(Extension::kNameKey, 42); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_EQ(Extension::kInvalidNameError, error); - - // Test invalid description - input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->SetInteger(Extension::kDescriptionKey, 42); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_EQ(Extension::kInvalidDescriptionError, error); - - // Test invalid user scripts list - input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->SetInteger(Extension::kContentScriptsKey, 42); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_EQ(Extension::kInvalidContentScriptsListError, error); - - // Test invalid user script item - input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - ListValue* content_scripts = NULL; - input_value->GetList(Extension::kContentScriptsKey, &content_scripts); - ASSERT_FALSE(NULL == content_scripts); - content_scripts->Set(0, Value::CreateIntegerValue(42)); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, Extension::kInvalidContentScriptError)); - - // Test missing and invalid matches array - input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->GetList(Extension::kContentScriptsKey, &content_scripts); - DictionaryValue* user_script = NULL; - content_scripts->GetDictionary(0, &user_script); - user_script->Remove(Extension::kMatchesKey, NULL); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchesError)); - - user_script->Set(Extension::kMatchesKey, Value::CreateIntegerValue(42)); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchesError)); - - ListValue* matches = new ListValue; - user_script->Set(Extension::kMatchesKey, matches); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchCountError)); - - // Test invalid match element - matches->Set(0, Value::CreateIntegerValue(42)); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, Extension::kInvalidMatchError)); - - // Test missing and invalid files array - input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->GetList(Extension::kContentScriptsKey, &content_scripts); - content_scripts->GetDictionary(0, &user_script); - user_script->Remove(Extension::kJsKey, NULL); - user_script->Remove(Extension::kCssKey, NULL); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, Extension::kMissingFileError)); - - user_script->Set(Extension::kJsKey, Value::CreateIntegerValue(42)); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsListError)); - - user_script->Set(Extension::kCssKey, new ListValue); - user_script->Set(Extension::kJsKey, new ListValue); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, Extension::kMissingFileError)); - user_script->Remove(Extension::kCssKey, NULL); - - ListValue* files = new ListValue; - user_script->Set(Extension::kJsKey, files); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, Extension::kMissingFileError)); - - // Test invalid file element - files->Set(0, Value::CreateIntegerValue(42)); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsError)); - - user_script->Remove(Extension::kJsKey, NULL); - // Test the css element - user_script->Set(Extension::kCssKey, Value::CreateIntegerValue(42)); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, Extension::kInvalidCssListError)); - - // Test invalid file element - ListValue* css_files = new ListValue; - user_script->Set(Extension::kCssKey, css_files); - css_files->Set(0, Value::CreateIntegerValue(42)); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, Extension::kInvalidCssError)); - - // Test missing and invalid permissions array - input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - EXPECT_TRUE(extension.InitFromValue(*input_value, true, &error)); - ListValue* permissions = NULL; - input_value->GetList(Extension::kPermissionsKey, &permissions); - ASSERT_FALSE(NULL == permissions); - - permissions = new ListValue; - input_value->Set(Extension::kPermissionsKey, permissions); - EXPECT_TRUE(extension.InitFromValue(*input_value, true, &error)); - const std::vector<std::string>* error_vector = - ExtensionErrorReporter::GetInstance()->GetErrors(); - const std::string log_error = error_vector->at(error_vector->size() - 1); - EXPECT_TRUE(MatchPattern(log_error, - Extension::kInvalidPermissionCountWarning)); - - input_value->Set(Extension::kPermissionsKey, Value::CreateIntegerValue(9)); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, Extension::kInvalidPermissionsError)); - - input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->GetList(Extension::kPermissionsKey, &permissions); - permissions->Set(0, Value::CreateIntegerValue(24)); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, Extension::kInvalidPermissionError)); - - permissions->Set(0, Value::CreateStringValue("www.google.com")); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, Extension::kInvalidPermissionError)); - - // Test permissions scheme. - input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); - input_value->GetList(Extension::kPermissionsKey, &permissions); - permissions->Set(0, Value::CreateStringValue("file:///C:/foo.txt")); - EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, Extension::kInvalidPermissionSchemeError)); -} - -TEST(ExtensionTest, InitFromValueValid) { -#if defined(OS_WIN) - FilePath path(FILE_PATH_LITERAL("C:\\foo")); -#elif defined(OS_POSIX) - FilePath path(FILE_PATH_LITERAL("/foo")); -#endif - Extension extension(path); - std::string error; - DictionaryValue input_value; - - // Test minimal extension - input_value.SetString(Extension::kIdKey, - "00123456789ABCDEF0123456789ABCDEF0123456"); - input_value.SetString(Extension::kVersionKey, "1.0.0.0"); - input_value.SetString(Extension::kNameKey, "my extension"); - - EXPECT_TRUE(extension.InitFromValue(input_value, true, &error)); - EXPECT_EQ("", error); - EXPECT_EQ("00123456789abcdef0123456789abcdef0123456", extension.id()); - EXPECT_EQ("1.0.0.0", extension.VersionString()); - EXPECT_EQ("my extension", extension.name()); - EXPECT_EQ("chrome-extension://00123456789abcdef0123456789abcdef0123456/", - extension.url().spec()); - EXPECT_EQ(path.value(), extension.path().value()); -} - -TEST(ExtensionTest, GetResourceURLAndPath) { -#if defined(OS_WIN) - FilePath path(FILE_PATH_LITERAL("C:\\foo")); -#elif defined(OS_POSIX) - FilePath path(FILE_PATH_LITERAL("/foo")); -#endif - Extension extension(path); - DictionaryValue input_value; - input_value.SetString(Extension::kIdKey, - "00123456789ABCDEF0123456789ABCDEF0123456"); - input_value.SetString(Extension::kVersionKey, "1.0.0.0"); - input_value.SetString(Extension::kNameKey, "my extension"); - EXPECT_TRUE(extension.InitFromValue(input_value, true, NULL)); - - EXPECT_EQ(extension.url().spec() + "bar/baz.js", - Extension::GetResourceURL(extension.url(), "bar/baz.js").spec()); - EXPECT_EQ(extension.url().spec() + "baz.js", - Extension::GetResourceURL(extension.url(), "bar/../baz.js").spec()); - EXPECT_EQ(extension.url().spec() + "baz.js", - Extension::GetResourceURL(extension.url(), "../baz.js").spec()); - - EXPECT_EQ(path.Append(FILE_PATH_LITERAL("bar")) - .Append(FILE_PATH_LITERAL("baz.js")).value(), - Extension::GetResourcePath(extension.path(), "bar/baz.js").value()); - EXPECT_EQ(path.Append(FILE_PATH_LITERAL("baz.js")).value(), - Extension::GetResourcePath(extension.path(), "bar/../baz.js") - .value()); - EXPECT_EQ(FilePath().value(), - Extension::GetResourcePath(extension.path(), "../baz.js").value()); -} diff --git a/chrome/browser/extensions/extension_view_unittest.cc b/chrome/browser/extensions/extension_view_unittest.cc index 0efffa5..b344330 100644 --- a/chrome/browser/extensions/extension_view_unittest.cc +++ b/chrome/browser/extensions/extension_view_unittest.cc @@ -6,7 +6,6 @@ #include "chrome/browser/browser.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/extensions/extension_shelf.h" -#include "chrome/browser/extensions/extension_error_reporter.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extensions_service.h" @@ -14,6 +13,7 @@ #include "chrome/browser/tab_contents/site_instance.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/extensions/extension_error_reporter.h" #include "chrome/test/in_process_browser_test.h" #include "chrome/test/ui_test_utils.h" diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index e62f537..12001e7 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -18,12 +18,12 @@ #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_thread.h" -#include "chrome/browser/extensions/extension.h" #include "chrome/browser/extensions/extension_browser_event_router.h" -#include "chrome/browser/extensions/extension_error_reporter.h" #include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/profile.h" #include "chrome/browser/utility_process_host.h" +#include "chrome/common/extensions/extension.h" +#include "chrome/common/extensions/extension_error_reporter.h" #include "chrome/common/extensions/extension_unpacker.h" #include "chrome/common/json_value_serializer.h" #include "chrome/common/notification_service.h" @@ -559,136 +559,6 @@ void ExtensionsServiceBackend::ReportExtensionsLoaded( frontend_, &ExtensionsService::OnExtensionsLoaded, extensions)); } -// The extension file format is a header, followed by the manifest, followed -// by the zip file. The header is a magic number, a version, the size of the -// header, and the size of the manifest. These ints are 4 byte little endian. -DictionaryValue* ExtensionsServiceBackend::ReadManifest( - const FilePath& extension_path) { - ScopedStdioHandle file(file_util::OpenFile(extension_path, "rb")); - if (!file.get()) { - ReportExtensionInstallError(extension_path, "no such extension file"); - return NULL; - } - - // Read and verify the header. - ExtensionHeader header; - size_t len; - - // TODO(erikkay): Yuck. I'm not a big fan of this kind of code, but it - // appears that we don't have any endian/alignment aware serialization - // code in the code base. So for now, this assumes that we're running - // on a little endian machine with 4 byte alignment. - len = fread(&header, 1, sizeof(ExtensionHeader), file.get()); - if (len < sizeof(ExtensionHeader)) { - ReportExtensionInstallError(extension_path, "invalid extension header"); - return NULL; - } - if (strncmp(kExtensionFileMagic, header.magic, sizeof(header.magic))) { - ReportExtensionInstallError(extension_path, "bad magic number"); - return NULL; - } - if (header.version != kExpectedVersion) { - ReportExtensionInstallError(extension_path, "bad version number"); - return NULL; - } - if (header.header_size > sizeof(ExtensionHeader)) - fseek(file.get(), header.header_size - sizeof(ExtensionHeader), SEEK_CUR); - - char buf[1 << 16]; - std::string manifest_str; - size_t read_size = std::min(sizeof(buf), header.manifest_size); - size_t remainder = header.manifest_size; - while ((len = fread(buf, 1, read_size, file.get())) > 0) { - manifest_str.append(buf, len); - if (len <= remainder) - break; - remainder -= len; - read_size = std::min(sizeof(buf), remainder); - } - - // Verify the JSON - JSONStringValueSerializer json(manifest_str); - std::string error; - scoped_ptr<Value> val(json.Deserialize(&error)); - if (!val.get()) { - ReportExtensionInstallError(extension_path, error); - return NULL; - } - if (!val->IsType(Value::TYPE_DICTIONARY)) { - ReportExtensionInstallError(extension_path, - "manifest isn't a JSON dictionary"); - return NULL; - } - DictionaryValue* manifest = static_cast<DictionaryValue*>(val.get()); - - // Check the version before proceeding. Although we verify the version - // again later, checking it here allows us to skip some potentially expensive - // work. - std::string id; - if (!manifest->GetString(Extension::kIdKey, &id)) { - ReportExtensionInstallError(extension_path, "missing id key"); - return NULL; - } - FilePath dest_dir = install_directory_.AppendASCII(id.c_str()); - if (file_util::PathExists(dest_dir)) { - std::string version; - if (!manifest->GetString(Extension::kVersionKey, &version)) { - ReportExtensionInstallError(extension_path, "missing version key"); - return NULL; - } - std::string current_version; - if (ReadCurrentVersion(dest_dir, ¤t_version)) { - if (!CheckCurrentVersion(version, current_version, dest_dir)) - return NULL; - } - } - - std::string zip_hash; - if (!manifest->GetString(Extension::kZipHashKey, &zip_hash)) { - ReportExtensionInstallError(extension_path, "missing zip_hash key"); - return NULL; - } - if (zip_hash.size() != kZipHashHexBytes) { - ReportExtensionInstallError(extension_path, "invalid zip_hash key"); - return NULL; - } - - // Read the rest of the zip file and compute a hash to compare against - // what the manifest claims. Compute the hash incrementally since the - // zip file could be large. - const unsigned char* ubuf = reinterpret_cast<const unsigned char*>(buf); - SHA256Context ctx; - SHA256_Begin(&ctx); - while ((len = fread(buf, 1, sizeof(buf), file.get())) > 0) - SHA256_Update(&ctx, ubuf, len); - uint8 hash[32]; - SHA256_End(&ctx, hash, NULL, sizeof(hash)); - - std::vector<uint8> zip_hash_bytes; - if (!HexStringToBytes(zip_hash, &zip_hash_bytes)) { - ReportExtensionInstallError(extension_path, "invalid zip_hash key"); - return NULL; - } - if (zip_hash_bytes.size() != kZipHashBytes) { - ReportExtensionInstallError(extension_path, "invalid zip_hash key"); - return NULL; - } - for (size_t i = 0; i < kZipHashBytes; ++i) { - if (zip_hash_bytes[i] != hash[i]) { - ReportExtensionInstallError(extension_path, - "zip_hash key didn't match zip hash"); - return NULL; - } - } - - // TODO(erikkay): The manifest will also contain a signature of the hash - // (or perhaps the whole manifest) for authentication purposes. - - // The caller owns val (now cast to manifest). - val.release(); - return manifest; -} - bool ExtensionsServiceBackend::ReadCurrentVersion(const FilePath& dir, std::string* version_string) { FilePath current_version = diff --git a/chrome/browser/extensions/extensions_service.h b/chrome/browser/extensions/extensions_service.h index 56bebee..105533a 100644 --- a/chrome/browser/extensions/extensions_service.h +++ b/chrome/browser/extensions/extensions_service.h @@ -196,10 +196,6 @@ class ExtensionsServiceBackend // Notify the frontend that the extension had already been installed. void ReportExtensionVersionReinstalled(const std::string& id); - // Read the manifest from the front of the extension file. - // Caller takes ownership of return value. - DictionaryValue* ReadManifest(const FilePath& extension_path); - // Reads the Current Version file from |dir| into |version_string|. bool ReadCurrentVersion(const FilePath& dir, std::string* version_string); diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc index 7b0a88f..57cd42c 100644 --- a/chrome/browser/extensions/extensions_service_unittest.cc +++ b/chrome/browser/extensions/extensions_service_unittest.cc @@ -12,11 +12,11 @@ #include "base/path_service.h" #include "base/string_util.h" #include "base/time.h" -#include "chrome/browser/extensions/extension.h" -#include "chrome/browser/extensions/extension_error_reporter.h" #include "chrome/browser/extensions/extensions_service.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/url_pattern.h" #include "chrome/common/chrome_paths.h" +#include "chrome/common/extensions/extension_error_reporter.h" #include "chrome/common/json_value_serializer.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/notification_service.h" diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc index 8dafb8e..c23dcb6 100644 --- a/chrome/browser/extensions/extensions_ui.cc +++ b/chrome/browser/extensions/extensions_ui.cc @@ -10,13 +10,13 @@ #include "base/thread.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/debugger/devtools_manager.h" -#include "chrome/browser/extensions/extension.h" #include "chrome/browser/extensions/extension_message_service.h" #include "chrome/browser/extensions/extensions_service.h" -#include "chrome/browser/extensions/extension_error_reporter.h" #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_widget_host.h" #include "chrome/browser/renderer_host/render_view_host.h" +#include "chrome/common/extensions/extension.h" +#include "chrome/common/extensions/extension_error_reporter.h" #include "chrome/common/extensions/user_script.h" #include "chrome/common/extensions/url_pattern.h" #include "chrome/common/jstemplate_builder.h" diff --git a/chrome/browser/extensions/test_extension_loader.h b/chrome/browser/extensions/test_extension_loader.h index 4fb74d9..60ca84f 100644 --- a/chrome/browser/extensions/test_extension_loader.h +++ b/chrome/browser/extensions/test_extension_loader.h @@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_LOADER_H_ #define CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_LOADER_H_ -#include "chrome/browser/extensions/extension.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" diff --git a/chrome/browser/extensions/user_script_master.cc b/chrome/browser/extensions/user_script_master.cc index 5051cd6..5d28cb4 100644 --- a/chrome/browser/extensions/user_script_master.cc +++ b/chrome/browser/extensions/user_script_master.cc @@ -14,8 +14,8 @@ #include "base/string_util.h" #include "base/thread.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/extensions/extension.h" #include "chrome/browser/extensions/extensions_service.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/notification_service.h" #include "chrome/common/url_constants.h" #include "net/base/net_util.h" diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index fced49f..42554ff 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -8,12 +8,12 @@ #include "base/string_util.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_thread.h" -#include "chrome/browser/extensions/extension.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/extensions/user_script_master.h" #include "chrome/browser/profile.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc index e2c6215..d5247e2 100644 --- a/chrome/browser/plugin_service.cc +++ b/chrome/browser/plugin_service.cc @@ -12,12 +12,12 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_plugin_host.h" #include "chrome/browser/chrome_thread.h" -#include "chrome/browser/extensions/extension.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/plugin_process_host.h" #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/common/chrome_plugin_lib.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/logging_chrome.h" #include "chrome/common/notification_type.h" #include "chrome/common/notification_service.h" diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc index 4afea85..5fba79e 100644 --- a/chrome/browser/profile.cc +++ b/chrome/browser/profile.cc @@ -14,7 +14,6 @@ #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/download/download_manager.h" -#include "chrome/browser/extensions/extension_error_reporter.h" #include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/extensions/user_script_master.h" @@ -35,6 +34,7 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/extensions/extension_error_reporter.h" #include "chrome/common/net/cookie_monster_sqlite.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index fdf641f..7f9a2fd 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -18,7 +18,6 @@ #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_theme_provider.h" -#include "chrome/browser/extensions/extension.h" #include "chrome/browser/extensions/extension_view.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/metrics/user_metrics.h" @@ -29,6 +28,7 @@ #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/view_ids.h" #include "chrome/browser/views/event_utils.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/notification_service.h" #include "chrome/common/page_transition_types.h" #include "chrome/common/pref_names.h" diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc index d9cc354..8287ac6 100644 --- a/chrome/browser/views/location_bar_view.cc +++ b/chrome/browser/views/location_bar_view.cc @@ -17,7 +17,6 @@ #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/command_updater.h" -#include "chrome/browser/extensions/extension.h" #include "chrome/browser/extensions/extension_browser_event_router.h" #include "chrome/browser/extensions/extension_tabs_module.h" #include "chrome/browser/extensions/extensions_service.h" @@ -28,6 +27,7 @@ #include "chrome/browser/view_ids.h" #include "chrome/browser/views/info_bubble.h" #include "chrome/browser/views/first_run_bubble.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/page_action.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" |