diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-26 17:23:46 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-26 17:23:46 +0000 |
commit | 3bb8499b2cd51027ee896ccda306e2c55fc2c5f0 (patch) | |
tree | 9397873271e126f2f4b8eb4d00ae92a5a2fb387e | |
parent | f59cdf7bf45ed21cf70c8d2bc43ef4cc70cc94c0 (diff) | |
download | chromium_src-3bb8499b2cd51027ee896ccda306e2c55fc2c5f0.zip chromium_src-3bb8499b2cd51027ee896ccda306e2c55fc2c5f0.tar.gz chromium_src-3bb8499b2cd51027ee896ccda306e2c55fc2c5f0.tar.bz2 |
FBTF: Forward declare and move constructors in chrome/common/extensions/.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/3207002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57543 0039d316-1c4b-4281-b951-d872f2087c98
26 files changed, 162 insertions, 61 deletions
diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index da8a842..5bb8e0f 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -54,6 +54,7 @@ class ExtensionPortContainer; class ExtensionTestResultNotificationObserver; class ExternalTabContainer; class InitialLoadObserver; +class ListValue; class LoginHandler; class MetricEventDurationObserver; class NavigationController; diff --git a/chrome/browser/cocoa/extension_installed_bubble_controller_unittest.mm b/chrome/browser/cocoa/extension_installed_bubble_controller_unittest.mm index a8a78be..adcc426 100644 --- a/chrome/browser/cocoa/extension_installed_bubble_controller_unittest.mm +++ b/chrome/browser/cocoa/extension_installed_bubble_controller_unittest.mm @@ -9,6 +9,7 @@ #include "base/file_util.h" #include "base/path_service.h" #include "base/scoped_ptr.h" +#include "base/values.h" #import "chrome/browser/browser_window.h" #import "chrome/browser/cocoa/browser_test_helper.h" #import "chrome/browser/cocoa/cocoa_test_helper.h" diff --git a/chrome/browser/extensions/extension_browser_actions_api.cc b/chrome/browser/extensions/extension_browser_actions_api.cc index fd251f7..1ce4dfe 100644 --- a/chrome/browser/extensions/extension_browser_actions_api.cc +++ b/chrome/browser/extensions/extension_browser_actions_api.cc @@ -4,6 +4,7 @@ #include "chrome/browser/extensions/extension_browser_actions_api.h" +#include "base/values.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" #include "chrome/common/extensions/extension.h" diff --git a/chrome/browser/extensions/extension_cookies_api.cc b/chrome/browser/extensions/extension_cookies_api.cc index 4c2f725..afb9c12 100644 --- a/chrome/browser/extensions/extension_cookies_api.cc +++ b/chrome/browser/extensions/extension_cookies_api.cc @@ -8,6 +8,7 @@ #include "base/json/json_writer.h" #include "base/task.h" +#include "base/values.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/extensions/extension_cookies_api_constants.h" diff --git a/chrome/browser/extensions/extension_infobar_module.cc b/chrome/browser/extensions/extension_infobar_module.cc index 2d3e67f..590bfc1 100644 --- a/chrome/browser/extensions/extension_infobar_module.cc +++ b/chrome/browser/extensions/extension_infobar_module.cc @@ -6,6 +6,7 @@ #include "base/string_util.h" #include "base/string_number_conversions.h" +#include "base/values.h" #include "chrome/browser/browser.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_infobar_module_constants.h" diff --git a/chrome/browser/extensions/extension_metrics_module.cc b/chrome/browser/extensions/extension_metrics_module.cc index 4368c86..0f0ab14 100644 --- a/chrome/browser/extensions/extension_metrics_module.cc +++ b/chrome/browser/extensions/extension_metrics_module.cc @@ -4,6 +4,7 @@ #include "chrome/browser/extensions/extension_metrics_module.h" +#include "base/values.h" #include "base/histogram.h" #include "chrome/common/extensions/extension.h" #include "chrome/browser/metrics/user_metrics.h" diff --git a/chrome/browser/extensions/extension_popup_api.cc b/chrome/browser/extensions/extension_popup_api.cc index 615279d..e6c559b 100644 --- a/chrome/browser/extensions/extension_popup_api.cc +++ b/chrome/browser/extensions/extension_popup_api.cc @@ -6,6 +6,7 @@ #include "base/json/json_writer.h" #include "base/string_util.h" +#include "base/values.h" #include "chrome/browser/extensions/extension_dom_ui.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_message_service.h" diff --git a/chrome/browser/extensions/extension_rlz_module.cc b/chrome/browser/extensions/extension_rlz_module.cc index 2ee0ff9..25724be 100644 --- a/chrome/browser/extensions/extension_rlz_module.cc +++ b/chrome/browser/extensions/extension_rlz_module.cc @@ -5,6 +5,7 @@ #include "chrome/browser/extensions/extension_rlz_module.h" #include "base/scoped_ptr.h" +#include "base/values.h" #include "chrome/common/extensions/extension.h" #include "rlz/win/lib/lib_values.h" diff --git a/chrome/browser/extensions/external_pref_extension_provider.h b/chrome/browser/extensions/external_pref_extension_provider.h index 4a1fcca..aef6b17 100644 --- a/chrome/browser/extensions/external_pref_extension_provider.h +++ b/chrome/browser/extensions/external_pref_extension_provider.h @@ -12,6 +12,7 @@ #include "chrome/browser/extensions/external_extension_provider.h" class DictionaryValue; +class ValueSerializer; class Version; // A specialization of the ExternalExtensionProvider that uses a json file to diff --git a/chrome/browser/sync/util/extensions_activity_monitor_unittest.cc b/chrome/browser/sync/util/extensions_activity_monitor_unittest.cc index f2cbf97..e532296 100644 --- a/chrome/browser/sync/util/extensions_activity_monitor_unittest.cc +++ b/chrome/browser/sync/util/extensions_activity_monitor_unittest.cc @@ -7,6 +7,7 @@ #include "base/file_path.h" #include "base/string_util.h" #include "base/waitable_event.h" +#include "base/values.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/extensions/extension_bookmarks_module.h" #include "chrome/common/extensions/extension.h" diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc index 1934700..2197fd2 100644 --- a/chrome/browser/themes/browser_theme_pack.cc +++ b/chrome/browser/themes/browser_theme_pack.cc @@ -9,6 +9,7 @@ #include "base/stl_util-inl.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" +#include "base/values.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/themes/browser_theme_provider.h" #include "gfx/codec/png_codec.h" diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index 8065cfd..b735004 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -20,6 +20,7 @@ #include "base/third_party/nss/sha256.h" #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" +#include "base/values.h" #include "base/version.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" @@ -1772,3 +1773,18 @@ bool Extension::IsAPIPermission(const std::string& str) { } return false; } + +ExtensionInfo::ExtensionInfo(const DictionaryValue* manifest, + const std::string& id, + const FilePath& path, + Extension::Location location) + : extension_id(id), + extension_path(path), + extension_location(location) { + if (manifest) + extension_manifest.reset( + static_cast<DictionaryValue*>(manifest->DeepCopy())); +} + +ExtensionInfo::~ExtensionInfo() { +} diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h index 5d993cfc..cad9059 100644 --- a/chrome/common/extensions/extension.h +++ b/chrome/common/extensions/extension.h @@ -14,13 +14,13 @@ #include "base/file_path.h" #include "base/gtest_prod_util.h" #include "base/scoped_ptr.h" -#include "base/values.h" #include "chrome/common/extensions/extension_extent.h" #include "chrome/common/extensions/user_script.h" #include "chrome/common/extensions/url_pattern.h" #include "gfx/size.h" #include "googleurl/src/gurl.h" +class DictionaryValue; class ExtensionAction; class ExtensionResource; class SkBitmap; @@ -599,14 +599,8 @@ struct ExtensionInfo { ExtensionInfo(const DictionaryValue* manifest, const std::string& id, const FilePath& path, - Extension::Location location) - : extension_id(id), - extension_path(path), - extension_location(location) { - if (manifest) - extension_manifest.reset( - static_cast<DictionaryValue*>(manifest->DeepCopy())); - } + Extension::Location location); + ~ExtensionInfo(); scoped_ptr<DictionaryValue> extension_manifest; std::string extension_id; diff --git a/chrome/common/extensions/extension_extent.cc b/chrome/common/extensions/extension_extent.cc index fe670b6..5b8260a 100644 --- a/chrome/common/extensions/extension_extent.cc +++ b/chrome/common/extensions/extension_extent.cc @@ -4,6 +4,36 @@ #include "chrome/common/extensions/extension_extent.h" +#include "chrome/common/extensions/url_pattern.h" +#include "googleurl/src/gurl.h" + +ExtensionExtent::ExtensionExtent() { +} + +ExtensionExtent::ExtensionExtent(const ExtensionExtent& rhs) + : patterns_(rhs.patterns_) { +} + +ExtensionExtent::~ExtensionExtent() { +} + +ExtensionExtent& ExtensionExtent::operator=(const ExtensionExtent& rhs) { + patterns_ = rhs.patterns_; + return *this; +} + +bool ExtensionExtent::is_empty() const { + return patterns_.empty(); +} + +void ExtensionExtent::AddPattern(const URLPattern& pattern) { + patterns_.push_back(pattern); +} + +void ExtensionExtent::ClearPaths() { + patterns_.clear(); +} + bool ExtensionExtent::ContainsURL(const GURL& url) const { for (PatternList::const_iterator pattern = patterns_.begin(); pattern != patterns_.end(); ++pattern) { diff --git a/chrome/common/extensions/extension_extent.h b/chrome/common/extensions/extension_extent.h index bb66e1b..cb4641f 100644 --- a/chrome/common/extensions/extension_extent.h +++ b/chrome/common/extensions/extension_extent.h @@ -8,19 +8,24 @@ #include <vector> -#include "chrome/common/extensions/url_pattern.h" -#include "googleurl/src/gurl.h" +class GURL; +class URLPattern; // Represents the set of URLs an extension uses for web content. class ExtensionExtent { public: typedef std::vector<URLPattern> PatternList; - bool is_empty() const { return patterns_.empty(); } + ExtensionExtent(); + ExtensionExtent(const ExtensionExtent& rhs); + ~ExtensionExtent(); + ExtensionExtent& operator=(const ExtensionExtent& rhs); + + bool is_empty() const; const PatternList& patterns() const { return patterns_; } - void AddPattern(const URLPattern& pattern) { patterns_.push_back(pattern); } - void ClearPaths() { patterns_.clear(); } + void AddPattern(const URLPattern& pattern); + void ClearPaths(); // Test if the extent contains a URL. bool ContainsURL(const GURL& url) const; diff --git a/chrome/common/extensions/extension_file_util.h b/chrome/common/extensions/extension_file_util.h index a938a24..548eb3c 100644 --- a/chrome/common/extensions/extension_file_util.h +++ b/chrome/common/extensions/extension_file_util.h @@ -7,11 +7,12 @@ #pragma once #include <string> +#include <map> -#include "chrome/common/extensions/extension.h" - +class Extension; class ExtensionMessageBundle; class FilePath; +class GURL; // Utilties for manipulating the on-disk storage of extensions. namespace extension_file_util { diff --git a/chrome/common/extensions/extension_message_bundle.cc b/chrome/common/extensions/extension_message_bundle.cc index 8dd5275..4e6222f 100644 --- a/chrome/common/extensions/extension_message_bundle.cc +++ b/chrome/common/extensions/extension_message_bundle.cc @@ -14,6 +14,7 @@ #include "base/scoped_ptr.h" #include "base/singleton.h" #include "base/stl_util-inl.h" +#include "base/string_util.h" #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/common/extensions/extension_constants.h" @@ -211,6 +212,9 @@ bool ExtensionMessageBundle::ReplaceMessages(std::string* text, return ReplaceMessagesWithExternalDictionary(dictionary_, text, error); } +ExtensionMessageBundle::~ExtensionMessageBundle() { +} + // static bool ExtensionMessageBundle::ReplaceMessagesWithExternalDictionary( const SubstitutionMap& dictionary, std::string* text, std::string* error) { @@ -270,6 +274,21 @@ bool ExtensionMessageBundle::ReplaceVariables( return true; } +// static +bool ExtensionMessageBundle::IsValidName(const std::string& name) { + if (name.empty()) + return false; + + std::string::const_iterator it = name.begin(); + for (; it != name.end(); ++it) { + // Allow only ascii 0-9, a-z, A-Z, and _ in the name. + if (!IsAsciiAlpha(*it) && !IsAsciiDigit(*it) && *it != '_' && *it != '@') + return false; + } + + return true; +} + // Dictionary interface. std::string ExtensionMessageBundle::GetL10nMessage( diff --git a/chrome/common/extensions/extension_message_bundle.h b/chrome/common/extensions/extension_message_bundle.h index 3a49021..46d59bd 100644 --- a/chrome/common/extensions/extension_message_bundle.h +++ b/chrome/common/extensions/extension_message_bundle.h @@ -11,8 +11,8 @@ #include <vector> #include "base/linked_ptr.h" -#include "base/string_util.h" -#include "base/values.h" + +class DictionaryValue; // Contains localized extension messages for one locale. Any messages that the // locale does not provide are pulled from the default locale. @@ -94,24 +94,13 @@ class ExtensionMessageBundle { // Allow only ascii 0-9, a-z, A-Z, and _ in the variable name. // Returns false if the input is empty or if it has illegal characters. - template<typename str> - static bool IsValidName(const str& name) { - if (name.empty()) - return false; - - typename str::const_iterator it = name.begin(); - for (; it != name.end(); ++it) { - // Allow only ascii 0-9, a-z, A-Z, and _ in the name. - if (!IsAsciiAlpha(*it) && !IsAsciiDigit(*it) && *it != '_' && *it != '@') - return false; - } - - return true; - } + static bool IsValidName(const std::string& name); // Getter for dictionary_. const SubstitutionMap* dictionary() const { return &dictionary_; } + ~ExtensionMessageBundle(); + private: // Testing friend. friend class ExtensionMessageBundleTest; diff --git a/chrome/common/extensions/extension_unpacker.cc b/chrome/common/extensions/extension_unpacker.cc index 014a0e3..23950c5 100644 --- a/chrome/common/extensions/extension_unpacker.cc +++ b/chrome/common/extensions/extension_unpacker.cc @@ -44,9 +44,7 @@ const char* kPathNamesMustBeAbsoluteOrLocalError = // A limit to stop us passing dangerously large canvases to the browser. const int kMaxImageCanvas = 4096 * 4096; -} // namespace - -static SkBitmap DecodeImage(const FilePath& path) { +SkBitmap DecodeImage(const FilePath& path) { // Read the file from disk. std::string file_contents; if (!file_util::PathExists(path) || @@ -65,7 +63,7 @@ static SkBitmap DecodeImage(const FilePath& path) { return bitmap; } -static bool PathContainsParentDirectory(const FilePath& path) { +bool PathContainsParentDirectory(const FilePath& path) { const FilePath::StringType kSeparators(FilePath::kSeparators); const FilePath::StringType kParentDirectory(FilePath::kParentDirectory); const size_t npos = FilePath::StringType::npos; @@ -85,6 +83,15 @@ static bool PathContainsParentDirectory(const FilePath& path) { return false; } +} // namespace + +ExtensionUnpacker::ExtensionUnpacker(const FilePath& extension_path) + : extension_path_(extension_path) { +} + +ExtensionUnpacker::~ExtensionUnpacker() { +} + DictionaryValue* ExtensionUnpacker::ReadManifest() { FilePath manifest_path = temp_install_dir_.Append(Extension::kManifestFilename); diff --git a/chrome/common/extensions/extension_unpacker.h b/chrome/common/extensions/extension_unpacker.h index ebe2915..6883597 100644 --- a/chrome/common/extensions/extension_unpacker.h +++ b/chrome/common/extensions/extension_unpacker.h @@ -24,8 +24,8 @@ class ExtensionUnpacker { public: typedef std::vector< Tuple2<SkBitmap, FilePath> > DecodedImages; - explicit ExtensionUnpacker(const FilePath& extension_path) - : extension_path_(extension_path) {} + explicit ExtensionUnpacker(const FilePath& extension_path); + ~ExtensionUnpacker(); // Install the extension file at |extension_path|. Returns true on success. // Otherwise, error_message will contain a string explaining what went wrong. diff --git a/chrome/common/extensions/update_manifest.h b/chrome/common/extensions/update_manifest.h index 9e8eb52..7c22d6f 100644 --- a/chrome/common/extensions/update_manifest.h +++ b/chrome/common/extensions/update_manifest.h @@ -9,7 +9,6 @@ #include <string> #include <vector> -#include "base/logging.h" #include "googleurl/src/gurl.h" class UpdateManifest { diff --git a/chrome/common/extensions/url_pattern.cc b/chrome/common/extensions/url_pattern.cc index 70240b4..544376d 100644 --- a/chrome/common/extensions/url_pattern.cc +++ b/chrome/common/extensions/url_pattern.cc @@ -7,6 +7,7 @@ #include "base/string_piece.h" #include "base/string_util.h" #include "chrome/common/url_constants.h" +#include "googleurl/src/gurl.h" // TODO(aa): Consider adding chrome-extension? What about more obscure ones // like data: and javascript: ? @@ -48,6 +49,9 @@ URLPattern::URLPattern(int valid_schemes, const std::string& pattern) NOTREACHED() << "URLPattern is invalid: " << pattern; } +URLPattern::~URLPattern() { +} + bool URLPattern::Parse(const std::string& pattern) { // Special case pattern to match every valid URL. if (pattern == kAllUrlsPattern) { diff --git a/chrome/common/extensions/url_pattern.h b/chrome/common/extensions/url_pattern.h index 0a0c074..69fc393 100644 --- a/chrome/common/extensions/url_pattern.h +++ b/chrome/common/extensions/url_pattern.h @@ -9,7 +9,7 @@ #include <string> #include <vector> -#include "googleurl/src/gurl.h" +class GURL; // A pattern that can be used to match URLs. A URLPattern is a very restricted // subset of URL syntax: @@ -97,6 +97,8 @@ class URLPattern { // Parse() instead, which returns success or failure. URLPattern(int valid_schemes, const std::string& pattern); + ~URLPattern(); + // Gets the bitmask of valid schemes. int valid_schemes() const { return valid_schemes_; } void set_valid_schemes(int valid_schemes) { valid_schemes_ = valid_schemes; } diff --git a/chrome/common/extensions/url_pattern_unittest.cc b/chrome/common/extensions/url_pattern_unittest.cc index 03558b9..47cbdc8 100644 --- a/chrome/common/extensions/url_pattern_unittest.cc +++ b/chrome/common/extensions/url_pattern_unittest.cc @@ -5,6 +5,7 @@ #include "base/scoped_ptr.h" #include "chrome/common/extensions/url_pattern.h" #include "testing/gtest/include/gtest/gtest.h" +#include "googleurl/src/gurl.h" // See url_pattern.h for examples of valid and invalid patterns. diff --git a/chrome/common/extensions/user_script.cc b/chrome/common/extensions/user_script.cc index c568e8e..2a40bec 100644 --- a/chrome/common/extensions/user_script.cc +++ b/chrome/common/extensions/user_script.cc @@ -8,8 +8,9 @@ #include "base/string_util.h" namespace { -static bool UrlMatchesPatterns(const UserScript::PatternList* patterns, - const GURL& url) { + +bool UrlMatchesPatterns(const UserScript::PatternList* patterns, + const GURL& url) { for (UserScript::PatternList::const_iterator pattern = patterns->begin(); pattern != patterns->end(); ++pattern) { if (pattern->MatchesUrl(url)) @@ -19,8 +20,8 @@ static bool UrlMatchesPatterns(const UserScript::PatternList* patterns, return false; } -static bool UrlMatchesGlobs(const std::vector<std::string>* globs, - const GURL& url) { +bool UrlMatchesGlobs(const std::vector<std::string>* globs, + const GURL& url) { for (std::vector<std::string>::const_iterator glob = globs->begin(); glob != globs->end(); ++glob) { if (MatchPatternASCII(url.spec(), *glob)) @@ -29,7 +30,8 @@ static bool UrlMatchesGlobs(const std::vector<std::string>* globs, return false; } -} + +} // namespace // static const char UserScript::kFileExtension[] = ".user.js"; @@ -48,6 +50,34 @@ bool UserScript::HasUserScriptFileExtension(const FilePath& path) { return EndsWith(path.BaseName().value(), extension.value(), false); } + +UserScript::File::File(const FilePath& extension_root, + const FilePath& relative_path, + const GURL& url) + : extension_root_(extension_root), + relative_path_(relative_path), + url_(url) { +} + +UserScript::File::File() {} + +UserScript::File::~File() {} + +UserScript::UserScript() + : run_location_(DOCUMENT_IDLE), emulate_greasemonkey_(false), + match_all_frames_(false), incognito_enabled_(false), + allow_file_access_(false) { +} + +UserScript::~UserScript() { +} + +void UserScript::add_url_pattern(const URLPattern& pattern) { + url_patterns_.push_back(pattern); +} + +void UserScript::clear_url_patterns() { url_patterns_.clear(); } + bool UserScript::MatchesUrl(const GURL& url) const { if (url_patterns_.size() > 0) { if (!UrlMatchesPatterns(&url_patterns_, url)) diff --git a/chrome/common/extensions/user_script.h b/chrome/common/extensions/user_script.h index 87ab5d2..203fb62 100644 --- a/chrome/common/extensions/user_script.h +++ b/chrome/common/extensions/user_script.h @@ -11,10 +11,11 @@ #include "base/file_path.h" #include "base/string_piece.h" -#include "chrome/common/extensions/url_pattern.h" #include "googleurl/src/gurl.h" +#include "chrome/common/extensions/url_pattern.h" class Pickle; +class URLPattern; // Represents a user script, either a standalone one, or one that is part of an // extension. @@ -50,12 +51,9 @@ class UserScript { class File { public: File(const FilePath& extension_root, const FilePath& relative_path, - const GURL& url): - extension_root_(extension_root), - relative_path_(relative_path), - url_(url) { - } - File() {} + const GURL& url); + File(); + ~File(); const FilePath& extension_root() const { return extension_root_; } const FilePath& relative_path() const { return relative_path_; } @@ -104,11 +102,8 @@ class UserScript { // Constructor. Default the run location to document end, which is like // Greasemonkey and probably more useful for typical scripts. - UserScript() - : run_location_(DOCUMENT_IDLE), emulate_greasemonkey_(false), - match_all_frames_(false), incognito_enabled_(false), - allow_file_access_(false) { - } + UserScript(); + ~UserScript(); const std::string& name_space() const { return name_space_; } void set_name_space(const std::string& name_space) { @@ -156,10 +151,8 @@ class UserScript { // The URLPatterns, if any, that determine which pages this script runs // against. const PatternList& url_patterns() const { return url_patterns_; } - void add_url_pattern(const URLPattern& pattern) { - url_patterns_.push_back(pattern); - } - void clear_url_patterns() { url_patterns_.clear(); } + void add_url_pattern(const URLPattern& pattern); + void clear_url_patterns(); // List of js scripts for this user script FileList& js_scripts() { return js_scripts_; } |