diff options
93 files changed, 896 insertions, 826 deletions
diff --git a/chrome/common/auto_start_linux.cc b/chrome/common/auto_start_linux.cc index 142086a..d212aaf 100644 --- a/chrome/common/auto_start_linux.cc +++ b/chrome/common/auto_start_linux.cc @@ -13,12 +13,13 @@ namespace { -const FilePath::CharType kAutostart[] = "autostart"; +const base::FilePath::CharType kAutostart[] = "autostart"; -FilePath GetAutostartDirectory(base::Environment* environment) { - FilePath result = base::nix::GetXDGDirectory(environment, - base::nix::kXdgConfigHomeEnvVar, - base::nix::kDotConfigDir); +base::FilePath GetAutostartDirectory(base::Environment* environment) { + base::FilePath result = base::nix::GetXDGDirectory( + environment, + base::nix::kXdgConfigHomeEnvVar, + base::nix::kDotConfigDir); result = result.Append(kAutostart); return result; } @@ -30,13 +31,14 @@ bool AutoStart::AddApplication(const std::string& autostart_filename, const std::string& command_line, bool is_terminal_app) { scoped_ptr<base::Environment> environment(base::Environment::Create()); - FilePath autostart_directory = GetAutostartDirectory(environment.get()); + base::FilePath autostart_directory = GetAutostartDirectory(environment.get()); if (!file_util::DirectoryExists(autostart_directory) && !file_util::CreateDirectory(autostart_directory)) { return false; } - FilePath autostart_file = autostart_directory.Append(autostart_filename); + base::FilePath autostart_file = + autostart_directory.Append(autostart_filename); std::string terminal = is_terminal_app ? "true" : "false"; std::string autostart_file_contents = "[Desktop Entry]\n" @@ -56,16 +58,18 @@ bool AutoStart::AddApplication(const std::string& autostart_filename, bool AutoStart::Remove(const std::string& autostart_filename) { scoped_ptr<base::Environment> environment(base::Environment::Create()); - FilePath autostart_directory = GetAutostartDirectory(environment.get()); - FilePath autostart_file = autostart_directory.Append(autostart_filename); + base::FilePath autostart_directory = GetAutostartDirectory(environment.get()); + base::FilePath autostart_file = + autostart_directory.Append(autostart_filename); return file_util::Delete(autostart_file, false); } bool AutoStart::GetAutostartFileContents( const std::string& autostart_filename, std::string* contents) { scoped_ptr<base::Environment> environment(base::Environment::Create()); - FilePath autostart_directory = GetAutostartDirectory(environment.get()); - FilePath autostart_file = autostart_directory.Append(autostart_filename); + base::FilePath autostart_directory = GetAutostartDirectory(environment.get()); + base::FilePath autostart_file = + autostart_directory.Append(autostart_filename); return file_util::ReadFileToString(autostart_file, contents); } diff --git a/chrome/common/automation_messages.cc b/chrome/common/automation_messages.cc index 1a60005..9012587 100644 --- a/chrome/common/automation_messages.cc +++ b/chrome/common/automation_messages.cc @@ -198,7 +198,7 @@ struct ParamTraits<net::UploadElement> { } default: { DCHECK(type == net::UploadElement::TYPE_FILE); - FilePath file_path; + base::FilePath file_path; uint64 offset, length; base::Time expected_modification_time; if (!ReadParam(m, iter, &file_path)) diff --git a/chrome/common/automation_messages_internal.h b/chrome/common/automation_messages_internal.h index 64a17a4..00167ee 100644 --- a/chrome/common/automation_messages_internal.h +++ b/chrome/common/automation_messages_internal.h @@ -220,7 +220,7 @@ IPC_MESSAGE_CONTROL1(AutomationMsg_DEPRECATED_SetFilteredInet, // Gets the directory that downloads will occur in for the active profile. IPC_SYNC_MESSAGE_CONTROL1_1(AutomationMsg_DEPRECATED_DownloadDirectory, int /* tab_handle */, - FilePath /* directory */) + base::FilePath /* directory */) // Opens a new browser window. // TODO(sky): remove this and replace with OpenNewBrowserWindowOfType. diff --git a/chrome/common/chrome_constants.cc b/chrome/common/chrome_constants.cc index 996de3b..c06d0b8 100644 --- a/chrome/common/chrome_constants.cc +++ b/chrome/common/chrome_constants.cc @@ -51,71 +51,79 @@ const char kChromeVersionEnvVar[] = "CHROME_VERSION"; // do so. #if defined(OS_WIN) -const FilePath::CharType kBrowserProcessExecutableNameChromium[] = +const base::FilePath::CharType kBrowserProcessExecutableNameChromium[] = FPL("chrome.exe"); -const FilePath::CharType kBrowserProcessExecutableName[] = FPL("chrome.exe"); -const FilePath::CharType kHelperProcessExecutableNameChromium[] = +const base::FilePath::CharType kBrowserProcessExecutableName[] = + FPL("chrome.exe"); +const base::FilePath::CharType kHelperProcessExecutableNameChromium[] = + FPL("chrome.exe"); +const base::FilePath::CharType kHelperProcessExecutableName[] = FPL("chrome.exe"); -const FilePath::CharType kHelperProcessExecutableName[] = FPL("chrome.exe"); #elif defined(OS_MACOSX) -const FilePath::CharType kBrowserProcessExecutableNameChromium[] = +const base::FilePath::CharType kBrowserProcessExecutableNameChromium[] = FPL(CHROMIUM_PRODUCT_STRING); -const FilePath::CharType kBrowserProcessExecutableName[] = FPL(PRODUCT_STRING); -const FilePath::CharType kHelperProcessExecutableNameChromium[] = +const base::FilePath::CharType kBrowserProcessExecutableName[] = + FPL(PRODUCT_STRING); +const base::FilePath::CharType kHelperProcessExecutableNameChromium[] = FPL(CHROMIUM_PRODUCT_STRING " Helper"); -const FilePath::CharType kHelperProcessExecutableName[] = +const base::FilePath::CharType kHelperProcessExecutableName[] = FPL(PRODUCT_STRING " Helper"); #elif defined(OS_ANDROID) // NOTE: Keep it synced with the process names defined in AndroidManifest.xml. -const FilePath::CharType kBrowserProcessExecutableName[] = FPL("chrome"); -const FilePath::CharType kBrowserProcessExecutableNameChromium[] = +const base::FilePath::CharType kBrowserProcessExecutableName[] = FPL("chrome"); +const base::FilePath::CharType kBrowserProcessExecutableNameChromium[] = FPL(""); -const FilePath::CharType kHelperProcessExecutableName[] = +const base::FilePath::CharType kHelperProcessExecutableName[] = FPL("sandboxed_process"); -const FilePath::CharType kHelperProcessExecutableNameChromium[] = FPL(""); +const base::FilePath::CharType kHelperProcessExecutableNameChromium[] = FPL(""); #elif defined(OS_POSIX) -const FilePath::CharType kBrowserProcessExecutableNameChromium[] = +const base::FilePath::CharType kBrowserProcessExecutableNameChromium[] = FPL("chrome"); -const FilePath::CharType kBrowserProcessExecutableName[] = FPL("chrome"); +const base::FilePath::CharType kBrowserProcessExecutableName[] = FPL("chrome"); // Helper processes end up with a name of "exe" due to execing via // /proc/self/exe. See bug 22703. -const FilePath::CharType kHelperProcessExecutableNameChromium[] = FPL("exe"); -const FilePath::CharType kHelperProcessExecutableName[] = FPL("exe"); +const base::FilePath::CharType kHelperProcessExecutableNameChromium[] = + FPL("exe"); +const base::FilePath::CharType kHelperProcessExecutableName[] = FPL("exe"); #endif // OS_* #if defined(OS_WIN) -const FilePath::CharType kBrowserProcessExecutablePathChromium[] = +const base::FilePath::CharType kBrowserProcessExecutablePathChromium[] = + FPL("chrome.exe"); +const base::FilePath::CharType kBrowserProcessExecutablePath[] = FPL("chrome.exe"); -const FilePath::CharType kBrowserProcessExecutablePath[] = FPL("chrome.exe"); -const FilePath::CharType kHelperProcessExecutablePathChromium[] = +const base::FilePath::CharType kHelperProcessExecutablePathChromium[] = + FPL("chrome.exe"); +const base::FilePath::CharType kHelperProcessExecutablePath[] = FPL("chrome.exe"); -const FilePath::CharType kHelperProcessExecutablePath[] = FPL("chrome.exe"); #elif defined(OS_MACOSX) -const FilePath::CharType kBrowserProcessExecutablePathChromium[] = +const base::FilePath::CharType kBrowserProcessExecutablePathChromium[] = FPL(CHROMIUM_PRODUCT_STRING ".app/Contents/MacOS/" CHROMIUM_PRODUCT_STRING); -const FilePath::CharType kBrowserProcessExecutablePath[] = +const base::FilePath::CharType kBrowserProcessExecutablePath[] = FPL(PRODUCT_STRING ".app/Contents/MacOS/" PRODUCT_STRING); -const FilePath::CharType kHelperProcessExecutablePathChromium[] = +const base::FilePath::CharType kHelperProcessExecutablePathChromium[] = FPL(CHROMIUM_PRODUCT_STRING " Helper.app/Contents/MacOS/" CHROMIUM_PRODUCT_STRING " Helper"); -const FilePath::CharType kHelperProcessExecutablePath[] = +const base::FilePath::CharType kHelperProcessExecutablePath[] = FPL(PRODUCT_STRING " Helper.app/Contents/MacOS/" PRODUCT_STRING " Helper"); #elif defined(OS_ANDROID) -const FilePath::CharType kBrowserProcessExecutablePath[] = FPL("chrome"); -const FilePath::CharType kHelperProcessExecutablePath[] = FPL("chrome"); -const FilePath::CharType kBrowserProcessExecutablePathChromium[] = +const base::FilePath::CharType kBrowserProcessExecutablePath[] = FPL("chrome"); +const base::FilePath::CharType kHelperProcessExecutablePath[] = FPL("chrome"); +const base::FilePath::CharType kBrowserProcessExecutablePathChromium[] = + FPL("chrome"); +const base::FilePath::CharType kHelperProcessExecutablePathChromium[] = FPL("chrome"); -const FilePath::CharType kHelperProcessExecutablePathChromium[] = FPL("chrome"); #elif defined(OS_POSIX) -const FilePath::CharType kBrowserProcessExecutablePathChromium[] = +const base::FilePath::CharType kBrowserProcessExecutablePathChromium[] = + FPL("chrome"); +const base::FilePath::CharType kBrowserProcessExecutablePath[] = FPL("chrome"); +const base::FilePath::CharType kHelperProcessExecutablePathChromium[] = FPL("chrome"); -const FilePath::CharType kBrowserProcessExecutablePath[] = FPL("chrome"); -const FilePath::CharType kHelperProcessExecutablePathChromium[] = FPL("chrome"); -const FilePath::CharType kHelperProcessExecutablePath[] = FPL("chrome"); +const base::FilePath::CharType kHelperProcessExecutablePath[] = FPL("chrome"); #endif // OS_* #if defined(OS_MACOSX) -const FilePath::CharType kFrameworkName[] = +const base::FilePath::CharType kFrameworkName[] = FPL(PRODUCT_STRING " Framework.framework"); const char* const kHelperFlavorSuffixes[] = { @@ -128,7 +136,7 @@ const char* const kHelperFlavorSuffixes[] = { const wchar_t kNaClAppName[] = L"nacl64"; #if defined(OS_WIN) -const FilePath::CharType kMetroDriverDll[] = FPL("metro_driver.dll"); +const base::FilePath::CharType kMetroDriverDll[] = FPL("metro_driver.dll"); const wchar_t kStatusTrayWindowClass[] = L"Chrome_StatusTrayWindow"; #endif // defined(OS_WIN) @@ -138,52 +146,59 @@ const wchar_t kTestingInterfaceDLL[] = L"testing_interface.dll"; const char kInitialProfile[] = "Default"; const char kMultiProfileDirPrefix[] = "Profile "; const wchar_t kBrowserResourcesDll[] = L"chrome.dll"; -const FilePath::CharType kExtensionFileExtension[] = FPL(".crx"); -const FilePath::CharType kExtensionKeyFileExtension[] = FPL(".pem"); +const base::FilePath::CharType kExtensionFileExtension[] = FPL(".crx"); +const base::FilePath::CharType kExtensionKeyFileExtension[] = FPL(".pem"); // filenames #if defined(OS_ANDROID) -const FilePath::CharType kAndroidCacheFilename[] = FPL("AndroidCache"); +const base::FilePath::CharType kAndroidCacheFilename[] = FPL("AndroidCache"); #endif -const FilePath::CharType kArchivedHistoryFilename[] = FPL("Archived History"); -const FilePath::CharType kBookmarksFileName[] = FPL("Bookmarks"); -const FilePath::CharType kCacheDirname[] = FPL("Cache"); -const FilePath::CharType kCookieFilename[] = FPL("Cookies"); -const FilePath::CharType kCRLSetFilename[] = +const base::FilePath::CharType kArchivedHistoryFilename[] = + FPL("Archived History"); +const base::FilePath::CharType kBookmarksFileName[] = FPL("Bookmarks"); +const base::FilePath::CharType kCacheDirname[] = FPL("Cache"); +const base::FilePath::CharType kCookieFilename[] = FPL("Cookies"); +const base::FilePath::CharType kCRLSetFilename[] = FPL("Certificate Revocation Lists"); -const FilePath::CharType kCustomDictionaryFileName[] = +const base::FilePath::CharType kCustomDictionaryFileName[] = FPL("Custom Dictionary.txt"); -const FilePath::CharType kExtensionActivityLogFilename[] = +const base::FilePath::CharType kExtensionActivityLogFilename[] = FPL("Extension Activity"); -const FilePath::CharType kExtensionsCookieFilename[] = FPL("Extension Cookies"); -const FilePath::CharType kFaviconsFilename[] = FPL("Favicons"); -const FilePath::CharType kFirstRunSentinel[] = FPL("First Run"); -const FilePath::CharType kHistoryFilename[] = FPL("History"); -const FilePath::CharType kJumpListIconDirname[] = FPL("JumpListIcons"); -const FilePath::CharType kLocalStateFilename[] = FPL("Local State"); -const FilePath::CharType kLoginDataFileName[] = FPL("Login Data"); -const FilePath::CharType kManagedModePolicyFilename[] = +const base::FilePath::CharType kExtensionsCookieFilename[] = + FPL("Extension Cookies"); +const base::FilePath::CharType kFaviconsFilename[] = FPL("Favicons"); +const base::FilePath::CharType kFirstRunSentinel[] = FPL("First Run"); +const base::FilePath::CharType kHistoryFilename[] = FPL("History"); +const base::FilePath::CharType kJumpListIconDirname[] = FPL("JumpListIcons"); +const base::FilePath::CharType kLocalStateFilename[] = FPL("Local State"); +const base::FilePath::CharType kLoginDataFileName[] = FPL("Login Data"); +const base::FilePath::CharType kManagedModePolicyFilename[] = FPL("Managed Mode Settings"); -const FilePath::CharType kMediaCacheDirname[] = FPL("Media Cache"); -const FilePath::CharType kNewTabThumbnailsFilename[] = FPL("Top Thumbnails"); -const FilePath::CharType kOBCertFilename[] = FPL("Origin Bound Certs"); -const FilePath::CharType kPreferencesFilename[] = FPL("Preferences"); -const FilePath::CharType kReadmeFilename[] = FPL("README"); -const FilePath::CharType kSafeBrowsingBaseFilename[] = FPL("Safe Browsing"); -const FilePath::CharType kServiceStateFileName[] = FPL("Service State"); -const FilePath::CharType kShortcutsDatabaseName[] = FPL("Shortcuts"); -const FilePath::CharType kSingletonCookieFilename[] = FPL("SingletonCookie"); -const FilePath::CharType kSingletonLockFilename[] = FPL("SingletonLock"); -const FilePath::CharType kSingletonSocketFilename[] = FPL("SingletonSocket"); -const FilePath::CharType kSyncCredentialsFilename[] = FPL("Sync Credentials"); -const FilePath::CharType kThemePackFilename[] = FPL("Cached Theme.pak"); -const FilePath::CharType kThumbnailsFilename[] = FPL("Thumbnails"); -const FilePath::CharType kTopSitesFilename[] = FPL("Top Sites"); -const FilePath::CharType kWebAppDirname[] = FPL("Web Applications"); -const FilePath::CharType kWebDataFilename[] = FPL("Web Data"); +const base::FilePath::CharType kMediaCacheDirname[] = FPL("Media Cache"); +const base::FilePath::CharType kNewTabThumbnailsFilename[] = + FPL("Top Thumbnails"); +const base::FilePath::CharType kOBCertFilename[] = FPL("Origin Bound Certs"); +const base::FilePath::CharType kPreferencesFilename[] = FPL("Preferences"); +const base::FilePath::CharType kReadmeFilename[] = FPL("README"); +const base::FilePath::CharType kSafeBrowsingBaseFilename[] = + FPL("Safe Browsing"); +const base::FilePath::CharType kServiceStateFileName[] = FPL("Service State"); +const base::FilePath::CharType kShortcutsDatabaseName[] = FPL("Shortcuts"); +const base::FilePath::CharType kSingletonCookieFilename[] = + FPL("SingletonCookie"); +const base::FilePath::CharType kSingletonLockFilename[] = FPL("SingletonLock"); +const base::FilePath::CharType kSingletonSocketFilename[] = + FPL("SingletonSocket"); +const base::FilePath::CharType kSyncCredentialsFilename[] = + FPL("Sync Credentials"); +const base::FilePath::CharType kThemePackFilename[] = FPL("Cached Theme.pak"); +const base::FilePath::CharType kThumbnailsFilename[] = FPL("Thumbnails"); +const base::FilePath::CharType kTopSitesFilename[] = FPL("Top Sites"); +const base::FilePath::CharType kWebAppDirname[] = FPL("Web Applications"); +const base::FilePath::CharType kWebDataFilename[] = FPL("Web Data"); // File name of the Pepper Flash plugin on different platforms. -const FilePath::CharType kPepperFlashPluginFilename[] = +const base::FilePath::CharType kPepperFlashPluginFilename[] = #if defined(OS_MACOSX) FPL("PepperFlashPlayer.plugin"); #elif defined(OS_WIN) @@ -196,7 +211,7 @@ const FilePath::CharType kPepperFlashPluginFilename[] = const wchar_t kUserDataDirname[] = L"User Data"; #if defined(OS_CHROMEOS) -const FilePath::CharType kDriveCacheDirname[] = FPL("GCache"); +const base::FilePath::CharType kDriveCacheDirname[] = FPL("GCache"); #endif // defined(OS_CHROMEOS) // We don't enable record mode in the released product because users could diff --git a/chrome/common/chrome_constants.h b/chrome/common/chrome_constants.h index e7be458..c236c3c 100644 --- a/chrome/common/chrome_constants.h +++ b/chrome/common/chrome_constants.h @@ -15,16 +15,16 @@ extern const char kChromeVersion[]; extern const char kChromeVersionEnvVar[]; -extern const FilePath::CharType kBrowserProcessExecutableName[]; -extern const FilePath::CharType kHelperProcessExecutableName[]; -extern const FilePath::CharType kBrowserProcessExecutablePath[]; -extern const FilePath::CharType kHelperProcessExecutablePath[]; -extern const FilePath::CharType kBrowserProcessExecutableNameChromium[]; -extern const FilePath::CharType kHelperProcessExecutableNameChromium[]; -extern const FilePath::CharType kBrowserProcessExecutablePathChromium[]; -extern const FilePath::CharType kHelperProcessExecutablePathChromium[]; +extern const base::FilePath::CharType kBrowserProcessExecutableName[]; +extern const base::FilePath::CharType kHelperProcessExecutableName[]; +extern const base::FilePath::CharType kBrowserProcessExecutablePath[]; +extern const base::FilePath::CharType kHelperProcessExecutablePath[]; +extern const base::FilePath::CharType kBrowserProcessExecutableNameChromium[]; +extern const base::FilePath::CharType kHelperProcessExecutableNameChromium[]; +extern const base::FilePath::CharType kBrowserProcessExecutablePathChromium[]; +extern const base::FilePath::CharType kHelperProcessExecutablePathChromium[]; #if defined(OS_MACOSX) -extern const FilePath::CharType kFrameworkName[]; +extern const base::FilePath::CharType kFrameworkName[]; // The helper .app bundle name and executable name may have one of these // suffixes to identify specific features, or it may have no suffix at all. @@ -34,10 +34,10 @@ extern const FilePath::CharType kFrameworkName[]; // Chromium Helper.app/Contents/MacOS/Chromium Helper, // Chromium Helper EN.app/Contents/MacOS/Chromium Helper EN, and // Chromium Helper MF.app/Contents/MacOS/Chromium Helper MF. -extern const FilePath::CharType* const kHelperFlavorSuffixes[]; +extern const base::FilePath::CharType* const kHelperFlavorSuffixes[]; #endif // OS_MACOSX #if defined(OS_WIN) -extern const FilePath::CharType kMetroDriverDll[]; +extern const base::FilePath::CharType kMetroDriverDll[]; extern const wchar_t kStatusTrayWindowClass[]; #endif // defined(OS_WIN) extern const wchar_t kMessageWindowClass[]; @@ -47,54 +47,54 @@ extern const char kInitialProfile[]; extern const char kMultiProfileDirPrefix[]; extern const wchar_t kBrowserResourcesDll[]; extern const wchar_t kNaClAppName[]; -extern const FilePath::CharType kExtensionFileExtension[]; -extern const FilePath::CharType kExtensionKeyFileExtension[]; +extern const base::FilePath::CharType kExtensionFileExtension[]; +extern const base::FilePath::CharType kExtensionKeyFileExtension[]; // filenames #if defined(OS_ANDROID) -extern const FilePath::CharType kAndroidCacheFilename[]; +extern const base::FilePath::CharType kAndroidCacheFilename[]; #endif -extern const FilePath::CharType kArchivedHistoryFilename[]; -extern const FilePath::CharType kBookmarksFileName[]; -extern const FilePath::CharType kCacheDirname[]; -extern const FilePath::CharType kCookieFilename[]; -extern const FilePath::CharType kCRLSetFilename[]; -extern const FilePath::CharType kCustomDictionaryFileName[]; -extern const FilePath::CharType kExtensionActivityLogFilename[]; -extern const FilePath::CharType kExtensionsCookieFilename[]; -extern const FilePath::CharType kFaviconsFilename[]; -extern const FilePath::CharType kFirstRunSentinel[]; -extern const FilePath::CharType kHistoryFilename[]; -extern const FilePath::CharType kJumpListIconDirname[]; -extern const FilePath::CharType kLocalStateFilename[]; -extern const FilePath::CharType kLoginDataFileName[]; -extern const FilePath::CharType kManagedModePolicyFilename[]; -extern const FilePath::CharType kMediaCacheDirname[]; -extern const FilePath::CharType kNewTabThumbnailsFilename[]; -extern const FilePath::CharType kOBCertFilename[]; -extern const FilePath::CharType kPreferencesFilename[]; -extern const FilePath::CharType kReadmeFilename[]; -extern const FilePath::CharType kSafeBrowsingBaseFilename[]; -extern const FilePath::CharType kServiceStateFileName[]; -extern const FilePath::CharType kShortcutsDatabaseName[]; -extern const FilePath::CharType kSingletonCookieFilename[]; -extern const FilePath::CharType kSingletonLockFilename[]; -extern const FilePath::CharType kSingletonSocketFilename[]; -extern const FilePath::CharType kSyncCredentialsFilename[]; -extern const FilePath::CharType kThemePackFilename[]; -extern const FilePath::CharType kThumbnailsFilename[]; -extern const FilePath::CharType kTopSitesFilename[]; -extern const FilePath::CharType kWebAppDirname[]; -extern const FilePath::CharType kWebDataFilename[]; +extern const base::FilePath::CharType kArchivedHistoryFilename[]; +extern const base::FilePath::CharType kBookmarksFileName[]; +extern const base::FilePath::CharType kCacheDirname[]; +extern const base::FilePath::CharType kCookieFilename[]; +extern const base::FilePath::CharType kCRLSetFilename[]; +extern const base::FilePath::CharType kCustomDictionaryFileName[]; +extern const base::FilePath::CharType kExtensionActivityLogFilename[]; +extern const base::FilePath::CharType kExtensionsCookieFilename[]; +extern const base::FilePath::CharType kFaviconsFilename[]; +extern const base::FilePath::CharType kFirstRunSentinel[]; +extern const base::FilePath::CharType kHistoryFilename[]; +extern const base::FilePath::CharType kJumpListIconDirname[]; +extern const base::FilePath::CharType kLocalStateFilename[]; +extern const base::FilePath::CharType kLoginDataFileName[]; +extern const base::FilePath::CharType kManagedModePolicyFilename[]; +extern const base::FilePath::CharType kMediaCacheDirname[]; +extern const base::FilePath::CharType kNewTabThumbnailsFilename[]; +extern const base::FilePath::CharType kOBCertFilename[]; +extern const base::FilePath::CharType kPreferencesFilename[]; +extern const base::FilePath::CharType kReadmeFilename[]; +extern const base::FilePath::CharType kSafeBrowsingBaseFilename[]; +extern const base::FilePath::CharType kServiceStateFileName[]; +extern const base::FilePath::CharType kShortcutsDatabaseName[]; +extern const base::FilePath::CharType kSingletonCookieFilename[]; +extern const base::FilePath::CharType kSingletonLockFilename[]; +extern const base::FilePath::CharType kSingletonSocketFilename[]; +extern const base::FilePath::CharType kSyncCredentialsFilename[]; +extern const base::FilePath::CharType kThemePackFilename[]; +extern const base::FilePath::CharType kThumbnailsFilename[]; +extern const base::FilePath::CharType kTopSitesFilename[]; +extern const base::FilePath::CharType kWebAppDirname[]; +extern const base::FilePath::CharType kWebDataFilename[]; // File name of the Pepper Flash plugin on different platforms. -extern const FilePath::CharType kPepperFlashPluginFilename[]; +extern const base::FilePath::CharType kPepperFlashPluginFilename[]; // directory names extern const wchar_t kUserDataDirname[]; #if defined(OS_CHROMEOS) -extern const FilePath::CharType kDriveCacheDirname[]; +extern const base::FilePath::CharType kDriveCacheDirname[]; #endif // defined(OS_CHROMEOS) extern const bool kRecordModeEnabled; diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc index 709a93f..1d2dbfb 100644 --- a/chrome/common/chrome_content_client.cc +++ b/chrome/common/chrome_content_client.cc @@ -99,7 +99,7 @@ const char kRemotingViewerPluginDescription[] = "shared with you. To use this plugin you must first install the " "<a href=\"https://chrome.google.com/remotedesktop\">" "Chrome Remote Desktop</a> webapp."; -const FilePath::CharType kRemotingViewerPluginPath[] = +const base::FilePath::CharType kRemotingViewerPluginPath[] = FILE_PATH_LITERAL("internal-remoting-viewer"); // Use a consistent MIME-type regardless of branding. const char kRemotingViewerPluginMimeType[] = @@ -126,7 +126,7 @@ void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { // So the first time through test if the file is available and then skip the // check on subsequent calls if yes. static bool skip_pdf_file_check = false; - FilePath path; + base::FilePath path; if (PathService::Get(chrome::FILE_PDF_PLUGIN, &path)) { if (skip_pdf_file_check || file_util::PathExists(path)) { content::PepperPluginInfo pdf; @@ -237,7 +237,7 @@ void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { info.is_out_of_process = true; info.name = kRemotingViewerPluginName; info.description = kRemotingViewerPluginDescription; - info.path = FilePath(kRemotingViewerPluginPath); + info.path = base::FilePath(kRemotingViewerPluginPath); webkit::WebPluginMimeType remoting_mime_type( kRemotingViewerPluginMimeType, kRemotingViewerPluginMimeExtension, @@ -253,7 +253,7 @@ void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { #endif } -content::PepperPluginInfo CreatePepperFlashInfo(const FilePath& path, +content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, const std::string& version) { content::PepperPluginInfo plugin; @@ -309,7 +309,7 @@ void AddPepperFlashFromCommandLine( switches::kPpapiFlashVersion); plugins->push_back( - CreatePepperFlashInfo(FilePath(flash_path), flash_version)); + CreatePepperFlashInfo(base::FilePath(flash_path), flash_version)); } bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) { @@ -332,7 +332,7 @@ bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) { return false; #endif // ARCH_CPU_X86 - FilePath flash_path; + base::FilePath flash_path; if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path)) return false; diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc index df00d29..dcc7a86 100644 --- a/chrome/common/chrome_paths.cc +++ b/chrome/common/chrome_paths.cc @@ -28,7 +28,7 @@ namespace { // File name of the internal Flash plugin on different platforms. -const FilePath::CharType kInternalFlashPluginFileName[] = +const base::FilePath::CharType kInternalFlashPluginFileName[] = #if defined(OS_MACOSX) FILE_PATH_LITERAL("Flash Player Plugin for Chrome.plugin"); #elif defined(OS_WIN) @@ -38,11 +38,11 @@ const FilePath::CharType kInternalFlashPluginFileName[] = #endif // The Pepper Flash plugins are in a directory with this name. -const FilePath::CharType kPepperFlashBaseDirectory[] = +const base::FilePath::CharType kPepperFlashBaseDirectory[] = FILE_PATH_LITERAL("PepperFlash"); // File name of the internal PDF plugin on different platforms. -const FilePath::CharType kInternalPDFPluginFileName[] = +const base::FilePath::CharType kInternalPDFPluginFileName[] = #if defined(OS_WIN) FILE_PATH_LITERAL("pdf.dll"); #elif defined(OS_MACOSX) @@ -52,7 +52,7 @@ const FilePath::CharType kInternalPDFPluginFileName[] = #endif // File name of the internal NaCl plugin on different platforms. -const FilePath::CharType kInternalNaClPluginFileName[] = +const base::FilePath::CharType kInternalNaClPluginFileName[] = #if defined(OS_WIN) FILE_PATH_LITERAL("ppGoogleNaClPluginChrome.dll"); #elif defined(OS_MACOSX) @@ -64,19 +64,19 @@ const FilePath::CharType kInternalNaClPluginFileName[] = #if defined(OS_POSIX) && !defined(OS_MACOSX) // File name of the nacl_helper and nacl_helper_bootstrap, Linux only. -const FilePath::CharType kInternalNaClHelperFileName[] = +const base::FilePath::CharType kInternalNaClHelperFileName[] = FILE_PATH_LITERAL("nacl_helper"); -const FilePath::CharType kInternalNaClHelperBootstrapFileName[] = +const base::FilePath::CharType kInternalNaClHelperBootstrapFileName[] = FILE_PATH_LITERAL("nacl_helper_bootstrap"); #endif #if defined(OS_POSIX) && !defined(OS_MACOSX) -const FilePath::CharType kO3DPluginFileName[] = +const base::FilePath::CharType kO3DPluginFileName[] = FILE_PATH_LITERAL("pepper/libppo3dautoplugin.so"); -const FilePath::CharType kGTalkPluginFileName[] = +const base::FilePath::CharType kGTalkPluginFileName[] = FILE_PATH_LITERAL("pepper/libppgoogletalk.so"); #endif // defined(OS_POSIX) && !defined(OS_MACOSX) @@ -106,7 +106,7 @@ const char kDefaultAppOrderFileName[] = namespace chrome { // Gets the path for internal plugins. -bool GetInternalPluginsDirectory(FilePath* result) { +bool GetInternalPluginsDirectory(base::FilePath* result) { #if defined(OS_MACOSX) && !defined(OS_IOS) // If called from Chrome, get internal plugins from a subdirectory of the // framework. @@ -123,7 +123,7 @@ bool GetInternalPluginsDirectory(FilePath* result) { return PathService::Get(base::DIR_MODULE, result); } -bool PathProvider(int key, FilePath* result) { +bool PathProvider(int key, base::FilePath* result) { // Some keys are just aliases... switch (key) { case chrome::DIR_APP: @@ -159,7 +159,7 @@ bool PathProvider(int key, FilePath* result) { // This flag can be set to true for the cases where we want to create it. bool create_dir = false; - FilePath cur; + base::FilePath cur; switch (key) { case chrome::DIR_USER_DATA: if (!GetDefaultUserDataDirectory(&cur)) { @@ -207,7 +207,7 @@ bool PathProvider(int key, FilePath* result) { case chrome::DIR_CRASH_DUMPS: #if defined(OS_CHROMEOS) // ChromeOS uses a separate directory. See http://crosbug.com/25089 - cur = FilePath("/var/log/chrome"); + cur = base::FilePath("/var/log/chrome"); #elif defined(OS_ANDROID) if (!base::android::GetCacheDirectory(&cur)) return false; @@ -398,7 +398,7 @@ bool PathProvider(int key, FilePath* result) { cur = cur.Append(FILE_PATH_LITERAL("wallpaper_thumbnails")); break; case chrome::FILE_DEFAULT_APP_ORDER: - cur = FilePath(FILE_PATH_LITERAL(kDefaultAppOrderFileName)); + cur = base::FilePath(FILE_PATH_LITERAL(kDefaultAppOrderFileName)); break; #endif // The following are only valid in the development environment, and @@ -432,9 +432,9 @@ bool PathProvider(int key, FilePath* result) { #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) case chrome::DIR_POLICY_FILES: { #if defined(GOOGLE_CHROME_BUILD) - cur = FilePath(FILE_PATH_LITERAL("/etc/opt/chrome/policies")); + cur = base::FilePath(FILE_PATH_LITERAL("/etc/opt/chrome/policies")); #else - cur = FilePath(FILE_PATH_LITERAL("/etc/chromium/policies")); + cur = base::FilePath(FILE_PATH_LITERAL("/etc/chromium/policies")); #endif break; } @@ -463,7 +463,7 @@ bool PathProvider(int key, FilePath* result) { #endif #if defined(OS_LINUX) case chrome::DIR_STANDALONE_EXTERNAL_EXTENSIONS: { - cur = FilePath(FILE_PATH_LITERAL(kFilepathSinglePrefExtensions)); + cur = base::FilePath(FILE_PATH_LITERAL(kFilepathSinglePrefExtensions)); break; } #endif diff --git a/chrome/common/chrome_paths_android.cc b/chrome/common/chrome_paths_android.cc index 6a7d9ea..a69b250 100644 --- a/chrome/common/chrome_paths_android.cc +++ b/chrome/common/chrome_paths_android.cc @@ -10,40 +10,41 @@ namespace chrome { -void GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result) { +void GetUserCacheDirectory(const base::FilePath& profile_dir, + base::FilePath* result) { if (!PathService::Get(base::DIR_CACHE, result)) *result = profile_dir; } -bool GetDefaultUserDataDirectory(FilePath* result) { +bool GetDefaultUserDataDirectory(base::FilePath* result) { return PathService::Get(base::DIR_ANDROID_APP_DATA, result); } -bool GetUserDocumentsDirectory(FilePath* result) { +bool GetUserDocumentsDirectory(base::FilePath* result) { if (!GetDefaultUserDataDirectory(result)) return false; *result = result->Append("Documents"); return true; } -bool GetUserDownloadsDirectory(FilePath* result) { +bool GetUserDownloadsDirectory(base::FilePath* result) { if (!GetDefaultUserDataDirectory(result)) return false; *result = result->Append("Downloads"); return true; } -bool GetUserMusicDirectory(FilePath* result) { +bool GetUserMusicDirectory(base::FilePath* result) { NOTIMPLEMENTED(); return false; } -bool GetUserPicturesDirectory(FilePath* result) { +bool GetUserPicturesDirectory(base::FilePath* result) { NOTIMPLEMENTED(); return false; } -bool GetUserVideosDirectory(FilePath* result) { +bool GetUserVideosDirectory(base::FilePath* result) { NOTIMPLEMENTED(); return false; } diff --git a/chrome/common/chrome_paths_linux.cc b/chrome/common/chrome_paths_linux.cc index babb501..e90c2f5 100644 --- a/chrome/common/chrome_paths_linux.cc +++ b/chrome/common/chrome_paths_linux.cc @@ -27,16 +27,16 @@ const char kVideosDir[] = "Videos"; // Generic function for GetUser{Music,Pictures,Video}Directory. bool GetUserMediaDirectory(const std::string& xdg_name, const std::string& fallback_name, - FilePath* result) { + base::FilePath* result) { #if defined(OS_CHROMEOS) // No local media directories on CrOS. return false; #else *result = GetXDGUserDirectory(xdg_name.c_str(), fallback_name.c_str()); - FilePath home = file_util::GetHomeDir(); + base::FilePath home = file_util::GetHomeDir(); if (*result != home) { - FilePath desktop; + base::FilePath desktop; if (!PathService::Get(base::DIR_USER_DESKTOP, &desktop)) return false; if (*result != desktop) { @@ -56,9 +56,9 @@ bool GetUserMediaDirectory(const std::string& xdg_name, // systems is we use ~/.config/chromium/ for Chromium and // ~/.config/google-chrome/ for official builds. // (This also helps us sidestep issues with other apps grabbing ~/.chromium .) -bool GetDefaultUserDataDirectory(FilePath* result) { +bool GetDefaultUserDataDirectory(base::FilePath* result) { scoped_ptr<base::Environment> env(base::Environment::Create()); - FilePath config_dir(GetXDGDirectory(env.get(), + base::FilePath config_dir(GetXDGDirectory(env.get(), kXdgConfigHomeEnvVar, kDotConfigDir)); #if defined(GOOGLE_CHROME_BUILD) @@ -69,7 +69,8 @@ bool GetDefaultUserDataDirectory(FilePath* result) { return true; } -void GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result) { +void GetUserCacheDirectory(const base::FilePath& profile_dir, + base::FilePath* result) { // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html // for a spec on where cache files go. Our rule is: // - if the user-data-dir in the standard place, @@ -83,10 +84,10 @@ void GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result) { scoped_ptr<base::Environment> env(base::Environment::Create()); - FilePath cache_dir; + base::FilePath cache_dir; if (!PathService::Get(base::DIR_CACHE, &cache_dir)) return; - FilePath config_dir(GetXDGDirectory(env.get(), + base::FilePath config_dir(GetXDGDirectory(env.get(), kXdgConfigHomeEnvVar, kDotConfigDir)); @@ -96,9 +97,9 @@ void GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result) { *result = cache_dir; } -bool GetChromeFrameUserDataDirectory(FilePath* result) { +bool GetChromeFrameUserDataDirectory(base::FilePath* result) { scoped_ptr<base::Environment> env(base::Environment::Create()); - FilePath config_dir(GetXDGDirectory(env.get(), + base::FilePath config_dir(GetXDGDirectory(env.get(), kXdgConfigHomeEnvVar, kDotConfigDir)); #if defined(GOOGLE_CHROME_BUILD) @@ -109,37 +110,37 @@ bool GetChromeFrameUserDataDirectory(FilePath* result) { return true; } -bool GetUserDocumentsDirectory(FilePath* result) { +bool GetUserDocumentsDirectory(base::FilePath* result) { *result = GetXDGUserDirectory("DOCUMENTS", "Documents"); return true; } -bool GetUserDownloadsDirectorySafe(FilePath* result) { - FilePath home = file_util::GetHomeDir(); +bool GetUserDownloadsDirectorySafe(base::FilePath* result) { + base::FilePath home = file_util::GetHomeDir(); *result = home.Append(kDownloadsDir); return true; } -bool GetUserDownloadsDirectory(FilePath* result) { +bool GetUserDownloadsDirectory(base::FilePath* result) { *result = base::nix::GetXDGUserDirectory("DOWNLOAD", kDownloadsDir); return true; } // We respect the user's preferred pictures location, unless it is // ~ or their desktop directory, in which case we default to ~/Music. -bool GetUserMusicDirectory(FilePath* result) { +bool GetUserMusicDirectory(base::FilePath* result) { return GetUserMediaDirectory("MUSIC", kMusicDir, result); } // We respect the user's preferred pictures location, unless it is // ~ or their desktop directory, in which case we default to ~/Pictures. -bool GetUserPicturesDirectory(FilePath* result) { +bool GetUserPicturesDirectory(base::FilePath* result) { return GetUserMediaDirectory("PICTURES", kPicturesDir, result); } // We respect the user's preferred pictures location, unless it is // ~ or their desktop directory, in which case we default to ~/Videos. -bool GetUserVideosDirectory(FilePath* result) { +bool GetUserVideosDirectory(base::FilePath* result) { return GetUserMediaDirectory("VIDEOS", kVideosDir, result); } diff --git a/chrome/common/chrome_paths_mac.mm b/chrome/common/chrome_paths_mac.mm index 5472903..ce99047 100644 --- a/chrome/common/chrome_paths_mac.mm +++ b/chrome/common/chrome_paths_mac.mm @@ -23,7 +23,7 @@ namespace { #if !defined(OS_IOS) -const FilePath* g_override_versioned_directory = NULL; +const base::FilePath* g_override_versioned_directory = NULL; // Return a retained (NOT autoreleased) NSBundle* as the internal // implementation of chrome::OuterAppBundle(), which should be the only @@ -42,8 +42,8 @@ NSBundle* OuterAppBundleInternal() { } // From C.app/Contents/Versions/1.2.3.4, go up three steps to get to C.app. - FilePath versioned_dir = chrome::GetVersionedDirectory(); - FilePath outer_app_dir = versioned_dir.DirName().DirName().DirName(); + base::FilePath versioned_dir = chrome::GetVersionedDirectory(); + base::FilePath outer_app_dir = versioned_dir.DirName().DirName().DirName(); const char* outer_app_dir_c = outer_app_dir.value().c_str(); NSString* outer_app_dir_ns = [NSString stringWithUTF8String:outer_app_dir_c]; @@ -100,7 +100,7 @@ std::string ProductDirName() { namespace chrome { -bool GetDefaultUserDataDirectory(FilePath* result) { +bool GetDefaultUserDataDirectory(base::FilePath* result) { bool success = false; if (result && PathService::Get(base::DIR_APP_DATA, result)) { *result = result->Append(ProductDirName()); @@ -109,11 +109,12 @@ bool GetDefaultUserDataDirectory(FilePath* result) { return success; } -bool GetUserDocumentsDirectory(FilePath* result) { +bool GetUserDocumentsDirectory(base::FilePath* result) { return base::mac::GetUserDirectory(NSDocumentDirectory, result); } -void GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result) { +void GetUserCacheDirectory(const base::FilePath& profile_dir, + base::FilePath* result) { // If the profile directory is under ~/Library/Application Support, // use a suitable cache directory under ~/Library/Caches. For // example, a profile directory of ~/Library/Application @@ -123,10 +124,10 @@ void GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result) { // Default value in cases where any of the following fails. *result = profile_dir; - FilePath app_data_dir; + base::FilePath app_data_dir; if (!PathService::Get(base::DIR_APP_DATA, &app_data_dir)) return; - FilePath cache_dir; + base::FilePath cache_dir; if (!PathService::Get(base::DIR_CACHE, &cache_dir)) return; if (!app_data_dir.AppendRelativePath(profile_dir, &cache_dir)) @@ -135,30 +136,30 @@ void GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result) { *result = cache_dir; } -bool GetUserDownloadsDirectory(FilePath* result) { +bool GetUserDownloadsDirectory(base::FilePath* result) { return base::mac::GetUserDirectory(NSDownloadsDirectory, result); } -bool GetUserMusicDirectory(FilePath* result) { +bool GetUserMusicDirectory(base::FilePath* result) { return base::mac::GetUserDirectory(NSMusicDirectory, result); } -bool GetUserPicturesDirectory(FilePath* result) { +bool GetUserPicturesDirectory(base::FilePath* result) { return base::mac::GetUserDirectory(NSPicturesDirectory, result); } -bool GetUserVideosDirectory(FilePath* result) { +bool GetUserVideosDirectory(base::FilePath* result) { return base::mac::GetUserDirectory(NSMoviesDirectory, result); } #if !defined(OS_IOS) -FilePath GetVersionedDirectory() { +base::FilePath GetVersionedDirectory() { if (g_override_versioned_directory) return *g_override_versioned_directory; // Start out with the path to the running executable. - FilePath path; + base::FilePath path; PathService::Get(base::FILE_EXE, &path); // One step up to MacOS, another to Contents. @@ -179,14 +180,14 @@ FilePath GetVersionedDirectory() { return path; } -void SetOverrideVersionedDirectory(const FilePath* path) { +void SetOverrideVersionedDirectory(const base::FilePath* path) { if (path != g_override_versioned_directory) { delete g_override_versioned_directory; g_override_versioned_directory = path; } } -FilePath GetFrameworkBundlePath() { +base::FilePath GetFrameworkBundlePath() { // It's tempting to use +[NSBundle bundleWithIdentifier:], but it's really // slow (about 30ms on 10.5 and 10.6), despite Apple's documentation stating // that it may be more efficient than +bundleForClass:. +bundleForClass: @@ -202,11 +203,11 @@ FilePath GetFrameworkBundlePath() { return GetVersionedDirectory().Append(kFrameworkName); } -bool GetLocalLibraryDirectory(FilePath* result) { +bool GetLocalLibraryDirectory(base::FilePath* result) { return base::mac::GetLocalDirectory(NSLibraryDirectory, result); } -bool GetGlobalApplicationSupportDirectory(FilePath* result) { +bool GetGlobalApplicationSupportDirectory(base::FilePath* result) { return base::mac::GetLocalDirectory(NSApplicationSupportDirectory, result); } diff --git a/chrome/common/chrome_paths_unittest.cc b/chrome/common/chrome_paths_unittest.cc index d747262..9f7441f 100644 --- a/chrome/common/chrome_paths_unittest.cc +++ b/chrome/common/chrome_paths_unittest.cc @@ -15,25 +15,25 @@ // Test the behavior of chrome::GetUserCacheDirectory. // See that function's comments for discussion of the subtleties. TEST(ChromePaths, UserCacheDir) { - FilePath test_profile_dir, cache_dir; + base::FilePath test_profile_dir, cache_dir; #if defined(OS_MACOSX) ASSERT_TRUE(PathService::Get(base::DIR_APP_DATA, &test_profile_dir)); test_profile_dir = test_profile_dir.Append("foobar"); - FilePath expected_cache_dir; + base::FilePath expected_cache_dir; ASSERT_TRUE(PathService::Get(base::DIR_CACHE, &expected_cache_dir)); expected_cache_dir = expected_cache_dir.Append("foobar"); #elif(OS_ANDROID) // No matter what the test_profile_dir is, Android always use the // application's cache directory since multiple profiles are not // supported. - FilePath expected_cache_dir; + base::FilePath expected_cache_dir; ASSERT_TRUE(PathService::Get(base::DIR_CACHE, &expected_cache_dir)); #elif(OS_POSIX) - FilePath homedir = file_util::GetHomeDir(); + base::FilePath homedir = file_util::GetHomeDir(); // Note: we assume XDG_CACHE_HOME/XDG_CONFIG_HOME are at their // default settings. test_profile_dir = homedir.Append(".config/foobar"); - FilePath expected_cache_dir = homedir.Append(".cache/foobar"); + base::FilePath expected_cache_dir = homedir.Append(".cache/foobar"); #endif // Verify that a profile in the special platform-specific source @@ -45,7 +45,7 @@ TEST(ChromePaths, UserCacheDir) { // Verify that a profile in some other random directory doesn't use // the special cache dir. - test_profile_dir = FilePath(FILE_PATH_LITERAL("/some/other/path")); + test_profile_dir = base::FilePath(FILE_PATH_LITERAL("/some/other/path")); chrome::GetUserCacheDirectory(test_profile_dir, &cache_dir); #if defined(OS_ANDROID) EXPECT_EQ(expected_cache_dir.value(), cache_dir.value()); diff --git a/chrome/common/chrome_paths_win.cc b/chrome/common/chrome_paths_win.cc index 0fa82a4..b3e7eff 100644 --- a/chrome/common/chrome_paths_win.cc +++ b/chrome/common/chrome_paths_win.cc @@ -23,7 +23,7 @@ namespace chrome { namespace { // Generic function to call SHGetFolderPath(). -bool GetUserDirectory(int csidl_folder, FilePath* result) { +bool GetUserDirectory(int csidl_folder, base::FilePath* result) { // We need to go compute the value. It would be nice to support paths // with names longer than MAX_PATH, but the system functions don't seem // to be designed for it either, with the exception of GetTempPath @@ -35,13 +35,13 @@ bool GetUserDirectory(int csidl_folder, FilePath* result) { SHGFP_TYPE_CURRENT, path_buf))) { return false; } - *result = FilePath(path_buf); + *result = base::FilePath(path_buf); return true; } } // namespace -bool GetDefaultUserDataDirectory(FilePath* result) { +bool GetDefaultUserDataDirectory(base::FilePath* result) { if (!PathService::Get(base::DIR_LOCAL_APP_DATA, result)) return false; BrowserDistribution* dist = BrowserDistribution::GetDistribution(); @@ -50,7 +50,7 @@ bool GetDefaultUserDataDirectory(FilePath* result) { return true; } -bool GetChromeFrameUserDataDirectory(FilePath* result) { +bool GetChromeFrameUserDataDirectory(base::FilePath* result) { if (!PathService::Get(base::DIR_LOCAL_APP_DATA, result)) return false; BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( @@ -60,12 +60,13 @@ bool GetChromeFrameUserDataDirectory(FilePath* result) { return true; } -void GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result) { +void GetUserCacheDirectory(const base::FilePath& profile_dir, + base::FilePath* result) { // This function does more complicated things on Mac/Linux. *result = profile_dir; } -bool GetUserDocumentsDirectory(FilePath* result) { +bool GetUserDocumentsDirectory(base::FilePath* result) { return GetUserDirectory(CSIDL_MYDOCUMENTS, result); } @@ -73,7 +74,7 @@ bool GetUserDocumentsDirectory(FilePath* result) { // We just use 'Downloads' under DIR_USER_DOCUMENTS. Localizing // 'downloads' is not a good idea because Chrome's UI language // can be changed. -bool GetUserDownloadsDirectorySafe(FilePath* result) { +bool GetUserDownloadsDirectorySafe(base::FilePath* result) { if (!GetUserDocumentsDirectory(result)) return false; @@ -84,28 +85,28 @@ bool GetUserDownloadsDirectorySafe(FilePath* result) { // On Vista and higher, use the downloads known folder. Since it can be // relocated to point to a "dangerous" folder, callers should validate that the // returned path is not dangerous before using it. -bool GetUserDownloadsDirectory(FilePath* result) { +bool GetUserDownloadsDirectory(base::FilePath* result) { typedef HRESULT (WINAPI *GetKnownFolderPath)( REFKNOWNFOLDERID, DWORD, HANDLE, PWSTR*); GetKnownFolderPath f = reinterpret_cast<GetKnownFolderPath>( GetProcAddress(GetModuleHandle(L"shell32.dll"), "SHGetKnownFolderPath")); base::win::ScopedCoMem<wchar_t> path_buf; if (f && SUCCEEDED(f(FOLDERID_Downloads, 0, NULL, &path_buf))) { - *result = FilePath(std::wstring(path_buf)); + *result = base::FilePath(std::wstring(path_buf)); return true; } return GetUserDownloadsDirectorySafe(result); } -bool GetUserMusicDirectory(FilePath* result) { +bool GetUserMusicDirectory(base::FilePath* result) { return GetUserDirectory(CSIDL_MYMUSIC, result); } -bool GetUserPicturesDirectory(FilePath* result) { +bool GetUserPicturesDirectory(base::FilePath* result) { return GetUserDirectory(CSIDL_MYPICTURES, result); } -bool GetUserVideosDirectory(FilePath* result) { +bool GetUserVideosDirectory(base::FilePath* result) { return GetUserDirectory(CSIDL_MYVIDEO, result); } diff --git a/chrome/common/chrome_utility_messages.h b/chrome/common/chrome_utility_messages.h index c1004ed..7a7b0e8 100644 --- a/chrome/common/chrome_utility_messages.h +++ b/chrome/common/chrome_utility_messages.h @@ -55,7 +55,7 @@ IPC_STRUCT_TRAITS_END() // Tell the utility process to unpack the given extension file in its // directory and verify that it is valid. IPC_MESSAGE_CONTROL4(ChromeUtilityMsg_UnpackExtension, - FilePath /* extension_filename */, + base::FilePath /* extension_filename */, std::string /* extension_id */, int /* Manifest::Location */, int /* InitFromValue flags */) @@ -81,7 +81,7 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_DecodeImageBase64, // Tell the utility process to render the given PDF into a metafile. IPC_MESSAGE_CONTROL4(ChromeUtilityMsg_RenderPDFPagesToMetafile, base::PlatformFile, // PDF file - FilePath, // Location for output metafile + base::FilePath, // Location for output metafile printing::PdfRenderSettings, // PDF render settitngs std::vector<printing::PageRange>) @@ -104,8 +104,8 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_GetPrinterCapsAndDefaults, #if defined(OS_CHROMEOS) // Tell the utility process to create a zip file on the given list of files. IPC_MESSAGE_CONTROL3(ChromeUtilityMsg_CreateZipFile, - FilePath /* src_dir */, - std::vector<FilePath> /* src_relative_paths */, + base::FilePath /* src_dir */, + std::vector<base::FilePath> /* src_relative_paths */, base::FileDescriptor /* dest_fd */) #endif // defined(OS_CHROMEOS) diff --git a/chrome/common/chrome_version_info_win.cc b/chrome/common/chrome_version_info_win.cc index 2dd77e1..a8ff8c8 100644 --- a/chrome/common/chrome_version_info_win.cc +++ b/chrome/common/chrome_version_info_win.cc @@ -16,7 +16,7 @@ namespace chrome { // static std::string VersionInfo::GetVersionStringModifier() { #if defined(GOOGLE_CHROME_BUILD) - FilePath module; + base::FilePath module; string16 channel; if (PathService::Get(base::FILE_MODULE, &module)) { bool is_system_install = @@ -36,7 +36,7 @@ VersionInfo::Channel VersionInfo::GetChannel() { #if defined(GOOGLE_CHROME_BUILD) std::wstring channel(L"unknown"); - FilePath module; + base::FilePath module; if (PathService::Get(base::FILE_MODULE, &module)) { bool is_system_install = !InstallUtil::IsPerUserInstall(module.value().c_str()); 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); diff --git a/chrome/common/json_schema_validator_unittest_base.cc b/chrome/common/json_schema_validator_unittest_base.cc index b3cc89d..8ef33db 100644 --- a/chrome/common/json_schema_validator_unittest_base.cc +++ b/chrome/common/json_schema_validator_unittest_base.cc @@ -26,7 +26,7 @@ namespace { #define TEST_SOURCE base::StringPrintf("%s:%i", __FILE__, __LINE__) Value* LoadValue(const std::string& filename) { - FilePath path; + base::FilePath path; PathService::Get(chrome::DIR_TEST_DATA, &path); path = path.AppendASCII("json_schema_validator").AppendASCII(filename); EXPECT_TRUE(file_util::PathExists(path)); diff --git a/chrome/common/json_value_serializer_perftest.cc b/chrome/common/json_value_serializer_perftest.cc index 791dc15..35fa440 100644 --- a/chrome/common/json_value_serializer_perftest.cc +++ b/chrome/common/json_value_serializer_perftest.cc @@ -26,7 +26,7 @@ class JSONValueSerializerTests : public testing::Test { // Load test cases for (size_t i = 0; i < arraysize(kTestFilenames); ++i) { - FilePath filename; + base::FilePath filename; EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &filename)); filename = filename.AppendASCII(kTestFilenames[i]); diff --git a/chrome/common/json_value_serializer_unittest.cc b/chrome/common/json_value_serializer_unittest.cc index 69685f2..46f45ab 100644 --- a/chrome/common/json_value_serializer_unittest.cc +++ b/chrome/common/json_value_serializer_unittest.cc @@ -248,7 +248,7 @@ protected: }; TEST_F(JSONFileValueSerializerTest, Roundtrip) { - FilePath original_file_path; + base::FilePath original_file_path; ASSERT_TRUE( PathService::Get(chrome::DIR_TEST_DATA, &original_file_path)); original_file_path = @@ -283,7 +283,7 @@ TEST_F(JSONFileValueSerializerTest, Roundtrip) { ASSERT_EQ("hello", string_value); // Now try writing. - const FilePath written_file_path = + const base::FilePath written_file_path = temp_dir_.path().Append(FILE_PATH_LITERAL("test_output.js")); ASSERT_FALSE(file_util::PathExists(written_file_path)); @@ -298,7 +298,7 @@ TEST_F(JSONFileValueSerializerTest, Roundtrip) { } TEST_F(JSONFileValueSerializerTest, RoundtripNested) { - FilePath original_file_path; + base::FilePath original_file_path; ASSERT_TRUE( PathService::Get(chrome::DIR_TEST_DATA, &original_file_path)); original_file_path = @@ -312,7 +312,7 @@ TEST_F(JSONFileValueSerializerTest, RoundtripNested) { ASSERT_TRUE(root.get()); // Now try writing. - FilePath written_file_path = + base::FilePath written_file_path = temp_dir_.path().Append(FILE_PATH_LITERAL("test_output.js")); ASSERT_FALSE(file_util::PathExists(written_file_path)); @@ -327,7 +327,7 @@ TEST_F(JSONFileValueSerializerTest, RoundtripNested) { } TEST_F(JSONFileValueSerializerTest, NoWhitespace) { - FilePath source_file_path; + base::FilePath source_file_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &source_file_path)); source_file_path = source_file_path.Append( FILE_PATH_LITERAL("serializer_test_nowhitespace.js")); diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc index 3b2e579..9a609b7 100644 --- a/chrome/common/logging_chrome.cc +++ b/chrome/common/logging_chrome.cc @@ -156,14 +156,15 @@ LoggingDestination DetermineLogMode(const CommandLine& command_line) { #if defined(OS_CHROMEOS) namespace { -FilePath SetUpSymlinkIfNeeded(const FilePath& symlink_path, bool new_log) { +base::FilePath SetUpSymlinkIfNeeded(const base::FilePath& symlink_path, + bool new_log) { DCHECK(!symlink_path.empty()); // If not starting a new log, then just log through the existing // symlink, but if the symlink doesn't exist, create it. If // starting a new log, then delete the old symlink and make a new // one to a fresh log file. - FilePath target_path; + base::FilePath target_path; bool symlink_exists = file_util::PathExists(symlink_path); if (new_log || !symlink_exists) { target_path = GenerateTimestampedName(symlink_path, base::Time::Now()); @@ -184,8 +185,8 @@ FilePath SetUpSymlinkIfNeeded(const FilePath& symlink_path, bool new_log) { return target_path; } -void RemoveSymlinkAndLog(const FilePath& link_path, - const FilePath& target_path) { +void RemoveSymlinkAndLog(const base::FilePath& link_path, + const base::FilePath& target_path) { if (::unlink(link_path.value().c_str()) == -1) DPLOG(WARNING) << "Unable to unlink symlink " << link_path.value(); if (::unlink(target_path.value().c_str()) == -1) @@ -194,16 +195,16 @@ void RemoveSymlinkAndLog(const FilePath& link_path, } // anonymous namespace -FilePath GetSessionLogFile(const CommandLine& command_line) { - FilePath log_dir; +base::FilePath GetSessionLogFile(const CommandLine& command_line) { + base::FilePath log_dir; std::string log_dir_str; scoped_ptr<base::Environment> env(base::Environment::Create()); if (env->GetVar(env_vars::kSessionLogDir, &log_dir_str) && !log_dir_str.empty()) { - log_dir = FilePath(log_dir_str); + log_dir = base::FilePath(log_dir_str); } else { PathService::Get(chrome::DIR_USER_DATA, &log_dir); - FilePath login_profile = + base::FilePath login_profile = command_line.GetSwitchValuePath(switches::kLoginProfile); log_dir = log_dir.Append(login_profile); } @@ -216,13 +217,13 @@ void RedirectChromeLogging(const CommandLine& command_line) { // Redirect logs to the session log directory, if set. Otherwise // defaults to the profile dir. - FilePath log_path = GetSessionLogFile(command_line); + base::FilePath log_path = GetSessionLogFile(command_line); // Creating symlink causes us to do blocking IO on UI thread. // Temporarily allow it until we fix http://crbug.com/61143 base::ThreadRestrictions::ScopedAllowIO allow_io; // Always force a new symlink when redirecting. - FilePath target_path = SetUpSymlinkIfNeeded(log_path, true); + base::FilePath target_path = SetUpSymlinkIfNeeded(log_path, true); logging::DcheckState dcheck_state = command_line.HasSwitch(switches::kEnableDCHECK) ? @@ -252,9 +253,9 @@ void InitChromeLogging(const CommandLine& command_line, LoggingDestination logging_dest = DetermineLogMode(command_line); LogLockingState log_locking_state = LOCK_LOG_FILE; - FilePath log_path; + base::FilePath log_path; #if defined(OS_CHROMEOS) - FilePath target_path; + base::FilePath target_path; #endif // Don't resolve the log path unless we need to. Otherwise we leave an open @@ -377,19 +378,19 @@ void CleanupChromeLogging() { chrome_logging_redirected_ = false; } -FilePath GetLogFileName() { +base::FilePath GetLogFileName() { std::string filename; scoped_ptr<base::Environment> env(base::Environment::Create()); if (env->GetVar(env_vars::kLogFileName, &filename) && !filename.empty()) { #if defined(OS_WIN) - return FilePath(UTF8ToWide(filename)); + return base::FilePath(UTF8ToWide(filename)); #elif defined(OS_POSIX) - return FilePath(filename); + return base::FilePath(filename); #endif } - const FilePath log_filename(FILE_PATH_LITERAL("chrome_debug.log")); - FilePath log_path; + const base::FilePath log_filename(FILE_PATH_LITERAL("chrome_debug.log")); + base::FilePath log_path; if (PathService::Get(chrome::DIR_LOGS, &log_path)) { log_path = log_path.Append(log_filename); @@ -432,8 +433,8 @@ size_t GetFatalAssertions(AssertionList* assertions) { return assertion_count; } -FilePath GenerateTimestampedName(const FilePath& base_path, - base::Time timestamp) { +base::FilePath GenerateTimestampedName(const base::FilePath& base_path, + base::Time timestamp) { base::Time::Exploded time_deets; timestamp.LocalExplode(&time_deets); std::string suffix = base::StringPrintf("_%02d%02d%02d-%02d%02d%02d", diff --git a/chrome/common/mac/app_mode_chrome_locator.mm b/chrome/common/mac/app_mode_chrome_locator.mm index 6ca56a7..292099d 100644 --- a/chrome/common/mac/app_mode_chrome_locator.mm +++ b/chrome/common/mac/app_mode_chrome_locator.mm @@ -14,7 +14,7 @@ namespace app_mode { -bool FindBundleById(NSString* bundle_id, FilePath* out_bundle) { +bool FindBundleById(NSString* bundle_id, base::FilePath* out_bundle) { NSWorkspace* ws = [NSWorkspace sharedWorkspace]; NSString *bundlePath = [ws absolutePathForAppBundleWithIdentifier:bundle_id]; if (!bundlePath) @@ -24,10 +24,10 @@ bool FindBundleById(NSString* bundle_id, FilePath* out_bundle) { return true; } -bool GetChromeBundleInfo(const FilePath& chrome_bundle, +bool GetChromeBundleInfo(const base::FilePath& chrome_bundle, string16* raw_version_str, - FilePath* version_path, - FilePath* framework_shlib_path) { + base::FilePath* version_path, + base::FilePath* framework_shlib_path) { using base::mac::ObjCCast; NSString* cr_bundle_path = base::mac::FilePathToNSString(chrome_bundle); diff --git a/chrome/common/mac/app_mode_chrome_locator_unittest.mm b/chrome/common/mac/app_mode_chrome_locator_unittest.mm index 2713ddc..69ea8a8 100644 --- a/chrome/common/mac/app_mode_chrome_locator_unittest.mm +++ b/chrome/common/mac/app_mode_chrome_locator_unittest.mm @@ -17,25 +17,25 @@ namespace { // Return the path to the Chrome/Chromium app bundle compiled along with the // test executable. -void GetChromeBundlePath(FilePath* chrome_bundle) { - FilePath path; +void GetChromeBundlePath(base::FilePath* chrome_bundle) { + base::FilePath path; PathService::Get(base::DIR_EXE, &path); path = path.Append(chrome::kBrowserProcessExecutableNameChromium); - path = path.ReplaceExtension(FilePath::StringType("app")); + path = path.ReplaceExtension(base::FilePath::StringType("app")); *chrome_bundle = path; } } // namespace TEST(ChromeLocatorTest, FindBundle) { - FilePath finder_bundle_path; + base::FilePath finder_bundle_path; EXPECT_TRUE( app_mode::FindBundleById(@"com.apple.finder", &finder_bundle_path)); EXPECT_TRUE(file_util::DirectoryExists(finder_bundle_path)); } TEST(ChromeLocatorTest, FindNonExistentBundle) { - FilePath dummy; + base::FilePath dummy; EXPECT_FALSE(app_mode::FindBundleById(@"this.doesnt.exist", &dummy)); } @@ -44,8 +44,8 @@ TEST(ChromeLocatorTest, GetNonExistentBundleInfo) { ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); string16 raw_version; - FilePath version_path; - FilePath framework_path; + base::FilePath version_path; + base::FilePath framework_path; EXPECT_FALSE(app_mode::GetChromeBundleInfo(temp_dir.path(), &raw_version, &version_path, &framework_path)); } @@ -53,13 +53,13 @@ TEST(ChromeLocatorTest, GetNonExistentBundleInfo) { TEST(ChromeLocatorTest, GetChromeBundleInfo) { using app_mode::GetChromeBundleInfo; - FilePath chrome_bundle_path; + base::FilePath chrome_bundle_path; GetChromeBundlePath(&chrome_bundle_path); ASSERT_TRUE(file_util::DirectoryExists(chrome_bundle_path)); string16 raw_version; - FilePath version_path; - FilePath framework_path; + base::FilePath version_path; + base::FilePath framework_path; EXPECT_TRUE(GetChromeBundleInfo(chrome_bundle_path, &raw_version, &version_path, &framework_path)); EXPECT_GT(raw_version.size(), 0U); diff --git a/chrome/common/mac/app_mode_common.h b/chrome/common/mac/app_mode_common.h index 4b604ff..2aef955 100644 --- a/chrome/common/mac/app_mode_common.h +++ b/chrome/common/mac/app_mode_common.h @@ -76,15 +76,15 @@ struct ChromeAppModeInfo { char** argv; // Required: v1.0 // Versioned path to the browser which is being loaded. - FilePath chrome_versioned_path; // Required: v1.0 + base::FilePath chrome_versioned_path; // Required: v1.0 // Path to Chrome app bundle. - FilePath chrome_outer_bundle_path; // Required: v1.0 + base::FilePath chrome_outer_bundle_path; // Required: v1.0 // Information about the App Mode shortcut: // Path to the App Mode Loader application bundle that launched the process. - FilePath app_mode_bundle_path; // Optional: v1.0 + base::FilePath app_mode_bundle_path; // Optional: v1.0 // Short ID string, preferably derived from |app_mode_short_name|. Should be // safe for the file system. @@ -97,10 +97,10 @@ struct ChromeAppModeInfo { std::string app_mode_url; // Required: v1.0 // Path to the app's user data directory. - FilePath user_data_dir; + base::FilePath user_data_dir; // Directory of the profile associated with the app. - FilePath profile_dir; + base::FilePath profile_dir; }; } // namespace app_mode diff --git a/chrome/common/mac/mock_launchd.cc b/chrome/common/mac/mock_launchd.cc index b6689d7..c6c196d 100644 --- a/chrome/common/mac/mock_launchd.cc +++ b/chrome/common/mac/mock_launchd.cc @@ -28,15 +28,15 @@ static const size_t kMaxPipeNameLength = sizeof(throwaway_sockaddr_un->sun_path); // static -bool MockLaunchd::MakeABundle(const FilePath& dst, +bool MockLaunchd::MakeABundle(const base::FilePath& dst, const std::string& name, - FilePath* bundle_root, - FilePath* executable) { + base::FilePath* bundle_root, + base::FilePath* executable) { *bundle_root = dst.Append(name + std::string(".app")); - FilePath contents = bundle_root->AppendASCII("Contents"); - FilePath mac_os = contents.AppendASCII("MacOS"); + base::FilePath contents = bundle_root->AppendASCII("Contents"); + base::FilePath mac_os = contents.AppendASCII("MacOS"); *executable = mac_os.Append(name); - FilePath info_plist = contents.Append("Info.plist"); + base::FilePath info_plist = contents.Append("Info.plist"); if (!file_util::CreateDirectory(mac_os)) { return false; @@ -93,7 +93,7 @@ bool MockLaunchd::MakeABundle(const FilePath& dst, return bundle.get(); } -MockLaunchd::MockLaunchd(const FilePath& file, MessageLoop* loop, +MockLaunchd::MockLaunchd(const base::FilePath& file, MessageLoop* loop, bool create_socket, bool as_service) : file_(file), message_loop_(loop), @@ -105,7 +105,7 @@ MockLaunchd::MockLaunchd(const FilePath& file, MessageLoop* loop, write_called_(false), delete_called_(false) { std::string pipe_suffix("_SOCKET"); - FilePath socket_path = file_; + base::FilePath socket_path = file_; while (socket_path.value().length() + pipe_suffix.length() > kMaxPipeNameLength - 2) { socket_path = socket_path.DirName(); diff --git a/chrome/common/mac/mock_launchd.h b/chrome/common/mac/mock_launchd.h index 147925c..0b52622 100644 --- a/chrome/common/mac/mock_launchd.h +++ b/chrome/common/mac/mock_launchd.h @@ -21,12 +21,12 @@ class MessageLoop; // http://crbug.com/76923 class MockLaunchd : public Launchd { public: - static bool MakeABundle(const FilePath& dst, + static bool MakeABundle(const base::FilePath& dst, const std::string& name, - FilePath* bundle_root, - FilePath* executable); + base::FilePath* bundle_root, + base::FilePath* executable); - MockLaunchd(const FilePath& file, MessageLoop* loop, + MockLaunchd(const base::FilePath& file, MessageLoop* loop, bool create_socket, bool as_service); virtual ~MockLaunchd(); @@ -60,7 +60,7 @@ class MockLaunchd : public Launchd { bool delete_called() const { return delete_called_; } private: - FilePath file_; + base::FilePath file_; std::string pipe_name_; MessageLoop* message_loop_; scoped_ptr<MultiProcessLock> running_lock_; diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index e259bc3..2634f4a 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -520,7 +520,7 @@ IPC_MESSAGE_ROUTED0(ChromeViewHostMsg_OpenAboutPlugins) // Tells the browser that there was an error loading a plug-in. IPC_MESSAGE_ROUTED1(ChromeViewHostMsg_CouldNotLoadPlugin, - FilePath /* plugin_path */) + base::FilePath /* plugin_path */) // Tells the browser that we blocked a plug-in because NPAPI is not supported. IPC_MESSAGE_ROUTED1(ChromeViewHostMsg_NPAPINotSupported, diff --git a/chrome/common/service_process_util.cc b/chrome/common/service_process_util.cc index 7161ca4..2dcd4f7 100644 --- a/chrome/common/service_process_util.cc +++ b/chrome/common/service_process_util.cc @@ -104,7 +104,7 @@ ServiceProcessRunningState GetServiceProcessRunningState( // use the hash of the user-data-dir as a scoping prefix. We can't use // the user-data-dir itself as we have limits on the size of the lock names. std::string GetServiceProcessScopedName(const std::string& append_str) { - FilePath user_data_dir; + base::FilePath user_data_dir; PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); #if defined(OS_WIN) std::string user_data_dir_path = WideToUTF8(user_data_dir.value()); @@ -250,7 +250,7 @@ IPC::ChannelHandle ServiceProcessState::GetServiceProcessChannel() { #endif // !OS_MACOSX void ServiceProcessState::CreateAutoRunCommandLine() { - FilePath exe_path; + base::FilePath exe_path; PathService::Get(content::CHILD_PROCESS_EXE, &exe_path); DCHECK(!exe_path.empty()) << "Unable to get service process binary name."; autorun_command_line_.reset(new CommandLine(exe_path)); @@ -260,7 +260,7 @@ void ServiceProcessState::CreateAutoRunCommandLine() { // The user data directory is the only other flag we currently want to // possibly store. const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); - FilePath user_data_dir = + base::FilePath user_data_dir = browser_command_line.GetSwitchValuePath(switches::kUserDataDir); if (!user_data_dir.empty()) autorun_command_line_->AppendSwitchPath(switches::kUserDataDir, diff --git a/chrome/common/service_process_util_linux.cc b/chrome/common/service_process_util_linux.cc index 0e912d0..f7c3ee5 100644 --- a/chrome/common/service_process_util_linux.cc +++ b/chrome/common/service_process_util_linux.cc @@ -51,7 +51,7 @@ bool ForceServiceProcessShutdown(const std::string& version, // Gets the name of the service process IPC channel. // Returns an absolute path as required. IPC::ChannelHandle GetServiceProcessChannel() { - FilePath temp_dir; + base::FilePath temp_dir; PathService::Get(base::DIR_TEMP, &temp_dir); std::string pipe_name = GetServiceProcessScopedVersionedName("_service_ipc"); std::string pipe_path = temp_dir.Append(pipe_name).value(); diff --git a/chrome/common/service_process_util_mac.mm b/chrome/common/service_process_util_mac.mm index 5751088..9ab7b08 100644 --- a/chrome/common/service_process_util_mac.mm +++ b/chrome/common/service_process_util_mac.mm @@ -47,7 +47,7 @@ NSString* GetServiceProcessLaunchDLabel() { scoped_nsobject<NSString> name( base::mac::CFToNSCast(CopyServiceProcessLaunchDName())); NSString *label = [name stringByAppendingString:@".service_process"]; - FilePath user_data_dir; + base::FilePath user_data_dir; PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); std::string user_data_dir_path = user_data_dir.value(); NSString *ns_path = base::SysUTF8ToNSString(user_data_dir_path); @@ -79,8 +79,8 @@ class ExecFilePathWatcherCallback { ExecFilePathWatcherCallback() {} ~ExecFilePathWatcherCallback() {} - bool Init(const FilePath& path); - void NotifyPathChanged(const FilePath& path, bool error); + bool Init(const base::FilePath& path); + void NotifyPathChanged(const base::FilePath& path, bool error); private: FSRef executable_fsref_; @@ -318,7 +318,8 @@ bool ServiceProcessState::StateData::WatchExecutable() { return false; } - FilePath executable_path = FilePath([exe_path fileSystemRepresentation]); + base::FilePath executable_path = + base::FilePath([exe_path fileSystemRepresentation]); scoped_ptr<ExecFilePathWatcherCallback> callback( new ExecFilePathWatcherCallback); if (!callback->Init(executable_path)) { @@ -336,11 +337,11 @@ bool ServiceProcessState::StateData::WatchExecutable() { return true; } -bool ExecFilePathWatcherCallback::Init(const FilePath& path) { +bool ExecFilePathWatcherCallback::Init(const base::FilePath& path) { return base::mac::FSRefFromPath(path.value(), &executable_fsref_); } -void ExecFilePathWatcherCallback::NotifyPathChanged(const FilePath& path, +void ExecFilePathWatcherCallback::NotifyPathChanged(const base::FilePath& path, bool error) { if (error) { NOTREACHED(); // TODO(darin): Do something smarter? diff --git a/chrome/common/service_process_util_unittest.cc b/chrome/common/service_process_util_unittest.cc index 618fc66..8fbccbb 100644 --- a/chrome/common/service_process_util_unittest.cc +++ b/chrome/common/service_process_util_unittest.cc @@ -279,9 +279,9 @@ class ServiceProcessStateFileManipulationTest : public ::testing::Test { } const MockLaunchd* mock_launchd() const { return mock_launchd_.get(); } - const FilePath& executable_path() const { return executable_path_; } - const FilePath& bundle_path() const { return bundle_path_; } - const FilePath& GetTempDirPath() const { return temp_dir_.path(); } + const base::FilePath& executable_path() const { return executable_path_; } + const base::FilePath& bundle_path() const { return bundle_path_; } + const base::FilePath& GetTempDirPath() const { return temp_dir_.path(); } base::MessageLoopProxy* GetIOMessageLoopProxy() { return io_thread_.message_loop_proxy().get(); @@ -292,38 +292,38 @@ class ServiceProcessStateFileManipulationTest : public ::testing::Test { base::ScopedTempDir temp_dir_; MessageLoopForUI loop_; base::Thread io_thread_; - FilePath executable_path_, bundle_path_; + base::FilePath executable_path_, bundle_path_; scoped_ptr<MockLaunchd> mock_launchd_; scoped_ptr<Launchd::ScopedInstance> scoped_launchd_instance_; ServiceProcessState service_process_state_; }; -void DeleteFunc(const FilePath& file) { +void DeleteFunc(const base::FilePath& file) { EXPECT_TRUE(file_util::Delete(file, true)); } -void MoveFunc(const FilePath& from, const FilePath& to) { +void MoveFunc(const base::FilePath& from, const base::FilePath& to) { EXPECT_TRUE(file_util::Move(from, to)); } -void ChangeAttr(const FilePath& from, int mode) { +void ChangeAttr(const base::FilePath& from, int mode) { EXPECT_EQ(chmod(from.value().c_str(), mode), 0); } class ScopedAttributesRestorer { public: - ScopedAttributesRestorer(const FilePath& path, int mode) + ScopedAttributesRestorer(const base::FilePath& path, int mode) : path_(path), mode_(mode) { } ~ScopedAttributesRestorer() { ChangeAttr(path_, mode_); } private: - FilePath path_; + base::FilePath path_; int mode_; }; -void TrashFunc(const FilePath& src) { +void TrashFunc(const base::FilePath& src) { FSRef path_ref; FSRef new_path_ref; EXPECT_TRUE(base::mac::FSRefFromPath(src.value(), &path_ref)); @@ -342,7 +342,7 @@ TEST_F(ServiceProcessStateFileManipulationTest, VerifyLaunchD) { // This test is designed to make sure that launchd is working. // http://crbug/75518 - CommandLine cl(FilePath("/bin/launchctl")); + CommandLine cl(base::FilePath("/bin/launchctl")); cl.AppendArg("list"); cl.AppendArg("com.apple.launchctl.Aqua"); @@ -372,7 +372,7 @@ TEST_F(ServiceProcessStateFileManipulationTest, DeleteBundle) { } TEST_F(ServiceProcessStateFileManipulationTest, MoveBundle) { - FilePath new_loc = GetTempDirPath().AppendASCII("MoveBundle"); + base::FilePath new_loc = GetTempDirPath().AppendASCII("MoveBundle"); GetIOMessageLoopProxy()->PostTask( FROM_HERE, base::Bind(&MoveFunc, bundle_path(), new_loc)); @@ -382,7 +382,7 @@ TEST_F(ServiceProcessStateFileManipulationTest, MoveBundle) { } TEST_F(ServiceProcessStateFileManipulationTest, MoveFile) { - FilePath new_loc = GetTempDirPath().AppendASCII("MoveFile"); + base::FilePath new_loc = GetTempDirPath().AppendASCII("MoveFile"); GetIOMessageLoopProxy()->PostTask( FROM_HERE, base::Bind(&MoveFunc, executable_path(), new_loc)); @@ -401,7 +401,7 @@ TEST_F(ServiceProcessStateFileManipulationTest, TrashBundle) { ASSERT_TRUE(mock_launchd()->remove_called()); ASSERT_TRUE(mock_launchd()->delete_called()); std::string path(base::mac::PathFromFSRef(bundle_ref)); - FilePath file_path(path); + base::FilePath file_path(path); ASSERT_TRUE(file_util::Delete(file_path, true)); } diff --git a/chrome/common/service_process_util_win.cc b/chrome/common/service_process_util_win.cc index d06989b..dfa2fc4 100644 --- a/chrome/common/service_process_util_win.cc +++ b/chrome/common/service_process_util_win.cc @@ -39,7 +39,7 @@ std::string GetServiceProcessAutoRunKey() { // Returns the name of the autotun reg value that we used to use for older // versions of Chrome. std::string GetObsoleteServiceProcessAutoRunKey() { - FilePath user_data_dir; + base::FilePath user_data_dir; PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); std::string scoped_name = WideToUTF8(user_data_dir.value()); std::replace(scoped_name.begin(), scoped_name.end(), '\\', '!'); diff --git a/chrome/common/spellcheck_common.cc b/chrome/common/spellcheck_common.cc index ea45664c..07ddc49a 100644 --- a/chrome/common/spellcheck_common.cc +++ b/chrome/common/spellcheck_common.cc @@ -88,8 +88,8 @@ std::string GetSpellCheckLanguageRegion(const std::string& input_language) { return input_language; } -FilePath GetVersionedFileName(const std::string& input_language, - const FilePath& dict_dir) { +base::FilePath GetVersionedFileName(const std::string& input_language, + const base::FilePath& dict_dir) { // The default dictionary version is 3-0. This version indicates that the bdic // file contains a checksum. static const char kDefaultVersionString[] = "-3-0"; diff --git a/chrome/common/web_apps_unittest.cc b/chrome/common/web_apps_unittest.cc index 5f71fcd..dbf04ab9 100644 --- a/chrome/common/web_apps_unittest.cc +++ b/chrome/common/web_apps_unittest.cc @@ -18,7 +18,7 @@ namespace { DictionaryValue* LoadDefinitionFile(const std::string& name) { - FilePath path; + base::FilePath path; if (!PathService::Get(chrome::DIR_TEST_DATA, &path)) { ADD_FAILURE() << "Could not get test data dir."; return NULL; diff --git a/chrome/common/zip.cc b/chrome/common/zip.cc index abd1247..e8bbbfb 100644 --- a/chrome/common/zip.cc +++ b/chrome/common/zip.cc @@ -23,7 +23,7 @@ namespace { -bool AddFileToZip(zipFile zip_file, const FilePath& src_dir) { +bool AddFileToZip(zipFile zip_file, const base::FilePath& src_dir) { net::FileStream stream(NULL); int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; if (stream.OpenSync(src_dir, flags) != 0) { @@ -48,8 +48,8 @@ bool AddFileToZip(zipFile zip_file, const FilePath& src_dir) { return true; } -bool AddEntryToZip(zipFile zip_file, const FilePath& path, - const FilePath& root_path) { +bool AddEntryToZip(zipFile zip_file, const base::FilePath& path, + const base::FilePath& root_path) { std::string str_path = path.AsUTF8Unsafe().substr(root_path.value().length() + 1); #if defined(OS_WIN) @@ -82,11 +82,11 @@ bool AddEntryToZip(zipFile zip_file, const FilePath& path, return success; } -bool ExcludeNoFilesFilter(const FilePath& file_path) { +bool ExcludeNoFilesFilter(const base::FilePath& file_path) { return true; } -bool ExcludeHiddenFilesFilter(const FilePath& file_path) { +bool ExcludeHiddenFilesFilter(const base::FilePath& file_path) { return file_path.BaseName().value()[0] != '.'; } @@ -94,7 +94,7 @@ bool ExcludeHiddenFilesFilter(const FilePath& file_path) { namespace zip { -bool Unzip(const FilePath& src_file, const FilePath& dest_dir) { +bool Unzip(const base::FilePath& src_file, const base::FilePath& dest_dir) { ZipReader reader; if (!reader.Open(src_file)) { DLOG(WARNING) << "Failed to open " << src_file.value(); @@ -123,7 +123,8 @@ bool Unzip(const FilePath& src_file, const FilePath& dest_dir) { return true; } -bool ZipWithFilterCallback(const FilePath& src_dir, const FilePath& dest_file, +bool ZipWithFilterCallback(const base::FilePath& src_dir, + const base::FilePath& dest_file, const FilterCallback& filter_cb) { DCHECK(file_util::DirectoryExists(src_dir)); @@ -139,7 +140,7 @@ bool ZipWithFilterCallback(const FilePath& src_dir, const FilePath& dest_file, file_util::FileEnumerator file_enumerator(src_dir, true /* recursive */, file_util::FileEnumerator::FILES | file_util::FileEnumerator::DIRECTORIES); - for (FilePath path = file_enumerator.Next(); !path.value().empty(); + for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); path = file_enumerator.Next()) { if (!filter_cb.Run(path)) { continue; @@ -159,7 +160,7 @@ bool ZipWithFilterCallback(const FilePath& src_dir, const FilePath& dest_file, return success; } -bool Zip(const FilePath& src_dir, const FilePath& dest_file, +bool Zip(const base::FilePath& src_dir, const base::FilePath& dest_file, bool include_hidden_files) { if (include_hidden_files) { return ZipWithFilterCallback( @@ -171,8 +172,8 @@ bool Zip(const FilePath& src_dir, const FilePath& dest_file, } #if defined(OS_POSIX) -bool ZipFiles(const FilePath& src_dir, - const std::vector<FilePath>& src_relative_paths, +bool ZipFiles(const base::FilePath& src_dir, + const std::vector<base::FilePath>& src_relative_paths, int dest_fd) { DCHECK(file_util::DirectoryExists(src_dir)); zipFile zip_file = internal::OpenFdForZipping(dest_fd, APPEND_STATUS_CREATE); @@ -183,9 +184,10 @@ bool ZipFiles(const FilePath& src_dir, } bool success = true; - for (std::vector<FilePath>::const_iterator iter = src_relative_paths.begin(); + for (std::vector<base::FilePath>::const_iterator iter = + src_relative_paths.begin(); iter != src_relative_paths.end(); ++iter) { - const FilePath& path = src_dir.Append(*iter); + const base::FilePath& path = src_dir.Append(*iter); if (!AddEntryToZip(zip_file, path, src_dir)) { // TODO(hshi): clean up the partial zip file when error occurs. success = false; diff --git a/chrome/common/zip.h b/chrome/common/zip.h index c5f34e7..26c5fec 100644 --- a/chrome/common/zip.h +++ b/chrome/common/zip.h @@ -15,14 +15,15 @@ namespace zip { // of src_dir will be at the root level of the created zip. For each file in // src_dir, include it only if the callback |filter_cb| returns true. Otherwise // omit it. -typedef base::Callback<bool(const FilePath&)> FilterCallback; -bool ZipWithFilterCallback(const FilePath& src_dir, const FilePath& dest_file, +typedef base::Callback<bool(const base::FilePath&)> FilterCallback; +bool ZipWithFilterCallback(const base::FilePath& src_dir, + const base::FilePath& dest_file, const FilterCallback& filter_cb); // Convenience method for callers who don't need to set up the filter callback. // If |include_hidden_files| is true, files starting with "." are included. // Otherwise they are omitted. -bool Zip(const FilePath& src_dir, const FilePath& dest_file, +bool Zip(const base::FilePath& src_dir, const base::FilePath& dest_file, bool include_hidden_files); #if defined(OS_POSIX) @@ -30,13 +31,13 @@ bool Zip(const FilePath& src_dir, const FilePath& dest_file, // descriptor |dest_fd|. The paths listed in |src_relative_paths| are relative // to the |src_dir| and will be used as the file names in the created zip file. // All source paths must be under |src_dir| in the file system hierarchy. -bool ZipFiles(const FilePath& src_dir, - const std::vector<FilePath>& src_relative_paths, +bool ZipFiles(const base::FilePath& src_dir, + const std::vector<base::FilePath>& src_relative_paths, int dest_fd); #endif // defined(OS_POSIX) // Unzip the contents of zip_file into dest_dir. -bool Unzip(const FilePath& zip_file, const FilePath& dest_dir); +bool Unzip(const base::FilePath& zip_file, const base::FilePath& dest_dir); } // namespace zip diff --git a/chrome/common/zip_reader.cc b/chrome/common/zip_reader.cc index 14960aa..d708f18 100644 --- a/chrome/common/zip_reader.cc +++ b/chrome/common/zip_reader.cc @@ -27,7 +27,7 @@ namespace zip { // function in zip.h, but not true for user-supplied random zip files. ZipReader::EntryInfo::EntryInfo(const std::string& file_name_in_zip, const unz_file_info& raw_file_info) - : file_path_(FilePath::FromUTF8Unsafe(file_name_in_zip)), + : file_path_(base::FilePath::FromUTF8Unsafe(file_name_in_zip)), is_directory_(false) { original_size_ = raw_file_info.uncompressed_size; @@ -77,7 +77,7 @@ ZipReader::~ZipReader() { Close(); } -bool ZipReader::Open(const FilePath& zip_file_path) { +bool ZipReader::Open(const base::FilePath& zip_file_path) { DCHECK(!zip_file_); // Use of "Unsafe" function does not look good, but there is no way to do @@ -168,7 +168,7 @@ bool ZipReader::OpenCurrentEntryInZip() { return true; } -bool ZipReader::LocateAndOpenEntry(const FilePath& path_in_zip) { +bool ZipReader::LocateAndOpenEntry(const base::FilePath& path_in_zip) { DCHECK(zip_file_); current_entry_info_.reset(); @@ -185,7 +185,7 @@ bool ZipReader::LocateAndOpenEntry(const FilePath& path_in_zip) { } bool ZipReader::ExtractCurrentEntryToFilePath( - const FilePath& output_file_path) { + const base::FilePath& output_file_path) { DCHECK(zip_file_); // If this is a directory, just create it and return. @@ -198,7 +198,7 @@ bool ZipReader::ExtractCurrentEntryToFilePath( // We can't rely on parent directory entries being specified in the // zip, so we make sure they are created. - FilePath output_dir_path = output_file_path.DirName(); + base::FilePath output_dir_path = output_file_path.DirName(); if (!file_util::CreateDirectory(output_dir_path)) return false; @@ -234,10 +234,10 @@ bool ZipReader::ExtractCurrentEntryToFilePath( } bool ZipReader::ExtractCurrentEntryIntoDirectory( - const FilePath& output_directory_path) { + const base::FilePath& output_directory_path) { DCHECK(current_entry_info_.get()); - FilePath output_file_path = output_directory_path.Append( + base::FilePath output_file_path = output_directory_path.Append( current_entry_info()->file_path()); return ExtractCurrentEntryToFilePath(output_file_path); } diff --git a/chrome/common/zip_reader.h b/chrome/common/zip_reader.h index cd3209d..a03f9b0 100644 --- a/chrome/common/zip_reader.h +++ b/chrome/common/zip_reader.h @@ -50,7 +50,7 @@ class ZipReader { // Returns the file path. The path is usually relative like // "foo/bar.txt", but if it's absolute, is_unsafe() returns true. - const FilePath& file_path() const { return file_path_; } + const base::FilePath& file_path() const { return file_path_; } // Returns the size of the original file (i.e. after uncompressed). // Returns 0 if the entry is a directory. @@ -67,7 +67,7 @@ class ZipReader { bool is_unsafe() const { return is_unsafe_; } private: - const FilePath file_path_; + const base::FilePath file_path_; int64 original_size_; base::Time last_modified_; bool is_directory_; @@ -80,7 +80,7 @@ class ZipReader { // Opens the zip file specified by |zip_file_path|. Returns true on // success. - bool Open(const FilePath& zip_file_path); + bool Open(const base::FilePath& zip_file_path); #if defined(OS_POSIX) // Opens the zip file referred to by the file descriptor |zip_fd|. @@ -121,7 +121,7 @@ class ZipReader { // Locates an entry in the zip file and opens it. Returns true on // success. This function internally calls OpenCurrentEntryInZip() on // success. On failure, current_entry_info() becomes NULL. - bool LocateAndOpenEntry(const FilePath& path_in_zip); + bool LocateAndOpenEntry(const base::FilePath& path_in_zip); // Extracts the current entry to the given output file path. If the // current file is a directory, just creates a directory @@ -129,7 +129,7 @@ class ZipReader { // called beforehand. // // This function does not preserve the timestamp of the original entry. - bool ExtractCurrentEntryToFilePath(const FilePath& output_file_path); + bool ExtractCurrentEntryToFilePath(const base::FilePath& output_file_path); // Extracts the current entry to the given output directory path using // ExtractCurrentEntryToFilePath(). Sub directories are created as needed @@ -139,7 +139,8 @@ class ZipReader { // // Returns true on success. OpenCurrentEntryInZip() must be called // beforehand. - bool ExtractCurrentEntryIntoDirectory(const FilePath& output_directory_path); + bool ExtractCurrentEntryIntoDirectory( + const base::FilePath& output_directory_path); #if defined(OS_POSIX) // Extracts the current entry by writing directly to a file descriptor. diff --git a/chrome/common/zip_reader_unittest.cc b/chrome/common/zip_reader_unittest.cc index 5afe4af..22aecf9 100644 --- a/chrome/common/zip_reader_unittest.cc +++ b/chrome/common/zip_reader_unittest.cc @@ -35,7 +35,7 @@ class FdWrapper { READ_WRITE } AccessMode; - FdWrapper(const FilePath& file, AccessMode mode) : fd_(-1) { + FdWrapper(const base::FilePath& file, AccessMode mode) : fd_(-1) { switch (mode) { case READ_ONLY: fd_ = open(file.value().c_str(), O_RDONLY); @@ -85,13 +85,17 @@ class ZipReaderTest : public PlatformTest { evil_via_absolute_file_name_zip_file_ = test_data_dir_.AppendASCII( "evil_via_absolute_file_name.zip"); - test_zip_contents_.insert(FilePath(FILE_PATH_LITERAL("foo/"))); - test_zip_contents_.insert(FilePath(FILE_PATH_LITERAL("foo/bar/"))); - test_zip_contents_.insert(FilePath(FILE_PATH_LITERAL("foo/bar/baz.txt"))); - test_zip_contents_.insert(FilePath(FILE_PATH_LITERAL("foo/bar/quux.txt"))); - test_zip_contents_.insert(FilePath(FILE_PATH_LITERAL("foo/bar.txt"))); - test_zip_contents_.insert(FilePath(FILE_PATH_LITERAL("foo.txt"))); - test_zip_contents_.insert(FilePath(FILE_PATH_LITERAL("foo/bar/.hidden"))); + test_zip_contents_.insert(base::FilePath(FILE_PATH_LITERAL("foo/"))); + test_zip_contents_.insert(base::FilePath(FILE_PATH_LITERAL("foo/bar/"))); + test_zip_contents_.insert( + base::FilePath(FILE_PATH_LITERAL("foo/bar/baz.txt"))); + test_zip_contents_.insert( + base::FilePath(FILE_PATH_LITERAL("foo/bar/quux.txt"))); + test_zip_contents_.insert( + base::FilePath(FILE_PATH_LITERAL("foo/bar.txt"))); + test_zip_contents_.insert(base::FilePath(FILE_PATH_LITERAL("foo.txt"))); + test_zip_contents_.insert( + base::FilePath(FILE_PATH_LITERAL("foo/bar/.hidden"))); } virtual void TearDown() { @@ -99,18 +103,18 @@ class ZipReaderTest : public PlatformTest { } // The path to temporary directory used to contain the test operations. - FilePath test_dir_; + base::FilePath test_dir_; // The path to the test data directory where test.zip etc. are located. - FilePath test_data_dir_; + base::FilePath test_data_dir_; // The path to test.zip in the test data directory. - FilePath test_zip_file_; + base::FilePath test_zip_file_; // The path to evil.zip in the test data directory. - FilePath evil_zip_file_; + base::FilePath evil_zip_file_; // The path to evil_via_invalid_utf8.zip in the test data directory. - FilePath evil_via_invalid_utf8_zip_file_; + base::FilePath evil_via_invalid_utf8_zip_file_; // The path to evil_via_absolute_file_name.zip in the test data directory. - FilePath evil_via_absolute_file_name_zip_file_; - std::set<FilePath> test_zip_contents_; + base::FilePath evil_via_absolute_file_name_zip_file_; + std::set<base::FilePath> test_zip_contents_; base::ScopedTempDir temp_dir_; }; @@ -141,7 +145,7 @@ TEST_F(ZipReaderTest, Open_ExistentButNonZipFile) { // Iterate through the contents in the test zip file, and compare that the // contents collected from the zip reader matches the expected contents. TEST_F(ZipReaderTest, Iteration) { - std::set<FilePath> actual_contents; + std::set<base::FilePath> actual_contents; ZipReader reader; ASSERT_TRUE(reader.Open(test_zip_file_)); while (reader.HasMore()) { @@ -160,7 +164,7 @@ TEST_F(ZipReaderTest, Iteration) { // Open the test zip file from a file descriptor, iterate through its contents, // and compare that they match the expected contents. TEST_F(ZipReaderTest, FdIteration) { - std::set<FilePath> actual_contents; + std::set<base::FilePath> actual_contents; ZipReader reader; FdWrapper zip_fd_wrapper(test_zip_file_, FdWrapper::READ_ONLY); ASSERT_TRUE(reader.OpenFromFd(zip_fd_wrapper.fd())); @@ -178,19 +182,19 @@ TEST_F(ZipReaderTest, FdIteration) { #endif TEST_F(ZipReaderTest, LocateAndOpenEntry_ValidFile) { - std::set<FilePath> actual_contents; + std::set<base::FilePath> actual_contents; ZipReader reader; ASSERT_TRUE(reader.Open(test_zip_file_)); - FilePath target_path(FILE_PATH_LITERAL("foo/bar/quux.txt")); + base::FilePath target_path(FILE_PATH_LITERAL("foo/bar/quux.txt")); ASSERT_TRUE(reader.LocateAndOpenEntry(target_path)); EXPECT_EQ(target_path, reader.current_entry_info()->file_path()); } TEST_F(ZipReaderTest, LocateAndOpenEntry_NonExistentFile) { - std::set<FilePath> actual_contents; + std::set<base::FilePath> actual_contents; ZipReader reader; ASSERT_TRUE(reader.Open(test_zip_file_)); - FilePath target_path(FILE_PATH_LITERAL("nonexistent.txt")); + base::FilePath target_path(FILE_PATH_LITERAL("nonexistent.txt")); ASSERT_FALSE(reader.LocateAndOpenEntry(target_path)); EXPECT_EQ(NULL, reader.current_entry_info()); } @@ -198,7 +202,7 @@ TEST_F(ZipReaderTest, LocateAndOpenEntry_NonExistentFile) { TEST_F(ZipReaderTest, ExtractCurrentEntryToFilePath_RegularFile) { ZipReader reader; ASSERT_TRUE(reader.Open(test_zip_file_)); - FilePath target_path(FILE_PATH_LITERAL("foo/bar/quux.txt")); + base::FilePath target_path(FILE_PATH_LITERAL("foo/bar/quux.txt")); ASSERT_TRUE(reader.LocateAndOpenEntry(target_path)); ASSERT_TRUE(reader.ExtractCurrentEntryToFilePath( test_dir_.AppendASCII("quux.txt"))); @@ -219,7 +223,7 @@ TEST_F(ZipReaderTest, FdExtractCurrentEntryToFilePath_RegularFile) { ZipReader reader; FdWrapper zip_fd_wrapper(test_zip_file_, FdWrapper::READ_ONLY); ASSERT_TRUE(reader.OpenFromFd(zip_fd_wrapper.fd())); - FilePath target_path(FILE_PATH_LITERAL("foo/bar/quux.txt")); + base::FilePath target_path(FILE_PATH_LITERAL("foo/bar/quux.txt")); ASSERT_TRUE(reader.LocateAndOpenEntry(target_path)); ASSERT_TRUE(reader.ExtractCurrentEntryToFilePath( test_dir_.AppendASCII("quux.txt"))); @@ -239,8 +243,8 @@ TEST_F(ZipReaderTest, FdExtractCurrentEntryToFd_RegularFile) { ZipReader reader; FdWrapper zip_fd_wrapper(test_zip_file_, FdWrapper::READ_ONLY); ASSERT_TRUE(reader.OpenFromFd(zip_fd_wrapper.fd())); - FilePath target_path(FILE_PATH_LITERAL("foo/bar/quux.txt")); - FilePath out_path = test_dir_.AppendASCII("quux.txt"); + base::FilePath target_path(FILE_PATH_LITERAL("foo/bar/quux.txt")); + base::FilePath out_path = test_dir_.AppendASCII("quux.txt"); FdWrapper out_fd_w(out_path, FdWrapper::READ_WRITE); ASSERT_TRUE(reader.LocateAndOpenEntry(target_path)); ASSERT_TRUE(reader.ExtractCurrentEntryToFd(out_fd_w.fd())); @@ -260,7 +264,7 @@ TEST_F(ZipReaderTest, FdExtractCurrentEntryToFd_RegularFile) { TEST_F(ZipReaderTest, ExtractCurrentEntryToFilePath_Directory) { ZipReader reader; ASSERT_TRUE(reader.Open(test_zip_file_)); - FilePath target_path(FILE_PATH_LITERAL("foo/")); + base::FilePath target_path(FILE_PATH_LITERAL("foo/")); ASSERT_TRUE(reader.LocateAndOpenEntry(target_path)); ASSERT_TRUE(reader.ExtractCurrentEntryToFilePath( test_dir_.AppendASCII("foo"))); @@ -271,7 +275,7 @@ TEST_F(ZipReaderTest, ExtractCurrentEntryToFilePath_Directory) { TEST_F(ZipReaderTest, ExtractCurrentEntryIntoDirectory_RegularFile) { ZipReader reader; ASSERT_TRUE(reader.Open(test_zip_file_)); - FilePath target_path(FILE_PATH_LITERAL("foo/bar/quux.txt")); + base::FilePath target_path(FILE_PATH_LITERAL("foo/bar/quux.txt")); ASSERT_TRUE(reader.LocateAndOpenEntry(target_path)); ASSERT_TRUE(reader.ExtractCurrentEntryIntoDirectory(test_dir_)); // Sub directories should be created. @@ -288,7 +292,7 @@ TEST_F(ZipReaderTest, ExtractCurrentEntryIntoDirectory_RegularFile) { TEST_F(ZipReaderTest, current_entry_info_RegularFile) { ZipReader reader; ASSERT_TRUE(reader.Open(test_zip_file_)); - FilePath target_path(FILE_PATH_LITERAL("foo/bar/quux.txt")); + base::FilePath target_path(FILE_PATH_LITERAL("foo/bar/quux.txt")); ASSERT_TRUE(reader.LocateAndOpenEntry(target_path)); ZipReader::EntryInfo* current_entry_info = reader.current_entry_info(); @@ -313,7 +317,7 @@ TEST_F(ZipReaderTest, current_entry_info_RegularFile) { TEST_F(ZipReaderTest, current_entry_info_DotDotFile) { ZipReader reader; ASSERT_TRUE(reader.Open(evil_zip_file_)); - FilePath target_path(FILE_PATH_LITERAL( + base::FilePath target_path(FILE_PATH_LITERAL( "../levilevilevilevilevilevilevilevilevilevilevilevil")); ASSERT_TRUE(reader.LocateAndOpenEntry(target_path)); ZipReader::EntryInfo* current_entry_info = reader.current_entry_info(); @@ -342,7 +346,7 @@ TEST_F(ZipReaderTest, current_entry_info_InvalidUTF8File) { TEST_F(ZipReaderTest, current_entry_info_AbsoluteFile) { ZipReader reader; ASSERT_TRUE(reader.Open(evil_via_absolute_file_name_zip_file_)); - FilePath target_path(FILE_PATH_LITERAL("/evil.txt")); + base::FilePath target_path(FILE_PATH_LITERAL("/evil.txt")); ASSERT_TRUE(reader.LocateAndOpenEntry(target_path)); ZipReader::EntryInfo* current_entry_info = reader.current_entry_info(); EXPECT_EQ(target_path, current_entry_info->file_path()); @@ -355,11 +359,11 @@ TEST_F(ZipReaderTest, current_entry_info_AbsoluteFile) { TEST_F(ZipReaderTest, current_entry_info_Directory) { ZipReader reader; ASSERT_TRUE(reader.Open(test_zip_file_)); - FilePath target_path(FILE_PATH_LITERAL("foo/bar/")); + base::FilePath target_path(FILE_PATH_LITERAL("foo/bar/")); ASSERT_TRUE(reader.LocateAndOpenEntry(target_path)); ZipReader::EntryInfo* current_entry_info = reader.current_entry_info(); - EXPECT_EQ(FilePath(FILE_PATH_LITERAL("foo/bar/")), + EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("foo/bar/")), current_entry_info->file_path()); // The directory size should be zero. EXPECT_EQ(0, current_entry_info->original_size()); @@ -402,7 +406,7 @@ TEST_F(ZipReaderTest, OpenFromString) { std::string data(kTestData, arraysize(kTestData)); ZipReader reader; ASSERT_TRUE(reader.OpenFromString(data)); - FilePath target_path(FILE_PATH_LITERAL("test.txt")); + base::FilePath target_path(FILE_PATH_LITERAL("test.txt")); ASSERT_TRUE(reader.LocateAndOpenEntry(target_path)); ASSERT_TRUE(reader.ExtractCurrentEntryToFilePath( test_dir_.AppendASCII("test.txt"))); diff --git a/chrome/common/zip_unittest.cc b/chrome/common/zip_unittest.cc index 2496170..e1230ba 100644 --- a/chrome/common/zip_unittest.cc +++ b/chrome/common/zip_unittest.cc @@ -26,7 +26,7 @@ class ZipTest : public PlatformTest { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); test_dir_ = temp_dir_.path(); - FilePath zip_path(test_dir_); + base::FilePath zip_path(test_dir_); zip_contents_.insert(zip_path.AppendASCII("foo.txt")); zip_path = zip_path.AppendASCII("foo"); zip_contents_.insert(zip_path); @@ -38,7 +38,7 @@ class ZipTest : public PlatformTest { zip_contents_.insert(zip_path.AppendASCII(".hidden")); // Include a subset of files in |zip_file_list_| to test ZipFiles(). - zip_file_list_.push_back(FilePath(FILE_PATH_LITERAL("foo.txt"))); + zip_file_list_.push_back(base::FilePath(FILE_PATH_LITERAL("foo.txt"))); zip_file_list_.push_back(FilePath(FILE_PATH_LITERAL("foo/bar/quux.txt"))); zip_file_list_.push_back(FilePath(FILE_PATH_LITERAL("foo/bar/.hidden"))); } diff --git a/content/common/child_process_host_impl.cc b/content/common/child_process_host_impl.cc index b88ca94..77d037c 100644 --- a/content/common/child_process_host_impl.cc +++ b/content/common/child_process_host_impl.cc @@ -38,25 +38,25 @@ namespace { // path for feature "NP" would be // ".../Chromium Helper NP.app/Contents/MacOS/Chromium Helper NP". The new // path is returned. -FilePath TransformPathForFeature(const FilePath& path, +base::FilePath TransformPathForFeature(const base::FilePath& path, const std::string& feature) { std::string basename = path.BaseName().value(); - FilePath macos_path = path.DirName(); + base::FilePath macos_path = path.DirName(); const char kMacOSName[] = "MacOS"; DCHECK_EQ(kMacOSName, macos_path.BaseName().value()); - FilePath contents_path = macos_path.DirName(); + base::FilePath contents_path = macos_path.DirName(); const char kContentsName[] = "Contents"; DCHECK_EQ(kContentsName, contents_path.BaseName().value()); - FilePath helper_app_path = contents_path.DirName(); + base::FilePath helper_app_path = contents_path.DirName(); const char kAppExtension[] = ".app"; std::string basename_app = basename; basename_app.append(kAppExtension); DCHECK_EQ(basename_app, helper_app_path.BaseName().value()); - FilePath root_path = helper_app_path.DirName(); + base::FilePath root_path = helper_app_path.DirName(); std::string new_basename = basename; new_basename.append(1, ' '); @@ -64,7 +64,7 @@ FilePath TransformPathForFeature(const FilePath& path, std::string new_basename_app = new_basename; new_basename_app.append(kAppExtension); - FilePath new_path = root_path.Append(new_basename_app) + base::FilePath new_path = root_path.Append(new_basename_app) .Append(kContentsName) .Append(kMacOSName) .Append(new_basename); @@ -85,8 +85,8 @@ ChildProcessHost* ChildProcessHost::Create(ChildProcessHostDelegate* delegate) { } // static -FilePath ChildProcessHost::GetChildPath(int flags) { - FilePath child_path; +base::FilePath ChildProcessHost::GetChildPath(int flags) { + base::FilePath child_path; child_path = CommandLine::ForCurrentProcess()->GetSwitchValuePath( switches::kBrowserSubprocessPath); @@ -98,7 +98,7 @@ FilePath ChildProcessHost::GetChildPath(int flags) { // Valgrind executable, which then crashes. However, it's almost safe to // assume that the updates won't happen while testing with Valgrind tools. if (child_path.empty() && flags & CHILD_ALLOW_SELF && !RunningOnValgrind()) - child_path = FilePath(base::kProcSelfExe); + child_path = base::FilePath(base::kProcSelfExe); #endif // On most platforms, the child executable is the same as the current diff --git a/content/common/content_paths.cc b/content/common/content_paths.cc index 19232b2..e6e1905 100644 --- a/content/common/content_paths.cc +++ b/content/common/content_paths.cc @@ -10,12 +10,12 @@ namespace content { -bool PathProvider(int key, FilePath* result) { +bool PathProvider(int key, base::FilePath* result) { switch (key) { case CHILD_PROCESS_EXE: return PathService::Get(base::FILE_EXE, result); case DIR_TEST_DATA: { - FilePath cur; + base::FilePath cur; if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("content")); @@ -38,7 +38,7 @@ bool PathProvider(int key, FilePath* result) { #endif } case DIR_LAYOUT_TESTS: { - FilePath cur; + base::FilePath cur; if (!PathService::Get(DIR_TEST_DATA, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("layout_tests")); diff --git a/content/common/file_utilities_messages.h b/content/common/file_utilities_messages.h index a8500f5..58fdbae 100644 --- a/content/common/file_utilities_messages.h +++ b/content/common/file_utilities_messages.h @@ -14,12 +14,12 @@ // File utilities messages sent from the renderer to the browser. IPC_SYNC_MESSAGE_CONTROL1_2(FileUtilitiesMsg_GetFileInfo, - FilePath /* path */, + base::FilePath /* path */, base::PlatformFileInfo /* result */, base::PlatformFileError /* status */) // Open the file. IPC_SYNC_MESSAGE_CONTROL2_1(FileUtilitiesMsg_OpenFile, - FilePath /* path */, + base::FilePath /* path */, int /* mode */, IPC::PlatformFileForTransit /* result */) diff --git a/content/common/fileapi/file_system_dispatcher.cc b/content/common/fileapi/file_system_dispatcher.cc index d48a82e..c3d495a 100644 --- a/content/common/fileapi/file_system_dispatcher.cc +++ b/content/common/fileapi/file_system_dispatcher.cc @@ -285,7 +285,7 @@ void FileSystemDispatcher::OnDidSucceed(int request_id) { void FileSystemDispatcher::OnDidReadMetadata( int request_id, const base::PlatformFileInfo& file_info, - const FilePath& platform_path) { + const base::FilePath& platform_path) { fileapi::FileSystemCallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); DCHECK(dispatcher); diff --git a/content/common/fileapi/file_system_messages.h b/content/common/fileapi/file_system_messages.h index 5de1aac..a6cfbdd 100644 --- a/content/common/fileapi/file_system_messages.h +++ b/content/common/fileapi/file_system_messages.h @@ -34,7 +34,7 @@ IPC_MESSAGE_CONTROL1(FileSystemMsg_DidSucceed, IPC_MESSAGE_CONTROL3(FileSystemMsg_DidReadMetadata, int /* request_id */, base::PlatformFileInfo, - FilePath /* true platform path, where possible */) + base::FilePath /* true platform path, where possible */) IPC_MESSAGE_CONTROL3(FileSystemMsg_DidReadDirectory, int /* request_id */, std::vector<base::FileUtilProxy::Entry> /* entries */, @@ -152,7 +152,7 @@ IPC_MESSAGE_CONTROL3(FileSystemHostMsg_CreateSnapshotFile, // For Pepper's URL loader. IPC_SYNC_MESSAGE_CONTROL1_1(FileSystemHostMsg_SyncGetPlatformPath, GURL /* file path */, - FilePath /* platform_path */) + base::FilePath /* platform_path */) // Pre- and post-update notifications for ppapi implementation. IPC_MESSAGE_CONTROL1(FileSystemHostMsg_WillUpdate, diff --git a/content/common/fileapi/webfilesystem_callback_dispatcher.cc b/content/common/fileapi/webfilesystem_callback_dispatcher.cc index a364b2c..391464d 100644 --- a/content/common/fileapi/webfilesystem_callback_dispatcher.cc +++ b/content/common/fileapi/webfilesystem_callback_dispatcher.cc @@ -38,7 +38,8 @@ void WebFileSystemCallbackDispatcher::DidSucceed() { } void WebFileSystemCallbackDispatcher::DidReadMetadata( - const base::PlatformFileInfo& file_info, const FilePath& platform_path) { + const base::PlatformFileInfo& file_info, + const base::FilePath& platform_path) { WebFileInfo web_file_info; webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info); web_file_info.platformPath = webkit_base::FilePathToWebString(platform_path); diff --git a/content/common/fileapi/webfilesystem_callback_dispatcher.h b/content/common/fileapi/webfilesystem_callback_dispatcher.h index 22a12c9..1450da3 100644 --- a/content/common/fileapi/webfilesystem_callback_dispatcher.h +++ b/content/common/fileapi/webfilesystem_callback_dispatcher.h @@ -27,7 +27,7 @@ class WebFileSystemCallbackDispatcher virtual void DidSucceed() OVERRIDE; virtual void DidReadMetadata( const base::PlatformFileInfo& file_info, - const FilePath& platform_path) OVERRIDE; + const base::FilePath& platform_path) OVERRIDE; virtual void DidReadDirectory( const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more) OVERRIDE; diff --git a/content/common/fileapi/webfilewriter_impl.cc b/content/common/fileapi/webfilewriter_impl.cc index c6a4d25..f441cad 100644 --- a/content/common/fileapi/webfilewriter_impl.cc +++ b/content/common/fileapi/webfilewriter_impl.cc @@ -24,7 +24,8 @@ class WebFileWriterImpl::CallbackDispatcher virtual ~CallbackDispatcher() { } - virtual void DidReadMetadata(const base::PlatformFileInfo&, const FilePath&) { + virtual void DidReadMetadata(const base::PlatformFileInfo&, + const base::FilePath&) { NOTREACHED(); } virtual void DidReadDirectory( diff --git a/content/common/gpu/media/h264_parser_unittest.cc b/content/common/gpu/media/h264_parser_unittest.cc index fdcd569..7c2a757 100644 --- a/content/common/gpu/media/h264_parser_unittest.cc +++ b/content/common/gpu/media/h264_parser_unittest.cc @@ -13,13 +13,13 @@ using content::H264Parser; using content::H264NALU; -const FilePath::CharType* test_stream_filename = +const base::FilePath::CharType* test_stream_filename = FILE_PATH_LITERAL("content/common/gpu/testdata/test-25fps.h264"); // Number of NALUs in the stream to be parsed. int num_nalus = 759; TEST(H264ParserTest, StreamFileParsing) { - FilePath fp(test_stream_filename); + base::FilePath fp(test_stream_filename); file_util::MemoryMappedFile stream; CHECK(stream.Initialize(fp)) << "Couldn't open stream file: " << test_stream_filename; diff --git a/content/common/gpu/media/video_decode_accelerator_unittest.cc b/content/common/gpu/media/video_decode_accelerator_unittest.cc index 756a904..8da4da3 100644 --- a/content/common/gpu/media/video_decode_accelerator_unittest.cc +++ b/content/common/gpu/media/video_decode_accelerator_unittest.cc @@ -76,13 +76,13 @@ namespace { // - |profile| is the media::VideoCodecProfile set during Initialization. // An empty value for a numeric field means "ignore". #if defined(OS_MACOSX) -const FilePath::CharType* test_video_data = +const base::FilePath::CharType* test_video_data = FILE_PATH_LITERAL("test-25fps_high.h264:1280:720:250:252:50:100:4"); #else // TODO(fischman): figure out how to support multiple test videos per run (needs // to refactor where ParseTestVideoData is called). For now just make it easy // to replace which file is used by commenting/uncommenting these lines: -const FilePath::CharType* test_video_data = +const base::FilePath::CharType* test_video_data = // FILE_PATH_LITERAL("test-25fps.vp8:320:240:250:250:50:175:11"); FILE_PATH_LITERAL("test-25fps.h264:320:240:250:258:50:175:1"); #endif @@ -90,15 +90,15 @@ const FilePath::CharType* test_video_data = // Parse |data| into its constituent parts and set the various output fields // accordingly. CHECK-fails on unexpected or missing required data. // Unspecified optional fields are set to -1. -void ParseTestVideoData(FilePath::StringType data, - FilePath::StringType* file_name, +void ParseTestVideoData(base::FilePath::StringType data, + base::FilePath::StringType* file_name, int* width, int* height, int* num_frames, int* num_fragments, int* min_fps_render, int* min_fps_no_render, int* profile) { - std::vector<FilePath::StringType> elements; + std::vector<base::FilePath::StringType> elements; base::SplitString(data, ':', &elements); CHECK_GE(elements.size(), 1U) << data; CHECK_LE(elements.size(), 8U) << data; @@ -694,7 +694,7 @@ TEST_P(VideoDecodeAcceleratorTest, TestSimpleDecode) { const int reset_after_frame_num = GetParam().e; const int delete_decoder_state = GetParam().f; - FilePath::StringType test_video_file; + base::FilePath::StringType test_video_file; int frame_width, frame_height; int num_frames, num_fragments, min_fps_render, min_fps_no_render, profile; ParseTestVideoData(test_video_data, &test_video_file, &frame_width, @@ -717,8 +717,9 @@ TEST_P(VideoDecodeAcceleratorTest, TestSimpleDecode) { // Read in the video data. std::string data_str; - CHECK(file_util::ReadFileToString(FilePath(test_video_file), &data_str)) - << "test_video_file: " << FilePath(test_video_file).MaybeAsASCII(); + CHECK(file_util::ReadFileToString(base::FilePath(test_video_file), + &data_str)) + << "test_video_file: " << base::FilePath(test_video_file).MaybeAsASCII(); // Initialize the rendering helper. base::Thread rendering_thread("GLRenderingVDAClientThread"); diff --git a/content/common/mac/font_loader.mm b/content/common/mac/font_loader.mm index dbede8b..b309ab9 100644 --- a/content/common/mac/font_loader.mm +++ b/content/common/mac/font_loader.mm @@ -103,7 +103,8 @@ void FontLoader::LoadFont(const FontDescriptor& font, DLOG(ERROR) << "Failed to find font file for " << font_name; return; } - FilePath font_path = FilePath(base::mac::PathFromFSRef(font_fsref)); + base::FilePath font_path = + base::FilePath(base::mac::PathFromFSRef(font_fsref)); // Load file into shared memory buffer. int64 font_file_size_64 = -1; diff --git a/content/common/mime_registry_messages.h b/content/common/mime_registry_messages.h index 559f0ac..6d94189 100644 --- a/content/common/mime_registry_messages.h +++ b/content/common/mime_registry_messages.h @@ -15,12 +15,12 @@ // Sent to query MIME information. IPC_SYNC_MESSAGE_CONTROL1_1(MimeRegistryMsg_GetMimeTypeFromExtension, - FilePath::StringType /* extension */, + base::FilePath::StringType /* extension */, std::string /* mime_type */) IPC_SYNC_MESSAGE_CONTROL1_1(MimeRegistryMsg_GetMimeTypeFromFile, - FilePath /* file_path */, + base::FilePath /* file_path */, std::string /* mime_type */) IPC_SYNC_MESSAGE_CONTROL1_1(MimeRegistryMsg_GetPreferredExtensionForMimeType, std::string /* mime_type */, - FilePath::StringType /* extension */) + base::FilePath::StringType /* extension */) diff --git a/content/common/npobject_stub.cc b/content/common/npobject_stub.cc index b715224..668cb08 100644 --- a/content/common/npobject_stub.cc +++ b/content/common/npobject_stub.cc @@ -247,7 +247,7 @@ void NPObjectStub::OnSetProperty(const NPIdentifier_Param& name, if (IsPluginProcess()) { if (npobject_->_class->setProperty) { #if defined(OS_WIN) - static FilePath plugin_path = + static base::FilePath plugin_path = CommandLine::ForCurrentProcess()->GetSwitchValuePath( switches::kPluginPath); static std::wstring filename = StringToLowerASCII( diff --git a/content/common/pepper_plugin_registry.cc b/content/common/pepper_plugin_registry.cc index 457ee8f..66690c6 100644 --- a/content/common/pepper_plugin_registry.cc +++ b/content/common/pepper_plugin_registry.cc @@ -53,9 +53,9 @@ void ComputePluginsFromCommandLine(std::vector<PepperPluginInfo>* plugins) { // This means we can't provide plugins from non-ASCII paths, but // since this switch is only for development I don't think that's // too awful. - plugin.path = FilePath(ASCIIToUTF16(name_parts[0])); + plugin.path = base::FilePath(ASCIIToUTF16(name_parts[0])); #else - plugin.path = FilePath(name_parts[0]); + plugin.path = base::FilePath(name_parts[0]); #endif if (name_parts.size() > 1) plugin.name = name_parts[1]; @@ -112,7 +112,7 @@ bool MakePepperPluginInfo(const webkit::WebPluginInfo& webplugin_info, pepper_info->is_sandboxed = webplugin_info.type != webkit::WebPluginInfo::PLUGIN_TYPE_PEPPER_UNSANDBOXED; - pepper_info->path = FilePath(webplugin_info.path); + pepper_info->path = base::FilePath(webplugin_info.path); pepper_info->name = UTF16ToASCII(webplugin_info.name); pepper_info->description = UTF16ToASCII(webplugin_info.desc); pepper_info->version = UTF16ToASCII(webplugin_info.version); @@ -175,14 +175,14 @@ const PepperPluginInfo* PepperPluginRegistry::GetInfoForPlugin( } webkit::ppapi::PluginModule* PepperPluginRegistry::GetLiveModule( - const FilePath& path) { + const base::FilePath& path) { NonOwningModuleMap::iterator it = live_modules_.find(path); if (it == live_modules_.end()) return NULL; return it->second; } -void PepperPluginRegistry::AddLiveModule(const FilePath& path, +void PepperPluginRegistry::AddLiveModule(const base::FilePath& path, webkit::ppapi::PluginModule* module) { DCHECK(live_modules_.find(path) == live_modules_.end()); live_modules_[path] = module; diff --git a/content/common/pepper_plugin_registry.h b/content/common/pepper_plugin_registry.h index f0a5ebf..de9e8b2 100644 --- a/content/common/pepper_plugin_registry.h +++ b/content/common/pepper_plugin_registry.h @@ -55,13 +55,14 @@ class PepperPluginRegistry // both preloaded in-process or currently active (non crashed) out-of-process // plugins matching the given name. Returns NULL if the plugin hasn't been // loaded. - webkit::ppapi::PluginModule* GetLiveModule(const FilePath& path); + webkit::ppapi::PluginModule* GetLiveModule(const base::FilePath& path); // Notifies the registry that a new non-preloaded module has been created. // This is normally called for out-of-process plugins. Once this is called, // the module is available to be returned by GetModule(). The module will // automatically unregister itself by calling PluginModuleDestroyed(). - void AddLiveModule(const FilePath& path, webkit::ppapi::PluginModule* module); + void AddLiveModule(const base::FilePath& path, + webkit::ppapi::PluginModule* module); // ModuleLifetime implementation. virtual void PluginModuleDead( @@ -75,7 +76,8 @@ class PepperPluginRegistry // Plugins that have been preloaded so they can be executed in-process in // the renderer (the sandbox prevents on-demand loading). - typedef std::map<FilePath, scoped_refptr<webkit::ppapi::PluginModule> > + typedef std::map<base::FilePath, + scoped_refptr<webkit::ppapi::PluginModule> > OwningModuleMap; OwningModuleMap preloaded_modules_; @@ -85,7 +87,8 @@ class PepperPluginRegistry // non-crashed modules. If an out-of-process module crashes, it may // continue as long as there are WebKit references to it, but it will not // appear in this list. - typedef std::map<FilePath, webkit::ppapi::PluginModule*> NonOwningModuleMap; + typedef std::map<base::FilePath, webkit::ppapi::PluginModule*> + NonOwningModuleMap; NonOwningModuleMap live_modules_; DISALLOW_COPY_AND_ASSIGN(PepperPluginRegistry); diff --git a/content/common/resource_messages.cc b/content/common/resource_messages.cc index 913883a..3edaee3 100644 --- a/content/common/resource_messages.cc +++ b/content/common/resource_messages.cc @@ -81,7 +81,7 @@ bool ParamTraits<webkit_base::DataElement>::Read( break; } case webkit_base::DataElement::TYPE_FILE: { - FilePath file_path; + base::FilePath file_path; uint64 offset, length; base::Time expected_modification_time; if (!ReadParam(m, iter, &file_path)) diff --git a/content/common/sandbox_init_mac.cc b/content/common/sandbox_init_mac.cc index 6e12c18..766497d 100644 --- a/content/common/sandbox_init_mac.cc +++ b/content/common/sandbox_init_mac.cc @@ -12,7 +12,7 @@ namespace content { -bool InitializeSandbox(int sandbox_type, const FilePath& allowed_dir) { +bool InitializeSandbox(int sandbox_type, const base::FilePath& allowed_dir) { // Warm up APIs before turning on the sandbox. Sandbox::SandboxWarmup(sandbox_type); @@ -24,12 +24,12 @@ bool InitializeSandbox(int sandbox_type, const FilePath& allowed_dir) { // false if the current process type doesn't need to be sandboxed or if the // sandbox was disabled from the command line. bool GetSandboxTypeFromCommandLine(int* sandbox_type, - FilePath* allowed_dir) { + base::FilePath* allowed_dir) { DCHECK(sandbox_type); DCHECK(allowed_dir); *sandbox_type = -1; - *allowed_dir = FilePath(); // Empty by default. + *allowed_dir = base::FilePath(); // Empty by default. const CommandLine& command_line = *CommandLine::ForCurrentProcess(); if (command_line.HasSwitch(switches::kNoSandbox)) @@ -78,7 +78,7 @@ bool GetSandboxTypeFromCommandLine(int* sandbox_type, bool InitializeSandbox() { int sandbox_type = 0; - FilePath allowed_dir; + base::FilePath allowed_dir; if (!GetSandboxTypeFromCommandLine(&sandbox_type, &allowed_dir)) return true; return InitializeSandbox(sandbox_type, allowed_dir); diff --git a/content/common/sandbox_linux.cc b/content/common/sandbox_linux.cc index 658063f..776e754 100644 --- a/content/common/sandbox_linux.cc +++ b/content/common/sandbox_linux.cc @@ -210,7 +210,7 @@ bool LinuxSandbox::IsSingleThreaded() const { // Possibly racy, but it's ok because this is more of a debug check to catch // new threaded situations arising during development. int num_threads = file_util::CountFilesCreatedAfter( - FilePath("/proc/self/task"), + base::FilePath("/proc/self/task"), base::Time::UnixEpoch()); // We pass the test if we don't know ( == 0), because the setuid sandbox diff --git a/content/common/sandbox_mac.mm b/content/common/sandbox_mac.mm index cf8b7f4..ef229f7 100644 --- a/content/common/sandbox_mac.mm +++ b/content/common/sandbox_mac.mm @@ -106,11 +106,11 @@ NOINLINE void FatalStringQuoteException(const std::string& str) { } // namespace // static -NSString* Sandbox::AllowMetadataForPath(const FilePath& allowed_path) { +NSString* Sandbox::AllowMetadataForPath(const base::FilePath& allowed_path) { // Collect a list of all parent directories. - FilePath last_path = allowed_path; - std::vector<FilePath> subpaths; - for (FilePath path = allowed_path; + base::FilePath last_path = allowed_path; + std::vector<base::FilePath> subpaths; + for (base::FilePath path = allowed_path; path.value() != last_path.value(); path = path.DirName()) { subpaths.push_back(path); @@ -119,7 +119,7 @@ NSString* Sandbox::AllowMetadataForPath(const FilePath& allowed_path) { // Iterate through all parents and allow stat() on them explicitly. NSString* sandbox_command = @"(allow file-read-metadata "; - for (std::vector<FilePath>::reverse_iterator i = subpaths.rbegin(); + for (std::vector<base::FilePath>::reverse_iterator i = subpaths.rbegin(); i != subpaths.rend(); ++i) { std::string subdir_escaped; @@ -311,7 +311,7 @@ void Sandbox::SandboxWarmup(int sandbox_type) { // static NSString* Sandbox::BuildAllowDirectoryAccessSandboxString( - const FilePath& allowed_dir, + const base::FilePath& allowed_dir, SandboxVariableSubstitions* substitutions) { // A whitelist is used to determine which directories can be statted // This means that in the case of an /a/b/c/d/ directory, we may be able to @@ -326,7 +326,7 @@ NSString* Sandbox::BuildAllowDirectoryAccessSandboxString( // needed so the caller doesn't need to worry about things like /var // being a link to /private/var (like in the paths CreateNewTempDirectory() // returns). - FilePath allowed_dir_canonical = GetCanonicalSandboxPath(allowed_dir); + base::FilePath allowed_dir_canonical = GetCanonicalSandboxPath(allowed_dir); NSString* sandbox_command = AllowMetadataForPath(allowed_dir_canonical); sandbox_command = [sandbox_command @@ -474,7 +474,7 @@ bool Sandbox::PostProcessSandboxProfile( // static bool Sandbox::EnableSandbox(int sandbox_type, - const FilePath& allowed_dir) { + const base::FilePath& allowed_dir) { // Sanity - currently only SANDBOX_TYPE_UTILITY supports a directory being // passed in. if (sandbox_type < SANDBOX_TYPE_AFTER_LAST_TYPE && @@ -529,7 +529,8 @@ bool Sandbox::EnableSandbox(int sandbox_type, // (see renderer.sb for details). std::string home_dir = [NSHomeDirectory() fileSystemRepresentation]; - FilePath home_dir_canonical = GetCanonicalSandboxPath(FilePath(home_dir)); + base::FilePath home_dir_canonical = + GetCanonicalSandboxPath(base::FilePath(home_dir)); substitutions["USER_HOMEDIR_AS_LITERAL"] = SandboxSubstring(home_dir_canonical.value(), @@ -546,7 +547,7 @@ bool Sandbox::EnableSandbox(int sandbox_type, // contains LC_RPATH load commands. The components build uses those. // See http://crbug.com/127465 if (base::mac::IsOSSnowLeopard()) { - FilePath bundle_executable = base::mac::NSStringToFilePath( + base::FilePath bundle_executable = base::mac::NSStringToFilePath( [base::mac::MainBundle() executablePath]); NSString* sandbox_command = AllowMetadataForPath( GetCanonicalSandboxPath(bundle_executable)); @@ -576,7 +577,7 @@ bool Sandbox::EnableSandbox(int sandbox_type, } // static -FilePath Sandbox::GetCanonicalSandboxPath(const FilePath& path) { +base::FilePath Sandbox::GetCanonicalSandboxPath(const base::FilePath& path) { int fd = HANDLE_EINTR(open(path.value().c_str(), O_RDONLY)); if (fd < 0) { DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " @@ -585,14 +586,14 @@ FilePath Sandbox::GetCanonicalSandboxPath(const FilePath& path) { } file_util::ScopedFD file_closer(&fd); - FilePath::CharType canonical_path[MAXPATHLEN]; + base::FilePath::CharType canonical_path[MAXPATHLEN]; if (HANDLE_EINTR(fcntl(fd, F_GETPATH, canonical_path)) != 0) { DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " << path.value(); return path; } - return FilePath(canonical_path); + return base::FilePath(canonical_path); } } // namespace content diff --git a/content/common/sandbox_mac_diraccess_unittest.mm b/content/common/sandbox_mac_diraccess_unittest.mm index a0b1df8..87061a8 100644 --- a/content/common/sandbox_mac_diraccess_unittest.mm +++ b/content/common/sandbox_mac_diraccess_unittest.mm @@ -133,19 +133,20 @@ TEST_F(MacDirAccessSandboxTest, RegexEscape) { // A class to handle auto-deleting a directory. class ScopedDirectoryDelete { public: - inline void operator()(FilePath* x) const { + inline void operator()(base::FilePath* x) const { if (x) { file_util::Delete(*x, true); } } }; -typedef scoped_ptr_malloc<FilePath, ScopedDirectoryDelete> ScopedDirectory; +typedef scoped_ptr_malloc<base::FilePath, ScopedDirectoryDelete> + ScopedDirectory; TEST_F(MacDirAccessSandboxTest, SandboxAccess) { using file_util::CreateDirectory; - FilePath tmp_dir; + base::FilePath tmp_dir; ASSERT_TRUE(file_util::CreateNewTempDirectory("", &tmp_dir)); // This step is important on OS X since the sandbox only understands "real" // paths and the paths CreateNewTempDirectory() returns are empirically in @@ -161,7 +162,7 @@ TEST_F(MacDirAccessSandboxTest, SandboxAccess) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(sandbox_dir_cases); ++i) { const char* sandbox_dir_name = sandbox_dir_cases[i]; - FilePath sandbox_dir = tmp_dir.Append(sandbox_dir_name); + base::FilePath sandbox_dir = tmp_dir.Append(sandbox_dir_name); ASSERT_TRUE(CreateDirectory(sandbox_dir)); ScopedDirectory cleanup_sandbox(&sandbox_dir); @@ -169,7 +170,7 @@ TEST_F(MacDirAccessSandboxTest, SandboxAccess) { // as a substring but to which access is denied. std::string sibling_sandbox_dir_name_denied = std::string(sandbox_dir_cases[i]) + kDeniedSuffix; - FilePath sibling_sandbox_dir = tmp_dir.Append( + base::FilePath sibling_sandbox_dir = tmp_dir.Append( sibling_sandbox_dir_name_denied.c_str()); ASSERT_TRUE(CreateDirectory(sibling_sandbox_dir)); ScopedDirectory cleanup_sandbox_sibling(&sibling_sandbox_dir); @@ -195,7 +196,7 @@ MULTIPROCESS_TEST_MAIN(mac_sandbox_path_access) { Sandbox::SandboxVariableSubstitions substitutions; NSString* allow_dir_sandbox_code = Sandbox::BuildAllowDirectoryAccessSandboxString( - FilePath(sandbox_allowed_dir), + base::FilePath(sandbox_allowed_dir), &substitutions); sandbox_profile = [sandbox_profile stringByReplacingOccurrencesOfString:@";ENABLE_DIRECTORY_ACCESS" @@ -233,16 +234,17 @@ MULTIPROCESS_TEST_MAIN(mac_sandbox_path_access) { closedir(file_list); // Test restrictions on accessing files. - FilePath allowed_dir_path(sandbox_allowed_dir); - FilePath allowed_file = allowed_dir_path.Append("ok_to_write"); - FilePath denied_file1 = allowed_dir_path.DirName().Append("cant_access"); + base::FilePath allowed_dir_path(sandbox_allowed_dir); + base::FilePath allowed_file = allowed_dir_path.Append("ok_to_write"); + base::FilePath denied_file1 = + allowed_dir_path.DirName().Append("cant_access"); // Try to write a file who's name has the same prefix as the directory we // allow access to. - FilePath basename = allowed_dir_path.BaseName(); - FilePath allowed_parent_dir = allowed_dir_path.DirName(); + base::FilePath basename = allowed_dir_path.BaseName(); + base::FilePath allowed_parent_dir = allowed_dir_path.DirName(); std::string tricky_filename = basename.value() + "123"; - FilePath denied_file2 = allowed_parent_dir.Append(tricky_filename); + base::FilePath denied_file2 = allowed_parent_dir.Append(tricky_filename); if (open(allowed_file.value().c_str(), O_WRONLY | O_CREAT) <= 0) { PLOG(ERROR) << "Sandbox overly restrictive: failed to write (" diff --git a/content/common/sandbox_mac_fontloading_unittest.mm b/content/common/sandbox_mac_fontloading_unittest.mm index 67b0bc2..30ac477 100644 --- a/content/common/sandbox_mac_fontloading_unittest.mm +++ b/content/common/sandbox_mac_fontloading_unittest.mm @@ -31,7 +31,8 @@ REGISTER_SANDBOX_TEST_CASE(FontLoadingTestCase); // Load raw font data into shared memory object. bool FontLoadingTestCase::BeforeSandboxInit() { std::string font_data; - if (!file_util::ReadFileToString(FilePath(test_data_.c_str()), &font_data)) { + if (!file_util::ReadFileToString(base::FilePath(test_data_.c_str()), + &font_data)) { LOG(ERROR) << "Failed to read font data from file (" << test_data_ << ")"; return false; } @@ -102,7 +103,7 @@ bool FontLoadingTestCase::SandboxedTest() { } TEST_F(MacSandboxTest, FontLoadingTest) { - FilePath temp_file_path; + base::FilePath temp_file_path; FILE* temp_file = file_util::CreateAndOpenTemporaryFile(&temp_file_path); ASSERT_TRUE(temp_file); file_util::ScopedFILE temp_file_closer(temp_file); diff --git a/content/common/sandbox_mac_unittest_helper.mm b/content/common/sandbox_mac_unittest_helper.mm index d71c7aa..8635b32 100644 --- a/content/common/sandbox_mac_unittest_helper.mm +++ b/content/common/sandbox_mac_unittest_helper.mm @@ -154,7 +154,7 @@ MULTIPROCESS_TEST_MAIN(mac_sandbox_test_runner) { Sandbox::SandboxWarmup(sandbox_type); - if (!Sandbox::EnableSandbox(sandbox_type, FilePath())) { + if (!Sandbox::EnableSandbox(sandbox_type, base::FilePath())) { LOG(ERROR) << "Failed to initialize sandbox " << sandbox_type; return -1; } diff --git a/content/common/sandbox_policy.cc b/content/common/sandbox_policy.cc index 6ce487b..58d6a92 100644 --- a/content/common/sandbox_policy.cc +++ b/content/common/sandbox_policy.cc @@ -123,7 +123,7 @@ const wchar_t* const kTroublesomeGpuDlls[] = { bool AddDirectory(int path, const wchar_t* sub_dir, bool children, sandbox::TargetPolicy::Semantics access, sandbox::TargetPolicy* policy) { - FilePath directory; + base::FilePath directory; if (!PathService::Get(path, &directory)) return false; @@ -181,7 +181,7 @@ bool IsExpandedModuleName(HMODULE module, const wchar_t* module_name) { } if (!::GetLongPathName(path, path, arraysize(path))) return false; - FilePath fname(path); + base::FilePath fname(path); return (fname.BaseName().value() == module_name); } @@ -341,7 +341,7 @@ bool AddGenericPolicy(sandbox::TargetPolicy* policy) { // Add the policy for debug message only in debug #ifndef NDEBUG - FilePath app_dir; + base::FilePath app_dir; if (!PathService::Get(base::DIR_MODULE, &app_dir)) return false; @@ -352,7 +352,7 @@ bool AddGenericPolicy(sandbox::TargetPolicy* policy) { if (long_path_return_value == 0 || long_path_return_value >= MAX_PATH) return false; - FilePath debug_message(long_path_buf); + base::FilePath debug_message(long_path_buf); debug_message = debug_message.AppendASCII("debug_message.exe"); result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_PROCESS, sandbox::TargetPolicy::PROCESS_MIN_EXEC, @@ -653,7 +653,7 @@ bool InitTargetServices(sandbox::TargetServices* target_services) { } base::ProcessHandle StartProcessWithAccess(CommandLine* cmd_line, - const FilePath& exposed_dir) { + const base::FilePath& exposed_dir) { const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); ProcessType type; std::string type_str = cmd_line->GetSwitchValueASCII(switches::kProcessType); @@ -810,7 +810,7 @@ base::ProcessHandle StartProcessWithAccess(CommandLine* cmd_line, if (result != sandbox::SBOX_ALL_OK) return 0; - FilePath exposed_files = exposed_dir.AppendASCII("*"); + base::FilePath exposed_files = exposed_dir.AppendASCII("*"); result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, sandbox::TargetPolicy::FILES_ALLOW_ANY, exposed_files.value().c_str()); diff --git a/content/common/set_process_title.cc b/content/common/set_process_title.cc index 425b44a..9641cc6 100644 --- a/content/common/set_process_title.cc +++ b/content/common/set_process_title.cc @@ -48,8 +48,8 @@ void SetProcessTitleFromCommandLine(const char** main_argv) { // show up as "exe" in process listings. Read the symlink /proc/self/exe and // use the path it points at for our process title. Note that this is only for // display purposes and has no TOCTTOU security implications. - FilePath target; - FilePath self_exe(base::kProcSelfExe); + base::FilePath target; + base::FilePath self_exe(base::kProcSelfExe); if (file_util::ReadSymbolicLink(self_exe, &target)) { have_argv0 = true; title = target.value(); @@ -63,7 +63,7 @@ void SetProcessTitleFromCommandLine(const char** main_argv) { // any errors if the kernel does not support it at runtime though. When // available, this lets us set the short process name that shows when the // full command line is not being displayed in most process listings. - prctl(PR_SET_NAME, FilePath(title).BaseName().value().c_str()); + prctl(PR_SET_NAME, base::FilePath(title).BaseName().value().c_str()); #endif // defined(PR_SET_NAME) } #endif // defined(OS_LINUX) diff --git a/content/common/utility_messages.h b/content/common/utility_messages.h index 19c0c03..01aaa7c 100644 --- a/content/common/utility_messages.h +++ b/content/common/utility_messages.h @@ -31,7 +31,7 @@ IPC_MESSAGE_CONTROL0(UtilityMsg_BatchMode_Finished) // Tells the utility process to load each plugin in the order specified by the // vector. It will respond after each load with the WebPluginInfo. IPC_MESSAGE_CONTROL1(UtilityMsg_LoadPlugins, - std::vector<FilePath> /* plugin paths */) + std::vector<base::FilePath> /* plugin paths */) #endif //------------------------------------------------------------------------------ @@ -43,7 +43,7 @@ IPC_MESSAGE_CONTROL1(UtilityMsg_LoadPlugins, // keep the canonical list in sync. IPC_SYNC_MESSAGE_CONTROL2_0(UtilityHostMsg_LoadPluginFailed, uint32_t /* index in the vector */, - FilePath /* path of plugin */) + base::FilePath /* path of plugin */) // Notifies the browser that a plugin in the vector sent by it has been loaded. IPC_SYNC_MESSAGE_CONTROL2_0(UtilityHostMsg_LoadedPlugin, diff --git a/content/common/view_messages.h b/content/common/view_messages.h index 75ece08..e4edc01 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -1127,7 +1127,7 @@ IPC_MESSAGE_ROUTED1(ViewMsg_RunFileChooserResponse, // Provides the results of directory enumeration. IPC_MESSAGE_ROUTED2(ViewMsg_EnumerateDirectoryResponse, int /* request_id */, - std::vector<FilePath> /* files_in_directory */) + std::vector<base::FilePath> /* files_in_directory */) // When a renderer sends a ViewHostMsg_Focus to the browser process, // the browser has the option of sending a ViewMsg_CantFocus back to @@ -1403,8 +1403,8 @@ IPC_MESSAGE_ROUTED1(ViewMsg_GetAllSavableResourceLinksForCurrentPage, // which contain all resource links that have local copy. IPC_MESSAGE_ROUTED3(ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, std::vector<GURL> /* urls that have local copy */, - std::vector<FilePath> /* paths of local copy */, - FilePath /* local directory path */) + std::vector<base::FilePath> /* paths of local copy */, + base::FilePath /* local directory path */) // Tells the render side that a ViewHostMsg_LockMouse message has been // processed. |succeeded| indicates whether the mouse has been successfully @@ -1881,7 +1881,7 @@ IPC_MESSAGE_ROUTED1(ViewHostMsg_GetWindowSnapshot, // // On error an empty string and null handles are returned. IPC_SYNC_MESSAGE_CONTROL1_3(ViewHostMsg_OpenChannelToPepperPlugin, - FilePath /* path */, + base::FilePath /* path */, IPC::ChannelHandle /* handle to channel */, base::ProcessId /* plugin_pid */, int /* plugin_child_id */) @@ -1922,7 +1922,7 @@ IPC_MESSAGE_CONTROL3(ViewHostMsg_DidDeleteOutOfProcessPepperInstance, IPC_MESSAGE_CONTROL3(ViewHostMsg_OpenChannelToPpapiBroker, int /* routing_id */, int /* request_id */, - FilePath /* path */) + base::FilePath /* path */) // A renderer sends this to the browser process when it wants to access a PPAPI // broker. In contrast to ViewHostMsg_OpenChannelToPpapiBroker, this is called @@ -1931,7 +1931,7 @@ IPC_MESSAGE_CONTROL3(ViewHostMsg_OpenChannelToPpapiBroker, IPC_MESSAGE_ROUTED3(ViewHostMsg_RequestPpapiBrokerPermission, int /* request_id */, GURL /* document_url */, - FilePath /* plugin_path */) + base::FilePath /* plugin_path */) #if defined(USE_X11) // A renderer sends this when it needs a browser-side widget for @@ -1991,7 +1991,7 @@ IPC_MESSAGE_ROUTED1(ViewHostMsg_RunFileChooser, // ViewMsg_EnumerateDirectoryResponse message. IPC_MESSAGE_ROUTED2(ViewHostMsg_EnumerateDirectory, int /* request_id */, - FilePath /* file_path */) + base::FilePath /* file_path */) // Tells the browser to move the focus to the next (previous if reverse is // true) focusable element. @@ -2032,7 +2032,7 @@ IPC_MESSAGE_ROUTED4(ViewHostMsg_AddMessageToConsole, // usage other than displaying it in a prompt to the user is very likely to be // wrong. IPC_MESSAGE_ROUTED2(ViewHostMsg_CrashedPlugin, - FilePath /* plugin_path */, + base::FilePath /* plugin_path */, base::ProcessId /* plugin_pid */) // Displays a box to confirm that the user wants to navigate away from the @@ -2187,7 +2187,7 @@ IPC_MESSAGE_ROUTED1(ViewHostMsg_SwapCompositorFrameAck, // Opens a file asynchronously. The response returns a file descriptor // and an error code from base/platform_file.h. IPC_MESSAGE_ROUTED3(ViewHostMsg_AsyncOpenFile, - FilePath /* file path */, + base::FilePath /* file path */, int /* flags */, int /* message_id */) @@ -2295,7 +2295,7 @@ IPC_MESSAGE_ROUTED2(ViewHostMsg_DomOperationResponse, // option of killing the plugin. IPC_MESSAGE_ROUTED3(ViewHostMsg_PepperPluginHung, int /* plugin_child_id */, - FilePath /* path */, + base::FilePath /* path */, bool /* is_hung */) // Screen was rotated. Dispatched to the onorientationchange javascript API. |