diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-07 19:21:48 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-07 19:21:48 +0000 |
commit | a732916421eb01c3a06187bf3e077e8ce0dd5912 (patch) | |
tree | 4981b7c3ceb04be445f093c1a7689107725f736e /chrome/common/extensions | |
parent | 2dec8ec385e65c80571c5723dc572264a934b7c9 (diff) | |
download | chromium_src-a732916421eb01c3a06187bf3e077e8ce0dd5912.zip chromium_src-a732916421eb01c3a06187bf3e077e8ce0dd5912.tar.gz chromium_src-a732916421eb01c3a06187bf3e077e8ce0dd5912.tar.bz2 |
Use base namespace for FilePath in chrome/common and content/common.
Review URL: https://codereview.chromium.org/12210058
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181350 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions')
30 files changed, 379 insertions, 353 deletions
diff --git a/chrome/common/extensions/api/extension_api_unittest.cc b/chrome/common/extensions/api/extension_api_unittest.cc index 2c8ab5d..35b1b64 100644 --- a/chrome/common/extensions/api/extension_api_unittest.cc +++ b/chrome/common/extensions/api/extension_api_unittest.cc @@ -145,7 +145,7 @@ TEST(ExtensionAPI, IsPrivilegedFeatures) { }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) { - FilePath manifest_path; + base::FilePath manifest_path; PathService::Get(chrome::DIR_TEST_DATA, &manifest_path); manifest_path = manifest_path.AppendASCII("extensions") .AppendASCII("extension_api_unittest") @@ -208,7 +208,7 @@ scoped_refptr<Extension> CreateExtensionWithPermissions( std::string error; scoped_refptr<Extension> extension(Extension::Create( - FilePath(), Manifest::LOAD, manifest, Extension::NO_FLAGS, &error)); + base::FilePath(), Manifest::LOAD, manifest, Extension::NO_FLAGS, &error)); CHECK(extension.get()); CHECK(error.empty()); @@ -429,7 +429,7 @@ static void GetDictionaryFromList(const DictionaryValue* schema, } TEST(ExtensionAPI, TypesHaveNamespace) { - FilePath manifest_path; + base::FilePath manifest_path; PathService::Get(chrome::DIR_TEST_DATA, &manifest_path); manifest_path = manifest_path.AppendASCII("extensions") .AppendASCII("extension_api_unittest") diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index be43f6c..8a067d8 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -222,11 +222,11 @@ scoped_ptr<ActionInfo> LoadExtensionActionInfoHelper( } // namespace -const FilePath::CharType Extension::kManifestFilename[] = +const base::FilePath::CharType Extension::kManifestFilename[] = FILE_PATH_LITERAL("manifest.json"); -const FilePath::CharType Extension::kLocaleFolder[] = +const base::FilePath::CharType Extension::kLocaleFolder[] = FILE_PATH_LITERAL("_locales"); -const FilePath::CharType Extension::kMessagesFilename[] = +const base::FilePath::CharType Extension::kMessagesFilename[] = FILE_PATH_LITERAL("messages.json"); #if defined(OS_WIN) @@ -261,7 +261,7 @@ Extension::Requirements::~Requirements() {} // // static -scoped_refptr<Extension> Extension::Create(const FilePath& path, +scoped_refptr<Extension> Extension::Create(const base::FilePath& path, Manifest::Location location, const DictionaryValue& value, int flags, @@ -274,7 +274,7 @@ scoped_refptr<Extension> Extension::Create(const FilePath& path, utf8_error); } -scoped_refptr<Extension> Extension::Create(const FilePath& path, +scoped_refptr<Extension> Extension::Create(const base::FilePath& path, Manifest::Location location, const DictionaryValue& value, int flags, @@ -329,17 +329,17 @@ bool Extension::IdIsValid(const std::string& id) { } // static -std::string Extension::GenerateIdForPath(const FilePath& path) { - FilePath new_path = Extension::MaybeNormalizePath(path); +std::string Extension::GenerateIdForPath(const base::FilePath& path) { + base::FilePath new_path = Extension::MaybeNormalizePath(path); std::string path_bytes = std::string(reinterpret_cast<const char*>(new_path.value().data()), - new_path.value().size() * sizeof(FilePath::CharType)); + new_path.value().size() * sizeof(base::FilePath::CharType)); std::string id; return GenerateId(path_bytes, &id) ? id : ""; } // static -bool Extension::IsExtension(const FilePath& file_name) { +bool Extension::IsExtension(const base::FilePath& file_name) { return file_name.MatchesExtension(chrome::kExtensionFileExtension); } @@ -408,9 +408,9 @@ ExtensionResource Extension::GetResource( if (!new_path.empty() && new_path.at(0) == '/') new_path.erase(0, 1); #if defined(OS_POSIX) - FilePath relative_file_path(new_path); + base::FilePath relative_file_path(new_path); #elif defined(OS_WIN) - FilePath relative_file_path(UTF8ToWide(new_path)); + base::FilePath relative_file_path(UTF8ToWide(new_path)); #endif ExtensionResource r(id(), path(), relative_file_path); if ((creation_flags() & Extension::FOLLOW_SYMLINKS_ANYWHERE)) { @@ -420,7 +420,7 @@ ExtensionResource Extension::GetResource( } ExtensionResource Extension::GetResource( - const FilePath& relative_file_path) const { + const base::FilePath& relative_file_path) const { ExtensionResource r(id(), path(), relative_file_path); if ((creation_flags() & Extension::FOLLOW_SYMLINKS_ANYWHERE)) { r.set_follow_symlinks_anywhere(); @@ -528,7 +528,7 @@ void Extension::DecodeIcon(const Extension* extension, } // static -void Extension::DecodeIconFromPath(const FilePath& icon_path, +void Extension::DecodeIconFromPath(const base::FilePath& icon_path, int icon_size, scoped_ptr<SkBitmap>* result) { if (icon_path.empty()) @@ -806,15 +806,16 @@ bool Extension::ShowConfigureContextMenus() const { return location() != Manifest::COMPONENT; } -std::set<FilePath> Extension::GetBrowserImages() const { - std::set<FilePath> image_paths; +std::set<base::FilePath> Extension::GetBrowserImages() const { + std::set<base::FilePath> image_paths; // TODO(viettrungluu): These |FilePath::FromWStringHack(UTF8ToWide())| // indicate that we're doing something wrong. // Extension icons. for (ExtensionIconSet::IconMap::const_iterator iter = icons().map().begin(); iter != icons().map().end(); ++iter) { - image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(iter->second))); + image_paths.insert( + base::FilePath::FromWStringHack(UTF8ToWide(iter->second))); } // Theme images. @@ -824,7 +825,7 @@ std::set<FilePath> Extension::GetBrowserImages() const { it.Advance()) { std::string val; if (it.value().GetAsString(&val)) - image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(val))); + image_paths.insert(base::FilePath::FromWStringHack(UTF8ToWide(val))); } } @@ -833,7 +834,8 @@ std::set<FilePath> Extension::GetBrowserImages() const { page_action_info()->default_icon.map().begin(); iter != page_action_info()->default_icon.map().end(); ++iter) { - image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(iter->second))); + image_paths.insert( + base::FilePath::FromWStringHack(UTF8ToWide(iter->second))); } } @@ -843,7 +845,8 @@ std::set<FilePath> Extension::GetBrowserImages() const { browser_action->default_icon.map().begin(); iter != browser_action->default_icon.map().end(); ++iter) { - image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(iter->second))); + image_paths.insert( + base::FilePath::FromWStringHack(UTF8ToWide(iter->second))); } } @@ -872,7 +875,7 @@ void Extension::SetCachedImage(const ExtensionResource& source, const gfx::Size& original_size) const { DCHECK(source.extension_root() == path()); // The resource must come from // this extension. - const FilePath& path = source.relative_path(); + const base::FilePath& path = source.relative_path(); gfx::Size actual_size(image.width(), image.height()); std::string location; if (actual_size != original_size) @@ -1268,7 +1271,7 @@ void Extension::RuntimeData::ClearTabSpecificPermissions(int tab_id) { // static bool Extension::InitExtensionID(extensions::Manifest* manifest, - const FilePath& path, + const base::FilePath& path, const std::string& explicit_id, int creation_flags, string16* error) { @@ -1309,7 +1312,7 @@ bool Extension::InitExtensionID(extensions::Manifest* manifest, } // static -FilePath Extension::MaybeNormalizePath(const FilePath& path) { +base::FilePath Extension::MaybeNormalizePath(const base::FilePath& path) { #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 @@ -1319,7 +1322,7 @@ FilePath Extension::MaybeNormalizePath(const FilePath& path) { path_str[1] == ':') path_str[0] += ('A' - 'a'); - return FilePath(path_str); + return base::FilePath(path_str); #else return path; #endif @@ -1348,13 +1351,13 @@ bool Extension::LoadManagedModeSites( if (!content_pack_value->HasKey(keys::kContentPackSites)) return true; - FilePath::StringType site_list_str; + base::FilePath::StringType site_list_str; if (!content_pack_value->GetString(keys::kContentPackSites, &site_list_str)) { *error = ASCIIToUTF16(errors::kInvalidContentPackSites); return false; } - content_pack_site_list_ = FilePath(site_list_str); + content_pack_site_list_ = base::FilePath(site_list_str); return true; } @@ -1372,7 +1375,7 @@ bool Extension::IsTrustedId(const std::string& id) { return id == std::string("nckgahadagoaajjgafhacjanaoiihapd"); } -Extension::Extension(const FilePath& path, +Extension::Extension(const base::FilePath& path, scoped_ptr<extensions::Manifest> manifest) : manifest_version_(0), incognito_split_mode_(false), @@ -1957,7 +1960,8 @@ bool Extension::LoadPlugins(string16* error) { } #endif // defined(OS_WIN). plugins_.push_back(PluginInfo()); - plugins_.back().path = path().Append(FilePath::FromUTF8Unsafe(path_str)); + plugins_.back().path = path().Append( + base::FilePath::FromUTF8Unsafe(path_str)); plugins_.back().is_public = is_public; } return true; @@ -2557,7 +2561,7 @@ bool Extension::LoadThemeDisplayProperties(const DictionaryValue* theme_value, } SkBitmap* Extension::GetCachedImageImpl(const ExtensionResource& source, const gfx::Size& max_size) const { - const FilePath& path = source.relative_path(); + const base::FilePath& path = source.relative_path(); // Look for exact size match. ImageCache::iterator i = image_cache_.find( @@ -2973,7 +2977,7 @@ bool Extension::CheckConflictingFeatures(std::string* utf8_error) const { ExtensionInfo::ExtensionInfo(const DictionaryValue* manifest, const std::string& id, - const FilePath& path, + const base::FilePath& path, Manifest::Location location) : extension_id(id), extension_path(path), diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h index 456505e..5ae4a2d 100644 --- a/chrome/common/extensions/extension.h +++ b/chrome/common/extensions/extension.h @@ -121,7 +121,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> { // An NPAPI plugin included in the extension. struct PluginInfo { - FilePath path; // Path to the plugin. + base::FilePath path; // Path to the plugin. bool is_public; // False if only this extension can load this plugin. }; @@ -179,7 +179,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> { WAS_INSTALLED_BY_DEFAULT = 1 << 7, }; - static scoped_refptr<Extension> Create(const FilePath& path, + static scoped_refptr<Extension> Create(const base::FilePath& path, Manifest::Location location, const base::DictionaryValue& value, int flags, @@ -187,7 +187,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> { // In a few special circumstances, we want to create an Extension and give it // an explicit id. Most consumers should just use the other Create() method. - static scoped_refptr<Extension> Create(const FilePath& path, + static scoped_refptr<Extension> Create(const base::FilePath& path, Manifest::Location location, const base::DictionaryValue& value, int flags, @@ -205,13 +205,13 @@ class Extension : public base::RefCountedThreadSafe<Extension> { static const int kValidHostPermissionSchemes; // The name of the manifest inside an extension. - static const FilePath::CharType kManifestFilename[]; + static const base::FilePath::CharType kManifestFilename[]; // The name of locale folder inside an extension. - static const FilePath::CharType kLocaleFolder[]; + static const base::FilePath::CharType kLocaleFolder[]; // The name of the messages file inside an extension. - static const FilePath::CharType kMessagesFilename[]; + static const base::FilePath::CharType kMessagesFilename[]; #if defined(OS_WIN) static const char kExtensionRegistryPath[]; @@ -228,10 +228,10 @@ class Extension : public base::RefCountedThreadSafe<Extension> { // Generate an ID for an extension in the given path. // Used while developing extensions, before they have a key. - static std::string GenerateIdForPath(const FilePath& file_name); + static std::string GenerateIdForPath(const base::FilePath& file_name); // Returns true if the specified file is an extension. - static bool IsExtension(const FilePath& file_name); + static bool IsExtension(const base::FilePath& file_name); // Fills the |info| dictionary with basic information about the extension. // |enabled| is injected for easier testing. @@ -269,7 +269,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> { ExtensionResource GetResource(const std::string& relative_path) const; // As above, but with |relative_path| following the file system's encoding. - ExtensionResource GetResource(const FilePath& relative_path) const; + ExtensionResource GetResource(const base::FilePath& relative_path) const; // |input| is expected to be the text of an rsa public or private key. It // tolerates the presence or absence of bracking header/footer like this: @@ -312,7 +312,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> { // result. In the browser process, this will DCHECK if not called on the // file thread. To easily load extension images on the UI thread, see // ImageLoadingTracker. - static void DecodeIconFromPath(const FilePath& icon_path, + static void DecodeIconFromPath(const base::FilePath& icon_path, int icon_size, scoped_ptr<SkBitmap>* result); @@ -392,7 +392,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> { // Returns a list of paths (relative to the extension dir) for images that // the browser might load (like themes and page action icons). - std::set<FilePath> GetBrowserImages() const; + std::set<base::FilePath> GetBrowserImages() const; // Get an extension icon as a resource or URL. ExtensionResource GetIconResource( @@ -495,7 +495,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> { // Accessors: const Requirements& requirements() const { return requirements_; } - const FilePath& path() const { return path_; } + const base::FilePath& path() const { return path_; } const GURL& url() const { return extension_url_; } Manifest::Location location() const; const std::string& id() const; @@ -608,7 +608,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> { // We keep a cache of images loaded from extension resources based on their // path and a string representation of a size that may have been used to // scale it (or the empty string if the image is at its original size). - typedef std::pair<FilePath, std::string> ImageCacheKey; + typedef std::pair<base::FilePath, std::string> ImageCacheKey; typedef std::map<ImageCacheKey, SkBitmap> ImageCache; class RuntimeData { @@ -640,19 +640,20 @@ class Extension : public base::RefCountedThreadSafe<Extension> { // Chooses the extension ID for an extension based on a variety of criteria. // The chosen ID will be set in |manifest|. static bool InitExtensionID(extensions::Manifest* manifest, - const FilePath& path, + const base::FilePath& path, const std::string& explicit_id, int creation_flags, string16* error); // Normalize the path for use by the extension. On Windows, this will make // sure the drive letter is uppercase. - static FilePath MaybeNormalizePath(const FilePath& path); + static base::FilePath MaybeNormalizePath(const base::FilePath& path); // Returns true if this extension id is from a trusted provider. static bool IsTrustedId(const std::string& id); - Extension(const FilePath& path, scoped_ptr<extensions::Manifest> manifest); + Extension(const base::FilePath& path, + scoped_ptr<extensions::Manifest> manifest); virtual ~Extension(); // Initialize the extension from a parsed manifest. @@ -807,7 +808,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> { Requirements requirements_; // The absolute path to the directory the extension is stored in. - FilePath path_; + base::FilePath path_; // If true, a separate process will be used for the extension in incognito // mode. @@ -906,7 +907,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> { scoped_ptr<base::DictionaryValue> theme_display_properties_; // A file containing a list of sites for Managed Mode. - FilePath content_pack_site_list_; + base::FilePath content_pack_site_list_; // The manifest from which this extension was created. scoped_ptr<Manifest> manifest_; @@ -977,13 +978,13 @@ typedef std::vector<std::string> ExtensionIdList; struct ExtensionInfo { ExtensionInfo(const base::DictionaryValue* manifest, const std::string& id, - const FilePath& path, + const base::FilePath& path, Manifest::Location location); ~ExtensionInfo(); scoped_ptr<base::DictionaryValue> extension_manifest; std::string extension_id; - FilePath extension_path; + base::FilePath extension_path; Manifest::Location extension_location; private: diff --git a/chrome/common/extensions/extension_builder.cc b/chrome/common/extensions/extension_builder.cc index 93be0c5..44d7b03 100644 --- a/chrome/common/extensions/extension_builder.cc +++ b/chrome/common/extensions/extension_builder.cc @@ -27,7 +27,7 @@ scoped_refptr<Extension> ExtensionBuilder::Build() { return extension; } -ExtensionBuilder& ExtensionBuilder::SetPath(const FilePath& path) { +ExtensionBuilder& ExtensionBuilder::SetPath(const base::FilePath& path) { path_ = path; return *this; } diff --git a/chrome/common/extensions/extension_builder.h b/chrome/common/extensions/extension_builder.h index b62092b..65cb453 100644 --- a/chrome/common/extensions/extension_builder.h +++ b/chrome/common/extensions/extension_builder.h @@ -27,7 +27,7 @@ class ExtensionBuilder { scoped_refptr<Extension> Build(); // Defaults to FilePath(). - ExtensionBuilder& SetPath(const FilePath& path); + ExtensionBuilder& SetPath(const base::FilePath& path); // Defaults to Manifest::LOAD. ExtensionBuilder& SetLocation(Manifest::Location location); @@ -43,7 +43,7 @@ class ExtensionBuilder { ExtensionBuilder& SetID(const std::string& id); private: - FilePath path_; + base::FilePath path_; Manifest::Location location_; scoped_ptr<base::DictionaryValue> manifest_; int flags_; diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc index 3ec7c9b..7edbb2c 100644 --- a/chrome/common/extensions/extension_file_util.cc +++ b/chrome/common/extensions/extension_file_util.cc @@ -43,7 +43,7 @@ namespace errors = extension_manifest_errors; namespace { -const FilePath::CharType kTempDirectoryName[] = FILE_PATH_LITERAL("Temp"); +const base::FilePath::CharType kTempDirectoryName[] = FILE_PATH_LITERAL("Temp"); bool ValidateExtensionIconSet(const ExtensionIconSet& icon_set, const Extension* extension, @@ -52,7 +52,8 @@ bool ValidateExtensionIconSet(const ExtensionIconSet& icon_set, for (ExtensionIconSet::IconMap::const_iterator iter = icon_set.map().begin(); iter != icon_set.map().end(); ++iter) { - const FilePath path = extension->GetResource(iter->second).GetFilePath(); + const base::FilePath path = + extension->GetResource(iter->second).GetFilePath(); if (!extension_file_util::ValidateFilePath(path)) { *error = l10n_util::GetStringFUTF8(error_message_id, UTF8ToUTF16(iter->second)); @@ -72,43 +73,44 @@ static bool ValidateLocaleInfo(const Extension& extension, // Returns false and sets the error if script file can't be loaded, // or if it's not UTF-8 encoded. -static bool IsScriptValid(const FilePath& path, const FilePath& relative_path, +static bool IsScriptValid(const base::FilePath& path, + const base::FilePath& relative_path, int message_id, std::string* error); -FilePath InstallExtension(const FilePath& unpacked_source_dir, - const std::string& id, - const std::string& version, - const FilePath& extensions_dir) { - FilePath extension_dir = extensions_dir.AppendASCII(id); - FilePath version_dir; +base::FilePath InstallExtension(const base::FilePath& unpacked_source_dir, + const std::string& id, + const std::string& version, + const base::FilePath& extensions_dir) { + base::FilePath extension_dir = extensions_dir.AppendASCII(id); + base::FilePath version_dir; // Create the extension directory if it doesn't exist already. if (!file_util::PathExists(extension_dir)) { if (!file_util::CreateDirectory(extension_dir)) - return FilePath(); + return base::FilePath(); } // Get a temp directory on the same file system as the profile. - FilePath install_temp_dir = GetInstallTempDir(extensions_dir); + base::FilePath install_temp_dir = GetInstallTempDir(extensions_dir); base::ScopedTempDir extension_temp_dir; if (install_temp_dir.empty() || !extension_temp_dir.CreateUniqueTempDirUnderPath(install_temp_dir)) { LOG(ERROR) << "Creating of temp dir under in the profile failed."; - return FilePath(); + return base::FilePath(); } - FilePath crx_temp_source = + base::FilePath crx_temp_source = extension_temp_dir.path().Append(unpacked_source_dir.BaseName()); if (!file_util::Move(unpacked_source_dir, crx_temp_source)) { LOG(ERROR) << "Moving extension from : " << unpacked_source_dir.value() << " to : " << crx_temp_source.value() << " failed."; - return FilePath(); + return base::FilePath(); } // Try to find a free directory. There can be legitimate conflicts in the case // of overinstallation of the same version. const int kMaxAttempts = 100; for (int i = 0; i < kMaxAttempts; ++i) { - FilePath candidate = extension_dir.AppendASCII( + base::FilePath candidate = extension_dir.AppendASCII( base::StringPrintf("%s_%u", version.c_str(), i)); if (!file_util::PathExists(candidate)) { version_dir = candidate; @@ -119,19 +121,19 @@ FilePath InstallExtension(const FilePath& unpacked_source_dir, if (version_dir.empty()) { LOG(ERROR) << "Could not find a home for extension " << id << " with " << "version " << version << "."; - return FilePath(); + return base::FilePath(); } if (!file_util::Move(crx_temp_source, version_dir)) { LOG(ERROR) << "Installing extension from : " << crx_temp_source.value() << " into : " << version_dir.value() << " failed."; - return FilePath(); + return base::FilePath(); } return version_dir; } -void UninstallExtension(const FilePath& extensions_dir, +void UninstallExtension(const base::FilePath& extensions_dir, const std::string& id) { // We don't care about the return value. If this fails (and it can, due to // plugins that aren't unloaded yet, it will get cleaned up by @@ -139,14 +141,14 @@ void UninstallExtension(const FilePath& extensions_dir, file_util::Delete(extensions_dir.AppendASCII(id), true); // recursive. } -scoped_refptr<Extension> LoadExtension(const FilePath& extension_path, +scoped_refptr<Extension> LoadExtension(const base::FilePath& extension_path, Manifest::Location location, int flags, std::string* error) { return LoadExtension(extension_path, std::string(), location, flags, error); } -scoped_refptr<Extension> LoadExtension(const FilePath& extension_path, +scoped_refptr<Extension> LoadExtension(const base::FilePath& extension_path, const std::string& extension_id, Manifest::Location location, int flags, @@ -176,9 +178,9 @@ scoped_refptr<Extension> LoadExtension(const FilePath& extension_path, return extension; } -DictionaryValue* LoadManifest(const FilePath& extension_path, +DictionaryValue* LoadManifest(const base::FilePath& extension_path, std::string* error) { - FilePath manifest_path = + base::FilePath manifest_path = extension_path.Append(Extension::kManifestFilename); if (!file_util::PathExists(manifest_path)) { *error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_UNREADABLE); @@ -210,12 +212,13 @@ DictionaryValue* LoadManifest(const FilePath& extension_path, return static_cast<DictionaryValue*>(root.release()); } -std::vector<FilePath> FindPrivateKeyFiles(const FilePath& extension_dir) { - std::vector<FilePath> result; +std::vector<base::FilePath> FindPrivateKeyFiles( + const base::FilePath& extension_dir) { + std::vector<base::FilePath> result; // Pattern matching only works at the root level, so filter manually. file_util::FileEnumerator traversal(extension_dir, /*recursive=*/true, file_util::FileEnumerator::FILES); - for (FilePath current = traversal.Next(); !current.empty(); + for (base::FilePath current = traversal.Next(); !current.empty(); current = traversal.Next()) { if (!current.MatchesExtension(chrome::kExtensionKeyFileExtension)) continue; @@ -236,7 +239,7 @@ std::vector<FilePath> FindPrivateKeyFiles(const FilePath& extension_dir) { return result; } -bool ValidateFilePath(const FilePath& path) { +bool ValidateFilePath(const base::FilePath& path) { int64 size = 0; if (!file_util::PathExists(path) || !file_util::GetFileSize(path, &size) || @@ -255,7 +258,8 @@ bool ValidateExtension(const Extension* extension, extension->icons().map().begin(); iter != extension->icons().map().end(); ++iter) { - const FilePath path = extension->GetResource(iter->second).GetFilePath(); + const base::FilePath path = + extension->GetResource(iter->second).GetFilePath(); if (!ValidateFilePath(path)) { *error = l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_ICON_FAILED, @@ -272,8 +276,8 @@ bool ValidateExtension(const Extension* extension, iter.Advance()) { std::string val; if (iter.value().GetAsString(&val)) { - FilePath image_path = extension->path().Append( - FilePath::FromUTF8Unsafe(val)); + base::FilePath image_path = extension->path().Append( + base::FilePath::FromUTF8Unsafe(val)); if (!file_util::PathExists(image_path)) { *error = l10n_util::GetStringFUTF8(IDS_EXTENSION_INVALID_IMAGE_PATH, @@ -303,7 +307,7 @@ bool ValidateExtension(const Extension* extension, for (size_t j = 0; j < script.js_scripts().size(); j++) { const extensions::UserScript::File& js_script = script.js_scripts()[j]; - const FilePath& path = ExtensionResource::GetFilePath( + const base::FilePath& path = ExtensionResource::GetFilePath( js_script.extension_root(), js_script.relative_path(), symlink_policy); if (!IsScriptValid(path, js_script.relative_path(), @@ -313,7 +317,7 @@ bool ValidateExtension(const Extension* extension, for (size_t j = 0; j < script.css_scripts().size(); j++) { const extensions::UserScript::File& css_script = script.css_scripts()[j]; - const FilePath& path = ExtensionResource::GetFilePath( + const base::FilePath& path = ExtensionResource::GetFilePath( css_script.extension_root(), css_script.relative_path(), symlink_policy); if (!IsScriptValid(path, css_script.relative_path(), @@ -366,9 +370,9 @@ bool ValidateExtension(const Extension* extension, if (extension->has_background_page() && !extension->is_hosted_app() && extension->background_scripts().empty()) { - FilePath page_path = ExtensionURLToRelativeFilePath( + base::FilePath page_path = ExtensionURLToRelativeFilePath( extension->GetBackgroundURL()); - const FilePath path = extension->GetResource(page_path).GetFilePath(); + const base::FilePath path = extension->GetResource(page_path).GetFilePath(); if (path.empty() || !file_util::PathExists(path)) { *error = l10n_util::GetStringFUTF8( @@ -382,9 +386,10 @@ bool ValidateExtension(const Extension* extension, // because they are expected to refer to an external URL. if (!extensions::ManifestURL::GetOptionsPage(extension).is_empty() && !extension->is_hosted_app()) { - const FilePath options_path = ExtensionURLToRelativeFilePath( + const base::FilePath options_path = ExtensionURLToRelativeFilePath( extensions::ManifestURL::GetOptionsPage(extension)); - const FilePath path = extension->GetResource(options_path).GetFilePath(); + const base::FilePath path = + extension->GetResource(options_path).GetFilePath(); if (path.empty() || !file_util::PathExists(path)) { *error = l10n_util::GetStringFUTF8( @@ -405,7 +410,8 @@ bool ValidateExtension(const Extension* extension, } // Check that extensions don't include private key files. - std::vector<FilePath> private_keys = FindPrivateKeyFiles(extension->path()); + std::vector<base::FilePath> private_keys = + FindPrivateKeyFiles(extension->path()); if (extension->creation_flags() & Extension::ERROR_ON_PRIVATE_KEY) { if (!private_keys.empty()) { // Only print one of the private keys because l10n_util doesn't have a way @@ -429,8 +435,8 @@ bool ValidateExtension(const Extension* extension, } void GarbageCollectExtensions( - const FilePath& install_directory, - const std::multimap<std::string, FilePath>& extension_paths) { + const base::FilePath& install_directory, + const std::multimap<std::string, base::FilePath>& extension_paths) { // Nothing to clean up if it doesn't exist. if (!file_util::DirectoryExists(install_directory)) return; @@ -439,12 +445,12 @@ void GarbageCollectExtensions( file_util::FileEnumerator enumerator(install_directory, false, // Not recursive. file_util::FileEnumerator::DIRECTORIES); - FilePath extension_path; + base::FilePath extension_path; for (extension_path = enumerator.Next(); !extension_path.value().empty(); extension_path = enumerator.Next()) { std::string extension_id; - FilePath basename = extension_path.BaseName(); + base::FilePath basename = extension_path.BaseName(); // Clean up temporary files left if Chrome crashed or quit in the middle // of an extension install. if (basename.value() == kTempDirectoryName) { @@ -469,7 +475,7 @@ void GarbageCollectExtensions( continue; } - typedef std::multimap<std::string, FilePath>::const_iterator Iter; + typedef std::multimap<std::string, base::FilePath>::const_iterator Iter; std::pair<Iter, Iter> iter_pair = extension_paths.equal_range(extension_id); // If there is no entry in the prefs file, just delete the directory and @@ -487,7 +493,7 @@ void GarbageCollectExtensions( extension_path, false, // Not recursive. file_util::FileEnumerator::DIRECTORIES); - for (FilePath version_dir = versions_enumerator.Next(); + for (base::FilePath version_dir = versions_enumerator.Next(); !version_dir.value().empty(); version_dir = versions_enumerator.Next()) { bool knownVersion = false; @@ -506,12 +512,12 @@ void GarbageCollectExtensions( } extensions::MessageBundle* LoadMessageBundle( - const FilePath& extension_path, + const base::FilePath& extension_path, const std::string& default_locale, std::string* error) { error->clear(); // Load locale information if available. - FilePath locale_path = extension_path.Append( + base::FilePath locale_path = extension_path.Append( Extension::kLocaleFolder); if (!file_util::PathExists(locale_path)) return NULL; @@ -539,7 +545,7 @@ extensions::MessageBundle* LoadMessageBundle( } SubstitutionMap* LoadMessageBundleSubstitutionMap( - const FilePath& extension_path, + const base::FilePath& extension_path, const std::string& extension_id, const std::string& default_locale) { SubstitutionMap* returnValue = new SubstitutionMap(); @@ -564,7 +570,7 @@ SubstitutionMap* LoadMessageBundleSubstitutionMap( static bool ValidateLocaleInfo(const Extension& extension, std::string* error) { // default_locale and _locales have to be both present or both missing. - const FilePath path = extension.path().Append( + const base::FilePath path = extension.path().Append( Extension::kLocaleFolder); bool path_exists = file_util::PathExists(path); std::string default_locale = @@ -590,16 +596,16 @@ static bool ValidateLocaleInfo(const Extension& extension, std::set<std::string> all_locales; extension_l10n_util::GetAllLocales(&all_locales); - const FilePath default_locale_path = path.AppendASCII(default_locale); + const base::FilePath default_locale_path = path.AppendASCII(default_locale); bool has_default_locale_message_file = false; - FilePath locale_path; + base::FilePath locale_path; while (!(locale_path = locales.Next()).empty()) { if (extension_l10n_util::ShouldSkipValidation(path, locale_path, all_locales)) continue; - FilePath messages_path = + base::FilePath messages_path = locale_path.Append(Extension::kMessagesFilename); if (!file_util::PathExists(messages_path)) { @@ -622,8 +628,8 @@ static bool ValidateLocaleInfo(const Extension& extension, return true; } -static bool IsScriptValid(const FilePath& path, - const FilePath& relative_path, +static bool IsScriptValid(const base::FilePath& path, + const base::FilePath& relative_path, int message_id, std::string* error) { std::string content; @@ -645,15 +651,15 @@ static bool IsScriptValid(const FilePath& path, return true; } -bool CheckForIllegalFilenames(const FilePath& extension_path, +bool CheckForIllegalFilenames(const base::FilePath& extension_path, std::string* error) { // Reserved underscore names. - static const FilePath::CharType* reserved_names[] = { + static const base::FilePath::CharType* reserved_names[] = { Extension::kLocaleFolder, FILE_PATH_LITERAL("__MACOSX"), }; CR_DEFINE_STATIC_LOCAL( - std::set<FilePath::StringType>, reserved_underscore_names, + std::set<base::FilePath::StringType>, reserved_underscore_names, (reserved_names, reserved_names + arraysize(reserved_names))); // Enumerate all files and directories in the extension root. @@ -664,9 +670,9 @@ bool CheckForIllegalFilenames(const FilePath& extension_path, file_util::FileEnumerator all_files( extension_path, false, kFilesAndDirectories); - FilePath file; + base::FilePath file; while (!(file = all_files.Next()).empty()) { - FilePath::StringType filename = file.BaseName().value(); + base::FilePath::StringType filename = file.BaseName().value(); // Skip all that don't start with "_". if (filename.find_first_of(FILE_PATH_LITERAL("_")) != 0) continue; if (reserved_underscore_names.find(filename) == @@ -682,10 +688,10 @@ bool CheckForIllegalFilenames(const FilePath& extension_path, return true; } -FilePath ExtensionURLToRelativeFilePath(const GURL& url) { +base::FilePath ExtensionURLToRelativeFilePath(const GURL& url) { std::string url_path = url.path(); if (url_path.empty() || url_path[0] != '/') - return FilePath(); + return base::FilePath(); // Drop the leading slashes and convert %-encoded UTF8 to regular UTF8. std::string file_path = net::UnescapeURLComponent(url_path, @@ -694,13 +700,13 @@ FilePath ExtensionURLToRelativeFilePath(const GURL& url) { if (skip != file_path.npos) file_path = file_path.substr(skip); - FilePath path = + base::FilePath path = #if defined(OS_POSIX) - FilePath(file_path); + base::FilePath(file_path); #elif defined(OS_WIN) - FilePath(UTF8ToWide(file_path)); + base::FilePath(UTF8ToWide(file_path)); #else - FilePath(); + base::FilePath(); NOTIMPLEMENTED(); #endif @@ -708,31 +714,32 @@ FilePath ExtensionURLToRelativeFilePath(const GURL& url) { // would still wind up not being considered relative at this point. // For example: chrome-extension://id/c:////foo.html if (path.IsAbsolute()) - return FilePath(); + return base::FilePath(); return path; } -FilePath ExtensionResourceURLToFilePath(const GURL& url, const FilePath& root) { +base::FilePath ExtensionResourceURLToFilePath(const GURL& url, + const base::FilePath& root) { std::string host = net::UnescapeURLComponent(url.host(), net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS); if (host.empty()) - return FilePath(); + return base::FilePath(); - FilePath relative_path = ExtensionURLToRelativeFilePath(url); + base::FilePath relative_path = ExtensionURLToRelativeFilePath(url); if (relative_path.empty()) - return FilePath(); + return base::FilePath(); - FilePath path = root.AppendASCII(host).Append(relative_path); + base::FilePath path = root.AppendASCII(host).Append(relative_path); if (!file_util::PathExists(path) || !file_util::AbsolutePath(&path) || !root.IsParent(path)) { - return FilePath(); + return base::FilePath(); } return path; } -FilePath GetInstallTempDir(const FilePath& extensions_dir) { +base::FilePath GetInstallTempDir(const base::FilePath& extensions_dir) { // We do file IO in this function, but only when the current profile's // Temp directory has never been used before, or in a rare error case. // Developers are not likely to see these situations often, so do an @@ -742,15 +749,15 @@ FilePath GetInstallTempDir(const FilePath& extensions_dir) { // Create the temp directory as a sub-directory of the Extensions directory. // This guarantees it is on the same file system as the extension's eventual // install target. - FilePath temp_path = extensions_dir.Append(kTempDirectoryName); + base::FilePath temp_path = extensions_dir.Append(kTempDirectoryName); if (file_util::PathExists(temp_path)) { if (!file_util::DirectoryExists(temp_path)) { DLOG(WARNING) << "Not a directory: " << temp_path.value(); - return FilePath(); + return base::FilePath(); } if (!file_util::PathIsWritable(temp_path)) { DLOG(WARNING) << "Can't write to path: " << temp_path.value(); - return FilePath(); + return base::FilePath(); } // This is a directory we can write to. return temp_path; @@ -759,12 +766,12 @@ FilePath GetInstallTempDir(const FilePath& extensions_dir) { // Directory doesn't exist, so create it. if (!file_util::CreateDirectory(temp_path)) { DLOG(WARNING) << "Couldn't create directory: " << temp_path.value(); - return FilePath(); + return base::FilePath(); } return temp_path; } -void DeleteFile(const FilePath& path, bool recursive) { +void DeleteFile(const base::FilePath& path, bool recursive) { file_util::Delete(path, recursive); } diff --git a/chrome/common/extensions/extension_file_util_unittest.cc b/chrome/common/extensions/extension_file_util_unittest.cc index ffd2eb0..9147af4 100644 --- a/chrome/common/extensions/extension_file_util_unittest.cc +++ b/chrome/common/extensions/extension_file_util_unittest.cc @@ -51,18 +51,19 @@ TEST_F(ExtensionFileUtilTest, InstallUninstallGarbageCollect) { // Create a source extension. std::string extension_id("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); std::string version("1.0"); - FilePath src = temp.path().AppendASCII(extension_id); + base::FilePath src = temp.path().AppendASCII(extension_id); ASSERT_TRUE(file_util::CreateDirectory(src)); // Create a extensions tree. - FilePath all_extensions = temp.path().AppendASCII("extensions"); + base::FilePath all_extensions = temp.path().AppendASCII("extensions"); ASSERT_TRUE(file_util::CreateDirectory(all_extensions)); // Install in empty directory. Should create parent directories as needed. - FilePath version_1 = extension_file_util::InstallExtension(src, - extension_id, - version, - all_extensions); + base::FilePath version_1 = extension_file_util::InstallExtension( + src, + extension_id, + version, + all_extensions); ASSERT_EQ(version_1.value(), all_extensions.AppendASCII(extension_id).AppendASCII("1.0_0") .value()); @@ -73,10 +74,11 @@ TEST_F(ExtensionFileUtilTest, InstallUninstallGarbageCollect) { // Install again. Should create a new one with different name. ASSERT_TRUE(file_util::CreateDirectory(src)); - FilePath version_2 = extension_file_util::InstallExtension(src, - extension_id, - version, - all_extensions); + base::FilePath version_2 = extension_file_util::InstallExtension( + src, + extension_id, + version, + all_extensions); ASSERT_EQ(version_2.value(), all_extensions.AppendASCII(extension_id).AppendASCII("1.0_1") .value()); @@ -87,21 +89,22 @@ TEST_F(ExtensionFileUtilTest, InstallUninstallGarbageCollect) { // Install yet again. Should create a new one with a different name. ASSERT_TRUE(file_util::CreateDirectory(src)); - FilePath version_3 = extension_file_util::InstallExtension(src, - extension_id, - version, - all_extensions); + base::FilePath version_3 = extension_file_util::InstallExtension( + src, + extension_id, + version, + all_extensions); ASSERT_EQ(version_3.value(), all_extensions.AppendASCII(extension_id).AppendASCII("1.0_2") .value()); ASSERT_TRUE(file_util::DirectoryExists(version_3)); // Collect garbage. Should remove first one. - std::multimap<std::string, FilePath> extension_paths; + std::multimap<std::string, base::FilePath> extension_paths; extension_paths.insert(std::make_pair(extension_id, - FilePath().AppendASCII(extension_id).Append(version_2.BaseName()))); + base::FilePath().AppendASCII(extension_id).Append(version_2.BaseName()))); extension_paths.insert(std::make_pair(extension_id, - FilePath().AppendASCII(extension_id).Append(version_3.BaseName()))); + base::FilePath().AppendASCII(extension_id).Append(version_3.BaseName()))); extension_file_util::GarbageCollectExtensions(all_extensions, extension_paths); ASSERT_FALSE(file_util::DirectoryExists(version_1)); @@ -116,7 +119,7 @@ TEST_F(ExtensionFileUtilTest, InstallUninstallGarbageCollect) { } TEST_F(ExtensionFileUtilTest, LoadExtensionWithValidLocales) { - FilePath install_dir; + base::FilePath install_dir; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir)); install_dir = install_dir.AppendASCII("extensions") .AppendASCII("good") @@ -132,7 +135,7 @@ TEST_F(ExtensionFileUtilTest, LoadExtensionWithValidLocales) { } TEST_F(ExtensionFileUtilTest, LoadExtensionWithoutLocalesFolder) { - FilePath install_dir; + base::FilePath install_dir; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir)); install_dir = install_dir.AppendASCII("extensions") .AppendASCII("good") @@ -156,7 +159,7 @@ TEST_F(ExtensionFileUtilTest, CheckIllegalFilenamesNoUnderscores) { base::ScopedTempDir temp; ASSERT_TRUE(temp.CreateUniqueTempDir()); - FilePath src_path = temp.path().AppendASCII("some_dir"); + base::FilePath src_path = temp.path().AppendASCII("some_dir"); ASSERT_TRUE(file_util::CreateDirectory(src_path)); std::string data = "{ \"name\": { \"message\": \"foobar\" } }"; @@ -176,7 +179,7 @@ TEST_F(ExtensionFileUtilTest, CheckIllegalFilenamesOnlyReserved) { base::ScopedTempDir temp; ASSERT_TRUE(temp.CreateUniqueTempDir()); - FilePath src_path = temp.path().Append(Extension::kLocaleFolder); + base::FilePath src_path = temp.path().Append(Extension::kLocaleFolder); ASSERT_TRUE(file_util::CreateDirectory(src_path)); std::string error; @@ -193,7 +196,7 @@ TEST_F(ExtensionFileUtilTest, CheckIllegalFilenamesReservedAndIllegal) { base::ScopedTempDir temp; ASSERT_TRUE(temp.CreateUniqueTempDir()); - FilePath src_path = temp.path().Append(Extension::kLocaleFolder); + base::FilePath src_path = temp.path().Append(Extension::kLocaleFolder); ASSERT_TRUE(file_util::CreateDirectory(src_path)); src_path = temp.path().AppendASCII("_some_dir"); @@ -206,7 +209,7 @@ TEST_F(ExtensionFileUtilTest, CheckIllegalFilenamesReservedAndIllegal) { TEST_F(ExtensionFileUtilTest, LoadExtensionGivesHelpfullErrorOnMissingManifest) { - FilePath install_dir; + base::FilePath install_dir; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir)); install_dir = install_dir.AppendASCII("extensions") .AppendASCII("bad") @@ -223,7 +226,7 @@ TEST_F(ExtensionFileUtilTest, } TEST_F(ExtensionFileUtilTest, LoadExtensionGivesHelpfullErrorOnBadManifest) { - FilePath install_dir; + base::FilePath install_dir; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir)); install_dir = install_dir.AppendASCII("extensions") .AppendASCII("bad") @@ -241,7 +244,7 @@ TEST_F(ExtensionFileUtilTest, LoadExtensionGivesHelpfullErrorOnBadManifest) { } TEST_F(ExtensionFileUtilTest, FailLoadingNonUTF8Scripts) { - FilePath install_dir; + base::FilePath install_dir; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir)); install_dir = install_dir.AppendASCII("extensions") .AppendASCII("bad") @@ -287,12 +290,13 @@ TEST_F(ExtensionFileUtilTest, ExtensionURLToRelativeFilePath) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { GURL url(test_cases[i].url); #if defined(OS_POSIX) - FilePath expected_path(test_cases[i].expected_relative_path); + base::FilePath expected_path(test_cases[i].expected_relative_path); #elif defined(OS_WIN) - FilePath expected_path(UTF8ToWide(test_cases[i].expected_relative_path)); + base::FilePath expected_path( + UTF8ToWide(test_cases[i].expected_relative_path)); #endif - FilePath actual_path = + base::FilePath actual_path = extension_file_util::ExtensionURLToRelativeFilePath(url); EXPECT_FALSE(actual_path.IsAbsolute()) << " For the path " << actual_path.value(); @@ -303,16 +307,16 @@ TEST_F(ExtensionFileUtilTest, ExtensionURLToRelativeFilePath) { TEST_F(ExtensionFileUtilTest, ExtensionResourceURLToFilePath) { // Setup filesystem for testing. - FilePath root_path; + base::FilePath root_path; ASSERT_TRUE(file_util::CreateNewTempDirectory( FILE_PATH_LITERAL(""), &root_path)); ASSERT_TRUE(file_util::AbsolutePath(&root_path)); - FilePath api_path = root_path.Append(FILE_PATH_LITERAL("apiname")); + base::FilePath api_path = root_path.Append(FILE_PATH_LITERAL("apiname")); ASSERT_TRUE(file_util::CreateDirectory(api_path)); const char data[] = "Test Data"; - FilePath resource_path = api_path.Append(FILE_PATH_LITERAL("test.js")); + base::FilePath resource_path = api_path.Append(FILE_PATH_LITERAL("test.js")); ASSERT_TRUE(file_util::WriteFile(resource_path, data, sizeof(data))); resource_path = api_path.Append(FILE_PATH_LITERAL("escape spaces.js")); ASSERT_TRUE(file_util::WriteFile(resource_path, data, sizeof(data))); @@ -325,7 +329,7 @@ TEST_F(ExtensionFileUtilTest, ExtensionResourceURLToFilePath) { #define URL_PREFIX "chrome-extension-resource://" struct TestCase { const char* url; - const FilePath::CharType* expected_path; + const base::FilePath::CharType* expected_path; } test_cases[] = { { URL_PREFIX "apiname/test.js", FILE_PATH_LITERAL("test.js") }, @@ -354,11 +358,11 @@ TEST_F(ExtensionFileUtilTest, ExtensionResourceURLToFilePath) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { GURL url(test_cases[i].url); - FilePath expected_path; + base::FilePath expected_path; if (test_cases[i].expected_path) expected_path = root_path.Append(FILE_PATH_LITERAL("apiname")).Append( test_cases[i].expected_path); - FilePath actual_path = + base::FilePath actual_path = extension_file_util::ExtensionResourceURLToFilePath(url, root_path); EXPECT_EQ(expected_path.value(), actual_path.value()) << " For the path " << url; @@ -369,7 +373,7 @@ TEST_F(ExtensionFileUtilTest, ExtensionResourceURLToFilePath) { static scoped_refptr<Extension> LoadExtensionManifest( DictionaryValue* manifest, - const FilePath& manifest_dir, + const base::FilePath& manifest_dir, Manifest::Location location, int extra_flags, std::string* error) { @@ -380,7 +384,7 @@ static scoped_refptr<Extension> LoadExtensionManifest( static scoped_refptr<Extension> LoadExtensionManifest( const std::string& manifest_value, - const FilePath& manifest_dir, + const base::FilePath& manifest_dir, Manifest::Location location, int extra_flags, std::string* error) { @@ -406,8 +410,8 @@ TEST_F(ExtensionFileUtilTest, ValidateThemeUTF8) { // "aeo" with accents. Use http://0xcc.net/jsescape/ to decode them. std::string non_ascii_file = "\xC3\xA0\xC3\xA8\xC3\xB2.png"; - FilePath non_ascii_path = temp.path().Append(FilePath::FromUTF8Unsafe( - non_ascii_file)); + base::FilePath non_ascii_path = + temp.path().Append(base::FilePath::FromUTF8Unsafe(non_ascii_file)); file_util::WriteFile(non_ascii_path, "", 0); std::string kManifest = @@ -500,7 +504,7 @@ TEST_F(ExtensionFileUtilTest, FindPrivateKeyFiles) { base::ScopedTempDir temp; ASSERT_TRUE(temp.CreateUniqueTempDir()); - FilePath src_path = temp.path().AppendASCII("some_dir"); + base::FilePath src_path = temp.path().AppendASCII("some_dir"); ASSERT_TRUE(file_util::CreateDirectory(src_path)); ASSERT_TRUE(file_util::WriteFile(src_path.AppendASCII("a_key.pem"), @@ -513,7 +517,7 @@ TEST_F(ExtensionFileUtilTest, FindPrivateKeyFiles) { // Shouldn't find a key that isn't parsable. ASSERT_TRUE(file_util::WriteFile(src_path.AppendASCII("unparsable_key.pem"), private_key, arraysize(private_key) - 30)); - std::vector<FilePath> private_keys = + std::vector<base::FilePath> private_keys = extension_file_util::FindPrivateKeyFiles(temp.path()); EXPECT_EQ(2U, private_keys.size()); EXPECT_THAT(private_keys, @@ -526,7 +530,7 @@ TEST_F(ExtensionFileUtilTest, WarnOnPrivateKey) { base::ScopedTempDir temp; ASSERT_TRUE(temp.CreateUniqueTempDir()); - FilePath ext_path = temp.path().AppendASCII("ext_root"); + base::FilePath ext_path = temp.path().AppendASCII("ext_root"); ASSERT_TRUE(file_util::CreateDirectory(ext_path)); const char manifest[] = @@ -566,11 +570,11 @@ TEST_F(ExtensionFileUtilTest, WarnOnPrivateKey) { } TEST_F(ExtensionFileUtilTest, CheckZeroLengthImageFile) { - FilePath install_dir; + base::FilePath install_dir; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir)); // Try to install an extension with a zero-length icon file. - FilePath ext_dir = install_dir.AppendASCII("extensions") + base::FilePath ext_dir = install_dir.AppendASCII("extensions") .AppendASCII("bad") .AppendASCII("Extensions") .AppendASCII("ffffffffffffffffffffffffffffffff"); diff --git a/chrome/common/extensions/extension_l10n_util.cc b/chrome/common/extensions/extension_l10n_util.cc index b07efb8..ce375b2 100644 --- a/chrome/common/extensions/extension_l10n_util.cc +++ b/chrome/common/extensions/extension_l10n_util.cc @@ -167,7 +167,7 @@ bool LocalizeManifest(const extensions::MessageBundle& messages, return true; } -bool LocalizeExtension(const FilePath& extension_path, +bool LocalizeExtension(const base::FilePath& extension_path, DictionaryValue* manifest, std::string* error) { DCHECK(manifest); @@ -189,7 +189,7 @@ bool LocalizeExtension(const FilePath& extension_path, } bool AddLocale(const std::set<std::string>& chrome_locales, - const FilePath& locale_folder, + const base::FilePath& locale_folder, const std::string& locale_name, std::set<std::string>* valid_locales, std::string* error) { @@ -246,7 +246,7 @@ void GetAllFallbackLocales(const std::string& application_locale, all_fallback_locales->push_back(default_locale); } -bool GetValidLocales(const FilePath& locale_path, +bool GetValidLocales(const base::FilePath& locale_path, std::set<std::string>* valid_locales, std::string* error) { std::set<std::string> chrome_locales; @@ -256,7 +256,7 @@ bool GetValidLocales(const FilePath& locale_path, file_util::FileEnumerator locales(locale_path, false, file_util::FileEnumerator::DIRECTORIES); - FilePath locale_folder; + base::FilePath locale_folder; while (!(locale_folder = locales.Next()).empty()) { std::string locale_name = locale_folder.BaseName().MaybeAsASCII(); if (locale_name.empty()) { @@ -283,11 +283,11 @@ bool GetValidLocales(const FilePath& locale_path, // Loads contents of the messages file for given locale. If file is not found, // or there was parsing error we return NULL and set |error|. // Caller owns the returned object. -static DictionaryValue* LoadMessageFile(const FilePath& locale_path, +static DictionaryValue* LoadMessageFile(const base::FilePath& locale_path, const std::string& locale, std::string* error) { std::string extension_locale = locale; - FilePath file = locale_path.AppendASCII(extension_locale) + base::FilePath file = locale_path.AppendASCII(extension_locale) .Append(extensions::Extension::kMessagesFilename); JSONFileValueSerializer messages_serializer(file); Value *dictionary = messages_serializer.Deserialize(NULL, error); @@ -302,7 +302,7 @@ static DictionaryValue* LoadMessageFile(const FilePath& locale_path, } extensions::MessageBundle* LoadMessageCatalogs( - const FilePath& locale_path, + const base::FilePath& locale_path, const std::string& default_locale, const std::string& application_locale, const std::set<std::string>& valid_locales, @@ -330,13 +330,13 @@ extensions::MessageBundle* LoadMessageCatalogs( return extensions::MessageBundle::Create(catalogs, error); } -bool ShouldSkipValidation(const FilePath& locales_path, - const FilePath& locale_path, +bool ShouldSkipValidation(const base::FilePath& locales_path, + const base::FilePath& locale_path, const std::set<std::string>& all_locales) { // Since we use this string as a key in a DictionaryValue, be paranoid about // skipping any strings with '.'. This happens sometimes, for example with // '.svn' directories. - FilePath relative_path; + base::FilePath relative_path; if (!locales_path.AppendRelativePath(locale_path, &relative_path)) { NOTREACHED(); return true; diff --git a/chrome/common/extensions/extension_l10n_util_unittest.cc b/chrome/common/extensions/extension_l10n_util_unittest.cc index 52c71de..3e00552 100644 --- a/chrome/common/extensions/extension_l10n_util_unittest.cc +++ b/chrome/common/extensions/extension_l10n_util_unittest.cc @@ -74,7 +74,7 @@ TEST(ExtensionL10nUtil, GetValidLocalesEmptyLocaleFolder) { base::ScopedTempDir temp; ASSERT_TRUE(temp.CreateUniqueTempDir()); - FilePath src_path = temp.path().Append(Extension::kLocaleFolder); + base::FilePath src_path = temp.path().Append(Extension::kLocaleFolder); ASSERT_TRUE(file_util::CreateDirectory(src_path)); std::string error; @@ -90,7 +90,7 @@ TEST(ExtensionL10nUtil, GetValidLocalesWithValidLocaleNoMessagesFile) { base::ScopedTempDir temp; ASSERT_TRUE(temp.CreateUniqueTempDir()); - FilePath src_path = temp.path().Append(Extension::kLocaleFolder); + base::FilePath src_path = temp.path().Append(Extension::kLocaleFolder); ASSERT_TRUE(file_util::CreateDirectory(src_path)); ASSERT_TRUE(file_util::CreateDirectory(src_path.AppendASCII("sr"))); @@ -107,10 +107,10 @@ TEST(ExtensionL10nUtil, GetValidLocalesWithUnsupportedLocale) { base::ScopedTempDir temp; ASSERT_TRUE(temp.CreateUniqueTempDir()); - FilePath src_path = temp.path().Append(Extension::kLocaleFolder); + base::FilePath src_path = temp.path().Append(Extension::kLocaleFolder); ASSERT_TRUE(file_util::CreateDirectory(src_path)); // Supported locale. - FilePath locale_1 = src_path.AppendASCII("sr"); + base::FilePath locale_1 = src_path.AppendASCII("sr"); ASSERT_TRUE(file_util::CreateDirectory(locale_1)); std::string data("whatever"); ASSERT_TRUE(file_util::WriteFile( @@ -131,7 +131,7 @@ TEST(ExtensionL10nUtil, GetValidLocalesWithUnsupportedLocale) { } TEST(ExtensionL10nUtil, GetValidLocalesWithValidLocalesAndMessagesFile) { - FilePath install_dir; + base::FilePath install_dir; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir)); install_dir = install_dir.AppendASCII("extensions") .AppendASCII("good") @@ -152,7 +152,7 @@ TEST(ExtensionL10nUtil, GetValidLocalesWithValidLocalesAndMessagesFile) { } TEST(ExtensionL10nUtil, LoadMessageCatalogsValidFallback) { - FilePath install_dir; + base::FilePath install_dir; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir)); install_dir = install_dir.AppendASCII("extensions") .AppendASCII("good") @@ -179,7 +179,7 @@ TEST(ExtensionL10nUtil, LoadMessageCatalogsMissingFiles) { base::ScopedTempDir temp; ASSERT_TRUE(temp.CreateUniqueTempDir()); - FilePath src_path = temp.path().Append(Extension::kLocaleFolder); + base::FilePath src_path = temp.path().Append(Extension::kLocaleFolder); ASSERT_TRUE(file_util::CreateDirectory(src_path)); std::set<std::string> valid_locales; @@ -198,10 +198,10 @@ TEST(ExtensionL10nUtil, LoadMessageCatalogsBadJSONFormat) { base::ScopedTempDir temp; ASSERT_TRUE(temp.CreateUniqueTempDir()); - FilePath src_path = temp.path().Append(Extension::kLocaleFolder); + base::FilePath src_path = temp.path().Append(Extension::kLocaleFolder); ASSERT_TRUE(file_util::CreateDirectory(src_path)); - FilePath locale = src_path.AppendASCII("sr"); + base::FilePath locale = src_path.AppendASCII("sr"); ASSERT_TRUE(file_util::CreateDirectory(locale)); std::string data = "{ \"name\":"; @@ -225,10 +225,10 @@ TEST(ExtensionL10nUtil, LoadMessageCatalogsDuplicateKeys) { base::ScopedTempDir temp; ASSERT_TRUE(temp.CreateUniqueTempDir()); - FilePath src_path = temp.path().Append(Extension::kLocaleFolder); + base::FilePath src_path = temp.path().Append(Extension::kLocaleFolder); ASSERT_TRUE(file_util::CreateDirectory(src_path)); - FilePath locale_1 = src_path.AppendASCII("en"); + base::FilePath locale_1 = src_path.AppendASCII("en"); ASSERT_TRUE(file_util::CreateDirectory(locale_1)); std::string data = @@ -238,7 +238,7 @@ TEST(ExtensionL10nUtil, LoadMessageCatalogsDuplicateKeys) { file_util::WriteFile(locale_1.Append(Extension::kMessagesFilename), data.c_str(), data.length())); - FilePath locale_2 = src_path.AppendASCII("sr"); + base::FilePath locale_2 = src_path.AppendASCII("sr"); ASSERT_TRUE(file_util::CreateDirectory(locale_2)); ASSERT_TRUE( @@ -561,7 +561,7 @@ TEST(ExtensionL10nUtil, LocalizeManifestWithNameDescriptionFileHandlerTitle) { // Try with NULL manifest. TEST(ExtensionL10nUtil, ShouldRelocalizeManifestWithNullManifest) { - ExtensionInfo info(NULL, "", FilePath(), Manifest::LOAD); + ExtensionInfo info(NULL, "", base::FilePath(), Manifest::LOAD); EXPECT_FALSE(extension_l10n_util::ShouldRelocalizeManifest(info)); } @@ -569,7 +569,7 @@ TEST(ExtensionL10nUtil, ShouldRelocalizeManifestWithNullManifest) { // Try with default and current locales missing. TEST(ExtensionL10nUtil, ShouldRelocalizeManifestEmptyManifest) { DictionaryValue manifest; - ExtensionInfo info(&manifest, "", FilePath(), Manifest::LOAD); + ExtensionInfo info(&manifest, "", base::FilePath(), Manifest::LOAD); EXPECT_FALSE(extension_l10n_util::ShouldRelocalizeManifest(info)); } @@ -579,7 +579,7 @@ TEST(ExtensionL10nUtil, ShouldRelocalizeManifestWithDefaultLocale) { DictionaryValue manifest; manifest.SetString(keys::kDefaultLocale, "en_US"); - ExtensionInfo info(&manifest, "", FilePath(), Manifest::LOAD); + ExtensionInfo info(&manifest, "", base::FilePath(), Manifest::LOAD); EXPECT_TRUE(extension_l10n_util::ShouldRelocalizeManifest(info)); } @@ -590,7 +590,7 @@ TEST(ExtensionL10nUtil, ShouldRelocalizeManifestWithCurrentLocale) { manifest.SetString(keys::kCurrentLocale, extension_l10n_util::CurrentLocaleOrDefault()); - ExtensionInfo info(&manifest, "", FilePath(), Manifest::LOAD); + ExtensionInfo info(&manifest, "", base::FilePath(), Manifest::LOAD); EXPECT_FALSE(extension_l10n_util::ShouldRelocalizeManifest(info)); } @@ -602,7 +602,7 @@ TEST(ExtensionL10nUtil, ShouldRelocalizeManifestSameCurrentLocale) { manifest.SetString(keys::kCurrentLocale, extension_l10n_util::CurrentLocaleOrDefault()); - ExtensionInfo info(&manifest, "", FilePath(), Manifest::LOAD); + ExtensionInfo info(&manifest, "", base::FilePath(), Manifest::LOAD); EXPECT_FALSE(extension_l10n_util::ShouldRelocalizeManifest(info)); } @@ -613,7 +613,7 @@ TEST(ExtensionL10nUtil, ShouldRelocalizeManifestDifferentCurrentLocale) { manifest.SetString(keys::kDefaultLocale, "en_US"); manifest.SetString(keys::kCurrentLocale, "sr"); - ExtensionInfo info(&manifest, "", FilePath(), Manifest::LOAD); + ExtensionInfo info(&manifest, "", base::FilePath(), Manifest::LOAD); EXPECT_TRUE(extension_l10n_util::ShouldRelocalizeManifest(info)); } diff --git a/chrome/common/extensions/extension_messages.h b/chrome/common/extensions/extension_messages.h index 57d90ae..aa3a52f 100644 --- a/chrome/common/extensions/extension_messages.h +++ b/chrome/common/extensions/extension_messages.h @@ -167,7 +167,7 @@ struct ExtensionMsg_Loaded_Params { // The path the extension was loaded from. This is used in the renderer only // to generate the extension ID for extensions that are loaded unpacked. - FilePath path; + base::FilePath path; // The extension's active permissions. extensions::APIPermissionSet apis; diff --git a/chrome/common/extensions/extension_resource.cc b/chrome/common/extensions/extension_resource.cc index c82ad3a..eded1ac 100644 --- a/chrome/common/extensions/extension_resource.cc +++ b/chrome/common/extensions/extension_resource.cc @@ -12,8 +12,8 @@ ExtensionResource::ExtensionResource() : follow_symlinks_anywhere_(false) { } ExtensionResource::ExtensionResource(const std::string& extension_id, - const FilePath& extension_root, - const FilePath& relative_path) + const base::FilePath& extension_root, + const base::FilePath& relative_path) : extension_id_(extension_id), extension_root_(extension_root), relative_path_(relative_path), @@ -26,7 +26,7 @@ void ExtensionResource::set_follow_symlinks_anywhere() { follow_symlinks_anywhere_ = true; } -const FilePath& ExtensionResource::GetFilePath() const { +const base::FilePath& ExtensionResource::GetFilePath() const { if (extension_root_.empty() || relative_path_.empty()) { DCHECK(full_resource_path_.empty()); return full_resource_path_; @@ -44,34 +44,34 @@ const FilePath& ExtensionResource::GetFilePath() const { } // static -FilePath ExtensionResource::GetFilePath( - const FilePath& extension_root, - const FilePath& relative_path, +base::FilePath ExtensionResource::GetFilePath( + const base::FilePath& extension_root, + const base::FilePath& relative_path, SymlinkPolicy symlink_policy) { // We need to resolve the parent references in the extension_root // path on its own because IsParent doesn't like parent references. - FilePath clean_extension_root(extension_root); + base::FilePath clean_extension_root(extension_root); if (!file_util::AbsolutePath(&clean_extension_root)) - return FilePath(); + return base::FilePath(); - FilePath full_path = clean_extension_root.Append(relative_path); + base::FilePath full_path = clean_extension_root.Append(relative_path); // If we are allowing the file to be a symlink outside of the root, then the // path before resolving the symlink must still be within it. if (symlink_policy == FOLLOW_SYMLINKS_ANYWHERE) { - std::vector<FilePath::StringType> components; + std::vector<base::FilePath::StringType> components; relative_path.GetComponents(&components); int depth = 0; - for (std::vector<FilePath::StringType>::const_iterator + for (std::vector<base::FilePath::StringType>::const_iterator i = components.begin(); i != components.end(); i++) { - if (*i == FilePath::kParentDirectory) { + if (*i == base::FilePath::kParentDirectory) { depth--; - } else if (*i != FilePath::kCurrentDirectory) { + } else if (*i != base::FilePath::kCurrentDirectory) { depth++; } if (depth < 0) { - return FilePath(); + return base::FilePath(); } } } @@ -90,17 +90,17 @@ FilePath ExtensionResource::GetFilePath( return full_path; } - return FilePath(); + return base::FilePath(); } // Unit-testing helpers. -FilePath::StringType ExtensionResource::NormalizeSeperators( - const FilePath::StringType& path) const { +base::FilePath::StringType ExtensionResource::NormalizeSeperators( + const base::FilePath::StringType& path) const { #if defined(FILE_PATH_USES_WIN_SEPARATORS) - FilePath::StringType win_path = path; + base::FilePath::StringType win_path = path; for (size_t i = 0; i < win_path.length(); i++) { - if (FilePath::IsSeparator(win_path[i])) - win_path[i] = FilePath::kSeparators[0]; + if (base::FilePath::IsSeparator(win_path[i])) + win_path[i] = base::FilePath::kSeparators[0]; } return win_path; #else @@ -108,7 +108,8 @@ FilePath::StringType ExtensionResource::NormalizeSeperators( #endif // FILE_PATH_USES_WIN_SEPARATORS } -bool ExtensionResource::ComparePathWithDefault(const FilePath& path) const { +bool ExtensionResource::ComparePathWithDefault( + const base::FilePath& path) const { // Make sure we have a cached value to test against... if (full_resource_path_.empty()) GetFilePath(); diff --git a/chrome/common/extensions/extension_resource.h b/chrome/common/extensions/extension_resource.h index 36d8218..be69ac8 100644 --- a/chrome/common/extensions/extension_resource.h +++ b/chrome/common/extensions/extension_resource.h @@ -25,8 +25,8 @@ class ExtensionResource { ExtensionResource(); ExtensionResource(const std::string& extension_id, - const FilePath& extension_root, - const FilePath& relative_path); + const base::FilePath& extension_root, + const base::FilePath& relative_path); ~ExtensionResource(); @@ -38,7 +38,7 @@ class ExtensionResource { // Returns actual path to the resource (default or locale specific). In the // browser process, this will DCHECK if not called on the file thread. To // easily load extension images on the UI thread, see ImageLoadingTracker. - const FilePath& GetFilePath() const; + const base::FilePath& GetFilePath() const; // Gets the physical file path for the extension resource, taking into account // localization. In the browser process, this will DCHECK if not called on the @@ -48,38 +48,38 @@ class ExtensionResource { // The relative path must not resolve to a location outside of // |extension_root|. Iff |file_can_symlink_outside_root| is true, then the // file can be a symlink that links outside of |extension_root|. - static FilePath GetFilePath(const FilePath& extension_root, - const FilePath& relative_path, - SymlinkPolicy symlink_policy); + static base::FilePath GetFilePath(const base::FilePath& extension_root, + const base::FilePath& relative_path, + SymlinkPolicy symlink_policy); // Getters const std::string& extension_id() const { return extension_id_; } - const FilePath& extension_root() const { return extension_root_; } - const FilePath& relative_path() const { return relative_path_; } + const base::FilePath& extension_root() const { return extension_root_; } + const base::FilePath& relative_path() const { return relative_path_; } bool empty() const { return extension_root().empty(); } // Unit test helpers. - FilePath::StringType NormalizeSeperators( - const FilePath::StringType& path) const; - bool ComparePathWithDefault(const FilePath& path) const; + base::FilePath::StringType NormalizeSeperators( + const base::FilePath::StringType& path) const; + bool ComparePathWithDefault(const base::FilePath& path) const; private: // The id of the extension that this resource is associated with. std::string extension_id_; // Extension root. - FilePath extension_root_; + base::FilePath extension_root_; // Relative path to resource. - FilePath relative_path_; + base::FilePath relative_path_; // If |follow_symlinks_anywhere_| is true then the resource itself must be // within |extension_root|, but it can be a symlink to a file that is not. bool follow_symlinks_anywhere_; // Full path to extension resource. Starts empty. - mutable FilePath full_resource_path_; + mutable base::FilePath full_resource_path_; }; #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_RESOURCE_H_ diff --git a/chrome/common/extensions/extension_resource_unittest.cc b/chrome/common/extensions/extension_resource_unittest.cc index feadc6c..02ef7d1 100644 --- a/chrome/common/extensions/extension_resource_unittest.cc +++ b/chrome/common/extensions/extension_resource_unittest.cc @@ -23,16 +23,17 @@ TEST(ExtensionResourceTest, CreateEmptyResource) { EXPECT_TRUE(resource.GetFilePath().empty()); } -const FilePath::StringType ToLower(const FilePath::StringType& in_str) { - FilePath::StringType str(in_str); +const base::FilePath::StringType ToLower( + const base::FilePath::StringType& in_str) { + base::FilePath::StringType str(in_str); std::transform(str.begin(), str.end(), str.begin(), tolower); return str; } TEST(ExtensionResourceTest, CreateWithMissingResourceOnDisk) { - FilePath root_path; + base::FilePath root_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &root_path)); - FilePath relative_path; + base::FilePath relative_path; relative_path = relative_path.AppendASCII("cira.js"); std::string extension_id = extension_test_util::MakeId("test"); ExtensionResource resource(extension_id, root_path, relative_path); @@ -47,44 +48,44 @@ TEST(ExtensionResourceTest, ResourcesOutsideOfPath) { base::ScopedTempDir temp; ASSERT_TRUE(temp.CreateUniqueTempDir()); - FilePath inner_dir = temp.path().AppendASCII("directory"); + base::FilePath inner_dir = temp.path().AppendASCII("directory"); ASSERT_TRUE(file_util::CreateDirectory(inner_dir)); - FilePath sub_dir = inner_dir.AppendASCII("subdir"); + base::FilePath sub_dir = inner_dir.AppendASCII("subdir"); ASSERT_TRUE(file_util::CreateDirectory(sub_dir)); - FilePath inner_file = inner_dir.AppendASCII("inner"); - FilePath outer_file = temp.path().AppendASCII("outer"); + base::FilePath inner_file = inner_dir.AppendASCII("inner"); + base::FilePath outer_file = temp.path().AppendASCII("outer"); ASSERT_TRUE(file_util::WriteFile(outer_file, "X", 1)); ASSERT_TRUE(file_util::WriteFile(inner_file, "X", 1)); std::string extension_id = extension_test_util::MakeId("test"); #if defined(OS_POSIX) - FilePath symlink_file = inner_dir.AppendASCII("symlink"); + base::FilePath symlink_file = inner_dir.AppendASCII("symlink"); file_util::CreateSymbolicLink( - FilePath().AppendASCII("..").AppendASCII("outer"), + base::FilePath().AppendASCII("..").AppendASCII("outer"), symlink_file); #endif // A non-packing extension should be able to access the file within the // directory. ExtensionResource r1(extension_id, inner_dir, - FilePath().AppendASCII("inner")); + base::FilePath().AppendASCII("inner")); EXPECT_FALSE(r1.GetFilePath().empty()); // ... but not a relative path that walks out of |inner_dir|. ExtensionResource r2(extension_id, inner_dir, - FilePath().AppendASCII("..").AppendASCII("outer")); + base::FilePath().AppendASCII("..").AppendASCII("outer")); EXPECT_TRUE(r2.GetFilePath().empty()); // A packing extension should also be able to access the file within the // directory. ExtensionResource r3(extension_id, inner_dir, - FilePath().AppendASCII("inner")); + base::FilePath().AppendASCII("inner")); r3.set_follow_symlinks_anywhere(); EXPECT_FALSE(r3.GetFilePath().empty()); // ... but, again, not a relative path that walks out of |inner_dir|. ExtensionResource r4(extension_id, inner_dir, - FilePath().AppendASCII("..").AppendASCII("outer")); + base::FilePath().AppendASCII("..").AppendASCII("outer")); r4.set_follow_symlinks_anywhere(); EXPECT_TRUE(r4.GetFilePath().empty()); @@ -93,7 +94,7 @@ TEST(ExtensionResourceTest, ResourcesOutsideOfPath) { // component due to quirks in FilePath::Append(), and the path must exist. ExtensionResource r4a( extension_id, inner_dir, - FilePath().AppendASCII("subdir").AppendASCII(".").AppendASCII(".."). + base::FilePath().AppendASCII("subdir").AppendASCII(".").AppendASCII(".."). AppendASCII("..").AppendASCII("outer")); r4a.set_follow_symlinks_anywhere(); EXPECT_TRUE(r4a.GetFilePath().empty()); @@ -102,12 +103,12 @@ TEST(ExtensionResourceTest, ResourcesOutsideOfPath) { // The non-packing extension should also not be able to access a resource that // symlinks out of the directory. ExtensionResource r5(extension_id, inner_dir, - FilePath().AppendASCII("symlink")); + base::FilePath().AppendASCII("symlink")); EXPECT_TRUE(r5.GetFilePath().empty()); // ... but a packing extension can. ExtensionResource r6(extension_id, inner_dir, - FilePath().AppendASCII("symlink")); + base::FilePath().AppendASCII("symlink")); r6.set_follow_symlinks_anywhere(); EXPECT_FALSE(r6.GetFilePath().empty()); #endif @@ -123,32 +124,33 @@ TEST(ExtensionResourceTest, CreateWithAllResourcesOnDisk) { // Create resource in the extension root. const char* filename = "res.ico"; - FilePath root_resource = temp.path().AppendASCII(filename); + base::FilePath root_resource = temp.path().AppendASCII(filename); std::string data = "some foo"; ASSERT_TRUE(file_util::WriteFile(root_resource, data.c_str(), data.length())); // Create l10n resources (for current locale and its parents). - FilePath l10n_path = temp.path().Append(extensions::Extension::kLocaleFolder); + base::FilePath l10n_path = + temp.path().Append(extensions::Extension::kLocaleFolder); ASSERT_TRUE(file_util::CreateDirectory(l10n_path)); std::vector<std::string> locales; l10n_util::GetParentLocales(l10n_util::GetApplicationLocale(""), &locales); ASSERT_FALSE(locales.empty()); for (size_t i = 0; i < locales.size(); i++) { - FilePath make_path; + base::FilePath make_path; make_path = l10n_path.AppendASCII(locales[i]); ASSERT_TRUE(file_util::CreateDirectory(make_path)); ASSERT_TRUE(file_util::WriteFile(make_path.AppendASCII(filename), data.c_str(), data.length())); } - FilePath path; + base::FilePath path; std::string extension_id = extension_test_util::MakeId("test"); ExtensionResource resource(extension_id, temp.path(), - FilePath().AppendASCII(filename)); - FilePath resolved_path = resource.GetFilePath(); + base::FilePath().AppendASCII(filename)); + base::FilePath resolved_path = resource.GetFilePath(); - FilePath expected_path; + base::FilePath expected_path; // Expect default path only, since fallback logic is disabled. // See http://crbug.com/27359. expected_path = root_resource; @@ -157,6 +159,6 @@ TEST(ExtensionResourceTest, CreateWithAllResourcesOnDisk) { EXPECT_EQ(ToLower(expected_path.value()), ToLower(resolved_path.value())); EXPECT_EQ(ToLower(temp.path().value()), ToLower(resource.extension_root().value())); - EXPECT_EQ(ToLower(FilePath().AppendASCII(filename).value()), + EXPECT_EQ(ToLower(base::FilePath().AppendASCII(filename).value()), ToLower(resource.relative_path().value())); } diff --git a/chrome/common/extensions/extension_set.h b/chrome/common/extensions/extension_set.h index 2cc553e..a34b8c7 100644 --- a/chrome/common/extensions/extension_set.h +++ b/chrome/common/extensions/extension_set.h @@ -41,7 +41,7 @@ class ExtensionURLInfo { // Only one extension can be in the set with a given ID. class ExtensionSet { public: - typedef std::pair<FilePath, std::string> ExtensionPathAndDefaultLocale; + typedef std::pair<base::FilePath, std::string> ExtensionPathAndDefaultLocale; typedef std::map<std::string, scoped_refptr<const extensions::Extension> > ExtensionMap; diff --git a/chrome/common/extensions/extension_set_unittest.cc b/chrome/common/extensions/extension_set_unittest.cc index ba2649b..2d28e65 100644 --- a/chrome/common/extensions/extension_set_unittest.cc +++ b/chrome/common/extensions/extension_set_unittest.cc @@ -19,9 +19,9 @@ scoped_refptr<Extension> CreateTestExtension(const std::string& name, const std::string& launch_url, const std::string& extent) { #if defined(OS_WIN) - FilePath path(FILE_PATH_LITERAL("c:\\")); + base::FilePath path(FILE_PATH_LITERAL("c:\\")); #else - FilePath path(FILE_PATH_LITERAL("/")); + base::FilePath path(FILE_PATH_LITERAL("/")); #endif path = path.AppendASCII(name); diff --git a/chrome/common/extensions/extension_test_util.cc b/chrome/common/extensions/extension_test_util.cc index 97f9d96..257b2e7 100644 --- a/chrome/common/extensions/extension_test_util.cc +++ b/chrome/common/extensions/extension_test_util.cc @@ -26,8 +26,8 @@ scoped_refptr<Extension> CreateExtensionWithID(std::string id) { values.SetString(extension_manifest_keys::kName, "test"); values.SetString(extension_manifest_keys::kVersion, "0.1"); std::string error; - return Extension::Create(FilePath(), extensions::Manifest::INTERNAL, values, - Extension::NO_FLAGS, id, &error); + return Extension::Create(base::FilePath(), extensions::Manifest::INTERNAL, + values, Extension::NO_FLAGS, id, &error); } } // namespace extension_test_util diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc index 9eec106..5f5c404 100644 --- a/chrome/common/extensions/extension_unittest.cc +++ b/chrome/common/extensions/extension_unittest.cc @@ -51,7 +51,7 @@ scoped_refptr<Extension> LoadManifestUnchecked( Manifest::Location location, int extra_flags, std::string* error) { - FilePath path; + base::FilePath path; PathService::Get(chrome::DIR_TEST_DATA, &path); path = path.AppendASCII("extensions") .AppendASCII(dir) @@ -363,7 +363,7 @@ TEST_F(ExtensionTest, GenerateID) { // This test ensures that the mimetype sniffing code stays in sync with the // actual crx files that we test other parts of the system with. TEST_F(ExtensionTest, MimeTypeSniffing) { - FilePath path; + base::FilePath path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); path = path.AppendASCII("extensions").AppendASCII("good.crx"); @@ -509,7 +509,7 @@ static bool SizeEquals(const SkBitmap& bitmap, const gfx::Size& size) { } TEST_F(ExtensionTest, ImageCaching) { - FilePath path; + base::FilePath path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); path = path.AppendASCII("extensions"); @@ -523,13 +523,14 @@ TEST_F(ExtensionTest, ImageCaching) { ASSERT_TRUE(extension.get()); // Create an ExtensionResource pointing at an icon. - FilePath icon_relative_path(FILE_PATH_LITERAL("icon3.png")); + base::FilePath icon_relative_path(FILE_PATH_LITERAL("icon3.png")); ExtensionResource resource(extension->id(), extension->path(), icon_relative_path); // Read in the icon file. - FilePath icon_absolute_path = extension->path().Append(icon_relative_path); + base::FilePath icon_absolute_path = + extension->path().Append(icon_relative_path); std::string raw_png; ASSERT_TRUE(file_util::ReadFileToString(icon_absolute_path, &raw_png)); SkBitmap image; @@ -774,7 +775,8 @@ class ExtensionScriptAndCaptureVisibleTest : public testing::Test { file_url("file:///foo/bar"), favicon_url("chrome://favicon/http://www.google.com"), extension_url("chrome-extension://" + - Extension::GenerateIdForPath(FilePath(FILE_PATH_LITERAL("foo")))), + Extension::GenerateIdForPath( + base::FilePath(FILE_PATH_LITERAL("foo")))), settings_url("chrome://settings"), about_url("about:flags") { urls_.insert(http_url); @@ -1061,7 +1063,7 @@ static scoped_refptr<Extension> MakeSyncTestExtension( const GURL& launch_url, Manifest::Location location, int num_plugins, - const FilePath& extension_path, + const base::FilePath& extension_path, int creation_flags) { DictionaryValue source; source.SetString(extension_manifest_keys::kName, @@ -1108,7 +1110,7 @@ static const char kValidUpdateUrl2[] = TEST_F(ExtensionTest, GetSyncTypeNormalExtensionNoUpdateUrl) { scoped_refptr<Extension> extension( MakeSyncTestExtension(EXTENSION, GURL(), GURL(), - Manifest::INTERNAL, 0, FilePath(), + Manifest::INTERNAL, 0, base::FilePath(), Extension::NO_FLAGS)); EXPECT_NE(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); } @@ -1117,7 +1119,7 @@ TEST_F(ExtensionTest, GetSyncTypeNormalExtensionNoUpdateUrl) { TEST_F(ExtensionTest, DISABLED_GetSyncTypeUserScriptValidUpdateUrl) { scoped_refptr<Extension> extension( MakeSyncTestExtension(USER_SCRIPT, GURL(kValidUpdateUrl1), GURL(), - Manifest::INTERNAL, 0, FilePath(), + Manifest::INTERNAL, 0, base::FilePath(), Extension::NO_FLAGS)); EXPECT_NE(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); } @@ -1125,7 +1127,7 @@ TEST_F(ExtensionTest, DISABLED_GetSyncTypeUserScriptValidUpdateUrl) { TEST_F(ExtensionTest, GetSyncTypeUserScriptNoUpdateUrl) { scoped_refptr<Extension> extension( MakeSyncTestExtension(USER_SCRIPT, GURL(), GURL(), - Manifest::INTERNAL, 0, FilePath(), + Manifest::INTERNAL, 0, base::FilePath(), Extension::NO_FLAGS)); EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); } @@ -1133,7 +1135,7 @@ TEST_F(ExtensionTest, GetSyncTypeUserScriptNoUpdateUrl) { TEST_F(ExtensionTest, GetSyncTypeThemeNoUpdateUrl) { scoped_refptr<Extension> extension( MakeSyncTestExtension(THEME, GURL(), GURL(), - Manifest::INTERNAL, 0, FilePath(), + Manifest::INTERNAL, 0, base::FilePath(), Extension::NO_FLAGS)); EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); } @@ -1141,7 +1143,7 @@ TEST_F(ExtensionTest, GetSyncTypeThemeNoUpdateUrl) { TEST_F(ExtensionTest, GetSyncTypeExtensionWithLaunchUrl) { scoped_refptr<Extension> extension( MakeSyncTestExtension(EXTENSION, GURL(), GURL("http://www.google.com"), - Manifest::INTERNAL, 0, FilePath(), + Manifest::INTERNAL, 0, base::FilePath(), Extension::NO_FLAGS)); EXPECT_NE(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); } @@ -1149,7 +1151,7 @@ TEST_F(ExtensionTest, GetSyncTypeExtensionWithLaunchUrl) { TEST_F(ExtensionTest, GetSyncTypeExtensionExternal) { scoped_refptr<Extension> extension( MakeSyncTestExtension(EXTENSION, GURL(), GURL(), - Manifest::EXTERNAL_PREF, 0, FilePath(), + Manifest::EXTERNAL_PREF, 0, base::FilePath(), Extension::NO_FLAGS)); EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); @@ -1159,14 +1161,14 @@ TEST_F(ExtensionTest, GetSyncTypeUserScriptThirdPartyUpdateUrl) { scoped_refptr<Extension> extension( MakeSyncTestExtension( USER_SCRIPT, GURL("http://third-party.update_url.com"), GURL(), - Manifest::INTERNAL, 0, FilePath(), Extension::NO_FLAGS)); + Manifest::INTERNAL, 0, base::FilePath(), Extension::NO_FLAGS)); EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); } TEST_F(ExtensionTest, OnlyDisplayAppsInLauncher) { scoped_refptr<Extension> extension( MakeSyncTestExtension(EXTENSION, GURL(), GURL(), - Manifest::INTERNAL, 0, FilePath(), + Manifest::INTERNAL, 0, base::FilePath(), Extension::NO_FLAGS)); EXPECT_FALSE(extension->ShouldDisplayInAppLauncher()); @@ -1174,7 +1176,7 @@ TEST_F(ExtensionTest, OnlyDisplayAppsInLauncher) { scoped_refptr<Extension> app( MakeSyncTestExtension(APP, GURL(), GURL("http://www.google.com"), - Manifest::INTERNAL, 0, FilePath(), + Manifest::INTERNAL, 0, base::FilePath(), Extension::NO_FLAGS)); EXPECT_TRUE(app->ShouldDisplayInAppLauncher()); EXPECT_TRUE(app->ShouldDisplayInNewTabPage()); @@ -1192,7 +1194,7 @@ TEST_F(ExtensionTest, DisplayInXManifestProperties) { // Default to true. app = Extension::Create( - FilePath(), Manifest::COMPONENT, manifest, 0, &error); + base::FilePath(), Manifest::COMPONENT, manifest, 0, &error); EXPECT_EQ(error, std::string()); EXPECT_TRUE(app->ShouldDisplayInAppLauncher()); EXPECT_TRUE(app->ShouldDisplayInNewTabPage()); @@ -1200,7 +1202,7 @@ TEST_F(ExtensionTest, DisplayInXManifestProperties) { // Value display_in_NTP defaults to display_in_launcher. manifest.SetBoolean(keys::kDisplayInLauncher, false); app = Extension::Create( - FilePath(), Manifest::COMPONENT, manifest, 0, &error); + base::FilePath(), Manifest::COMPONENT, manifest, 0, &error); EXPECT_EQ(error, std::string()); EXPECT_FALSE(app->ShouldDisplayInAppLauncher()); EXPECT_FALSE(app->ShouldDisplayInNewTabPage()); @@ -1208,7 +1210,7 @@ TEST_F(ExtensionTest, DisplayInXManifestProperties) { // Value display_in_NTP = true overriding display_in_launcher = false. manifest.SetBoolean(keys::kDisplayInNewTabPage, true); app = Extension::Create( - FilePath(), Manifest::COMPONENT, manifest, 0, &error); + base::FilePath(), Manifest::COMPONENT, manifest, 0, &error); EXPECT_EQ(error, std::string()); EXPECT_FALSE(app->ShouldDisplayInAppLauncher()); EXPECT_TRUE(app->ShouldDisplayInNewTabPage()); @@ -1217,7 +1219,7 @@ TEST_F(ExtensionTest, DisplayInXManifestProperties) { manifest.Remove(keys::kDisplayInLauncher, NULL); manifest.SetBoolean(keys::kDisplayInNewTabPage, false); app = Extension::Create( - FilePath(), Manifest::COMPONENT, manifest, 0, &error); + base::FilePath(), Manifest::COMPONENT, manifest, 0, &error); EXPECT_EQ(error, std::string()); EXPECT_TRUE(app->ShouldDisplayInAppLauncher()); EXPECT_FALSE(app->ShouldDisplayInNewTabPage()); @@ -1225,20 +1227,20 @@ TEST_F(ExtensionTest, DisplayInXManifestProperties) { // Error checking. manifest.SetString(keys::kDisplayInNewTabPage, "invalid"); app = Extension::Create( - FilePath(), Manifest::COMPONENT, manifest, 0, &error); + base::FilePath(), Manifest::COMPONENT, manifest, 0, &error); EXPECT_EQ(error, std::string(errors::kInvalidDisplayInNewTabPage)); } TEST_F(ExtensionTest, OnlySyncInternal) { scoped_refptr<Extension> extension_internal( MakeSyncTestExtension(EXTENSION, GURL(), GURL(), - Manifest::INTERNAL, 0, FilePath(), + Manifest::INTERNAL, 0, base::FilePath(), Extension::NO_FLAGS)); EXPECT_TRUE(extension_internal->IsSyncable()); scoped_refptr<Extension> extension_noninternal( MakeSyncTestExtension(EXTENSION, GURL(), GURL(), - Manifest::COMPONENT, 0, FilePath(), + Manifest::COMPONENT, 0, base::FilePath(), Extension::NO_FLAGS)); EXPECT_FALSE(extension_noninternal->IsSyncable()); } @@ -1246,7 +1248,7 @@ TEST_F(ExtensionTest, OnlySyncInternal) { TEST_F(ExtensionTest, DontSyncDefault) { scoped_refptr<Extension> extension_default( MakeSyncTestExtension(EXTENSION, GURL(), GURL(), - Manifest::INTERNAL, 0, FilePath(), + Manifest::INTERNAL, 0, base::FilePath(), Extension::WAS_INSTALLED_BY_DEFAULT)); EXPECT_FALSE(extension_default->IsSyncable()); } @@ -1282,7 +1284,7 @@ TEST_F(ExtensionTest, OptionalOnlyPermission) { TEST_F(ExtensionTest, GetSyncTypeExtensionWithPlugin) { scoped_refptr<Extension> extension( MakeSyncTestExtension(EXTENSION, GURL(), GURL(), - Manifest::INTERNAL, 1, FilePath(), + Manifest::INTERNAL, 1, base::FilePath(), Extension::NO_FLAGS)); if (extension) EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); @@ -1291,7 +1293,7 @@ TEST_F(ExtensionTest, GetSyncTypeExtensionWithPlugin) { TEST_F(ExtensionTest, GetSyncTypeExtensionWithTwoPlugins) { scoped_refptr<Extension> extension( MakeSyncTestExtension(EXTENSION, GURL(), GURL(), - Manifest::INTERNAL, 2, FilePath(), + Manifest::INTERNAL, 2, base::FilePath(), Extension::NO_FLAGS)); if (extension) EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); diff --git a/chrome/common/extensions/features/base_feature_provider_unittest.cc b/chrome/common/extensions/features/base_feature_provider_unittest.cc index 9eea06e5..fd0a6b4 100644 --- a/chrome/common/extensions/features/base_feature_provider_unittest.cc +++ b/chrome/common/extensions/features/base_feature_provider_unittest.cc @@ -38,7 +38,7 @@ TEST(BaseFeatureProvider, ManifestFeatures) { std::string error; scoped_refptr<const Extension> extension(Extension::Create( - FilePath(), Manifest::INTERNAL, manifest, Extension::NO_FLAGS, + base::FilePath(), Manifest::INTERNAL, manifest, Extension::NO_FLAGS, &error)); ASSERT_TRUE(extension.get()); @@ -80,7 +80,7 @@ TEST(BaseFeatureProvider, PermissionFeatures) { std::string error; scoped_refptr<const Extension> extension(Extension::Create( - FilePath(), Manifest::INTERNAL, manifest, Extension::NO_FLAGS, + base::FilePath(), Manifest::INTERNAL, manifest, Extension::NO_FLAGS, &error)); ASSERT_TRUE(extension.get()); diff --git a/chrome/common/extensions/features/simple_feature_unittest.cc b/chrome/common/extensions/features/simple_feature_unittest.cc index dff44dd..f8338cd 100644 --- a/chrome/common/extensions/features/simple_feature_unittest.cc +++ b/chrome/common/extensions/features/simple_feature_unittest.cc @@ -135,7 +135,8 @@ TEST_F(ExtensionSimpleFeatureTest, Context) { std::string error; scoped_refptr<const Extension> extension(Extension::Create( - FilePath(), Manifest::INTERNAL, manifest, Extension::NO_FLAGS, &error)); + base::FilePath(), Manifest::INTERNAL, manifest, Extension::NO_FLAGS, + &error)); EXPECT_EQ("", error); ASSERT_TRUE(extension.get()); diff --git a/chrome/common/extensions/manifest_handler_unittest.cc b/chrome/common/extensions/manifest_handler_unittest.cc index 83116c2..d1bbd68 100644 --- a/chrome/common/extensions/manifest_handler_unittest.cc +++ b/chrome/common/extensions/manifest_handler_unittest.cc @@ -164,7 +164,7 @@ TEST_F(ManifestHandlerTest, FailingHandlers) { // Succeeds when "a" is not recognized. std::string error; scoped_refptr<Extension> extension = Extension::Create( - FilePath(), + base::FilePath(), Manifest::INVALID_LOCATION, *manifest_a, Extension::NO_FLAGS, @@ -178,7 +178,7 @@ TEST_F(ManifestHandlerTest, FailingHandlers) { "A", std::vector<std::string>(), &watcher))); extension = Extension::Create( - FilePath(), + base::FilePath(), Manifest::INVALID_LOCATION, *manifest_a, Extension::NO_FLAGS, diff --git a/chrome/common/extensions/manifest_tests/extension_manifest_test.cc b/chrome/common/extensions/manifest_tests/extension_manifest_test.cc index 2e12386..63315e9 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifest_test.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifest_test.cc @@ -29,9 +29,9 @@ void ExtensionManifestTest::SetUp() { DictionaryValue* ExtensionManifestTest::LoadManifestFile( const std::string& filename, std::string* error) { - FilePath filename_path(FilePath::FromUTF8Unsafe(filename)); - FilePath extension_path; - FilePath manifest_path; + base::FilePath filename_path(base::FilePath::FromUTF8Unsafe(filename)); + base::FilePath extension_path; + base::FilePath manifest_path; if (filename_path.IsAbsolute()) { extension_path = filename_path.DirName(); @@ -98,7 +98,7 @@ scoped_refptr<Extension> ExtensionManifestTest::LoadExtension( DictionaryValue* value = manifest.GetManifest(error); if (!value) return NULL; - FilePath path; + base::FilePath path; PathService::Get(chrome::DIR_TEST_DATA, &path); path = path.AppendASCII("extensions").AppendASCII("manifest_tests"); return Extension::Create(path.DirName(), location, *value, flags, error); diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc index ed658be..b134167 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc @@ -88,7 +88,7 @@ TEST_F(InitValueManifestTest, InitFromValueValid) { scoped_refptr<extensions::Extension> extension(LoadAndExpectSuccess( "init_valid_minimal.json")); - FilePath path; + base::FilePath path; PathService::Get(chrome::DIR_TEST_DATA, &path); path = path.AppendASCII("extensions"); diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc index 135de36..84c96f2 100644 --- a/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc +++ b/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc @@ -121,7 +121,7 @@ TEST_F(ExtensionManifestTest, CertainApisRequirePlatformApps) { // Each of these files lives in the scoped temp directory, so it will be // cleaned up at test teardown. - FilePath file_path = temp_dir.path().AppendASCII(api_name); + base::FilePath file_path = temp_dir.path().AppendASCII(api_name); JSONFileValueSerializer serializer(file_path); serializer.Serialize(*(manifest.get())); } @@ -129,7 +129,7 @@ TEST_F(ExtensionManifestTest, CertainApisRequirePlatformApps) { // First try to load without any flags. This should fail for every API. for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { const char* api_name = kPlatformAppExperimentalApis[i]; - FilePath file_path = temp_dir.path().AppendASCII(api_name); + base::FilePath file_path = temp_dir.path().AppendASCII(api_name); LoadAndExpectError(file_path.MaybeAsASCII().c_str(), errors::kExperimentalFlagRequired); } @@ -139,7 +139,7 @@ TEST_F(ExtensionManifestTest, CertainApisRequirePlatformApps) { switches::kEnableExperimentalExtensionApis); for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { const char* api_name = kPlatformAppExperimentalApis[i]; - FilePath file_path = temp_dir.path().AppendASCII(api_name); + base::FilePath file_path = temp_dir.path().AppendASCII(api_name); LoadAndExpectSuccess(file_path.MaybeAsASCII().c_str()); } } diff --git a/chrome/common/extensions/permissions/permission_set_unittest.cc b/chrome/common/extensions/permissions/permission_set_unittest.cc index 94c9455..5b87774 100644 --- a/chrome/common/extensions/permissions/permission_set_unittest.cc +++ b/chrome/common/extensions/permissions/permission_set_unittest.cc @@ -31,7 +31,7 @@ namespace { scoped_refptr<Extension> LoadManifest(const std::string& dir, const std::string& test_file, int extra_flags) { - FilePath path; + base::FilePath path; PathService::Get(chrome::DIR_TEST_DATA, &path); path = path.AppendASCII("extensions") .AppendASCII(dir) diff --git a/chrome/common/extensions/unpacker.cc b/chrome/common/extensions/unpacker.cc index 41bf772..234ec30 100644 --- a/chrome/common/extensions/unpacker.cc +++ b/chrome/common/extensions/unpacker.cc @@ -40,7 +40,7 @@ namespace { // A limit to stop us passing dangerously large canvases to the browser. const int kMaxImageCanvas = 4096 * 4096; -SkBitmap DecodeImage(const FilePath& path) { +SkBitmap DecodeImage(const base::FilePath& path) { // Read the file from disk. std::string file_contents; if (!file_util::PathExists(path) || @@ -59,11 +59,12 @@ SkBitmap DecodeImage(const FilePath& path) { return bitmap; } -bool PathContainsParentDirectory(const FilePath& path) { - const FilePath::StringType kSeparators(FilePath::kSeparators); - const FilePath::StringType kParentDirectory(FilePath::kParentDirectory); - const size_t npos = FilePath::StringType::npos; - const FilePath::StringType& value = path.value(); +bool PathContainsParentDirectory(const base::FilePath& path) { + const base::FilePath::StringType kSeparators(base::FilePath::kSeparators); + const base::FilePath::StringType kParentDirectory( + base::FilePath::kParentDirectory); + const size_t npos = base::FilePath::StringType::npos; + const base::FilePath::StringType& value = path.value(); for (size_t i = 0; i < value.length(); ) { i = value.find(kParentDirectory, i); @@ -83,7 +84,7 @@ bool PathContainsParentDirectory(const FilePath& path) { namespace extensions { -Unpacker::Unpacker(const FilePath& extension_path, +Unpacker::Unpacker(const base::FilePath& extension_path, const std::string& extension_id, Manifest::Location location, int creation_flags) @@ -97,7 +98,7 @@ Unpacker::~Unpacker() { } DictionaryValue* Unpacker::ReadManifest() { - FilePath manifest_path = + base::FilePath manifest_path = temp_install_dir_.Append(Extension::kManifestFilename); if (!file_util::PathExists(manifest_path)) { SetError(errors::kInvalidManifest); @@ -121,7 +122,7 @@ DictionaryValue* Unpacker::ReadManifest() { } bool Unpacker::ReadAllMessageCatalogs(const std::string& default_locale) { - FilePath locales_path = + base::FilePath locales_path = temp_install_dir_.Append(Extension::kLocaleFolder); // Not all folders under _locales have to be valid locales. @@ -131,13 +132,13 @@ bool Unpacker::ReadAllMessageCatalogs(const std::string& default_locale) { std::set<std::string> all_locales; extension_l10n_util::GetAllLocales(&all_locales); - FilePath locale_path; + base::FilePath locale_path; while (!(locale_path = locales.Next()).empty()) { if (extension_l10n_util::ShouldSkipValidation(locales_path, locale_path, all_locales)) continue; - FilePath messages_path = + base::FilePath messages_path = locale_path.Append(Extension::kMessagesFilename); if (!ReadMessageCatalog(messages_path)) @@ -195,8 +196,8 @@ bool Unpacker::Run() { extension->AddInstallWarnings(warnings); // Decode any images that the browser needs to display. - std::set<FilePath> image_paths = extension->GetBrowserImages(); - for (std::set<FilePath>::iterator it = image_paths.begin(); + std::set<base::FilePath> image_paths = extension->GetBrowserImages(); + for (std::set<base::FilePath>::iterator it = image_paths.begin(); it != image_paths.end(); ++it) { if (!AddDecodedImage(*it)) return false; // Error was already reported. @@ -216,7 +217,7 @@ bool Unpacker::DumpImagesToFile() { IPC::Message pickle; // We use a Message so we can use WriteParam. IPC::WriteParam(&pickle, decoded_images_); - FilePath path = extension_path_.DirName().AppendASCII( + base::FilePath path = extension_path_.DirName().AppendASCII( filenames::kDecodedImagesFilename); if (!file_util::WriteFile(path, static_cast<const char*>(pickle.data()), pickle.size())) { @@ -231,7 +232,7 @@ bool Unpacker::DumpMessageCatalogsToFile() { IPC::Message pickle; IPC::WriteParam(&pickle, *parsed_catalogs_.get()); - FilePath path = extension_path_.DirName().AppendASCII( + base::FilePath path = extension_path_.DirName().AppendASCII( filenames::kDecodedMessageCatalogsFilename); if (!file_util::WriteFile(path, static_cast<const char*>(pickle.data()), pickle.size())) { @@ -243,9 +244,10 @@ bool Unpacker::DumpMessageCatalogsToFile() { } // static -bool Unpacker::ReadImagesFromFile(const FilePath& extension_path, +bool Unpacker::ReadImagesFromFile(const base::FilePath& extension_path, DecodedImages* images) { - FilePath path = extension_path.AppendASCII(filenames::kDecodedImagesFilename); + base::FilePath path = + extension_path.AppendASCII(filenames::kDecodedImagesFilename); std::string file_str; if (!file_util::ReadFileToString(path, &file_str)) return false; @@ -256,9 +258,9 @@ bool Unpacker::ReadImagesFromFile(const FilePath& extension_path, } // static -bool Unpacker::ReadMessageCatalogsFromFile(const FilePath& extension_path, +bool Unpacker::ReadMessageCatalogsFromFile(const base::FilePath& extension_path, DictionaryValue* catalogs) { - FilePath path = extension_path.AppendASCII( + base::FilePath path = extension_path.AppendASCII( filenames::kDecodedMessageCatalogsFilename); std::string file_str; if (!file_util::ReadFileToString(path, &file_str)) @@ -269,7 +271,7 @@ bool Unpacker::ReadMessageCatalogsFromFile(const FilePath& extension_path, return IPC::ReadParam(&pickle, &iter, catalogs); } -bool Unpacker::AddDecodedImage(const FilePath& path) { +bool Unpacker::AddDecodedImage(const base::FilePath& path) { // Make sure it's not referencing a file outside the extension's subdir. if (path.IsAbsolute() || PathContainsParentDirectory(path)) { SetUTF16Error( @@ -294,7 +296,7 @@ bool Unpacker::AddDecodedImage(const FilePath& path) { return true; } -bool Unpacker::ReadMessageCatalog(const FilePath& message_path) { +bool Unpacker::ReadMessageCatalog(const base::FilePath& message_path) { std::string error; JSONFileValueSerializer serializer(message_path); scoped_ptr<DictionaryValue> root( @@ -313,7 +315,7 @@ bool Unpacker::ReadMessageCatalog(const FilePath& message_path) { return false; } - FilePath relative_path; + base::FilePath relative_path; // message_path was created from temp_install_dir. This should never fail. if (!temp_install_dir_.AppendRelativePath(message_path, &relative_path)) { NOTREACHED(); diff --git a/chrome/common/extensions/unpacker.h b/chrome/common/extensions/unpacker.h index 1c68fdd..b63a325 100644 --- a/chrome/common/extensions/unpacker.h +++ b/chrome/common/extensions/unpacker.h @@ -27,9 +27,9 @@ namespace extensions { // and writes them back out to disk for later use. class Unpacker { public: - typedef std::vector< Tuple2<SkBitmap, FilePath> > DecodedImages; + typedef std::vector< Tuple2<SkBitmap, base::FilePath> > DecodedImages; - Unpacker(const FilePath& extension_path, + Unpacker(const base::FilePath& extension_path, const std::string& extension_id, Manifest::Location location, int creation_flags); @@ -52,13 +52,13 @@ class Unpacker { // Read the decoded images back from the file we saved them to. // |extension_path| is the path to the extension we unpacked that wrote the // data. Returns true on success. - static bool ReadImagesFromFile(const FilePath& extension_path, + static bool ReadImagesFromFile(const base::FilePath& extension_path, DecodedImages* images); // Read the decoded message catalogs back from the file we saved them to. // |extension_path| is the path to the extension we unpacked that wrote the // data. Returns true on success. - static bool ReadMessageCatalogsFromFile(const FilePath& extension_path, + static bool ReadMessageCatalogsFromFile(const base::FilePath& extension_path, base::DictionaryValue* catalogs); const string16& error_message() { return error_message_; } @@ -78,18 +78,18 @@ class Unpacker { // Decodes the image at the given path and puts it in our list of decoded // images. - bool AddDecodedImage(const FilePath& path); + bool AddDecodedImage(const base::FilePath& path); // Parses the catalog at the given path and puts it in our list of parsed // catalogs. - bool ReadMessageCatalog(const FilePath& message_path); + bool ReadMessageCatalog(const base::FilePath& message_path); // Set the error message. void SetError(const std::string& error); void SetUTF16Error(const string16& error); // The extension to unpack. - FilePath extension_path_; + base::FilePath extension_path_; // The extension ID if known. std::string extension_id_; @@ -101,7 +101,7 @@ class Unpacker { int creation_flags_; // The place we unpacked the extension to. - FilePath temp_install_dir_; + base::FilePath temp_install_dir_; // The parsed version of the manifest JSON contained in the extension. scoped_ptr<base::DictionaryValue> parsed_manifest_; diff --git a/chrome/common/extensions/unpacker_unittest.cc b/chrome/common/extensions/unpacker_unittest.cc index a7dd825..8d3e195 100644 --- a/chrome/common/extensions/unpacker_unittest.cc +++ b/chrome/common/extensions/unpacker_unittest.cc @@ -40,7 +40,7 @@ public: } void SetupUnpacker(const std::string& crx_name) { - FilePath original_path; + base::FilePath original_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &original_path)); original_path = original_path.AppendASCII("extensions") .AppendASCII("unpacker") @@ -51,7 +51,7 @@ public: // a temp folder to play in. ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); - FilePath crx_path = temp_dir_.path().AppendASCII(crx_name); + base::FilePath crx_path = temp_dir_.path().AppendASCII(crx_name); ASSERT_TRUE(file_util::CopyFile(original_path, crx_path)) << "Original path " << original_path.value() << ", Crx path " << crx_path.value(); @@ -214,7 +214,8 @@ TEST_F(UnpackerTest, MAYBE_NoL10n) { TEST_F(UnpackerTest, MAYBE_UnzipDirectoryError) { const char* kExpected = "Could not create directory for unzipping: "; SetupUnpacker("good_package.crx"); - FilePath path = temp_dir_.path().AppendASCII(filenames::kTempExtensionName); + base::FilePath path = + temp_dir_.path().AppendASCII(filenames::kTempExtensionName); ASSERT_TRUE(file_util::WriteFile(path, "foo", 3)); EXPECT_FALSE(unpacker_->Run()); EXPECT_TRUE(StartsWith(unpacker_->error_message(), diff --git a/chrome/common/extensions/user_script.cc b/chrome/common/extensions/user_script.cc index 0334e58..dc62066 100644 --- a/chrome/common/extensions/user_script.cc +++ b/chrome/common/extensions/user_script.cc @@ -33,8 +33,8 @@ bool UserScript::IsURLUserScript(const GURL& url, mime_type != "text/html"; } -UserScript::File::File(const FilePath& extension_root, - const FilePath& relative_path, +UserScript::File::File(const base::FilePath& extension_root, + const base::FilePath& relative_path, const GURL& url) : extension_root_(extension_root), relative_path_(relative_path), diff --git a/chrome/common/extensions/user_script.h b/chrome/common/extensions/user_script.h index 6faab4e..df12959 100644 --- a/chrome/common/extensions/user_script.h +++ b/chrome/common/extensions/user_script.h @@ -55,13 +55,14 @@ class UserScript { // Holds actual script file info. class File { public: - File(const FilePath& extension_root, const FilePath& relative_path, + File(const base::FilePath& extension_root, + const base::FilePath& relative_path, const GURL& url); File(); ~File(); - const FilePath& extension_root() const { return extension_root_; } - const FilePath& relative_path() const { return relative_path_; } + const base::FilePath& extension_root() const { return extension_root_; } + const base::FilePath& relative_path() const { return relative_path_; } const GURL& url() const { return url_; } void set_url(const GURL& url) { url_ = url; } @@ -89,8 +90,8 @@ class UserScript { private: // Where the script file lives on the disk. We keep the path split so that // it can be localized at will. - FilePath extension_root_; - FilePath relative_path_; + base::FilePath extension_root_; + base::FilePath relative_path_; // The url to this scipt file. GURL url_; diff --git a/chrome/common/extensions/user_script_unittest.cc b/chrome/common/extensions/user_script_unittest.cc index 323f573..4b97d85 100644 --- a/chrome/common/extensions/user_script_unittest.cc +++ b/chrome/common/extensions/user_script_unittest.cc @@ -170,16 +170,16 @@ TEST(ExtensionUserScriptTest, Pickle) { UserScript script1; script1.js_scripts().push_back(UserScript::File( - FilePath(FILE_PATH_LITERAL("c:\\foo\\")), - FilePath(FILE_PATH_LITERAL("foo.user.js")), + base::FilePath(FILE_PATH_LITERAL("c:\\foo\\")), + base::FilePath(FILE_PATH_LITERAL("foo.user.js")), GURL("chrome-extension://abc/foo.user.js"))); script1.css_scripts().push_back(UserScript::File( - FilePath(FILE_PATH_LITERAL("c:\\foo\\")), - FilePath(FILE_PATH_LITERAL("foo.user.css")), + base::FilePath(FILE_PATH_LITERAL("c:\\foo\\")), + base::FilePath(FILE_PATH_LITERAL("foo.user.css")), GURL("chrome-extension://abc/foo.user.css"))); script1.css_scripts().push_back(UserScript::File( - FilePath(FILE_PATH_LITERAL("c:\\foo\\")), - FilePath(FILE_PATH_LITERAL("foo2.user.css")), + base::FilePath(FILE_PATH_LITERAL("c:\\foo\\")), + base::FilePath(FILE_PATH_LITERAL("foo2.user.css")), GURL("chrome-extension://abc/foo2.user.css"))); script1.set_run_location(UserScript::DOCUMENT_START); |