diff options
47 files changed, 3441 insertions, 80 deletions
diff --git a/chromium/DEPS b/chromium/DEPS index e18a979995c..b2bc7dbefca 100644 --- a/chromium/DEPS +++ b/chromium/DEPS @@ -4,7 +4,7 @@ vars = { 'boringssl_revision': '3cab5572b1fcf5a8f6018529dc30dc8d21b2a4bd', 'buildspec_platforms': - 'chromeos,', + 'all', 'buildtools_revision': '454e53abae6e4d68ee992b0a93a4174b75519393', 'catapult_revision': @@ -164,7 +164,7 @@ deps = { 'src/tools/swarming_client': (Var("chromium_git")) + '/external/swarming.client.git@df6e95e7669883c8fe9ef956c69a544154701a49', 'src/v8': - (Var("chromium_git")) + '/v8/v8.git@73e056d4941819d44ad73cba47d51f39be139874' + (Var("chromium_git")) + '/v8/v8.git@0431e266f3df7565381a20da8d303c06d5ea6cf5' } deps_os = { diff --git a/chromium/build/util/LASTCHANGE b/chromium/build/util/LASTCHANGE index b9a8faa4c7d..bcb1d84a17e 100644 --- a/chromium/build/util/LASTCHANGE +++ b/chromium/build/util/LASTCHANGE @@ -1 +1 @@ -LASTCHANGE=27f68172e443d6d6eaba9993e7446ccf6aa8e18e +LASTCHANGE=eaa48df377e24569345792db0a3acb55bf808b82 diff --git a/chromium/build/util/LASTCHANGE.blink b/chromium/build/util/LASTCHANGE.blink index b9a8faa4c7d..bcb1d84a17e 100644 --- a/chromium/build/util/LASTCHANGE.blink +++ b/chromium/build/util/LASTCHANGE.blink @@ -1 +1 @@ -LASTCHANGE=27f68172e443d6d6eaba9993e7446ccf6aa8e18e +LASTCHANGE=eaa48df377e24569345792db0a3acb55bf808b82 diff --git a/chromium/chrome/VERSION b/chromium/chrome/VERSION index 9bbe017208e..497c6395f67 100644 --- a/chromium/chrome/VERSION +++ b/chromium/chrome/VERSION @@ -1,4 +1,4 @@ MAJOR=53 MINOR=0 BUILD=2785 -PATCH=117 +PATCH=148 diff --git a/chromium/chrome/common/chrome_constants.cc b/chromium/chrome/common/chrome_constants.cc new file mode 100644 index 00000000000..257c02f95f9 --- /dev/null +++ b/chromium/chrome/common/chrome_constants.cc @@ -0,0 +1,227 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/chrome_constants.h" + +#include "build/build_config.h" +#include "chrome/common/chrome_version.h" + +#define FPL FILE_PATH_LITERAL + +#if defined(OS_MACOSX) +#define CHROMIUM_PRODUCT_STRING "Chromium" +#if defined(GOOGLE_CHROME_BUILD) +#define PRODUCT_STRING "Google Chrome" +#elif defined(CHROMIUM_BUILD) +#define PRODUCT_STRING "Chromium" +#else +#error Unknown branding +#endif +#endif // defined(OS_MACOSX) + +namespace chrome { + +const char kChromeVersion[] = CHROME_VERSION_STRING; + +// The following should not be used for UI strings; they are meant +// for system strings only. UI changes should be made in the GRD. +// +// There are four constants used to locate the executable name and path: +// +// kBrowserProcessExecutableName +// kHelperProcessExecutableName +// kBrowserProcessExecutablePath +// kHelperProcessExecutablePath +// +// In one condition, our tests will be built using the Chrome branding +// though we want to actually execute a Chromium branded application. +// This happens for the reference build on Mac. To support that case, +// we also include a Chromium version of each of the four constants and +// in the UITest class we support switching to that version when told to +// do so. + +#if defined(OS_WIN) +const base::FilePath::CharType kBrowserProcessExecutableNameChromium[] = + FPL("chrome.exe"); +const base::FilePath::CharType kBrowserProcessExecutableName[] = + FPL("chrome.exe"); +const base::FilePath::CharType kHelperProcessExecutableNameChromium[] = + FPL("chrome.exe"); +const base::FilePath::CharType kHelperProcessExecutableName[] = + FPL("chrome.exe"); +#elif defined(OS_MACOSX) +const base::FilePath::CharType kBrowserProcessExecutableNameChromium[] = + FPL(CHROMIUM_PRODUCT_STRING); +const base::FilePath::CharType kBrowserProcessExecutableName[] = + FPL(PRODUCT_STRING); +const base::FilePath::CharType kHelperProcessExecutableNameChromium[] = + FPL(CHROMIUM_PRODUCT_STRING " Helper"); +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 base::FilePath::CharType kBrowserProcessExecutableName[] = FPL("chrome"); +const base::FilePath::CharType kBrowserProcessExecutableNameChromium[] = + FPL(""); +const base::FilePath::CharType kHelperProcessExecutableName[] = + FPL("sandboxed_process"); +const base::FilePath::CharType kHelperProcessExecutableNameChromium[] = FPL(""); +#elif defined(OS_POSIX) +const base::FilePath::CharType kBrowserProcessExecutableNameChromium[] = + 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 base::FilePath::CharType kHelperProcessExecutableNameChromium[] = + FPL("exe"); +const base::FilePath::CharType kHelperProcessExecutableName[] = FPL("exe"); +#endif // OS_* + +#if defined(OS_WIN) +const base::FilePath::CharType kBrowserProcessExecutablePathChromium[] = + FPL("chrome.exe"); +const base::FilePath::CharType kBrowserProcessExecutablePath[] = + FPL("chrome.exe"); +const base::FilePath::CharType kHelperProcessExecutablePathChromium[] = + FPL("chrome.exe"); +const base::FilePath::CharType kHelperProcessExecutablePath[] = + FPL("chrome.exe"); +#elif defined(OS_MACOSX) +const base::FilePath::CharType kBrowserProcessExecutablePathChromium[] = + FPL(CHROMIUM_PRODUCT_STRING ".app/Contents/MacOS/" CHROMIUM_PRODUCT_STRING); +const base::FilePath::CharType kBrowserProcessExecutablePath[] = + FPL(PRODUCT_STRING ".app/Contents/MacOS/" PRODUCT_STRING); +const base::FilePath::CharType kHelperProcessExecutablePathChromium[] = + FPL(CHROMIUM_PRODUCT_STRING " Helper.app/Contents/MacOS/" + CHROMIUM_PRODUCT_STRING " Helper"); +const base::FilePath::CharType kHelperProcessExecutablePath[] = + FPL(PRODUCT_STRING " Helper.app/Contents/MacOS/" PRODUCT_STRING " Helper"); +#elif defined(OS_ANDROID) +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"); +#elif defined(OS_POSIX) +const base::FilePath::CharType kBrowserProcessExecutablePathChromium[] = + FPL("chrome"); +const base::FilePath::CharType kBrowserProcessExecutablePath[] = FPL("chrome"); +const base::FilePath::CharType kHelperProcessExecutablePathChromium[] = + FPL("chrome"); +const base::FilePath::CharType kHelperProcessExecutablePath[] = FPL("chrome"); +#endif // OS_* + +#if defined(OS_MACOSX) +const base::FilePath::CharType kFrameworkName[] = + FPL(PRODUCT_STRING " Framework.framework"); +#endif // OS_MACOSX + +#if defined(OS_WIN) +const base::FilePath::CharType kBrowserResourcesDll[] = FPL("chrome.dll"); +const base::FilePath::CharType kStatusTrayWindowClass[] = + FPL("Chrome_StatusTrayWindow"); +#endif // defined(OS_WIN) + +const char kInitialProfile[] = "Default"; +const char kMultiProfileDirPrefix[] = "Profile "; +const base::FilePath::CharType kGuestProfileDir[] = FPL("Guest Profile"); +const base::FilePath::CharType kSystemProfileDir[] = FPL("System Profile"); + +// filenames +const base::FilePath::CharType kCacheDirname[] = FPL("Cache"); +const base::FilePath::CharType kChannelIDFilename[] = FPL("Origin Bound Certs"); +const base::FilePath::CharType kCookieFilename[] = FPL("Cookies"); +const base::FilePath::CharType kCRLSetFilename[] = + FPL("Certificate Revocation Lists"); +const base::FilePath::CharType kCustomDictionaryFileName[] = + FPL("Custom Dictionary.txt"); +const base::FilePath::CharType kExtensionActivityLogFilename[] = + FPL("Extension Activity"); +const base::FilePath::CharType kExtensionsCookieFilename[] = + FPL("Extension Cookies"); +const base::FilePath::CharType kFirstRunSentinel[] = FPL("First Run"); +const base::FilePath::CharType kGCMStoreDirname[] = FPL("GCM Store"); +const base::FilePath::CharType kLocalStateFilename[] = FPL("Local State"); +const base::FilePath::CharType kLocalStorePoolName[] = FPL("LocalStorePool"); +const base::FilePath::CharType kMediaCacheDirname[] = FPL("Media Cache"); +const base::FilePath::CharType kNetworkPersistentStateFilename[] = + FPL("Network Persistent State"); +const base::FilePath::CharType kOfflinePageArchivesDirname[] = + FPL("Offline Pages/archives"); +const base::FilePath::CharType kOfflinePageMetadataDirname[] = + FPL("Offline Pages/metadata"); +const base::FilePath::CharType kOfflinePageRequestQueueDirname[] = + FPL("Offline Pages/request_queue"); +const base::FilePath::CharType kPreferencesFilename[] = FPL("Preferences"); +const base::FilePath::CharType kProtectedPreferencesFilenameDeprecated[] = + FPL("Protected Preferences"); +const base::FilePath::CharType kReadmeFilename[] = FPL("README"); +const base::FilePath::CharType kSafeBrowsingBaseFilename[] = + FPL("Safe Browsing"); +const base::FilePath::CharType kSecurePreferencesFilename[] = + FPL("Secure Preferences"); +const base::FilePath::CharType kServiceStateFileName[] = FPL("Service State"); +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 kSupervisedUserSettingsFilename[] = + FPL("Managed Mode Settings"); +const base::FilePath::CharType kThemePackFilename[] = FPL("Cached Theme.pak"); +const base::FilePath::CharType kThemePackMaterialDesignFilename[] = + FPL("Cached Theme Material Design.pak"); +const base::FilePath::CharType kWebAppDirname[] = FPL("Web Applications"); + +#if defined(OS_WIN) +const base::FilePath::CharType kJumpListIconDirname[] = FPL("JumpListIcons"); +#endif + +// File name of the Pepper Flash plugin on different platforms. +const base::FilePath::CharType kPepperFlashPluginFilename[] = +#if defined(OS_MACOSX) + FPL("PepperFlashPlayer.plugin"); +#elif defined(OS_WIN) + FPL("pepflashplayer.dll"); +#else // OS_LINUX, etc. + FPL("libpepflashplayer.so"); +#endif + +// directory names +#if defined(OS_WIN) +const wchar_t kUserDataDirname[] = L"User Data"; +#endif + +const float kMaxShareOfExtensionProcesses = 0.30f; + +#if defined(OS_LINUX) +const int kLowestRendererOomScore = 300; +const int kHighestRendererOomScore = 1000; +#endif + +#if defined(OS_WIN) +const wchar_t kMetroNavigationAndSearchMessage[] = + L"CHROME_METRO_NAV_SEARCH_REQUEST"; +const wchar_t kMetroGetCurrentTabInfoMessage[] = + L"CHROME_METRO_GET_CURRENT_TAB_INFO"; +#endif + +#if defined(OS_CHROMEOS) +const char kProfileDirPrefix[] = "u-"; +const char kLegacyProfileDir[] = "user"; +const char kTestUserProfileDir[] = "test-user"; +#endif + +// This GUID is associated with any 'don't ask me again' settings that the +// user can select for different file types. +// {2676A9A2-D919-4FEE-9187-152100393AB2} +const char kApplicationClientIDStringForAVScanning[] = + "2676A9A2-D919-4FEE-9187-152100393AB2"; + +const size_t kMaxMetaTagAttributeLength = 2000; + +} // namespace chrome + +#undef FPL diff --git a/chromium/chrome/common/chrome_constants.h b/chromium/chrome/common/chrome_constants.h new file mode 100644 index 00000000000..5780d1ab820 --- /dev/null +++ b/chromium/chrome/common/chrome_constants.h @@ -0,0 +1,129 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// A handful of resource-like constants related to the Chrome application. + +#ifndef CHROME_COMMON_CHROME_CONSTANTS_H_ +#define CHROME_COMMON_CHROME_CONSTANTS_H_ + +#include <stddef.h> + +#include "base/files/file_path.h" +#include "build/build_config.h" + +namespace chrome { + +extern const char kChromeVersion[]; +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) +// NOTE: if you change the value of kFrameworkName, please don't forget to +// update components/test/run_all_unittests.cc as well. +// TODO(tfarina): Remove the comment above, when you fix components to use plist +// on Mac. +extern const base::FilePath::CharType kFrameworkName[]; +#endif // OS_MACOSX +#if defined(OS_WIN) +extern const base::FilePath::CharType kBrowserResourcesDll[]; +extern const base::FilePath::CharType kMetroDriverDll[]; +extern const base::FilePath::CharType kStatusTrayWindowClass[]; +#endif // defined(OS_WIN) + +extern const char kInitialProfile[]; +extern const char kMultiProfileDirPrefix[]; +extern const base::FilePath::CharType kGuestProfileDir[]; +extern const base::FilePath::CharType kSystemProfileDir[]; + +// filenames +extern const base::FilePath::CharType kCacheDirname[]; +extern const base::FilePath::CharType kChannelIDFilename[]; +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 kFirstRunSentinel[]; +extern const base::FilePath::CharType kGCMStoreDirname[]; +extern const base::FilePath::CharType kLocalStateFilename[]; +extern const base::FilePath::CharType kLocalStorePoolName[]; +extern const base::FilePath::CharType kMediaCacheDirname[]; +extern const base::FilePath::CharType kNetworkPersistentStateFilename[]; +extern const base::FilePath::CharType kOfflinePageArchivesDirname[]; +extern const base::FilePath::CharType kOfflinePageMetadataDirname[]; +extern const base::FilePath::CharType kOfflinePageRequestQueueDirname[]; +extern const base::FilePath::CharType kPreferencesFilename[]; +extern const base::FilePath::CharType kProtectedPreferencesFilenameDeprecated[]; +extern const base::FilePath::CharType kReadmeFilename[]; +extern const base::FilePath::CharType kSafeBrowsingBaseFilename[]; +extern const base::FilePath::CharType kSecurePreferencesFilename[]; +extern const base::FilePath::CharType kServiceStateFileName[]; +extern const base::FilePath::CharType kSingletonCookieFilename[]; +extern const base::FilePath::CharType kSingletonLockFilename[]; +extern const base::FilePath::CharType kSingletonSocketFilename[]; +extern const base::FilePath::CharType kSupervisedUserSettingsFilename[]; +extern const base::FilePath::CharType kThemePackFilename[]; +extern const base::FilePath::CharType kThemePackMaterialDesignFilename[]; +extern const base::FilePath::CharType kWebAppDirname[]; + +#if defined(OS_WIN) +extern const base::FilePath::CharType kJumpListIconDirname[]; +#endif + +// File name of the Pepper Flash plugin on different platforms. +extern const base::FilePath::CharType kPepperFlashPluginFilename[]; + +// directory names +#if defined(OS_WIN) +extern const wchar_t kUserDataDirname[]; +#endif + +// Fraction of the total number of processes to be used for hosting +// extensions. If we have more extensions than this percentage, we will start +// combining extensions in existing processes. This allows web pages to have +// enough render processes and not be starved when a lot of extensions are +// installed. +extern const float kMaxShareOfExtensionProcesses; + +#if defined(OS_LINUX) +// The highest and lowest assigned OOM score adjustment +// (oom_score_adj) used by the OomPriority Manager. +extern const int kLowestRendererOomScore; +extern const int kHighestRendererOomScore; +#endif + +#if defined(OS_WIN) +// Used by Metro Chrome to initiate navigation and search requests. +extern const wchar_t kMetroNavigationAndSearchMessage[]; +// Used by Metro Chrome to get information about the current tab. +extern const wchar_t kMetroGetCurrentTabInfoMessage[]; +#endif + +#if defined(OS_CHROMEOS) +// Chrome OS profile directories have custom prefix. +// Profile path format: [user_data_dir]/u-[$hash] +// Ex.: /home/chronos/u-0123456789 +extern const char kProfileDirPrefix[]; + +// Legacy profile dir that was used when only one cryptohome has been mounted. +extern const char kLegacyProfileDir[]; + +// This must be kept in sync with TestingProfile::kTestUserProfileDir. +extern const char kTestUserProfileDir[]; +#endif + +// Used to identify the application to the system AV function in Windows. +extern const char kApplicationClientIDStringForAVScanning[]; + +// The largest reasonable length we'd assume for a meta tag attribute. +extern const size_t kMaxMetaTagAttributeLength; + +} // namespace chrome + +#endif // CHROME_COMMON_CHROME_CONSTANTS_H_ diff --git a/chromium/chrome/common/chrome_paths.cc b/chromium/chrome/common/chrome_paths.cc new file mode 100644 index 00000000000..86499317e4c --- /dev/null +++ b/chromium/chrome/common/chrome_paths.cc @@ -0,0 +1,601 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/chrome_paths.h" + +#include "base/files/file_util.h" +#include "base/lazy_instance.h" +#include "base/logging.h" +#include "base/mac/bundle_locations.h" +#include "base/path_service.h" +#include "base/strings/string_util.h" +#include "base/sys_info.h" +#include "base/threading/thread_restrictions.h" +#include "base/version.h" +#include "build/build_config.h" +#include "chrome/common/chrome_constants.h" +#include "chrome/common/chrome_paths_internal.h" +#include "media/cdm/cdm_paths.h" + +#if defined(OS_ANDROID) +#include "base/android/path_utils.h" +#include "base/base_paths_android.h" +// ui/base must only be used on Android. See BUILD.gn for dependency info. +#include "ui/base/ui_base_paths.h" // nogncheck +#endif + +#if defined(OS_MACOSX) +#include "base/mac/foundation_util.h" +#endif + +#if defined(OS_WIN) +#include "base/win/registry.h" +#endif + +#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. + +namespace { + +// The Pepper Flash plugins are in a directory with this name. +const base::FilePath::CharType kPepperFlashBaseDirectory[] = + FILE_PATH_LITERAL("PepperFlash"); + +#if defined(OS_MACOSX) +const base::FilePath::CharType kPepperFlashSystemBaseDirectory[] = + FILE_PATH_LITERAL("Internet Plug-Ins/PepperFlashPlayer"); +#endif + +const base::FilePath::CharType kInternalNaClPluginFileName[] = + FILE_PATH_LITERAL("internal-nacl-plugin"); + +#if defined(OS_LINUX) +// The path to the external extension <id>.json files. +// /usr/share seems like a good choice, see: http://www.pathname.com/fhs/ +const base::FilePath::CharType kFilepathSinglePrefExtensions[] = +#if defined(GOOGLE_CHROME_BUILD) + FILE_PATH_LITERAL("/usr/share/google-chrome/extensions"); +#else + FILE_PATH_LITERAL("/usr/share/chromium/extensions"); +#endif // defined(GOOGLE_CHROME_BUILD) + +// The path to the hint file that tells the pepper plugin loader +// where it can find the latest component updated flash. +const base::FilePath::CharType kComponentUpdatedFlashHint[] = + FILE_PATH_LITERAL("latest-component-updated-flash"); +#endif // defined(OS_LINUX) + +static base::LazyInstance<base::FilePath> + g_invalid_specified_user_data_dir = LAZY_INSTANCE_INITIALIZER; + +// Gets the path for internal plugins. +bool GetInternalPluginsDirectory(base::FilePath* result) { +#if defined(OS_MACOSX) + // If called from Chrome, get internal plugins from a subdirectory of the + // framework. + if (base::mac::AmIBundled()) { + *result = chrome::GetFrameworkBundlePath(); + DCHECK(!result->empty()); + *result = result->Append("Internet Plug-Ins"); + return true; + } + // In tests, just look in the module directory (below). +#endif + + // The rest of the world expects plugins in the module directory. + return PathService::Get(base::DIR_MODULE, result); +} + +// Gets the path for bundled implementations of components. Note that these +// implementations should not be used if higher-versioned component-updated +// implementations are available in DIR_USER_DATA. +bool GetComponentDirectory(base::FilePath* result) { +#if defined(OS_MACOSX) + // If called from Chrome, return the framework's Libraries directory. + if (base::mac::AmIBundled()) { + *result = chrome::GetFrameworkBundlePath(); + DCHECK(!result->empty()); + *result = result->Append("Libraries"); + return true; + } +// In tests, just look in the module directory (below). +#endif + + // The rest of the world expects components in the module directory. + return PathService::Get(base::DIR_MODULE, result); +} + +#if defined(OS_WIN) +// Gets the Pepper Flash path if installed on the system. +bool GetSystemFlashFilename(base::FilePath* out_path) { + const wchar_t kPepperFlashRegistryRoot[] = + L"SOFTWARE\\Macromedia\\FlashPlayerPepper"; + const wchar_t kFlashPlayerPathValueName[] = L"PlayerPath"; + + base::win::RegKey path_key(HKEY_LOCAL_MACHINE, kPepperFlashRegistryRoot, + KEY_READ); + base::string16 path_str; + if (FAILED(path_key.ReadValue(kFlashPlayerPathValueName, &path_str))) + return false; + + *out_path = base::FilePath(path_str); + return true; +} +#endif + +} // namespace + +namespace chrome { + +bool PathProvider(int key, base::FilePath* result) { + // Some keys are just aliases... + switch (key) { + case chrome::DIR_APP: + return PathService::Get(base::DIR_MODULE, result); + case chrome::DIR_LOGS: +#ifdef NDEBUG + // Release builds write to the data dir + return PathService::Get(chrome::DIR_USER_DATA, result); +#else + // Debug builds write next to the binary (in the build tree) +#if defined(OS_MACOSX) + if (!PathService::Get(base::DIR_EXE, result)) + return false; + if (base::mac::AmIBundled()) { + // If we're called from chrome, dump it beside the app (outside the + // app bundle), if we're called from a unittest, we'll already + // outside the bundle so use the exe dir. + // exe_dir gave us .../Chromium.app/Contents/MacOS/Chromium. + *result = result->DirName(); + *result = result->DirName(); + *result = result->DirName(); + } + return true; +#else + return PathService::Get(base::DIR_EXE, result); +#endif // defined(OS_MACOSX) +#endif // NDEBUG + case chrome::FILE_RESOURCE_MODULE: + return PathService::Get(base::FILE_MODULE, result); + } + + // Assume that we will not need to create the directory if it does not exist. + // This flag can be set to true for the cases where we want to create it. + bool create_dir = false; + + base::FilePath cur; + switch (key) { + case chrome::DIR_USER_DATA: + if (!GetDefaultUserDataDirectory(&cur)) { + NOTREACHED(); + return false; + } + create_dir = true; + break; + case chrome::DIR_USER_DOCUMENTS: + if (!GetUserDocumentsDirectory(&cur)) + return false; + create_dir = true; + break; + case chrome::DIR_USER_MUSIC: + if (!GetUserMusicDirectory(&cur)) + return false; + break; + case chrome::DIR_USER_PICTURES: + if (!GetUserPicturesDirectory(&cur)) + return false; + break; + case chrome::DIR_USER_VIDEOS: + if (!GetUserVideosDirectory(&cur)) + return false; + break; + case chrome::DIR_DEFAULT_DOWNLOADS_SAFE: +#if defined(OS_WIN) || defined(OS_LINUX) + if (!GetUserDownloadsDirectorySafe(&cur)) + return false; + break; +#else + // Fall through for all other platforms. +#endif + case chrome::DIR_DEFAULT_DOWNLOADS: +#if defined(OS_ANDROID) + if (!base::android::GetDownloadsDirectory(&cur)) + return false; +#else + if (!GetUserDownloadsDirectory(&cur)) + return false; + // Do not create the download directory here, we have done it twice now + // and annoyed a lot of users. +#endif + break; + case chrome::DIR_CRASH_DUMPS: +#if defined(OS_CHROMEOS) + // ChromeOS uses a separate directory. See http://crosbug.com/25089 + cur = base::FilePath("/var/log/chrome"); +#elif defined(OS_ANDROID) + if (!base::android::GetCacheDirectory(&cur)) + return false; +#else + // The crash reports are always stored relative to the default user data + // directory. This avoids the problem of having to re-initialize the + // exception handler after parsing command line options, which may + // override the location of the app's profile directory. + // TODO(scottmg): Consider supporting --user-data-dir. See + // https://crbug.com/565446. + if (!GetDefaultUserDataDirectory(&cur)) + return false; +#endif +#if defined(OS_MACOSX) || defined(OS_WIN) + cur = cur.Append(FILE_PATH_LITERAL("Crashpad")); +#else + cur = cur.Append(FILE_PATH_LITERAL("Crash Reports")); +#endif + create_dir = true; + break; +#if defined(OS_WIN) + case chrome::DIR_WATCHER_DATA: + // The watcher data is always stored relative to the default user data + // directory. This allows the watcher to be initialized before + // command-line options have been parsed. + if (!GetDefaultUserDataDirectory(&cur)) + return false; + cur = cur.Append(FILE_PATH_LITERAL("Diagnostics")); + break; +#endif + case chrome::DIR_RESOURCES: +#if defined(OS_MACOSX) + cur = base::mac::FrameworkBundlePath(); + cur = cur.Append(FILE_PATH_LITERAL("Resources")); +#else + if (!PathService::Get(chrome::DIR_APP, &cur)) + return false; + cur = cur.Append(FILE_PATH_LITERAL("resources")); +#endif + break; + case chrome::DIR_INSPECTOR: + if (!PathService::Get(chrome::DIR_RESOURCES, &cur)) + return false; + cur = cur.Append(FILE_PATH_LITERAL("inspector")); + break; + case chrome::DIR_APP_DICTIONARIES: +#if defined(OS_POSIX) + // We can't write into the EXE dir on Linux, so keep dictionaries + // alongside the safe browsing database in the user data dir. + // And we don't want to write into the bundle on the Mac, so push + // it to the user data dir there also. + if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) + return false; +#else + if (!PathService::Get(base::DIR_EXE, &cur)) + return false; +#endif + cur = cur.Append(FILE_PATH_LITERAL("Dictionaries")); + create_dir = true; + break; + case chrome::DIR_INTERNAL_PLUGINS: + if (!GetInternalPluginsDirectory(&cur)) + return false; + break; + case chrome::DIR_COMPONENTS: + if (!GetComponentDirectory(&cur)) + return false; + break; + case chrome::DIR_PEPPER_FLASH_PLUGIN: + if (!GetInternalPluginsDirectory(&cur)) + return false; + cur = cur.Append(kPepperFlashBaseDirectory); + break; + case chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN: + if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) + return false; + cur = cur.Append(kPepperFlashBaseDirectory); + break; + case chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN: +#if defined(OS_WIN) + if (!GetSystemFlashFilename(&cur)) + return false; +#elif defined(OS_MACOSX) + if (!GetLocalLibraryDirectory(&cur)) + return false; + cur = cur.Append(kPepperFlashSystemBaseDirectory); + cur = cur.Append(chrome::kPepperFlashPluginFilename); +#else + // Chrome on iOS does not supports PPAPI binaries, return false. + // TODO(wfh): If Adobe release PPAPI binaries for Linux, add support here. + return false; +#endif + break; + case chrome::FILE_LOCAL_STATE: + if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) + return false; + cur = cur.Append(chrome::kLocalStateFilename); + break; + case chrome::FILE_RECORDED_SCRIPT: + if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) + return false; + cur = cur.Append(FILE_PATH_LITERAL("script.log")); + break; + case chrome::FILE_PEPPER_FLASH_PLUGIN: + if (!PathService::Get(chrome::DIR_PEPPER_FLASH_PLUGIN, &cur)) + return false; + cur = cur.Append(chrome::kPepperFlashPluginFilename); + break; + // TODO(teravest): Remove this case once the internal NaCl plugin is gone. + // We currently need a path here to look up whether the plugin is disabled + // and what its permissions are. + case chrome::FILE_NACL_PLUGIN: + if (!GetInternalPluginsDirectory(&cur)) + return false; + cur = cur.Append(kInternalNaClPluginFileName); + break; + // PNaCl is currenly installable via the component updater or by being + // simply built-in. DIR_PNACL_BASE is used as the base directory for + // installation via component updater. DIR_PNACL_COMPONENT will be + // the final location of pnacl, which is a subdir of DIR_PNACL_BASE. + case chrome::DIR_PNACL_BASE: + if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) + return false; + cur = cur.Append(FILE_PATH_LITERAL("pnacl")); + break; + // Where PNaCl files are ultimately located. The default finds the files + // inside the InternalPluginsDirectory / build directory, as if it + // was shipped along with chrome. The value can be overridden + // if it is installed via component updater. + case chrome::DIR_PNACL_COMPONENT: +#if defined(OS_MACOSX) + // PNaCl really belongs in the InternalPluginsDirectory but actually + // copying it there would result in the files also being shipped, which + // we don't want yet. So for now, just find them in the directory where + // they get built. + if (!PathService::Get(base::DIR_EXE, &cur)) + return false; + if (base::mac::AmIBundled()) { + // If we're called from chrome, it's beside the app (outside the + // app bundle), if we're called from a unittest, we'll already be + // outside the bundle so use the exe dir. + // exe_dir gave us .../Chromium.app/Contents/MacOS/Chromium. + cur = cur.DirName(); + cur = cur.DirName(); + cur = cur.DirName(); + } +#else + if (!GetInternalPluginsDirectory(&cur)) + return false; +#endif + cur = cur.Append(FILE_PATH_LITERAL("pnacl")); + break; +#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +#if defined(WIDEVINE_CDM_IS_COMPONENT) + case chrome::DIR_COMPONENT_WIDEVINE_CDM: + if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) + return false; + cur = cur.AppendASCII(kWidevineCdmBaseDirectory); + break; +#endif // defined(WIDEVINE_CDM_IS_COMPONENT) + // TODO(xhwang): FILE_WIDEVINE_CDM_ADAPTER has different meanings. + // In the component case, this is the source adapter. Otherwise, it is the + // actual Pepper module that gets loaded. + case chrome::FILE_WIDEVINE_CDM_ADAPTER: + if (!GetComponentDirectory(&cur)) + return false; + cur = cur.Append( + media::GetPlatformSpecificDirectory(kWidevineCdmBaseDirectory)); + cur = cur.AppendASCII(kWidevineCdmAdapterFileName); + break; +#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) + case chrome::FILE_RESOURCES_PACK: +#if defined(OS_MACOSX) + cur = base::mac::FrameworkBundlePath(); + cur = cur.Append(FILE_PATH_LITERAL("Resources")) + .Append(FILE_PATH_LITERAL("resources.pak")); + break; +#elif defined(OS_ANDROID) + if (!PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &cur)) + return false; +#else + // If we're not bundled on mac or Android, resources.pak should be next + // to the binary (e.g., for unit tests). + if (!PathService::Get(base::DIR_MODULE, &cur)) + return false; +#endif + cur = cur.Append(FILE_PATH_LITERAL("resources.pak")); + break; + case chrome::DIR_RESOURCES_EXTENSION: + if (!PathService::Get(base::DIR_MODULE, &cur)) + return false; + cur = cur.Append(FILE_PATH_LITERAL("resources")) + .Append(FILE_PATH_LITERAL("extension")); + break; +#if defined(OS_CHROMEOS) + case chrome::DIR_CHROMEOS_WALLPAPERS: + if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) + return false; + cur = cur.Append(FILE_PATH_LITERAL("wallpapers")); + break; + case chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS: + if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) + return false; + cur = cur.Append(FILE_PATH_LITERAL("wallpaper_thumbnails")); + break; + case chrome::DIR_CHROMEOS_CUSTOM_WALLPAPERS: + if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) + return false; + cur = cur.Append(FILE_PATH_LITERAL("custom_wallpapers")); + break; +#endif +#if defined(ENABLE_SUPERVISED_USERS) +#if defined(OS_LINUX) + case chrome::DIR_SUPERVISED_USERS_DEFAULT_APPS: + if (!PathService::Get(chrome::DIR_STANDALONE_EXTERNAL_EXTENSIONS, &cur)) + return false; + cur = cur.Append(FILE_PATH_LITERAL("managed_users")); + break; +#endif + case chrome::DIR_SUPERVISED_USER_INSTALLED_WHITELISTS: + if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) + return false; + cur = cur.Append(FILE_PATH_LITERAL("SupervisedUserInstalledWhitelists")); + break; +#endif + // The following are only valid in the development environment, and + // will fail if executed from an installed executable (because the + // generated path won't exist). + case chrome::DIR_GEN_TEST_DATA: +#if defined(OS_ANDROID) + // On Android, our tests don't have permission to write to DIR_MODULE. + // gtest/test_runner.py pushes data to external storage. + if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) + return false; +#else + if (!PathService::Get(base::DIR_MODULE, &cur)) + return false; +#endif + cur = cur.Append(FILE_PATH_LITERAL("test_data")); + if (!base::PathExists(cur)) // We don't want to create this. + return false; + break; + case chrome::DIR_TEST_DATA: + if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) + return false; + cur = cur.Append(FILE_PATH_LITERAL("chrome")); + cur = cur.Append(FILE_PATH_LITERAL("test")); + cur = cur.Append(FILE_PATH_LITERAL("data")); + if (!base::PathExists(cur)) // We don't want to create this. + return false; + break; + case chrome::DIR_TEST_TOOLS: + if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) + return false; + cur = cur.Append(FILE_PATH_LITERAL("chrome")); + cur = cur.Append(FILE_PATH_LITERAL("tools")); + cur = cur.Append(FILE_PATH_LITERAL("test")); + if (!base::PathExists(cur)) // We don't want to create this + return false; + break; +#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) + case chrome::DIR_POLICY_FILES: { +#if defined(GOOGLE_CHROME_BUILD) + cur = base::FilePath(FILE_PATH_LITERAL("/etc/opt/chrome/policies")); +#else + cur = base::FilePath(FILE_PATH_LITERAL("/etc/chromium/policies")); +#endif + break; + } +#endif +#if defined(OS_CHROMEOS) || (defined(OS_LINUX) && defined(CHROMIUM_BUILD)) || \ + defined(OS_MACOSX) + case chrome::DIR_USER_EXTERNAL_EXTENSIONS: { + if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) + return false; + cur = cur.Append(FILE_PATH_LITERAL("External Extensions")); + break; + } +#endif +#if defined(OS_LINUX) + case chrome::DIR_STANDALONE_EXTERNAL_EXTENSIONS: { + cur = base::FilePath(kFilepathSinglePrefExtensions); + break; + } +#endif + case chrome::DIR_EXTERNAL_EXTENSIONS: +#if defined(OS_MACOSX) + if (!chrome::GetGlobalApplicationSupportDirectory(&cur)) + return false; + + cur = cur.Append(FILE_PATH_LITERAL("Google")) + .Append(FILE_PATH_LITERAL("Chrome")) + .Append(FILE_PATH_LITERAL("External Extensions")); + create_dir = false; +#else + if (!PathService::Get(base::DIR_MODULE, &cur)) + return false; + + cur = cur.Append(FILE_PATH_LITERAL("extensions")); + create_dir = true; +#endif + break; + + case chrome::DIR_DEFAULT_APPS: +#if defined(OS_MACOSX) + cur = base::mac::FrameworkBundlePath(); + cur = cur.Append(FILE_PATH_LITERAL("Default Apps")); +#else + if (!PathService::Get(chrome::DIR_APP, &cur)) + return false; + cur = cur.Append(FILE_PATH_LITERAL("default_apps")); +#endif + break; + +#if defined(OS_LINUX) || defined(OS_MACOSX) + case chrome::DIR_NATIVE_MESSAGING: +#if defined(OS_MACOSX) +#if defined(GOOGLE_CHROME_BUILD) + cur = base::FilePath(FILE_PATH_LITERAL( + "/Library/Google/Chrome/NativeMessagingHosts")); +#else + cur = base::FilePath(FILE_PATH_LITERAL( + "/Library/Application Support/Chromium/NativeMessagingHosts")); +#endif +#else // defined(OS_MACOSX) +#if defined(GOOGLE_CHROME_BUILD) + cur = base::FilePath(FILE_PATH_LITERAL( + "/etc/opt/chrome/native-messaging-hosts")); +#else + cur = base::FilePath(FILE_PATH_LITERAL( + "/etc/chromium/native-messaging-hosts")); +#endif +#endif // !defined(OS_MACOSX) + break; + + case chrome::DIR_USER_NATIVE_MESSAGING: + if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) + return false; + cur = cur.Append(FILE_PATH_LITERAL("NativeMessagingHosts")); + break; +#endif // defined(OS_LINUX) || defined(OS_MACOSX) +#if !defined(OS_ANDROID) + case chrome::DIR_GLOBAL_GCM_STORE: + if (!PathService::Get(chrome::DIR_USER_DATA, &cur)) + return false; + cur = cur.Append(kGCMStoreDirname); + break; +#endif // !defined(OS_ANDROID) +#if defined(OS_LINUX) + case chrome::FILE_COMPONENT_FLASH_HINT: + if (!PathService::Get(chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN, + &cur)) { + return false; + } + cur = cur.Append(kComponentUpdatedFlashHint); + break; +#endif // defined(OS_LINUX) + + default: + return false; + } + + // TODO(bauerb): http://crbug.com/259796 + base::ThreadRestrictions::ScopedAllowIO allow_io; + if (create_dir && !base::PathExists(cur) && + !base::CreateDirectory(cur)) + return false; + + *result = cur; + return true; +} + +// This cannot be done as a static initializer sadly since Visual Studio will +// eliminate this object file if there is no direct entry point into it. +void RegisterPathProvider() { + PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); +} + +void SetInvalidSpecifiedUserDataDir(const base::FilePath& user_data_dir) { + g_invalid_specified_user_data_dir.Get() = user_data_dir; +} + +const base::FilePath& GetInvalidSpecifiedUserDataDir() { + return g_invalid_specified_user_data_dir.Get(); +} + +} // namespace chrome diff --git a/chromium/chrome/common/chrome_paths.h b/chromium/chrome/common/chrome_paths.h new file mode 100644 index 00000000000..13762bd2341 --- /dev/null +++ b/chromium/chrome/common/chrome_paths.h @@ -0,0 +1,146 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_COMMON_CHROME_PATHS_H__ +#define CHROME_COMMON_CHROME_PATHS_H__ + +#include "build/build_config.h" + +namespace base { +class FilePath; +} + +// This file declares path keys for the chrome module. These can be used with +// the PathService to access various special directories and files. + +namespace chrome { + +enum { + PATH_START = 1000, + + DIR_APP = PATH_START, // Directory where dlls and data reside. + DIR_LOGS, // Directory where logs should be written. + DIR_USER_DATA, // Directory where user data can be written. + DIR_CRASH_DUMPS, // Directory where crash dumps are written. +#if defined(OS_WIN) + DIR_WATCHER_DATA, // Directory where the Chrome watcher stores + // data. +#endif + DIR_RESOURCES, // Directory containing separate file resources + // used by Chrome at runtime. + DIR_INSPECTOR, // Directory where web inspector is located. + DIR_APP_DICTIONARIES, // Directory where the global dictionaries are. + DIR_USER_DOCUMENTS, // Directory for a user's "My Documents". + DIR_USER_MUSIC, // Directory for a user's music. + DIR_USER_PICTURES, // Directory for a user's pictures. + DIR_USER_VIDEOS, // Directory for a user's videos. + DIR_DEFAULT_DOWNLOADS_SAFE, // Directory for a user's + // "My Documents/Downloads", (Windows) or + // "Downloads". (Linux) + DIR_DEFAULT_DOWNLOADS, // Directory for a user's downloads. + DIR_INTERNAL_PLUGINS, // Directory where internal plugins reside. + DIR_COMPONENTS, // Directory where built-in implementations of + // component-updated libraries or data reside. +#if defined(OS_POSIX) && !defined(OS_MACOSX) + DIR_POLICY_FILES, // Directory for system-wide read-only + // policy files that allow sys-admins + // to set policies for chrome. This directory + // contains subdirectories. +#endif +#if defined(OS_CHROMEOS) || (defined(OS_LINUX) && defined(CHROMIUM_BUILD)) || \ + defined(OS_MACOSX) + DIR_USER_EXTERNAL_EXTENSIONS, // Directory for per-user external extensions + // on Chrome Mac and Chromium Linux. + // On Chrome OS, this path is used for OEM + // customization. Getting this path does not + // create it. +#endif + +#if defined(OS_LINUX) + DIR_STANDALONE_EXTERNAL_EXTENSIONS, // Directory for 'per-extension' + // definition manifest files that + // describe extensions which are to be + // installed when chrome is run. +#endif + DIR_EXTERNAL_EXTENSIONS, // Directory where installer places .crx files. + + DIR_DEFAULT_APPS, // Directory where installer places .crx files + // to be installed when chrome is first run. + DIR_PEPPER_FLASH_PLUGIN, // Directory to the bundled Pepper Flash plugin, + // containing the plugin and the manifest. + DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN, // Base directory of the Pepper + // Flash plugins downloaded by the + // component updater. + FILE_RESOURCE_MODULE, // Full path and filename of the module that + // contains embedded resources (version, + // strings, images, etc.). + FILE_LOCAL_STATE, // Path and filename to the file in which + // machine/installation-specific state is saved. + FILE_RECORDED_SCRIPT, // Full path to the script.log file that + // contains recorded browser events for + // playback. + FILE_PEPPER_FLASH_PLUGIN, // Full path to the bundled Pepper Flash plugin + // file. + FILE_PEPPER_FLASH_SYSTEM_PLUGIN, // Full path to the system version of the + // Pepper Flash plugin, downloadable from + // Adobe website. Querying this path might + // succeed no matter the file exists or not. + FILE_NACL_PLUGIN, // Full path to the internal NaCl plugin file. + DIR_PNACL_BASE, // Full path to the base dir for PNaCl. + DIR_PNACL_COMPONENT, // Full path to the latest PNaCl version + // (subdir of DIR_PNACL_BASE). + DIR_COMPONENT_WIDEVINE_CDM, // Directory that contains component-updated + // Widevine CDM files. + FILE_WIDEVINE_CDM_ADAPTER, // Full path to the Widevine CDM adapter file. + FILE_RESOURCES_PACK, // Full path to the .pak file containing + // binary data (e.g., html files and images + // used by internal pages). + DIR_RESOURCES_EXTENSION, // Full path to extension resources. +#if defined(OS_CHROMEOS) + DIR_CHROMEOS_WALLPAPERS, // Directory where downloaded chromeos + // wallpapers reside. + DIR_CHROMEOS_WALLPAPER_THUMBNAILS, // Directory where downloaded chromeos + // wallpaper thumbnails reside. + DIR_CHROMEOS_CUSTOM_WALLPAPERS, // Directory where custom wallpapers + // reside. +#endif + DIR_SUPERVISED_USERS_DEFAULT_APPS, // Directory where installer places .crx + // files to be installed when managed user + // session starts. + DIR_SUPERVISED_USER_INSTALLED_WHITELISTS, // Directory where sanitized + // supervised user whitelists are + // installed. +#if defined(OS_LINUX) || defined(OS_MACOSX) + DIR_NATIVE_MESSAGING, // System directory where native messaging host + // manifest files are stored. + DIR_USER_NATIVE_MESSAGING, // Directory with Native Messaging Hosts + // installed per-user. +#endif +#if !defined(OS_ANDROID) + DIR_GLOBAL_GCM_STORE, // Directory where the global GCM instance + // stores its data. +#endif + + // Valid only in development environment; TODO(darin): move these + DIR_GEN_TEST_DATA, // Directory where generated test data resides. + DIR_TEST_DATA, // Directory where unit test data resides. + DIR_TEST_TOOLS, // Directory where unit test tools reside. +#if defined(OS_LINUX) + FILE_COMPONENT_FLASH_HINT, // A file in a known location that points to + // the component updated flash plugin. +#endif // defined(OS_LINUX) + + PATH_END +}; + +// Call once to register the provider for the path keys defined above. +void RegisterPathProvider(); + +// Get or set the invalid user data dir that was originally specified. +void SetInvalidSpecifiedUserDataDir(const base::FilePath& user_data_dir); +const base::FilePath& GetInvalidSpecifiedUserDataDir(); + +} // namespace chrome + +#endif // CHROME_COMMON_CHROME_PATHS_H__ diff --git a/chromium/chrome/common/chrome_paths_android.cc b/chromium/chrome/common/chrome_paths_android.cc new file mode 100644 index 00000000000..9184418e9e0 --- /dev/null +++ b/chromium/chrome/common/chrome_paths_android.cc @@ -0,0 +1,58 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/chrome_paths_internal.h" + +#include "base/files/file_path.h" +#include "base/logging.h" +#include "base/path_service.h" + +namespace chrome { + +void GetUserCacheDirectory(const base::FilePath& profile_dir, + base::FilePath* result) { + if (!PathService::Get(base::DIR_CACHE, result)) + *result = profile_dir; +} + +bool GetDefaultUserDataDirectory(base::FilePath* result) { + return PathService::Get(base::DIR_ANDROID_APP_DATA, result); +} + +bool GetUserDocumentsDirectory(base::FilePath* result) { + if (!GetDefaultUserDataDirectory(result)) + return false; + *result = result->Append("Documents"); + return true; +} + +bool GetUserDownloadsDirectory(base::FilePath* result) { + if (!GetDefaultUserDataDirectory(result)) + return false; + *result = result->Append("Downloads"); + return true; +} + +bool GetUserMusicDirectory(base::FilePath* result) { + NOTIMPLEMENTED(); + return false; +} + +bool GetUserPicturesDirectory(base::FilePath* result) { + NOTIMPLEMENTED(); + return false; +} + +bool GetUserVideosDirectory(base::FilePath* result) { + NOTIMPLEMENTED(); + return false; +} + +bool ProcessNeedsProfileDir(const std::string& process_type) { + // SELinux prohibits accessing the data directory from isolated services. Only + // the browser (empty process type) should access the profile directory. + return process_type.empty(); +} + +} // namespace chrome diff --git a/chromium/chrome/common/chrome_paths_internal.h b/chromium/chrome/common/chrome_paths_internal.h new file mode 100644 index 00000000000..4b9322a5754 --- /dev/null +++ b/chromium/chrome/common/chrome_paths_internal.h @@ -0,0 +1,105 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_COMMON_CHROME_PATHS_INTERNAL_H_ +#define CHROME_COMMON_CHROME_PATHS_INTERNAL_H_ + +#include <string> + +#include "build/build_config.h" + +#if defined(OS_MACOSX) +#if defined(__OBJC__) +@class NSBundle; +#else +class NSBundle; +#endif +#endif + +namespace base { +class FilePath; +} + +namespace chrome { + +// Get the path to the user's data directory, regardless of whether +// DIR_USER_DATA has been overridden by a command-line option. +bool GetDefaultUserDataDirectory(base::FilePath* result); + +// Get the path to the user's cache directory. This is normally the +// same as the profile directory, but on Linux it can also be +// $XDG_CACHE_HOME and on Mac it can be under ~/Library/Caches. +// Note that the Chrome cache directories are actually subdirectories +// of this directory, with names like "Cache" and "Media Cache". +// This will always fill in |result| with a directory, sometimes +// just |profile_dir|. +void GetUserCacheDirectory(const base::FilePath& profile_dir, base::FilePath* result); + +// Get the path to the user's documents directory. +bool GetUserDocumentsDirectory(base::FilePath* result); + +#if defined(OS_WIN) || defined(OS_LINUX) +// Gets the path to a safe default download directory for a user. +bool GetUserDownloadsDirectorySafe(base::FilePath* result); +#endif + +// Get the path to the user's downloads directory. +bool GetUserDownloadsDirectory(base::FilePath* result); + +// Gets the path to the user's music directory. +bool GetUserMusicDirectory(base::FilePath* result); + +// Gets the path to the user's pictures directory. +bool GetUserPicturesDirectory(base::FilePath* result); + +// Gets the path to the user's videos directory. +bool GetUserVideosDirectory(base::FilePath* result); + +#if defined(OS_MACOSX) +// The "versioned directory" is a directory in the browser .app bundle. It +// contains the bulk of the application, except for the things that the system +// requires be located at spepcific locations. The versioned directory is +// in the .app at Contents/Versions/w.x.y.z. +base::FilePath GetVersionedDirectory(); + +// This overrides the directory returned by |GetVersionedDirectory()|, to be +// used when |GetVersionedDirectory()| can't automatically determine the proper +// location. This is the case when the browser didn't load itself but by, e.g., +// the app mode loader. This should be called before |ChromeMain()|. This takes +// ownership of the object |path| and the caller must not delete it. +void SetOverrideVersionedDirectory(const base::FilePath* path); + +// Most of the application is further contained within the framework. The +// framework bundle is located within the versioned directory at a specific +// path. The only components in the versioned directory not included in the +// framework are things that also depend on the framework, such as the helper +// app bundle. +base::FilePath GetFrameworkBundlePath(); + +// Get the local library directory. +bool GetLocalLibraryDirectory(base::FilePath* result); + +// Get the global Application Support directory (under /Library/). +bool GetGlobalApplicationSupportDirectory(base::FilePath* result); + +// Returns the NSBundle for the outer browser application, even when running +// inside the helper. In unbundled applications, such as tests, returns nil. +NSBundle* OuterAppBundle(); + +// Get the user data directory for the Chrome browser bundle at |bundle|. +// |bundle| should be the same value that would be returned from +[NSBundle +// mainBundle] if Chrome were launched normaly. This is used by app shims, +// which run from a bundle which isn't Chrome itself, but which need access to +// the user data directory to connect to a UNIX-domain socket therein. +// Returns false if there was a problem fetching the app data directory. +bool GetUserDataDirectoryForBrowserBundle(NSBundle* bundle, + base::FilePath* result); + +#endif // OS_MACOSX +// Checks if the |process_type| has the rights to access the profile. +bool ProcessNeedsProfileDir(const std::string& process_type); + +} // namespace chrome + +#endif // CHROME_COMMON_CHROME_PATHS_INTERNAL_H_ diff --git a/chromium/chrome/common/chrome_paths_linux.cc b/chromium/chrome/common/chrome_paths_linux.cc new file mode 100644 index 00000000000..aa26cc9bbb9 --- /dev/null +++ b/chromium/chrome/common/chrome_paths_linux.cc @@ -0,0 +1,147 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/chrome_paths.h" + +#include <memory> + +#include "base/base_paths.h" +#include "base/environment.h" +#include "base/files/file_util.h" +#include "base/nix/xdg_util.h" +#include "base/path_service.h" +#include "build/build_config.h" +#include "chrome/common/chrome_paths_internal.h" + +namespace chrome { + +using base::nix::GetXDGDirectory; +using base::nix::GetXDGUserDirectory; +using base::nix::kDotConfigDir; +using base::nix::kXdgConfigHomeEnvVar; + +namespace { + +const char kDownloadsDir[] = "Downloads"; +const char kMusicDir[] = "Music"; +const char kPicturesDir[] = "Pictures"; +const char kVideosDir[] = "Videos"; + +// Generic function for GetUser{Music,Pictures,Video}Directory. +bool GetUserMediaDirectory(const std::string& xdg_name, + const std::string& fallback_name, + 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()); + + base::FilePath home; + PathService::Get(base::DIR_HOME, &home); + if (*result != home) { + base::FilePath desktop; + if (!PathService::Get(base::DIR_USER_DESKTOP, &desktop)) + return false; + if (*result != desktop) { + return true; + } + } + + *result = home.Append(fallback_name); + return true; +#endif +} + +} // namespace + +// See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html +// for a spec on where config files go. The net effect for most +// 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(base::FilePath* result) { + std::unique_ptr<base::Environment> env(base::Environment::Create()); + base::FilePath config_dir(GetXDGDirectory(env.get(), + kXdgConfigHomeEnvVar, + kDotConfigDir)); +#if defined(GOOGLE_CHROME_BUILD) + *result = config_dir.Append("google-chrome"); +#else + *result = config_dir.Append("chromium"); +#endif + return true; +} + +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, + // use same subdirectory of the cache directory. + // (this maps ~/.config/google-chrome to ~/.cache/google-chrome as well + // as the same thing for ~/.config/chromium) + // - otherwise, use the profile dir directly. + + // Default value in cases where any of the following fails. + *result = profile_dir; + + std::unique_ptr<base::Environment> env(base::Environment::Create()); + + base::FilePath cache_dir; + if (!PathService::Get(base::DIR_CACHE, &cache_dir)) + return; + base::FilePath config_dir(GetXDGDirectory(env.get(), + kXdgConfigHomeEnvVar, + kDotConfigDir)); + + if (!config_dir.AppendRelativePath(profile_dir, &cache_dir)) + return; + + *result = cache_dir; +} + +bool GetUserDocumentsDirectory(base::FilePath* result) { + *result = GetXDGUserDirectory("DOCUMENTS", "Documents"); + return true; +} + +bool GetUserDownloadsDirectorySafe(base::FilePath* result) { + base::FilePath home; + PathService::Get(base::DIR_HOME, &home); + *result = home.Append(kDownloadsDir); + return true; +} + +bool GetUserDownloadsDirectory(base::FilePath* result) { + *result = 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(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(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(base::FilePath* result) { + return GetUserMediaDirectory("VIDEOS", kVideosDir, result); +} + +bool ProcessNeedsProfileDir(const std::string& process_type) { + // For now we have no reason to forbid this on Linux as we don't + // have the roaming profile troubles there. Moreover the Linux breakpad needs + // profile dir access in all process if enabled on Linux. + return true; +} + +} // namespace chrome diff --git a/chromium/chrome/common/chrome_paths_mac.mm b/chromium/chrome/common/chrome_paths_mac.mm new file mode 100644 index 00000000000..d0bbbf72ff0 --- /dev/null +++ b/chromium/chrome/common/chrome_paths_mac.mm @@ -0,0 +1,245 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import <Foundation/Foundation.h> +#include <string.h> + +#include <memory> +#include <string> + +#include "base/base_paths.h" +#include "base/logging.h" +#import "base/mac/foundation_util.h" +#import "base/mac/scoped_nsautorelease_pool.h" +#include "base/memory/free_deleter.h" +#include "base/path_service.h" +#include "build/build_config.h" +#include "chrome/common/chrome_constants.h" +#include "chrome/common/chrome_paths_internal.h" + +namespace { + +#if !defined(OS_IOS) +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 +// caller. +NSBundle* OuterAppBundleInternal() { + base::mac::ScopedNSAutoreleasePool pool; + + if (!base::mac::AmIBundled()) { + // If unbundled (as in a test), there's no app bundle. + return nil; + } + + if (!base::mac::IsBackgroundOnlyProcess()) { + // Shortcut: in the browser process, just return the main app bundle. + return [[NSBundle mainBundle] retain]; + } + + // From C.app/Contents/Versions/1.2.3.4, go up three steps to get to C.app. + 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]; + + return [[NSBundle bundleWithPath:outer_app_dir_ns] retain]; +} +#endif // !defined(OS_IOS) + +char* ProductDirNameForBundle(NSBundle* chrome_bundle) { + const char* product_dir_name = NULL; +#if !defined(OS_IOS) + base::mac::ScopedNSAutoreleasePool pool; + + NSString* product_dir_name_ns = + [chrome_bundle objectForInfoDictionaryKey:@"CrProductDirName"]; + product_dir_name = [product_dir_name_ns fileSystemRepresentation]; +#else + DCHECK(!chrome_bundle); +#endif + + if (!product_dir_name) { +#if defined(GOOGLE_CHROME_BUILD) + product_dir_name = "Google/Chrome"; +#else + product_dir_name = "Chromium"; +#endif + } + + // Leaked, but the only caller initializes a static with this result, so it + // only happens once, and that's OK. + return strdup(product_dir_name); +} + +// ProductDirName returns the name of the directory inside +// ~/Library/Application Support that should hold the product application +// data. This can be overridden by setting the CrProductDirName key in the +// outer browser .app's Info.plist. The default is "Google/Chrome" for +// officially-branded builds, and "Chromium" for unbranded builds. For the +// official canary channel, the Info.plist will have CrProductDirName set +// to "Google/Chrome Canary". +std::string ProductDirName() { +#if defined(OS_IOS) + static const char* product_dir_name = ProductDirNameForBundle(nil); +#else + // Use OuterAppBundle() to get the main app's bundle. This key needs to live + // in the main app's bundle because it will be set differently on the canary + // channel, and the autoupdate system dictates that there can be no + // differences between channels within the versioned directory. This would + // normally use base::mac::FrameworkBundle(), but that references the + // framework bundle within the versioned directory. Ordinarily, the profile + // should not be accessed from non-browser processes, but those processes do + // attempt to get the profile directory, so direct them to look in the outer + // browser .app's Info.plist for the CrProductDirName key. + static const char* product_dir_name = + ProductDirNameForBundle(chrome::OuterAppBundle()); +#endif + return std::string(product_dir_name); +} + +bool GetDefaultUserDataDirectoryForProduct(const std::string& product_dir, + base::FilePath* result) { + bool success = false; + if (result && PathService::Get(base::DIR_APP_DATA, result)) { + *result = result->Append(product_dir); + success = true; + } + return success; +} + +} // namespace + +namespace chrome { + +bool GetDefaultUserDataDirectory(base::FilePath* result) { + return GetDefaultUserDataDirectoryForProduct(ProductDirName(), result); +} + +bool GetUserDocumentsDirectory(base::FilePath* result) { + return base::mac::GetUserDirectory(NSDocumentDirectory, 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 + // Support/Google/Chrome/MyProfileName would use the cache directory + // ~/Library/Caches/Google/Chrome/MyProfileName. + + // Default value in cases where any of the following fails. + *result = profile_dir; + + base::FilePath app_data_dir; + if (!PathService::Get(base::DIR_APP_DATA, &app_data_dir)) + return; + base::FilePath cache_dir; + if (!PathService::Get(base::DIR_CACHE, &cache_dir)) + return; + if (!app_data_dir.AppendRelativePath(profile_dir, &cache_dir)) + return; + + *result = cache_dir; +} + +bool GetUserDownloadsDirectory(base::FilePath* result) { + return base::mac::GetUserDirectory(NSDownloadsDirectory, result); +} + +bool GetUserMusicDirectory(base::FilePath* result) { + return base::mac::GetUserDirectory(NSMusicDirectory, result); +} + +bool GetUserPicturesDirectory(base::FilePath* result) { + return base::mac::GetUserDirectory(NSPicturesDirectory, result); +} + +bool GetUserVideosDirectory(base::FilePath* result) { + return base::mac::GetUserDirectory(NSMoviesDirectory, result); +} + +#if !defined(OS_IOS) + +base::FilePath GetVersionedDirectory() { + if (g_override_versioned_directory) + return *g_override_versioned_directory; + + // Start out with the path to the running executable. + base::FilePath path; + PathService::Get(base::FILE_EXE, &path); + + // One step up to MacOS, another to Contents. + path = path.DirName().DirName(); + DCHECK_EQ(path.BaseName().value(), "Contents"); + + if (base::mac::IsBackgroundOnlyProcess()) { + // path identifies the helper .app's Contents directory in the browser + // .app's versioned directory. Go up two steps to get to the browser + // .app's versioned directory. + path = path.DirName().DirName(); + DCHECK_EQ(path.BaseName().value(), kChromeVersion); + } else { + // Go into the versioned directory. + path = path.Append("Versions").Append(kChromeVersion); + } + + return path; +} + +void SetOverrideVersionedDirectory(const base::FilePath* path) { + if (path != g_override_versioned_directory) { + delete g_override_versioned_directory; + g_override_versioned_directory = path; + } +} + +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: + // itself takes 1-2ms. Getting an NSBundle from a path, on the other hand, + // essentially takes no time at all, at least when the bundle has already + // been loaded as it will have been in this case. The FilePath operations + // needed to compute the framework's path are also effectively free, so that + // is the approach that is used here. NSBundle is also documented as being + // not thread-safe, and thread safety may be a concern here. + + // The framework bundle is at a known path and name from the browser .app's + // versioned directory. + return GetVersionedDirectory().Append(kFrameworkName); +} + +bool GetLocalLibraryDirectory(base::FilePath* result) { + return base::mac::GetLocalDirectory(NSLibraryDirectory, result); +} + +bool GetGlobalApplicationSupportDirectory(base::FilePath* result) { + return base::mac::GetLocalDirectory(NSApplicationSupportDirectory, result); +} + +NSBundle* OuterAppBundle() { + // Cache this. Foundation leaks it anyway, and this should be the only call + // to OuterAppBundleInternal(). + static NSBundle* bundle = OuterAppBundleInternal(); + return bundle; +} + +bool GetUserDataDirectoryForBrowserBundle(NSBundle* bundle, + base::FilePath* result) { + std::unique_ptr<char, base::FreeDeleter> product_dir_name( + ProductDirNameForBundle(bundle)); + return GetDefaultUserDataDirectoryForProduct(product_dir_name.get(), result); +} + +#endif // !defined(OS_IOS) + +bool ProcessNeedsProfileDir(const std::string& process_type) { + // For now we have no reason to forbid this on other MacOS as we don't + // have the roaming profile troubles there. + return true; +} + +} // namespace chrome diff --git a/chromium/chrome/common/chrome_paths_unittest.cc b/chromium/chrome/common/chrome_paths_unittest.cc new file mode 100644 index 00000000000..ca7d43a1aee --- /dev/null +++ b/chromium/chrome/common/chrome_paths_unittest.cc @@ -0,0 +1,58 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/chrome_paths_internal.h" + +#include <stdlib.h> + +#include "base/base_paths.h" +#include "base/files/file_path.h" +#include "base/files/file_util.h" +#include "base/path_service.h" +#include "build/build_config.h" +#include "chrome/common/chrome_constants.h" +#include "testing/gtest/include/gtest/gtest.h" + +// Test the behavior of chrome::GetUserCacheDirectory. +// See that function's comments for discussion of the subtleties. +TEST(ChromePaths, UserCacheDir) { + 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"); + 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. + base::FilePath expected_cache_dir; + ASSERT_TRUE(PathService::Get(base::DIR_CACHE, &expected_cache_dir)); +#elif(OS_POSIX) + base::FilePath homedir; + PathService::Get(base::DIR_HOME, &homedir); + // Note: we assume XDG_CACHE_HOME/XDG_CONFIG_HOME are at their + // default settings. + test_profile_dir = homedir.Append(".config/foobar"); + base::FilePath expected_cache_dir = homedir.Append(".cache/foobar"); +#endif + + // Verify that a profile in the special platform-specific source + // location ends up in the special target location. +#if !defined(OS_WIN) // No special behavior on Windows. + chrome::GetUserCacheDirectory(test_profile_dir, &cache_dir); + EXPECT_EQ(expected_cache_dir.value(), cache_dir.value()); +#endif + + // Verify that a profile in some other random directory doesn't use + // the special cache dir. + 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()); +#else + EXPECT_EQ(test_profile_dir.value(), cache_dir.value()); +#endif +} diff --git a/chromium/chrome/common/chrome_paths_win.cc b/chromium/chrome/common/chrome_paths_win.cc new file mode 100644 index 00000000000..597448bdf67 --- /dev/null +++ b/chromium/chrome/common/chrome_paths_win.cc @@ -0,0 +1,122 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/chrome_paths_internal.h" + +#include <windows.h> +#include <knownfolders.h> +#include <shellapi.h> +#include <shlobj.h> +#include <shobjidl.h> + +#include "base/files/file_path.h" +#include "base/files/file_util.h" +#include "base/path_service.h" +#include "base/win/scoped_co_mem.h" +#include "chrome/common/chrome_constants.h" +#include "chrome/common/chrome_switches.h" +#include "chrome/installer/util/browser_distribution.h" +#include "components/nacl/common/nacl_switches.h" + +namespace chrome { + +namespace { + +// Generic function to call SHGetFolderPath(). +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 + // (but other things will surely break if the temp path is too long, + // so we don't bother handling it. + wchar_t path_buf[MAX_PATH]; + path_buf[0] = 0; + if (FAILED(SHGetFolderPath(NULL, csidl_folder, NULL, + SHGFP_TYPE_CURRENT, path_buf))) { + return false; + } + *result = base::FilePath(path_buf); + return true; +} + +} // namespace + +bool GetDefaultUserDataDirectory(base::FilePath* result) { + if (!PathService::Get(base::DIR_LOCAL_APP_DATA, result)) + return false; + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + *result = result->Append(dist->GetInstallSubDir()); + *result = result->Append(chrome::kUserDataDirname); + return true; +} + +void GetUserCacheDirectory(const base::FilePath& profile_dir, + base::FilePath* result) { + // This function does more complicated things on Mac/Linux. + *result = profile_dir; +} + +bool GetUserDocumentsDirectory(base::FilePath* result) { + return GetUserDirectory(CSIDL_MYDOCUMENTS, result); +} + +// Return a default path for downloads that is safe. +// 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(base::FilePath* result) { + if (!GetUserDocumentsDirectory(result)) + return false; + + *result = result->Append(L"Downloads"); + return true; +} + +// 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(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 = base::FilePath(std::wstring(path_buf)); + return true; + } + return GetUserDownloadsDirectorySafe(result); +} + +bool GetUserMusicDirectory(base::FilePath* result) { + return GetUserDirectory(CSIDL_MYMUSIC, result); +} + +bool GetUserPicturesDirectory(base::FilePath* result) { + return GetUserDirectory(CSIDL_MYPICTURES, result); +} + +bool GetUserVideosDirectory(base::FilePath* result) { + return GetUserDirectory(CSIDL_MYVIDEO, result); +} + +bool ProcessNeedsProfileDir(const std::string& process_type) { + // On windows we don't want subprocesses other than the browser process and + // service processes to be able to use the profile directory because if it + // lies on a network share the sandbox will prevent us from accessing it. + + if (process_type.empty() || process_type == switches::kServiceProcess) + return true; + +#if !defined(DISABLE_NACL) + if (process_type == switches::kNaClBrokerProcess || + process_type == switches::kNaClLoaderProcess) { + return true; + } +#endif + + return false; +} + +} // namespace chrome diff --git a/chromium/chrome/common/url_constants.cc b/chromium/chrome/common/url_constants.cc new file mode 100644 index 00000000000..b994412b531 --- /dev/null +++ b/chromium/chrome/common/url_constants.cc @@ -0,0 +1,789 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/url_constants.h" + +#include <algorithm> + +#include "base/macros.h" +#include "build/build_config.h" +#include "chrome/common/features.h" +#include "content/public/common/url_constants.h" +#include "url/url_util.h" + +namespace chrome { + +#if defined(OS_CHROMEOS) +const char kCrosScheme[] = "cros"; +#endif + +#if defined(OS_ANDROID) +const char kAndroidAppScheme[] = "android-app"; +#endif + +// Add Chrome UI URLs as necessary, in alphabetical order. +// Be sure to add the corresponding kChromeUI*Host constant below. +// This is a WebUI page that lists other WebUI pages. +const char kChromeUIAboutURL[] = "chrome://about/"; +const char kChromeUIAppsURL[] = "chrome://apps/"; +const char kChromeUIAppListStartPageURL[] = "chrome://app-list/"; +const char kChromeUIBookmarksURL[] = "chrome://bookmarks/"; +const char kChromeUICertificateViewerURL[] = "chrome://view-cert/"; +const char kChromeUICertificateViewerDialogURL[] = "chrome://view-cert-dialog/"; +const char kChromeUIChromeSigninURL[] = "chrome://chrome-signin/"; +const char kChromeUIChromeURLsURL[] = "chrome://chrome-urls/"; +const char kChromeUIComponentsURL[] = "chrome://components/"; +const char kChromeUIConflictsURL[] = "chrome://conflicts/"; +const char kChromeUIConstrainedHTMLTestURL[] = "chrome://constrained-test/"; +const char kChromeUICrashesURL[] = "chrome://crashes/"; +const char kChromeUICreditsURL[] = "chrome://credits/"; +const char kChromeUIDevicesURL[] = "chrome://devices/"; +const char kChromeUIDevToolsURL[] = + "chrome-devtools://devtools/bundled/inspector.html"; +const char kChromeUIDomainReliabilityInternalsURL[] = + "chrome://domain-reliability-internals/"; +const char kChromeUIDownloadsURL[] = "chrome://downloads/"; +const char kChromeUIExtensionIconURL[] = "chrome://extension-icon/"; +const char kChromeUIExtensionsFrameURL[] = "chrome://extensions-frame/"; +const char kChromeUIExtensionsURL[] = "chrome://extensions/"; +const char kChromeUIFallbackIconURL[] = "chrome://fallback-icon/"; +const char kChromeUIFaviconURL[] = "chrome://favicon/"; +const char kChromeUIFeedbackURL[] = "chrome://feedback/"; +const char kChromeUIFlagsURL[] = "chrome://flags/"; +const char kChromeUIFlashURL[] = "chrome://flash/"; +const char kChromeUIGCMInternalsURL[] = "chrome://gcm-internals/"; +const char kChromeUIHelpFrameURL[] = "chrome://help-frame/"; +const char kChromeUIHelpURL[] = "chrome://help/"; +const char kChromeUIHistoryURL[] = "chrome://history/"; +const char kChromeUIHistoryFrameURL[] = "chrome://history-frame/"; +const char kChromeUIIdentityInternalsURL[] = "chrome://identity-internals/"; +const char kChromeUIInspectURL[] = "chrome://inspect/"; +const char kChromeUIInstantURL[] = "chrome://instant/"; +const char kChromeUIInterstitialURL[] = "chrome://interstitials/"; +const char kChromeUIInvalidationsURL[] = "chrome://invalidations/"; +const char kChromeUILargeIconURL[] = "chrome://large-icon/"; +const char kChromeUIMdPolicyURL[] = "chrome://md-policy/"; +const char kChromeUIMdSettingsURL[] = "chrome://md-settings/"; +const char kChromeUINaClURL[] = "chrome://nacl/"; +const char kChromeUINetInternalsURL[] = "chrome://net-internals/"; +const char kChromeUINewProfileURL[] = "chrome://newprofile/"; +const char kChromeUINewTabURL[] = "chrome://newtab/"; +const char kChromeUIOmniboxURL[] = "chrome://omnibox/"; +const char kChromeUIPluginsURL[] = "chrome://plugins/"; +const char kChromeUIPolicyURL[] = "chrome://policy/"; +const char kChromeUIProfileSigninConfirmationURL[] = + "chrome://profile-signin-confirmation/"; +const char kChromeUIUserManagerURL[] = "chrome://user-manager/"; +const char kChromeUIMdUserManagerUrl[] = "chrome://md-user-manager/"; +const char kChromeUIPrintURL[] = "chrome://print/"; +const char kChromeUIQuitURL[] = "chrome://quit/"; +const char kChromeUIRestartURL[] = "chrome://restart/"; +const char kChromeUISettingsURL[] = "chrome://settings/"; +const char kChromeUIContentSettingsURL[] = "chrome://settings/content"; +const char kChromeUISettingsFrameURL[] = "chrome://settings-frame/"; +const char kChromeUISuggestionsURL[] = "chrome://suggestions/"; +const char kChromeUISupervisedUserPassphrasePageURL[] = + "chrome://managed-user-passphrase/"; +const char kChromeUISyncConfirmationURL[] = "chrome://sync-confirmation/"; +const char kChromeUITermsURL[] = "chrome://terms/"; +const char kChromeUIThemeURL[] = "chrome://theme/"; +const char kChromeUIThumbnailURL[] = "chrome://thumb/"; +const char kChromeUIThumbnailListURL[] = "chrome://thumbnails/"; +const char kChromeUIUberFrameURL[] = "chrome://uber-frame/"; +const char kChromeUIUserActionsURL[] = "chrome://user-actions/"; +const char kChromeUIVersionURL[] = "chrome://version/"; + +#if BUILDFLAG(ANDROID_JAVA_UI) +const char kChromeUIContextualSearchPromoURL[] = + "chrome://contextual-search-promo"; +const char kChromeUINativeScheme[] = "chrome-native"; +const char kChromeUINativeNewTabURL[] = "chrome-native://newtab/"; +const char kChromeUINativeBookmarksURL[] = "chrome-native://bookmarks/"; +const char kChromeUINativePhysicalWebURL[] = "chrome-native://physical-web/"; +const char kChromeUINativeRecentTabsURL[] = "chrome-native://recent-tabs/"; +#endif + +#if defined(OS_CHROMEOS) +const char kChromeUIBluetoothPairingURL[] = "chrome://bluetooth-pairing/"; +const char kChromeUICertificateManagerDialogURL[] = + "chrome://certificate-manager/"; +const char kChromeUIChooseMobileNetworkURL[] = + "chrome://choose-mobile-network/"; +const char kChromeUIDeviceEmulatorURL[] = "chrome://device-emulator/"; +const char kChromeUIFirstRunURL[] = "chrome://first-run/"; +const char kChromeUIKeyboardOverlayURL[] = "chrome://keyboardoverlay/"; +const char kChromeUIMobileSetupURL[] = "chrome://mobilesetup/"; +const char kChromeUINfcDebugURL[] = "chrome://nfc-debug/"; +const char kChromeUIOobeURL[] = "chrome://oobe/"; +const char kChromeUIOSCreditsURL[] = "chrome://os-credits/"; +const char kChromeUIProxySettingsURL[] = "chrome://proxy-settings/"; +const char kChromeUIScreenlockIconURL[] = "chrome://screenlock-icon/"; +const char kChromeUISetTimeURL[] = "chrome://set-time/"; +const char kChromeUISimUnlockURL[] = "chrome://sim-unlock/"; +const char kChromeUISlowURL[] = "chrome://slow/"; +const char kChromeUISystemInfoURL[] = "chrome://system/"; +const char kChromeUITermsOemURL[] = "chrome://terms/oem"; +const char kChromeUIUserImageURL[] = "chrome://userimage/"; +#endif // defined(OS_CHROMEOS) + +#if defined(OS_WIN) +const char kChromeUIMetroFlowURL[] = "chrome://make-metro/"; +#endif + +#if (defined(OS_LINUX) && defined(TOOLKIT_VIEWS)) || defined(USE_AURA) +const char kChromeUITabModalConfirmDialogURL[] = + "chrome://tab-modal-confirm-dialog/"; +#endif + +#if !defined(OS_ANDROID) +const char kChromeUICopresenceURL[] = "chrome://copresence/"; +#endif + +#if defined(ENABLE_WEBRTC) +const char kChromeUIWebRtcLogsURL[] = "chrome://webrtc-logs/"; +#endif + +#if defined(ENABLE_MEDIA_ROUTER) +const char kChromeUIMediaRouterURL[] = "chrome://media-router/"; +#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) +const char kChromeUICastURL[] = "chrome://cast/"; +#endif +#endif + +#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) +const char kChromeUIDiscardsHost[] = "discards"; +const char kChromeUIDiscardsURL[] = "chrome://discards/"; +#endif + +// Add Chrome UI hosts here, in alphabetical order. +// Add hosts to kChromePaths in browser_about_handler.cc to be listed by +// chrome://chrome-urls (about:about) and the built-in AutocompleteProvider. +const char kChromeUIAboutHost[] = "about"; +const char kChromeUIBlankHost[] = "blank"; +const char kChromeUIAppLauncherPageHost[] = "apps"; +const char kChromeUIAppListStartPageHost[] = "app-list"; +const char kChromeUIBookmarksHost[] = "bookmarks"; +const char kChromeUICacheHost[] = "cache"; +const char kChromeUICertificateViewerHost[] = "view-cert"; +const char kChromeUICertificateViewerDialogHost[] = "view-cert-dialog"; +const char kChromeUIChromeSigninHost[] = "chrome-signin"; +const char kChromeUIChromeURLsHost[] = "chrome-urls"; +const char kChromeUIConflictsHost[] = "conflicts"; +const char kChromeUIConstrainedHTMLTestHost[] = "constrained-test"; +const char kChromeUICrashesHost[] = "crashes"; +const char kChromeUICrashHost[] = "crash"; +const char kChromeUICreditsHost[] = "credits"; +const char kChromeUIDefaultHost[] = "version"; +const char kChromeUIDelayedHangUIHost[] = "delayeduithreadhang"; +const char kChromeUIDeviceLogHost[] = "device-log"; +const char kChromeUIDevicesHost[] = "devices"; +const char kChromeUIDevToolsHost[] = "devtools"; +const char kChromeUIDevToolsBundledPath[] = "bundled"; +const char kChromeUIDevToolsRemotePath[] = "remote"; +const char kChromeUIDNSHost[] = "dns"; +const char kChromeUIDomainReliabilityInternalsHost[] = + "domain-reliability-internals"; +const char kChromeUIDownloadsHost[] = "downloads"; +const char kChromeUIDriveInternalsHost[] = "drive-internals"; +const char kChromeUIExtensionIconHost[] = "extension-icon"; +const char kChromeUIExtensionsFrameHost[] = "extensions-frame"; +const char kChromeUIExtensionsHost[] = "extensions"; +const char kChromeUIFallbackIconHost[] = "fallback-icon"; +const char kChromeUIFaviconHost[] = "favicon"; +const char kChromeUIFeedbackHost[] = "feedback"; +const char kChromeUIFlagsHost[] = "flags"; +const char kChromeUIFlashHost[] = "flash"; +const char kChromeUIGCMInternalsHost[] = "gcm-internals"; +const char kChromeUIHangHost[] = "hang"; +const char kChromeUIHangUIHost[] = "uithreadhang"; +const char kChromeUIHelpFrameHost[] = "help-frame"; +const char kChromeUIHelpHost[] = "help"; +const char kChromeUIHistoryHost[] = "history"; +const char kChromeUIHistoryFrameHost[] = "history-frame"; +const char kChromeUIIdentityInternalsHost[] = "identity-internals"; +const char kChromeUIInspectHost[] = "inspect"; +const char kChromeUIInstantHost[] = "instant"; +const char kChromeUIInterstitialHost[] = "interstitials"; +const char kChromeUIInvalidationsHost[] = "invalidations"; +const char kChromeUIKillHost[] = "kill"; +const char kChromeUILargeIconHost[] = "large-icon"; +const char kChromeUILocalStateHost[] = "local-state"; +const char kChromeUIMdPolicyHost[] = "md-policy"; +const char kChromeUIMdSettingsHost[] = "md-settings"; +const char kChromeUINaClHost[] = "nacl"; +const char kChromeUINetExportHost[] = "net-export"; +const char kChromeUINetInternalsHost[] = "net-internals"; +const char kChromeUINewTabHost[] = "newtab"; +const char kChromeUIOmniboxHost[] = "omnibox"; +const char kChromeUIPasswordManagerInternalsHost[] = + "password-manager-internals"; +const char kChromeUIPluginsHost[] = "plugins"; +const char kChromeUIComponentsHost[] = "components"; +const char kChromeUIPolicyHost[] = "policy"; +const char kChromeUIProfileSigninConfirmationHost[] = + "profile-signin-confirmation"; +const char kChromeUIUserManagerHost[] = "user-manager"; +const char kChromeUIMdUserManagerHost[] = "md-user-manager"; +const char kChromeUIPredictorsHost[] = "predictors"; +const char kChromeUIProfilerHost[] = "profiler"; +const char kChromeUIQuotaInternalsHost[] = "quota-internals"; +const char kChromeUIQuitHost[] = "quit"; +const char kChromeUIRestartHost[] = "restart"; +const char kChromeUISettingsHost[] = "settings"; +const char kChromeUISettingsFrameHost[] = "settings-frame"; +const char kChromeUIShorthangHost[] = "shorthang"; +const char kChromeUISignInInternalsHost[] = "signin-internals"; +const char kChromeUISiteEngagementHost[] = "site-engagement"; +const char kChromeUISuggestionsHost[] = "suggestions"; +const char kChromeUISupervisedUserInternalsHost[] = "supervised-user-internals"; +const char kChromeUISupervisedUserPassphrasePageHost[] = + "managed-user-passphrase"; +const char kChromeUISyncConfirmationHost[] = "sync-confirmation"; +const char kChromeUISyncHost[] = "sync"; +const char kChromeUISyncFileSystemInternalsHost[] = "syncfs-internals"; +const char kChromeUISyncInternalsHost[] = "sync-internals"; +const char kChromeUISyncResourcesHost[] = "syncresources"; +const char kChromeUISystemInfoHost[] = "system"; +const char kChromeUITermsHost[] = "terms"; +const char kChromeUIThemeHost[] = "theme"; +const char kChromeUIThumbnailHost[] = "thumb"; +const char kChromeUIThumbnailHost2[] = "thumb2"; +const char kChromeUIThumbnailListHost[] = "thumbnails"; +const char kChromeUITouchIconHost[] = "touch-icon"; +const char kChromeUITranslateInternalsHost[] = "translate-internals"; +const char kChromeUIUberFrameHost[] = "uber-frame"; +const char kChromeUIUberHost[] = "chrome"; +const char kChromeUIUserActionsHost[] = "user-actions"; +const char kChromeUIVersionHost[] = "version"; +const char kChromeUIWorkersHost[] = "workers"; + +const char kChromeUIThemePath[] = "theme"; + +#if defined(ENABLE_PRINT_PREVIEW) +const char kChromeUIPrintHost[] = "print"; +#endif // ENABLE_PRINT_PREVIEW + +#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) +const char kChromeUILinuxProxyConfigHost[] = "linux-proxy-config"; +const char kChromeUISandboxHost[] = "sandbox"; +#endif + +#if defined(OS_ANDROID) +const char kChromeUIContextualSearchPromoHost[] = "contextual-search-promo"; +const char kChromeUIOfflineInternalsHost[] = "offline-internals"; +const char kChromeUIPhysicalWebHost[] = "physical-web"; +const char kChromeUIPopularSitesInternalsHost[] = "popular-sites-internals"; +const char kChromeUISnippetsInternalsHost[] = "snippets-internals"; +#endif + +#if defined(OS_CHROMEOS) +const char kChromeUIActivationMessageHost[] = "activationmessage"; +const char kChromeUIAppLaunchHost[] = "app-launch"; +const char kChromeUIBluetoothPairingHost[] = "bluetooth-pairing"; +const char kChromeUICertificateManagerHost[] = "certificate-manager"; +const char kChromeUIChooseMobileNetworkHost[] = "choose-mobile-network"; +const char kChromeUICryptohomeHost[] = "cryptohome"; +const char kChromeUIDeviceEmulatorHost[] = "device-emulator"; +const char kChromeUIFirstRunHost[] = "first-run"; +const char kChromeUIKeyboardOverlayHost[] = "keyboardoverlay"; +const char kChromeUILoginContainerHost[] = "login-container"; +const char kChromeUILoginHost[] = "login"; +const char kChromeUIMobileSetupHost[] = "mobilesetup"; +const char kChromeUINfcDebugHost[] = "nfc-debug"; +const char kChromeUINetworkHost[] = "network"; +const char kChromeUIOobeHost[] = "oobe"; +const char kChromeUIOSCreditsHost[] = "os-credits"; +const char kChromeUIPowerHost[] = "power"; +const char kChromeUIProxySettingsHost[] = "proxy-settings"; +const char kChromeUIRotateHost[] = "rotate"; +const char kChromeUIScreenlockIconHost[] = "screenlock-icon"; +const char kChromeUISetTimeHost[] = "set-time"; +const char kChromeUISimUnlockHost[] = "sim-unlock"; +const char kChromeUISlowHost[] = "slow"; +const char kChromeUISlowTraceHost[] = "slow_trace"; +const char kChromeUIUserImageHost[] = "userimage"; +const char kChromeUIVoiceSearchHost[] = "voicesearch"; + +const char kEULAPathFormat[] = "/usr/share/chromeos-assets/eula/%s/eula.html"; +const char kOemEulaURLPath[] = "oem"; +const char kOnlineEulaURLPath[] = + "https://www.google.com/intl/%s/chrome/eula_text.html"; + +const char kChromeOSCreditsPath[] = + "/opt/google/chrome/resources/about_os_credits.html"; + +const char kChromeOSAssetHost[] = "chromeos-asset"; +const char kChromeOSAssetPath[] = "/usr/share/chromeos-assets/"; +#endif // defined(OS_CHROMEOS) + +#if defined(OS_WIN) +const char kChromeUIMetroFlowHost[] = "make-metro"; +#endif + +#if (defined(OS_LINUX) && defined(TOOLKIT_VIEWS)) || defined(USE_AURA) +const char kChromeUITabModalConfirmDialogHost[] = "tab-modal-confirm-dialog"; +#endif + +#if !defined(OS_ANDROID) +const char kChromeUICopresenceHost[] = "copresence"; +#endif + +#if defined(ENABLE_WEBRTC) +const char kChromeUIWebRtcLogsHost[] = "webrtc-logs"; +#endif + +#if defined(ENABLE_MEDIA_ROUTER) +const char kChromeUIMediaRouterHost[] = "media-router"; +#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) +const char kChromeUICastHost[] = "cast"; +#endif +#endif + +// Option sub pages. +// Add sub page paths to kChromeSettingsSubPages in builtin_provider.cc to be +// listed by the built-in AutocompleteProvider. +const char kAutofillSubPage[] = "autofill"; +const char kClearBrowserDataSubPage[] = "clearBrowserData"; +const char kContentSettingsExceptionsSubPage[] = "contentExceptions"; +const char kContentSettingsSubPage[] = "content"; +const char kCreateProfileSubPage[] = "createProfile"; +const char kExtensionsSubPage[] = "extensions"; +const char kHandlerSettingsSubPage[] = "handlers"; +const char kImportDataSubPage[] = "importData"; +const char kLanguageOptionsSubPage[] = "languages"; +const char kManageProfileSubPage[] = "manageProfile"; +const char kPasswordManagerSubPage[] = "passwords"; +const char kPowerOptionsSubPage[] = "power-overlay"; +const char kResetProfileSettingsSubPage[] = "resetProfileSettings"; +const char kSearchEnginesSubPage[] = "searchEngines"; +const char kSearchSubPage[] = "search"; +const char kSearchUsersSubPage[] = "search#Users"; +const char kSyncSetupSubPage[] = "syncSetup"; +const char kTriggeredResetProfileSettingsSubPage[] = + "triggeredResetProfileSettings"; +#if defined(OS_CHROMEOS) +const char kInternetOptionsSubPage[] = "internet"; +const char kChangeProfilePictureSubPage[] = "changePicture"; +#endif + +// Extension sub pages. +const char kExtensionConfigureCommandsSubPage[] = "configureCommands"; + +const char kExtensionInvalidRequestURL[] = "chrome-extension://invalid/"; +const char kExtensionResourceInvalidRequestURL[] = + "chrome-extension-resource://invalid/"; + +const char kSyncGoogleDashboardURL[] = + "https://www.google.com/settings/chrome/sync/"; + +const char kGoogleAccountActivityControlsURL[] = + "https://myaccount.google.com/activitycontrols/search"; + +const char kPasswordManagerLearnMoreURL[] = +#if defined(OS_CHROMEOS) + "https://support.google.com/chromebook/?p=settings_password"; +#else + "https://support.google.com/chrome/?p=settings_password"; +#endif + +const char kUpgradeHelpCenterBaseURL[] = + "https://support.google.com/installer/?product=" + "{8A69D345-D564-463c-AFF1-A69D9E530F96}&error="; + +const char kSmartLockHelpPage[] = + "https://support.google.com/accounts/answer/6197437"; + +const char kExtensionControlledSettingLearnMoreURL[] = + "https://support.google.com/chrome/?p=ui_settings_api_extension"; + +const char kChromeHelpViaKeyboardURL[] = +#if defined(OS_CHROMEOS) +#if defined(OFFICIAL_BUILD) + "chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"; +#else + "https://support.google.com/chromebook/?p=help&ctx=keyboard"; +#endif // defined(OFFICIAL_BUILD +#else + "https://support.google.com/chrome/?p=help&ctx=keyboard"; +#endif // defined(OS_CHROMEOS) + +const char kChromeHelpViaMenuURL[] = +#if defined(OS_CHROMEOS) +#if defined(OFFICIAL_BUILD) + "chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"; +#else + "https://support.google.com/chromebook/?p=help&ctx=menu"; +#endif // defined(OFFICIAL_BUILD +#else + "https://support.google.com/chrome/?p=help&ctx=menu"; +#endif // defined(OS_CHROMEOS) + +const char kChromeHelpViaWebUIURL[] = +#if defined(OS_CHROMEOS) +#if defined(OFFICIAL_BUILD) + "chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"; +#else + "https://support.google.com/chromebook/?p=help&ctx=settings"; +#endif // defined(OFFICIAL_BUILD +#else + "https://support.google.com/chrome/?p=help&ctx=settings"; +#endif // defined(OS_CHROMEOS) + +#if defined(OS_CHROMEOS) +const char kChromeAccessibilityHelpURL[] = + "https://support.google.com/chromebook/?p=accessibility_menu"; +const char kChromeAccessibilitySettingsURL[] = + "/chromevox/background/options.html"; +#endif // defined(OS_CHROMEOS) + +#if BUILDFLAG(ENABLE_ONE_CLICK_SIGNIN) +const char kChromeSyncLearnMoreURL[] = + "https://support.google.com/chrome/answer/165139"; + +const char kChromeSyncMergeTroubleshootingURL[] = + "https://support.google.com/chrome/answer/1181420#merge"; +#endif // BUILDFLAG(ENABLE_ONE_CLICK_SIGNIN) + +#if defined(OS_MACOSX) +const char kChromeEnterpriseSignInLearnMoreURL[] = + "https://support.google.com/chromebook/answer/1331549"; +#endif + +const char kResetProfileSettingsLearnMoreURL[] = + "https://support.google.com/chrome/?p=ui_reset_settings"; + +const char kAutomaticSettingsResetLearnMoreURL[] = + "https://support.google.com/chrome/?p=ui_automatic_settings_reset"; + +const char kLegacySupervisedUserManagementURL[] = + "https://www.chrome.com/manage"; +const char kLegacySupervisedUserManagementDisplayURL[] = + "www.chrome.com/manage"; + +const char kSettingsSearchHelpURL[] = +#if defined(OS_CHROMEOS) + "https://support.google.com/chromebook/?p=settings_search_help"; +#else + "https://support.google.com/chrome/?p=settings_search_help"; +#endif + +const char kOmniboxLearnMoreURL[] = +#if defined(OS_CHROMEOS) + "https://support.google.com/chromebook/?p=settings_omnibox"; +#else + "https://support.google.com/chrome/?p=settings_omnibox"; +#endif + +const char kPageInfoHelpCenterURL[] = +#if defined(OS_CHROMEOS) + "https://support.google.com/chromebook/?p=ui_security_indicator"; +#else + "https://support.google.com/chrome/?p=ui_security_indicator"; +#endif + +const char kCrashReasonURL[] = +#if defined(OS_CHROMEOS) + "https://support.google.com/chromebook/?p=e_awsnap"; +#else + "https://support.google.com/chrome/?p=e_awsnap"; +#endif + +const char kCrashReasonFeedbackDisplayedURL[] = +#if defined(OS_CHROMEOS) + "https://support.google.com/chromebook/?p=e_awsnap_rl"; +#else + "https://support.google.com/chrome/?p=e_awsnap_rl"; +#endif + +const char kPrivacyLearnMoreURL[] = +#if defined(OS_CHROMEOS) + "https://support.google.com/chromebook/?p=settings_privacy"; +#else + "https://support.google.com/chrome/?p=settings_privacy"; +#endif + +const char kDoNotTrackLearnMoreURL[] = +#if defined(OS_CHROMEOS) + "https://support.google.com/chromebook/?p=settings_do_not_track"; +#else + "https://support.google.com/chrome/?p=settings_do_not_track"; +#endif + +#if defined(OS_CHROMEOS) +const char kAttestationForContentProtectionLearnMoreURL[] = + "https://support.google.com/chromebook/?p=verified_access"; +#endif + +#if defined(OS_CHROMEOS) || defined(OS_ANDROID) +const char kEnhancedPlaybackNotificationLearnMoreURL[] = +#endif +#if defined(OS_CHROMEOS) + "https://support.google.com/chromebook/?p=enhanced_playback"; +#elif defined(OS_ANDROID) +// Keep in sync with chrome/android/java/strings/android_chrome_strings.grd + "https://support.google.com/chrome/?p=mobile_protected_content"; +#endif + +const char kChromiumProjectURL[] = "https://www.chromium.org/"; + +const char kLearnMoreReportingURL[] = + "https://support.google.com/chrome/?p=ui_usagestat"; + +#if defined(ENABLE_PLUGIN_INSTALLATION) +const char kOutdatedPluginLearnMoreURL[] = + "https://support.google.com/chrome/?p=ib_outdated_plugin"; +#endif + +const char kBlockedPluginLearnMoreURL[] = + "https://support.google.com/chrome/?p=ib_blocked_plugin"; + +const char kHotwordLearnMoreURL[] = + "https://support.google.com/chrome/?p=ui_hotword_search"; + +const char kManageAudioHistoryURL[] = + "https://history.google.com/history/audio"; + +const char kLearnMoreRegisterProtocolHandlerURL[] = + "https://support.google.com/chrome/?p=ib_protocol_handler"; + +const char kSyncLearnMoreURL[] = + "https://support.google.com/chrome/?p=settings_sign_in"; + +const char kDownloadScanningLearnMoreURL[] = + "https://support.google.com/chrome/?p=ib_download_blocked"; + +const char kDownloadInterruptedLearnMoreURL[] = + "https://support.google.com/chrome/?p=ui_download_errors"; + +const char kSyncEverythingLearnMoreURL[] = + "https://support.google.com/chrome/?p=settings_sync_all"; + +const char kCloudPrintLearnMoreURL[] = +#if defined(OS_CHROMEOS) + "https://support.google.com/chromebook/?p=settings_cloud_print"; +#else + "https://support.google.com/chrome/?p=settings_cloud_print"; +#endif + +const char kCloudPrintNoDestinationsLearnMoreURL[] = + "https://www.google.com/cloudprint/learn/"; + +const char kAppLauncherHelpURL[] = + "https://support.google.com/chrome_webstore/?p=cws_app_launcher"; + +const char kSyncEncryptionHelpURL[] = +#if defined(OS_CHROMEOS) + "https://support.google.com/chromebook/?p=settings_encryption"; +#else + "https://support.google.com/chrome/?p=settings_encryption"; +#endif + +const char kSyncErrorsHelpURL[] = + "https://support.google.com/chrome/?p=settings_sync_error"; + +#if defined(OS_CHROMEOS) +const char kNaturalScrollHelpURL[] = + "https://support.google.com/chromebook/?p=simple_scrolling"; +#endif + +#if defined(OS_CHROMEOS) +const char kLearnMoreEnterpriseURL[] = + "https://support.google.com/chromebook/answer/2535613"; +#endif + +const char kRemoveNonCWSExtensionURL[] = + "https://support.google.com/chrome/?p=ui_remove_non_cws_extensions"; + +#if defined(OS_WIN) +const char kNotificationsHelpURL[] = + "https://support.google.com/chrome/?p=ui_notifications"; +#endif + +const char kNotificationWelcomeLearnMoreURL[] = + "https://support.google.com/chrome/?p=ib_google_now_welcome"; + +// Add hosts here to be included in chrome://chrome-urls (about:about). +// These hosts will also be suggested by BuiltinProvider. +const char* const kChromeHostURLs[] = { + kChromeUICacheHost, + kChromeUIChromeURLsHost, + kChromeUIComponentsHost, + kChromeUICrashesHost, + kChromeUICreditsHost, + kChromeUIDeviceLogHost, + kChromeUIDNSHost, + kChromeUIFlagsHost, + kChromeUIGCMInternalsHost, + kChromeUIHistoryHost, + kChromeUIInvalidationsHost, + kChromeUILocalStateHost, + kChromeUINetInternalsHost, + kChromeUINewTabHost, + kChromeUIOmniboxHost, + kChromeUIPasswordManagerInternalsHost, + kChromeUIPolicyHost, + kChromeUIPredictorsHost, + kChromeUIProfilerHost, + kChromeUISignInInternalsHost, + kChromeUISuggestionsHost, + kChromeUISupervisedUserInternalsHost, + kChromeUISyncInternalsHost, + kChromeUITermsHost, + kChromeUIThumbnailListHost, + kChromeUITranslateInternalsHost, + kChromeUIUserActionsHost, + kChromeUIVersionHost, + content::kChromeUIAccessibilityHost, + content::kChromeUIAppCacheInternalsHost, + content::kChromeUIBlobInternalsHost, + content::kChromeUIGpuHost, + content::kChromeUIHistogramHost, + content::kChromeUIIndexedDBInternalsHost, + content::kChromeUIMediaInternalsHost, + content::kChromeUINetworkErrorHost, + content::kChromeUINetworkErrorsListingHost, + content::kChromeUINetworkViewCacheHost, + content::kChromeUIServiceWorkerInternalsHost, + content::kChromeUITracingHost, + content::kChromeUIWebRTCInternalsHost, +#if !defined(OS_ANDROID) +#if !defined(OS_CHROMEOS) + kChromeUIAppLauncherPageHost, +#endif + kChromeUIBookmarksHost, + kChromeUIDownloadsHost, + kChromeUIFlashHost, + kChromeUIHelpHost, + kChromeUIInspectHost, + kChromeUIPluginsHost, + kChromeUIQuotaInternalsHost, + kChromeUISettingsHost, + kChromeUISystemInfoHost, + kChromeUIUberHost, +#endif +#if defined(OS_ANDROID) + kChromeUINetExportHost, + kChromeUIOfflineInternalsHost, + kChromeUIPopularSitesInternalsHost, + kChromeUISnippetsInternalsHost, +#else // non-mobile + kChromeUICopresenceHost, +#endif +#if defined(OS_CHROMEOS) + kChromeUICertificateManagerHost, + kChromeUIChooseMobileNetworkHost, + kChromeUICryptohomeHost, + kChromeUIDriveInternalsHost, + kChromeUIFirstRunHost, + kChromeUIKeyboardOverlayHost, + kChromeUILoginHost, + kChromeUINetworkHost, + kChromeUIOobeHost, + kChromeUIOSCreditsHost, + kChromeUIPowerHost, + kChromeUIProxySettingsHost, + kChromeUIVoiceSearchHost, +#endif +#if defined(OS_WIN) || defined(OS_CHROMEOS) + kChromeUIDiscardsHost, +#endif +#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) + kChromeUILinuxProxyConfigHost, + kChromeUISandboxHost, +#endif +#if defined(OS_WIN) + kChromeUIConflictsHost, +#endif +#if !defined(DISABLE_NACL) + kChromeUINaClHost, +#endif +#if defined(ENABLE_EXTENSIONS) + kChromeUIExtensionsHost, +#endif +#if defined(ENABLE_PRINT_PREVIEW) + kChromeUIPrintHost, +#endif +#if defined(ENABLE_SERVICE_DISCOVERY) + kChromeUIDevicesHost, +#endif +#if defined(ENABLE_WEBRTC) + kChromeUIWebRtcLogsHost, +#endif +}; +const size_t kNumberOfChromeHostURLs = arraysize(kChromeHostURLs); + +const char* const kChromeDebugURLs[] = { + content::kChromeUIBadCastCrashURL, + content::kChromeUICrashURL, + content::kChromeUIDumpURL, + content::kChromeUIKillURL, + content::kChromeUIHangURL, + content::kChromeUIShorthangURL, + content::kChromeUIGpuCleanURL, + content::kChromeUIGpuCrashURL, + content::kChromeUIGpuHangURL, + content::kChromeUIPpapiFlashCrashURL, + content::kChromeUIPpapiFlashHangURL, + chrome::kChromeUIQuitURL, + chrome::kChromeUIRestartURL +}; +const int kNumberOfChromeDebugURLs = + static_cast<int>(arraysize(kChromeDebugURLs)); + +const char kChromeNativeScheme[] = "chrome-native"; + +const char kChromeSearchScheme[] = "chrome-search"; +const char kChromeSearchLocalNtpHost[] = "local-ntp"; +const char kChromeSearchLocalNtpUrl[] = + "chrome-search://local-ntp/local-ntp.html"; +const char kChromeSearchRemoteNtpHost[] = "remote-ntp"; + +const char kChromeSearchMostVisitedHost[] = "most-visited"; +const char kChromeSearchMostVisitedUrl[] = "chrome-search://most-visited/"; + +const char kEasyUnlockLearnMoreUrl[] = + "https://support.google.com/chromebook/?p=smart_lock"; + +// Google SafeSearch query parameters. +const char kSafeSearchSafeParameter[] = "safe=active"; +const char kSafeSearchSsuiParameter[] = "ssui=on"; + +const char kMediaAccessLearnMoreUrl[] = + "https://support.google.com/chrome/?p=ib_access_cam_mic"; + +const char kLanguageSettingsLearnMoreUrl[] = +#if defined(OS_CHROMEOS) + "https://support.google.com/chromebook/answer/1059490"; +#else + "https://support.google.com/chrome/topic/1678461"; +#endif + +#if defined(GOOGLE_CHROME_BUILD) && defined(OS_LINUX) && !defined(OS_CHROMEOS) +const char kLinuxWheezyPreciseDeprecationURL[] = + "https://support.google.com/chrome/answer/95346"; +#endif + +#if defined(OS_MACOSX) +// TODO(mark): Change to a Help Center URL when one is available. +// https://crbug.com/555044 +const char kMac10_678_DeprecationURL[] = + "https://chrome.blogspot.com/2015/11/updates-to-chrome-platform-support.html"; +#endif + +#if defined(OS_WIN) +const char kWindowsXPVistaDeprecationURL[] = + "https://chrome.blogspot.com/2015/11/updates-to-chrome-platform-support.html"; +#endif + +const char kChooserBluetoothOverviewURL[] = + "https://support.google.com/chrome?p=bluetooth"; + +const char kChooserUsbOverviewURL[] = + "https://support.google.com/chrome?p=webusb"; + +#if defined(OS_CHROMEOS) +const char kEolNotificationURL[] = "https://www.google.com/chromebook/older/"; +#endif + +} // namespace chrome diff --git a/chromium/chrome/common/url_constants.h b/chromium/chrome/common/url_constants.h new file mode 100644 index 00000000000..86a58d162f8 --- /dev/null +++ b/chromium/chrome/common/url_constants.h @@ -0,0 +1,602 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Contains constants for known URLs and portions thereof. + +#ifndef CHROME_COMMON_URL_CONSTANTS_H_ +#define CHROME_COMMON_URL_CONSTANTS_H_ + +#include <stddef.h> + +#include <string> +#include <vector> + +#include "build/build_config.h" +#include "chrome/common/features.h" +#include "content/public/common/url_constants.h" + +namespace chrome { + +// chrome: URLs (including schemes). Should be kept in sync with the +// components below. +extern const char kChromeUIAboutURL[]; +extern const char kChromeUIAppsURL[]; +extern const char kChromeUIAppListStartPageURL[]; +extern const char kChromeUIBookmarksURL[]; +extern const char kChromeUICertificateViewerURL[]; +extern const char kChromeUICertificateViewerDialogURL[]; +extern const char kChromeUIChromeSigninURL[]; +extern const char kChromeUIChromeURLsURL[]; +extern const char kChromeUIComponentsURL[]; +extern const char kChromeUIConflictsURL[]; +extern const char kChromeUIConstrainedHTMLTestURL[]; +extern const char kChromeUICrashesURL[]; +extern const char kChromeUICreditsURL[]; +extern const char kChromeUIDevicesURL[]; +extern const char kChromeUIDevToolsURL[]; +extern const char kChromeUIDomainReliabilityInternalsURL[]; +extern const char kChromeUIDownloadsURL[]; +extern const char kChromeUIExtensionIconURL[]; +extern const char kChromeUIExtensionsFrameURL[]; +extern const char kChromeUIExtensionsURL[]; +extern const char kChromeUIFallbackIconURL[]; +extern const char kChromeUIFaviconURL[]; +extern const char kChromeUIFeedbackURL[]; +extern const char kChromeUIFlagsURL[]; +extern const char kChromeUIFlashURL[]; +extern const char kChromeUIGCMInternalsURL[]; +extern const char kChromeUIHelpFrameURL[]; +extern const char kChromeUIHelpURL[]; +extern const char kChromeUIHistoryURL[]; +extern const char kChromeUIHistoryFrameURL[]; +extern const char kChromeUIIdentityInternalsURL[]; +extern const char kChromeUIInspectURL[]; +extern const char kChromeUIInstantURL[]; +extern const char kChromeUIInterstitialURL[]; +extern const char kChromeUIInvalidationsURL[]; +extern const char kChromeUILargeIconURL[]; +extern const char kChromeUIMdPolicyURL[]; +extern const char kChromeUINaClURL[]; +extern const char kChromeUINetInternalsURL[]; +extern const char kChromeUINewProfileURL[]; +extern const char kChromeUINewTabURL[]; +extern const char kChromeUIOmniboxURL[]; +extern const char kChromeUIPasswordManagerInternalsHost[]; +extern const char kChromeUIPluginsURL[]; +extern const char kChromeUIPolicyURL[]; +extern const char kChromeUIProfileSigninConfirmationURL[]; +extern const char kChromeUIMdUserManagerUrl[]; +extern const char kChromeUIPrintURL[]; +extern const char kChromeUIQuitURL[]; +extern const char kChromeUIRestartURL[]; +extern const char kChromeUIMdSettingsURL[]; +extern const char kChromeUISettingsURL[]; +extern const char kChromeUIContentSettingsURL[]; +extern const char kChromeUISettingsFrameURL[]; +extern const char kChromeUISiteEngagementHost[]; +extern const char kChromeUISuggestionsURL[]; +extern const char kChromeUISupervisedUserPassphrasePageURL[]; +extern const char kChromeUISyncConfirmationURL[]; +extern const char kChromeUITermsURL[]; +extern const char kChromeUIThemeURL[]; +extern const char kChromeUIThumbnailURL[]; +extern const char kChromeUIThumbnailListURL[]; +extern const char kChromeUIUberFrameURL[]; +extern const char kChromeUIUserActionsURL[]; +extern const char kChromeUIUserManagerURL[]; +extern const char kChromeUIVersionURL[]; + +#if BUILDFLAG(ANDROID_JAVA_UI) +extern const char kChromeUIContextualSearchPromoURL[]; +extern const char kChromeUINativeScheme[]; +extern const char kChromeUINativeNewTabURL[]; +extern const char kChromeUINativeBookmarksURL[]; +extern const char kChromeUINativePhysicalWebURL[]; +extern const char kChromeUINativeRecentTabsURL[]; +#endif + +#if defined(OS_CHROMEOS) +extern const char kChromeUIBluetoothPairingURL[]; +extern const char kChromeUICertificateManagerDialogURL[]; +extern const char kChromeUIChooseMobileNetworkURL[]; +extern const char kChromeUIDeviceEmulatorURL[]; +extern const char kChromeUIFirstRunURL[]; +extern const char kChromeUIKeyboardOverlayURL[]; +extern const char kChromeUIMobileSetupURL[]; +extern const char kChromeUINfcDebugURL[]; +extern const char kChromeUIOobeURL[]; +extern const char kChromeUIOSCreditsURL[]; +extern const char kChromeUIProxySettingsURL[]; +extern const char kChromeUIScreenlockIconURL[]; +extern const char kChromeUISetTimeURL[]; +extern const char kChromeUISimUnlockURL[]; +extern const char kChromeUISlowURL[]; +extern const char kChromeUISystemInfoURL[]; +extern const char kChromeUITermsOemURL[]; +extern const char kChromeUIUserImageURL[]; +#endif // defined(OS_CHROMEOS) + +#if defined(OS_WIN) +extern const char kChromeUIMetroFlowURL[]; +#endif + +#if (defined(OS_LINUX) && defined(TOOLKIT_VIEWS)) || defined(USE_AURA) +extern const char kChromeUITabModalConfirmDialogURL[]; +#endif + +#if !defined(OS_ANDROID) +extern const char kChromeUICopresenceURL[]; +extern const char kChromeUICopresenceHost[]; +#endif + +#if defined(ENABLE_WEBRTC) +extern const char kChromeUIWebRtcLogsURL[]; +#endif + +#if defined(ENABLE_MEDIA_ROUTER) +extern const char kChromeUIMediaRouterURL[]; +#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) +extern const char kChromeUICastURL[]; +#endif +#endif + +#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) +extern const char kChromeUIDiscardsHost[]; +extern const char kChromeUIDiscardsURL[]; +#endif + +// chrome components of URLs. Should be kept in sync with the full URLs above. +extern const char kChromeUIAboutHost[]; +extern const char kChromeUIAboutPageFrameHost[]; +extern const char kChromeUIBlankHost[]; +extern const char kChromeUIAppLauncherPageHost[]; +extern const char kChromeUIAppListStartPageHost[]; +extern const char kChromeUIBookmarksHost[]; +extern const char kChromeUICacheHost[]; +extern const char kChromeUICertificateViewerHost[]; +extern const char kChromeUICertificateViewerDialogHost[]; +extern const char kChromeUIChromeSigninHost[]; +extern const char kChromeUIChromeURLsHost[]; +extern const char kChromeUIConflictsHost[]; +extern const char kChromeUIConstrainedHTMLTestHost[]; +extern const char kChromeUICrashesHost[]; +extern const char kChromeUICrashHost[]; +extern const char kChromeUICreditsHost[]; +extern const char kChromeUIDefaultHost[]; +extern const char kChromeUIDelayedHangUIHost[]; +extern const char kChromeUIDeviceLogHost[]; +extern const char kChromeUIDevicesHost[]; +extern const char kChromeUIDevToolsHost[]; +extern const char kChromeUIDevToolsBundledPath[]; +extern const char kChromeUIDevToolsRemotePath[]; +extern const char kChromeUIDNSHost[]; +extern const char kChromeUIDomainReliabilityInternalsHost[]; +extern const char kChromeUIDownloadsHost[]; +extern const char kChromeUIDriveInternalsHost[]; +extern const char kChromeUIExtensionIconHost[]; +extern const char kChromeUIExtensionsFrameHost[]; +extern const char kChromeUIExtensionsHost[]; +extern const char kChromeUIFallbackIconHost[]; +extern const char kChromeUIFaviconHost[]; +extern const char kChromeUIFeedbackHost[]; +extern const char kChromeUIFlagsHost[]; +extern const char kChromeUIFlashHost[]; +extern const char kChromeUIGCMInternalsHost[]; +extern const char kChromeUIHelpFrameHost[]; +extern const char kChromeUIHelpHost[]; +extern const char kChromeUIHangHost[]; +extern const char kChromeUIHangUIHost[]; +extern const char kChromeUIHistoryHost[]; +extern const char kChromeUIHistoryFrameHost[]; +extern const char kChromeUIIdentityInternalsHost[]; +extern const char kChromeUIInspectHost[]; +extern const char kChromeUIInstantHost[]; +extern const char kChromeUIInterstitialHost[]; +extern const char kChromeUIInvalidationsHost[]; +extern const char kChromeUIKillHost[]; +extern const char kChromeUILargeIconHost[]; +extern const char kChromeUILocalStateHost[]; +extern const char kChromeUIMdPolicyHost[]; +extern const char kChromeUIMdSettingsHost[]; +extern const char kChromeUINaClHost[]; +extern const char kChromeUINetExportHost[]; +extern const char kChromeUINetInternalsHost[]; +extern const char kChromeUINewTabHost[]; +extern const char kChromeUIOfflineInternalsHost[]; +extern const char kChromeUIOmniboxHost[]; +extern const char kChromeUIPluginsHost[]; +extern const char kChromeUIComponentsHost[]; +extern const char kChromeUIPolicyHost[]; +extern const char kChromeUIProfileSigninConfirmationHost[]; +extern const char kChromeUIUserManagerHost[]; +extern const char kChromeUIMdUserManagerHost[]; +extern const char kChromeUIPredictorsHost[]; +extern const char kChromeUIProfilerHost[]; +extern const char kChromeUIQuotaInternalsHost[]; +extern const char kChromeUIQuitHost[]; +extern const char kChromeUIRestartHost[]; +extern const char kChromeUISettingsHost[]; +extern const char kChromeUISettingsFrameHost[]; +extern const char kChromeUIShorthangHost[]; +extern const char kChromeUISignInInternalsHost[]; +extern const char kChromeUISuggestionsHost[]; +extern const char kChromeUISupervisedUserInternalsHost[]; +extern const char kChromeUISupervisedUserPassphrasePageHost[]; +extern const char kChromeUISyncConfirmationHost[]; +extern const char kChromeUISyncHost[]; +extern const char kChromeUISyncFileSystemInternalsHost[]; +extern const char kChromeUISyncInternalsHost[]; +extern const char kChromeUISyncResourcesHost[]; +extern const char kChromeUISystemInfoHost[]; +extern const char kChromeUITermsHost[]; +extern const char kChromeUIThemeHost[]; +extern const char kChromeUIThumbnailHost[]; +extern const char kChromeUIThumbnailHost2[]; +extern const char kChromeUIThumbnailListHost[]; +extern const char kChromeUITouchIconHost[]; +extern const char kChromeUITranslateInternalsHost[]; +extern const char kChromeUIUberFrameHost[]; +extern const char kChromeUIUberHost[]; +extern const char kChromeUIUserActionsHost[]; +extern const char kChromeUIVersionHost[]; +extern const char kChromeUIWorkersHost[]; + +extern const char kChromeUIThemePath[]; + +#if defined(ENABLE_PRINT_PREVIEW) +extern const char kChromeUIPrintHost[]; +#endif // ENABLE_PRINT_PREVIEW + +#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) +extern const char kChromeUILinuxProxyConfigHost[]; +extern const char kChromeUISandboxHost[]; +#endif + +#if defined(OS_ANDROID) +extern const char kChromeUIContextualSearchPromoHost[]; +extern const char kChromeUIOfflineInternalsURL[]; +extern const char kChromeUIPhysicalWebHost[]; +extern const char kChromeUIPopularSitesInternalsHost[]; +extern const char kChromeUISnippetsInternalsHost[]; +#endif + +#if defined(OS_CHROMEOS) +extern const char kChromeUIActivationMessageHost[]; +extern const char kChromeUIAppLaunchHost[]; +extern const char kChromeUIBluetoothPairingHost[]; +extern const char kChromeUICertificateManagerHost[]; +extern const char kChromeUIChooseMobileNetworkHost[]; +extern const char kChromeUICryptohomeHost[]; +extern const char kChromeUIDeviceEmulatorHost[]; +extern const char kChromeUIFirstRunHost[]; +extern const char kChromeUIKeyboardOverlayHost[]; +extern const char kChromeUILoginContainerHost[]; +extern const char kChromeUILoginHost[]; +extern const char kChromeUIMobileSetupHost[]; +extern const char kChromeUINetworkHost[]; +extern const char kChromeUINfcDebugHost[]; +extern const char kChromeUIOobeHost[]; +extern const char kChromeUIOSCreditsHost[]; +extern const char kChromeUIPowerHost[]; +extern const char kChromeUIProxySettingsHost[]; +extern const char kChromeUIRotateHost[]; +extern const char kChromeUIScreenlockIconHost[]; +extern const char kChromeUISetTimeHost[]; +extern const char kChromeUISimUnlockHost[]; +extern const char kChromeUISlowHost[]; +extern const char kChromeUISlowTraceHost[]; +extern const char kChromeUIUserImageHost[]; +extern const char kChromeUIVoiceSearchHost[]; + +extern const char kEULAPathFormat[]; +extern const char kOemEulaURLPath[]; +extern const char kOnlineEulaURLPath[]; + +extern const char kChromeOSCreditsPath[]; + +extern const char kChromeOSAssetHost[]; +extern const char kChromeOSAssetPath[]; +#endif // defined(OS_CHROMEOS) + +#if defined(OS_WIN) +extern const char kChromeUIMetroFlowHost[]; +#endif + +#if (defined(OS_LINUX) && defined(TOOLKIT_VIEWS)) || defined(USE_AURA) +extern const char kChromeUITabModalConfirmDialogHost[]; +#endif + +#if defined(ENABLE_WEBRTC) +extern const char kChromeUIWebRtcLogsHost[]; +#endif + +#if defined(ENABLE_MEDIA_ROUTER) +extern const char kChromeUIMediaRouterHost[]; +#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) +extern const char kChromeUICastHost[]; +#endif +#endif + +// Options sub-pages. +extern const char kAutofillSubPage[]; +extern const char kClearBrowserDataSubPage[]; +extern const char kContentSettingsExceptionsSubPage[]; +extern const char kContentSettingsSubPage[]; +extern const char kCreateProfileSubPage[]; +extern const char kExtensionsSubPage[]; +extern const char kHandlerSettingsSubPage[]; +extern const char kImportDataSubPage[]; +extern const char kLanguageOptionsSubPage[]; +extern const char kManageProfileSubPage[]; +extern const char kPasswordManagerSubPage[]; +extern const char kPowerOptionsSubPage[]; +extern const char kResetProfileSettingsSubPage[]; +extern const char kSearchEnginesSubPage[]; +extern const char kSearchSubPage[]; +extern const char kSearchUsersSubPage[]; +extern const char kSyncSetupSubPage[]; +extern const char kTriggeredResetProfileSettingsSubPage[]; +#if defined(OS_CHROMEOS) +extern const char kInternetOptionsSubPage[]; +extern const char kChangeProfilePictureSubPage[]; +#endif + +// Extensions sub pages. +extern const char kExtensionConfigureCommandsSubPage[]; + +// URLs used to indicate that an extension resource load request +// was invalid. +extern const char kExtensionInvalidRequestURL[]; +extern const char kExtensionResourceInvalidRequestURL[]; + +extern const char kSyncGoogleDashboardURL[]; + +// URL of the 'Activity controls' section of the privacy settings page. +extern const char kGoogleAccountActivityControlsURL[]; + +extern const char kPasswordManagerLearnMoreURL[]; +extern const char kUpgradeHelpCenterBaseURL[]; +extern const char kSmartLockHelpPage[]; + +// "Learn more" URL for the Settings API, NTP bubble and other settings bubbles +// showing which extension is controlling them. +extern const char kExtensionControlledSettingLearnMoreURL[]; + +// General help links for Chrome, opened using various actions. +extern const char kChromeHelpViaKeyboardURL[]; +extern const char kChromeHelpViaMenuURL[]; +extern const char kChromeHelpViaWebUIURL[]; + +#if defined(OS_CHROMEOS) +// Accessibility help link for Chrome. +extern const char kChromeAccessibilityHelpURL[]; +// Accessibility settings link for Chrome. +extern const char kChromeAccessibilitySettingsURL[]; +#endif + +#if BUILDFLAG(ENABLE_ONE_CLICK_SIGNIN) +// "Learn more" URL for the one click signin infobar. +extern const char kChromeSyncLearnMoreURL[]; + +// "Learn more" URL for the "Sign in with a different account" confirmation +// dialog. +extern const char kChromeSyncMergeTroubleshootingURL[]; +#endif + +#if defined(OS_MACOSX) +// "Learn more" URL for the enterprise sign-in confirmation dialog. +extern const char kChromeEnterpriseSignInLearnMoreURL[]; +#endif + +// "Learn more" URL for resetting profile preferences. +extern const char kResetProfileSettingsLearnMoreURL[]; + +// "Learn more" URL for when profile settings are automatically reset. +extern const char kAutomaticSettingsResetLearnMoreURL[]; + +// Management URL for Chrome Supervised Users. +extern const char kLegacySupervisedUserManagementURL[]; + +// Management URL for Chrome Supervised Users - version without scheme, used +// for display. +extern const char kLegacySupervisedUserManagementDisplayURL[]; + +// Help URL for the settings page's search feature. +extern const char kSettingsSearchHelpURL[]; + +// Help URL for the Omnibox setting. +extern const char kOmniboxLearnMoreURL[]; + +// "What do these mean?" URL for the Page Info bubble. +extern const char kPageInfoHelpCenterURL[]; + +// "Learn more" URL for "Aw snap" page when showing "Reload" button. +extern const char kCrashReasonURL[]; + +// "Learn more" URL for "Aw snap" page when showing "Send feedback" button. +extern const char kCrashReasonFeedbackDisplayedURL[]; + +// "Learn more" URL for killed tab page. +extern const char kKillReasonURL[]; + +// "Learn more" URL for the Privacy section under Options. +extern const char kPrivacyLearnMoreURL[]; + +// "Learn more" URL for the "Do not track" setting in the privacy section. +extern const char kDoNotTrackLearnMoreURL[]; + +#if defined(OS_CHROMEOS) +// "Learn more" URL for the attestation of content protection setting. +extern const char kAttestationForContentProtectionLearnMoreURL[]; +#endif + +#if defined(OS_CHROMEOS) || defined(OS_ANDROID) +// "Learn more" URL for the enhanced playback notification dialog. +extern const char kEnhancedPlaybackNotificationLearnMoreURL[]; +#endif + +// The URL for the Chromium project used in the About dialog. +extern const char kChromiumProjectURL[]; + +// The URL for the "Learn more" page for the usage/crash reporting option in the +// first run dialog. +extern const char kLearnMoreReportingURL[]; + +#if defined(ENABLE_PLUGIN_INSTALLATION) +// The URL for the "Learn more" page for the outdated plugin infobar. +extern const char kOutdatedPluginLearnMoreURL[]; +#endif + +// The URL for the "Learn more" page for the blocked plugin infobar. +extern const char kBlockedPluginLearnMoreURL[]; + +// The URL for the "Learn more" page for hotword search voice trigger. +extern const char kHotwordLearnMoreURL[]; + +// The URL for managing a user's audio history. +extern const char kManageAudioHistoryURL[]; + +// The URL for the "Learn more" page for register protocol handler infobars. +extern const char kLearnMoreRegisterProtocolHandlerURL[]; + +// The URL for the "Learn more" page for sync setup on the personal stuff page. +extern const char kSyncLearnMoreURL[]; + +// The URL for the "Learn more" page for download scanning. +extern const char kDownloadScanningLearnMoreURL[]; + +// The URL for the "Learn more" page for interrupted downloads. +extern const char kDownloadInterruptedLearnMoreURL[]; + +// The URL for the "Learn more" page on the sync setup dialog, when syncing +// everything. +extern const char kSyncEverythingLearnMoreURL[]; + +// The URL for information on how to use the app launcher. +extern const char kAppLauncherHelpURL[]; + +// The URL for the "Learn more" page on sync encryption. +extern const char kSyncEncryptionHelpURL[]; + +// The URL for the "Learn more" link when there is a sync error. +extern const char kSyncErrorsHelpURL[]; + +#if defined(OS_CHROMEOS) +// The URL for the "Learn more" link for natural scrolling on ChromeOS. +extern const char kNaturalScrollHelpURL[]; + +// The URL for the Learn More page about enterprise enrolled devices. +extern const char kLearnMoreEnterpriseURL[]; +#endif + +// The URL for the Learn More link of the non-CWS bubble. +extern const char kRemoveNonCWSExtensionURL[]; + +#if defined(OS_WIN) +extern const char kNotificationsHelpURL[]; +#endif + +// The Welcome Notification More Info URL. +extern const char kNotificationWelcomeLearnMoreURL[]; + +// Gets the hosts/domains that are shown in chrome://chrome-urls. +extern const char* const kChromeHostURLs[]; +extern const size_t kNumberOfChromeHostURLs; + +// "Debug" pages which are dangerous and not for general consumption. +extern const char* const kChromeDebugURLs[]; +extern const int kNumberOfChromeDebugURLs; + +// The chrome-native: scheme is used show pages rendered with platform specific +// widgets instead of using HTML. +extern const char kChromeNativeScheme[]; + +// The chrome-search: scheme is served by the same backend as chrome:. However, +// only specific URLDataSources are enabled to serve requests via the +// chrome-search: scheme. See |InstantIOContext::ShouldServiceRequest| and its +// callers for details. Note that WebUIBindings should never be granted to +// chrome-search: pages. chrome-search: pages are displayable but not readable +// by external search providers (that are rendered by Instant renderer +// processes), and neither displayable nor readable by normal (non-Instant) web +// pages. To summarize, a non-Instant process, when trying to access +// 'chrome-search://something', will bump up against the following: +// +// 1. Renderer: The display-isolated check in WebKit will deny the request, +// 2. Browser: Assuming they got by #1, the scheme checks in +// URLDataSource::ShouldServiceRequest will deny the request, +// 3. Browser: for specific sub-classes of URLDataSource, like ThemeSource +// there are additional Instant-PID checks that make sure the request is +// coming from a blessed Instant process, and deny the request. +extern const char kChromeSearchScheme[]; + +// Pages under chrome-search. +extern const char kChromeSearchLocalNtpHost[]; +extern const char kChromeSearchLocalNtpUrl[]; +extern const char kChromeSearchRemoteNtpHost[]; + +// Host and URL for most visited iframes used on the Instant Extended NTP. +extern const char kChromeSearchMostVisitedHost[]; +extern const char kChromeSearchMostVisitedUrl[]; + +#if defined(OS_WIN) || defined(OS_CHROMEOS) +extern const char kChromeUIDiscardsHost[]; +extern const char kChromeUIDiscardsURL[]; +#endif + +#if defined(OS_CHROMEOS) +extern const char kCrosScheme[]; +#endif + +#if defined(OS_ANDROID) +extern const char kAndroidAppScheme[]; +#endif + +// "Learn more" URL for the Cloud Print section under Options. +extern const char kCloudPrintLearnMoreURL[]; + +// "Learn more" URL for the Cloud Print Preview No Destinations Promotion. +extern const char kCloudPrintNoDestinationsLearnMoreURL[]; + +// The URL for the "Learn more" link the the Easy Unlock settings. +extern const char kEasyUnlockLearnMoreUrl[]; + +// Parameters that get appended to force SafeSearch. +extern const char kSafeSearchSafeParameter[]; +extern const char kSafeSearchSsuiParameter[]; + +// The URL for the "Learn more" link in the media access infobar. +extern const char kMediaAccessLearnMoreUrl[]; + +// The URL for the "Learn more" link in the language settings. +extern const char kLanguageSettingsLearnMoreUrl[]; + +#if defined(GOOGLE_CHROME_BUILD) && defined(OS_LINUX) && !defined(OS_CHROMEOS) +extern const char kLinuxWheezyPreciseDeprecationURL[]; +#endif + +#if defined(OS_MACOSX) +// The URL for the Mac OS X 10.6/10.7/10.8 deprecation help center article. +extern const char kMac10_678_DeprecationURL[]; +#endif + +#if defined(OS_WIN) +// The URL for the Windows XP/Vista deprecation help center article. +extern const char kWindowsXPVistaDeprecationURL[]; +#endif + +// The URL for the Bluetooth Overview help center article in the Web Bluetooth +// Chooser. +extern const char kChooserBluetoothOverviewURL[]; + +// The URL for the WebUsb help center article. +extern const char kChooserUsbOverviewURL[]; + +#if defined(OS_CHROMEOS) +// The URL for EOL notification +extern const char kEolNotificationURL[]; +#endif + +} // namespace chrome + +#endif // CHROME_COMMON_URL_CONSTANTS_H_ diff --git a/chromium/components/arc.gypi b/chromium/components/arc.gypi index 16a54e0d27d..bb3ab9e65d4 100644 --- a/chromium/components/arc.gypi +++ b/chromium/components/arc.gypi @@ -113,6 +113,7 @@ '..', ], 'dependencies': [ + 'arc_mojo_bindings', '../skia/skia.gyp:skia', ], 'sources': [ @@ -155,6 +156,7 @@ 'mojom_typemaps': [ 'arc/common/app.typemap', 'arc/common/bluetooth.typemap', + '../mojo/common/common_custom_types.typemap', ], }, 'sources': [ @@ -186,7 +188,10 @@ 'arc/common/app_struct_traits.cc', ], 'includes': [ '../mojo/mojom_bindings_generator.gypi' ], - 'dependencies': [ '../ui/gfx/gfx.gyp:gfx_geometry' ], + 'dependencies': [ + '../ui/gfx/gfx.gyp:gfx_geometry', + '../mojo/mojo_base.gyp:mojo_common_custom_types_mojom', + ], }, { # GN version: //components/arc:arc_standalone_service diff --git a/chromium/components/arc/BUILD.gn b/chromium/components/arc/BUILD.gn index aabcfc1c880..8b190f8a69f 100644 --- a/chromium/components/arc/BUILD.gn +++ b/chromium/components/arc/BUILD.gn @@ -17,6 +17,7 @@ static_library("arc") { "audio/arc_audio_bridge.h", "bluetooth/arc_bluetooth_bridge.cc", "bluetooth/arc_bluetooth_bridge.h", + "bluetooth/bluetooth_struct_traits.h", "bluetooth/bluetooth_type_converters.cc", "bluetooth/bluetooth_type_converters.h", "clipboard/arc_clipboard_bridge.cc", @@ -157,7 +158,7 @@ mojom("arc_bindings") { "common/window_manager.mojom", ] - deps = [ + public_deps = [ "//mojo/common:common_custom_types", "//ui/gfx/geometry/mojo", ] diff --git a/chromium/content/renderer/media/webmediaplayer_ms.cc b/chromium/content/renderer/media/webmediaplayer_ms.cc index c0e023b3058..044ab6e8c0a 100644 --- a/chromium/content/renderer/media/webmediaplayer_ms.cc +++ b/chromium/content/renderer/media/webmediaplayer_ms.cc @@ -25,6 +25,7 @@ #include "content/renderer/render_thread_impl.h" #include "media/base/media_log.h" #include "media/base/video_frame.h" +#include "media/base/video_types.h" #include "media/blink/webmediaplayer_util.h" #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" @@ -52,6 +53,7 @@ WebMediaPlayerMS::WebMediaPlayerMS( client_(client), delegate_(delegate), delegate_id_(0), + last_frame_opaque_(true), paused_(true), render_frame_suspended_(false), received_first_frame_(false), @@ -490,21 +492,30 @@ void WebMediaPlayerMS::OnFrameAvailable( } else { TRACE_EVENT0("webrtc", "WebMediaPlayerMS::OnFrameAvailable"); } + const bool is_opaque = media::IsOpaque(frame->format()); if (!received_first_frame_) { received_first_frame_ = true; + last_frame_opaque_ = is_opaque; SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); if (video_frame_provider_.get()) { video_weblayer_.reset(new cc_blink::WebLayerImpl( cc::VideoLayer::Create(compositor_.get(), media::VIDEO_ROTATION_0))); - video_weblayer_->layer()->SetContentsOpaque(false); + video_weblayer_->layer()->SetContentsOpaque(is_opaque); video_weblayer_->SetContentsOpaqueIsFixed(true); get_client()->setWebLayer(video_weblayer_.get()); } } + // Only configure opacity on changes, since marking it as transparent is + // expensive, see https://crbug.com/647886. + if (video_weblayer_ && last_frame_opaque_ != is_opaque) { + last_frame_opaque_ = is_opaque; + video_weblayer_->layer()->SetContentsOpaque(is_opaque); + } + compositor_->EnqueueFrame(frame); } diff --git a/chromium/content/renderer/media/webmediaplayer_ms.h b/chromium/content/renderer/media/webmediaplayer_ms.h index 51d116099d7..3ade16a0e67 100644 --- a/chromium/content/renderer/media/webmediaplayer_ms.h +++ b/chromium/content/renderer/media/webmediaplayer_ms.h @@ -201,6 +201,7 @@ class CONTENT_EXPORT WebMediaPlayerMS scoped_refptr<MediaStreamAudioRenderer> audio_renderer_; // Weak media::SkCanvasVideoRenderer video_renderer_; + bool last_frame_opaque_; bool paused_; bool render_frame_suspended_; bool received_first_frame_; diff --git a/chromium/content/renderer/pepper/pepper_plugin_instance_impl.cc b/chromium/content/renderer/pepper/pepper_plugin_instance_impl.cc index 0baa32e1b27..ce91ee3a1b2 100644 --- a/chromium/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/chromium/content/renderer/pepper/pepper_plugin_instance_impl.cc @@ -538,8 +538,8 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl( memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); module_->InstanceCreated(this); - if (render_frame) { // NULL in tests - render_frame->PepperInstanceCreated(this); + if (render_frame_) { // NULL in tests or if the frame has been destroyed. + render_frame_->PepperInstanceCreated(this); view_data_.is_page_visible = !render_frame_->GetRenderWidget()->is_hidden(); // Set the initial focus. diff --git a/chromium/third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp b/chromium/third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp index 7781999bbd9..2b24aad6582 100644 --- a/chromium/third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp +++ b/chromium/third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp @@ -106,8 +106,10 @@ void CSSStyleSheetResource::checkNotify() m_decodedSheetText = decodedText(); ResourceClientWalker<StyleSheetResourceClient> w(m_clients); - while (StyleSheetResourceClient* c = w.next()) - c->setCSSStyleSheet(m_resourceRequest.url(), m_response.url(), encoding(), this); + while (StyleSheetResourceClient* c = w.next()) { + markClientFinished(c); + c->setCSSStyleSheet(resourceRequest().url(), response().url(), encoding(), this); + } // Clear the decoded text as it is unlikely to be needed immediately again and is cheap to regenerate. m_decodedSheetText = String(); } diff --git a/chromium/third_party/WebKit/Source/core/fetch/XSLStyleSheetResource.cpp b/chromium/third_party/WebKit/Source/core/fetch/XSLStyleSheetResource.cpp index 4f352d88864..e68cd46a453 100644 --- a/chromium/third_party/WebKit/Source/core/fetch/XSLStyleSheetResource.cpp +++ b/chromium/third_party/WebKit/Source/core/fetch/XSLStyleSheetResource.cpp @@ -86,8 +86,10 @@ void XSLStyleSheetResource::checkNotify() m_sheet = decodedText(); ResourceClientWalker<StyleSheetResourceClient> w(m_clients); - while (StyleSheetResourceClient* c = w.next()) - c->setXSLStyleSheet(m_resourceRequest.url(), m_response.url(), m_sheet); + while (StyleSheetResourceClient* c = w.next()) { + markClientFinished(c); + c->setXSLStyleSheet(resourceRequest().url(), response().url(), m_sheet); + } } } // namespace blink diff --git a/chromium/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp b/chromium/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp index 8872d9016e7..aba541d0d22 100644 --- a/chromium/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp +++ b/chromium/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp @@ -471,8 +471,13 @@ inline bool LayoutBlockFlow::layoutBlockFlow(bool relayoutChildren, LayoutUnit & layoutBlockChildren(relayoutChildren, layoutScope, beforeEdge, afterEdge); bool preferredLogicalWidthsBecameDirty = !preferredLogicalWidthsWereDirty && preferredLogicalWidthsDirty(); - if (preferredLogicalWidthsBecameDirty) - return false; + if (preferredLogicalWidthsBecameDirty) { + // The only thing that should dirty preferred widths at this point is the addition of + // overflow:auto scrollbars in a descendant. To avoid a potential infinite loop, + // run layout again with auto scrollbars frozen in their current state. + PaintLayerScrollableArea::FreezeScrollbarsScope freezeScrollbars; + return layoutBlockFlow(relayoutChildren, pageLogicalHeight, layoutScope); + } // Expand our intrinsic height to encompass floats. if (lowestFloatLogicalBottom() > (logicalHeight() - afterEdge) && createsNewFormattingContext()) diff --git a/chromium/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/chromium/third_party/WebKit/Source/core/layout/LayoutBox.cpp index eac327c5497..d6ac5c7a279 100644 --- a/chromium/third_party/WebKit/Source/core/layout/LayoutBox.cpp +++ b/chromium/third_party/WebKit/Source/core/layout/LayoutBox.cpp @@ -4859,7 +4859,7 @@ LayoutUnit LayoutBox::pageRemainingLogicalHeightForOffset(LayoutUnit offset, Pag LayoutFlowThread* flowThread = flowThreadContainingBlock(); if (!flowThread) { - LayoutUnit pageLogicalHeight = layoutView->layoutState()->pageLogicalHeight(); + LayoutUnit pageLogicalHeight = layoutView->pageLogicalHeight(); LayoutUnit remainingHeight = pageLogicalHeight - intMod(offset, pageLogicalHeight); if (pageBoundaryRule == AssociateWithFormerPage) { // An offset exactly at a page boundary will act as being part of the former page in diff --git a/chromium/third_party/WebKit/Source/core/layout/LayoutTable.cpp b/chromium/third_party/WebKit/Source/core/layout/LayoutTable.cpp index ffaac3ba830..d078fac195f 100644 --- a/chromium/third_party/WebKit/Source/core/layout/LayoutTable.cpp +++ b/chromium/third_party/WebKit/Source/core/layout/LayoutTable.cpp @@ -543,9 +543,15 @@ void LayoutTable::layout() section->setLogicalTop(logicalOffset); section->layoutRows(); logicalOffset += section->logicalHeight(); - if (isPaginated && m_head && m_head == section) { + // If the section is a repeating header group that allows at least one row of content then store the + // offset for other sections to offset their rows against. + if (isPaginated && m_head && m_head == section && section->logicalHeight() < section->pageLogicalHeightForOffset(logicalOffset) + && section->getPaginationBreakability() != LayoutBox::AllowAnyBreaks) { LayoutUnit offsetForTableHeaders = state.heightOffsetForTableHeaders(); + // Don't include any strut in the header group - we only want the height from its content. offsetForTableHeaders += section->logicalHeight(); + if (LayoutTableRow* row = section->firstRow()) + offsetForTableHeaders -= section->paginationStrutForRow(row, section->logicalTop()); state.setHeightOffsetForTableHeaders(offsetForTableHeaders); } } diff --git a/chromium/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp b/chromium/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp index 407c56fca2d..8d978bbb47e 100644 --- a/chromium/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp +++ b/chromium/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp @@ -991,6 +991,10 @@ void LayoutTableSection::layoutRows() if (isPaginated) { paginationStrutOnRow = paginationStrutForRow(rowLayoutObject, LayoutUnit(m_rowPos[r])); if (paginationStrutOnRow) { + // If there isn't room for at least one content row on a page with a header group, then + // we won't repeat the header on each page. + if (!r && table()->header() && table()->sectionAbove(this) == table()->header()) + state.setHeightOffsetForTableHeaders(state.heightOffsetForTableHeaders() - table()->header()->logicalHeight()); // If we have a header group we will paint it at the top of each page, move the rows // down to accomodate it. paginationStrutOnRow += state.heightOffsetForTableHeaders().toInt(); @@ -1121,6 +1125,7 @@ void LayoutTableSection::layoutRows() int LayoutTableSection::paginationStrutForRow(LayoutTableRow* row, LayoutUnit logicalOffset) const { + DCHECK(row); // Even if the row allows us to break-inside, we will want to put a strut on the row if we have a header // group that wants to appear at the top of each page. bool tableHeaderForcesStrut = table()->header() ? table()->header()->getPaginationBreakability() != AllowAnyBreaks : false; @@ -1690,4 +1695,40 @@ void LayoutTableSection::setLogicalPositionForCell(LayoutTableCell* cell, unsign cell->setLogicalLocation(cellLocation); } +bool LayoutTableSection::hasRepeatingHeaderGroup() const +{ + if (getPaginationBreakability() == LayoutBox::AllowAnyBreaks) + return false; + // TODO(rhogan): Should we paint a header repeatedly if it's self-painting? + if (hasSelfPaintingLayer()) + return false; + LayoutUnit pageHeight = table()->pageLogicalHeightForOffset(LayoutUnit()); + if (!pageHeight) + return false; + + if (logicalHeight() > pageHeight) + return false; + + // If the first row of the section after the header group doesn't fit on the page, then + // don't repeat the header on each page. See https://drafts.csswg.org/css-tables-3/#repeated-headers + LayoutTableSection* sectionBelow = table()->sectionBelow(this); + if (sectionBelow && sectionBelow->paginationStrutForRow(sectionBelow->firstRow(), sectionBelow->logicalTop())) + return false; + + return true; +} + +bool LayoutTableSection::mapToVisualRectInAncestorSpace(const LayoutBoxModelObject* ancestor, LayoutRect& rect, VisualRectFlags flags) const +{ + if (ancestor == this) + return true; + // Repeating table headers are painted once per fragmentation page/column. This does not go through the regular fragmentation machinery, + // so we need special code to expand the invalidation rect to contain all positions of the header in all columns. + // Note that this is in flow thread coordinates, not visual coordinates. The enclosing LayoutFlowThread will convert to visual coordinates. + if (table()->header() == this && hasRepeatingHeaderGroup()) + rect.setHeight(table()->logicalHeight()); + return LayoutTableBoxComponent::mapToVisualRectInAncestorSpace(ancestor, rect, flags); +} + + } // namespace blink diff --git a/chromium/third_party/WebKit/Source/core/layout/LayoutTableSection.h b/chromium/third_party/WebKit/Source/core/layout/LayoutTableSection.h index 3d330f6d473..549a25316c4 100644 --- a/chromium/third_party/WebKit/Source/core/layout/LayoutTableSection.h +++ b/chromium/third_party/WebKit/Source/core/layout/LayoutTableSection.h @@ -302,6 +302,10 @@ public: void setOffsetForRepeatingHeader(LayoutUnit offset) { m_offsetForRepeatingHeader = offset; } LayoutUnit offsetForRepeatingHeader() const { return m_offsetForRepeatingHeader; } + bool mapToVisualRectInAncestorSpace(const LayoutBoxModelObject* ancestor, LayoutRect&, VisualRectFlags = DefaultVisualRectFlags) const override; + + bool hasRepeatingHeaderGroup() const; + protected: void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override; bool nodeAtPoint(HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override; diff --git a/chromium/third_party/WebKit/Source/core/paint/TableSectionPainter.cpp b/chromium/third_party/WebKit/Source/core/paint/TableSectionPainter.cpp index 4296c815b4c..877edf918a7 100644 --- a/chromium/third_party/WebKit/Source/core/paint/TableSectionPainter.cpp +++ b/chromium/third_party/WebKit/Source/core/paint/TableSectionPainter.cpp @@ -37,19 +37,20 @@ inline const LayoutTableCell* TableSectionPainter::primaryCellToPaint(unsigned r void TableSectionPainter::paintRepeatingHeaderGroup(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, const CollapsedBorderValue& currentBorderValue, ItemToPaint itemToPaint) { - if (m_layoutTableSection.getPaginationBreakability() == LayoutBox::AllowAnyBreaks) - return; - // TODO(rhogan): Should we paint a header repeatedly if it's self-painting? - if (m_layoutTableSection.hasSelfPaintingLayer()) + if (!m_layoutTableSection.hasRepeatingHeaderGroup()) return; + LayoutTable* table = m_layoutTableSection.table(); + LayoutPoint paginationOffset = paintOffset; LayoutUnit pageHeight = table->pageLogicalHeightForOffset(LayoutUnit()); - if (!pageHeight) - return; - LayoutPoint paginationOffset = paintOffset; - // Move paginationOffset to the top of the second page. - paginationOffset.move(0, pageHeight - table->pageLogicalOffset()); + // Move paginationOffset to the top of the next page. + // The header may have a pagination strut before it so we need to account for that when establishing its position. + LayoutUnit headerGroupOffset = table->pageLogicalOffset(); + if (LayoutTableRow* row = m_layoutTableSection.firstRow()) + headerGroupOffset += m_layoutTableSection.paginationStrutForRow(row, table->pageLogicalOffset()); + LayoutUnit offsetToNextPage = pageHeight - intMod(headerGroupOffset, pageHeight); + paginationOffset.move(0, offsetToNextPage); // Now move paginationOffset to the top of the page the cull rect starts on. if (paintInfo.cullRect().m_rect.y() > paginationOffset.y()) paginationOffset.move(0, pageHeight * static_cast<int>((paintInfo.cullRect().m_rect.y() - paginationOffset.y()) / pageHeight)); diff --git a/chromium/third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandle.cpp b/chromium/third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandle.cpp index b3a22c55371..c3e277f7a44 100644 --- a/chromium/third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandle.cpp +++ b/chromium/third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandle.cpp @@ -78,6 +78,8 @@ public: m_loader->cancel(); m_loader.reset(); } + if (!m_registeredBlobURL.isEmpty()) + BlobRegistry::revokePublicBlobURL(m_registeredBlobURL); } void start(ExecutionContext* executionContext) override @@ -85,17 +87,17 @@ public: ASSERT(executionContext->isContextThread()); ASSERT(!m_loader); - KURL url = BlobURL::createPublicURL(executionContext->getSecurityOrigin()); - if (url.isEmpty()) { + m_registeredBlobURL = BlobURL::createPublicURL(executionContext->getSecurityOrigin()); + if (m_registeredBlobURL.isEmpty()) { m_updater->update(createUnexpectedErrorDataConsumerHandle()); return; } - BlobRegistry::registerPublicBlobURL(executionContext->getSecurityOrigin(), url, m_blobDataHandle); + BlobRegistry::registerPublicBlobURL(executionContext->getSecurityOrigin(), m_registeredBlobURL, m_blobDataHandle); m_loader = createLoader(executionContext, this); ASSERT(m_loader); - ResourceRequest request(url); + ResourceRequest request(m_registeredBlobURL); request.setRequestContext(WebURLRequest::RequestContextInternal); request.setUseStreamOnResponse(true); // We intentionally skip 'setExternalRequestStateFromRequestorAddressSpace', as 'data:' can never be external. @@ -155,6 +157,7 @@ private: RefPtr<BlobDataHandle> m_blobDataHandle; Persistent<FetchBlobDataConsumerHandle::LoaderFactory> m_loaderFactory; std::unique_ptr<ThreadableLoader> m_loader; + KURL m_registeredBlobURL; bool m_receivedResponse; }; diff --git a/chromium/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp b/chromium/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp index ea48d8b7958..18707ed78f2 100644 --- a/chromium/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp +++ b/chromium/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp @@ -115,7 +115,8 @@ InjectedScript::~InjectedScript() void InjectedScript::getProperties(ErrorString* errorString, v8::Local<v8::Object> object, const String16& groupName, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, std::unique_ptr<Array<PropertyDescriptor>>* properties, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) { v8::HandleScope handles(m_context->isolate()); - V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value(), "getProperties"); + v8::Local<v8::Context> context = m_context->context(); + V8FunctionCall function(m_context->debugger(), context, v8Value(), "getProperties"); function.appendArgument(object); function.appendArgument(groupName); function.appendArgument(ownProperties); @@ -131,7 +132,7 @@ void InjectedScript::getProperties(ErrorString* errorString, v8::Local<v8::Objec return; } - std::unique_ptr<protocol::Value> protocolValue = toProtocolValue(function.context(), resultValue); + std::unique_ptr<protocol::Value> protocolValue = toProtocolValue(context, resultValue); if (hasInternalError(errorString, !protocolValue)) return; protocol::ErrorSupport errors(errorString); @@ -158,10 +159,11 @@ std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(Erro { v8::HandleScope handles(m_context->isolate()); v8::Local<v8::Value> wrappedObject; + v8::Local<v8::Context> context = m_context->context(); if (!wrapValue(errorString, value, groupName, forceValueType, generatePreview).ToLocal(&wrappedObject)) return nullptr; protocol::ErrorSupport errors; - std::unique_ptr<protocol::Runtime::RemoteObject> remoteObject = protocol::Runtime::RemoteObject::parse(toProtocolValue(m_context->context(), wrappedObject).get(), &errors); + std::unique_ptr<protocol::Runtime::RemoteObject> remoteObject = protocol::Runtime::RemoteObject::parse(toProtocolValue(context, wrappedObject).get(), &errors); if (!remoteObject) *errorString = "Object has too long reference chain"; return remoteObject; @@ -170,12 +172,13 @@ std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(Erro bool InjectedScript::wrapObjectProperty(ErrorString* errorString, v8::Local<v8::Object> object, v8::Local<v8::Name> key, const String16& groupName, bool forceValueType, bool generatePreview) const { v8::Local<v8::Value> property; - if (hasInternalError(errorString, !object->Get(m_context->context(), key).ToLocal(&property))) + v8::Local<v8::Context> context = m_context->context(); + if (hasInternalError(errorString, !object->Get(context, key).ToLocal(&property))) return false; v8::Local<v8::Value> wrappedProperty; if (!wrapValue(errorString, property, groupName, forceValueType, generatePreview).ToLocal(&wrappedProperty)) return false; - v8::Maybe<bool> success = createDataProperty(m_context->context(), object, key, wrappedProperty); + v8::Maybe<bool> success = createDataProperty(context, object, key, wrappedProperty); if (hasInternalError(errorString, success.IsNothing() || !success.FromJust())) return false; return true; @@ -226,7 +229,8 @@ v8::MaybeLocal<v8::Value> InjectedScript::wrapValue(ErrorString* errorString, v8 std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::Local<v8::Value> table, v8::Local<v8::Value> columns) const { v8::HandleScope handles(m_context->isolate()); - V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value(), "wrapTable"); + v8::Local<v8::Context> context = m_context->context(); + V8FunctionCall function(m_context->debugger(), context, v8Value(), "wrapTable"); function.appendArgument(canAccessInspectedWindow()); function.appendArgument(table); if (columns.IsEmpty()) @@ -238,7 +242,7 @@ std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::L if (hadException) return nullptr; protocol::ErrorSupport errors; - return protocol::Runtime::RemoteObject::parse(toProtocolValue(m_context->context(), r).get(), &errors); + return protocol::Runtime::RemoteObject::parse(toProtocolValue(context, r).get(), &errors); } bool InjectedScript::findObject(ErrorString* errorString, const RemoteObjectId& objectId, v8::Local<v8::Value>* outObject) const diff --git a/chromium/third_party/WebKit/Source/platform/v8_inspector/V8ConsoleAgentImpl.cpp b/chromium/third_party/WebKit/Source/platform/v8_inspector/V8ConsoleAgentImpl.cpp index 310e57d5268..f68382963d4 100644 --- a/chromium/third_party/WebKit/Source/platform/v8_inspector/V8ConsoleAgentImpl.cpp +++ b/chromium/third_party/WebKit/Source/platform/v8_inspector/V8ConsoleAgentImpl.cpp @@ -95,14 +95,17 @@ void V8ConsoleAgentImpl::reportAllMessages() m_frontend.messageAdded(std::move(expired)); m_frontend.flush(); } - for (const auto& message : storage->messages()) - reportMessage(message.get(), false); + for (const auto& message : storage->messages()) { + if (!reportMessage(message.get(), false)) + return; + } } -void V8ConsoleAgentImpl::reportMessage(V8ConsoleMessage* message, bool generatePreview) +bool V8ConsoleAgentImpl::reportMessage(V8ConsoleMessage* message, bool generatePreview) { m_frontend.messageAdded(message->buildInspectorObject(m_session, generatePreview)); m_frontend.flush(); + return m_session->debugger()->hasConsoleMessageStorage(m_session->contextGroupId()); } } // namespace blink diff --git a/chromium/third_party/WebKit/Source/platform/v8_inspector/V8ConsoleAgentImpl.h b/chromium/third_party/WebKit/Source/platform/v8_inspector/V8ConsoleAgentImpl.h index bc897ac352e..3ea326c7b8f 100644 --- a/chromium/third_party/WebKit/Source/platform/v8_inspector/V8ConsoleAgentImpl.h +++ b/chromium/third_party/WebKit/Source/platform/v8_inspector/V8ConsoleAgentImpl.h @@ -31,7 +31,7 @@ public: private: void reportAllMessages(); - void reportMessage(V8ConsoleMessage*, bool generatePreview); + bool reportMessage(V8ConsoleMessage*, bool generatePreview); V8InspectorSessionImpl* m_session; protocol::DictionaryValue* m_state; diff --git a/chromium/third_party/WebKit/Source/platform/v8_inspector/V8ConsoleMessage.cpp b/chromium/third_party/WebKit/Source/platform/v8_inspector/V8ConsoleMessage.cpp index 3fcdf36d35c..0c45ad7bd0f 100644 --- a/chromium/third_party/WebKit/Source/platform/v8_inspector/V8ConsoleMessage.cpp +++ b/chromium/third_party/WebKit/Source/platform/v8_inspector/V8ConsoleMessage.cpp @@ -306,6 +306,11 @@ MessageType V8ConsoleMessage::type() const // static std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForConsoleAPI(double timestampMS, MessageType type, MessageLevel level, const String16& messageText, std::vector<v8::Local<v8::Value>>* arguments, std::unique_ptr<V8StackTrace> stackTrace, InspectedContext* context) { + v8::Isolate* isolate = context->isolate(); + int contextId = context->contextId(); + int contextGroupId = context->contextGroupId(); + V8DebuggerImpl* debugger = context->debugger(); + String16 url; unsigned lineNumber = 0; unsigned columnNumber = 0; @@ -320,19 +325,19 @@ std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForConsoleAPI(double t Arguments messageArguments; if (arguments && arguments->size()) { for (size_t i = 0; i < arguments->size(); ++i) - messageArguments.push_back(wrapUnique(new v8::Global<v8::Value>(context->isolate(), arguments->at(i)))); + messageArguments.push_back(wrapUnique(new v8::Global<v8::Value>(isolate, arguments->at(i)))); if (actualMessage.isEmpty()) - actualMessage = V8ValueStringBuilder::toString(messageArguments.at(0)->Get(context->isolate()), context->isolate()); + actualMessage = V8ValueStringBuilder::toString(messageArguments.at(0)->Get(isolate), isolate); } std::unique_ptr<V8ConsoleMessage> message = wrapUnique(new V8ConsoleMessage(timestampMS, ConsoleAPIMessageSource, level, actualMessage, url, lineNumber, columnNumber, std::move(stackTrace), 0 /* scriptId */, String16() /* requestIdentifier */)); message->m_type = type; if (messageArguments.size()) { - message->m_contextId = context->contextId(); + message->m_contextId = contextId; message->m_arguments.swap(messageArguments); } - context->debugger()->client()->messageAddedToConsole(context->contextGroupId(), message->m_source, message->m_level, message->m_message, message->m_url, message->m_lineNumber, message->m_columnNumber, message->m_stackTrace.get()); + debugger->client()->messageAddedToConsole(contextGroupId, message->m_source, message->m_level, message->m_message, message->m_url, message->m_lineNumber, message->m_columnNumber, message->m_stackTrace.get()); return message; } @@ -382,12 +387,17 @@ V8ConsoleMessageStorage::~V8ConsoleMessageStorage() void V8ConsoleMessageStorage::addMessage(std::unique_ptr<V8ConsoleMessage> message) { + int contextGroupId = m_contextGroupId; + V8DebuggerImpl* debugger = m_debugger; + if (message->type() == ClearMessageType) clear(); - V8InspectorSessionImpl* session = m_debugger->sessionForContextGroup(m_contextGroupId); + V8InspectorSessionImpl* session = debugger->sessionForContextGroup(contextGroupId); if (session) session->consoleAgent()->messageAdded(message.get()); + if (!debugger->hasConsoleMessageStorage(contextGroupId)) + return; DCHECK(m_messages.size() <= maxConsoleMessageCount); if (m_messages.size() == maxConsoleMessageCount) { diff --git a/chromium/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp b/chromium/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp index 22f64fca626..712d9fbdb3e 100644 --- a/chromium/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp +++ b/chromium/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp @@ -809,6 +809,12 @@ V8ConsoleMessageStorage* V8DebuggerImpl::ensureConsoleMessageStorage(int context return storageIt->second.get(); } +bool V8DebuggerImpl::hasConsoleMessageStorage(int contextGroupId) +{ + ConsoleStorageMap::iterator storageIt = m_consoleStorageMap.find(contextGroupId); + return storageIt != m_consoleStorageMap.end(); +} + std::unique_ptr<V8StackTrace> V8DebuggerImpl::createStackTrace(v8::Local<v8::StackTrace> stackTrace) { int contextGroupId = m_isolate->InContext() ? getGroupId(m_isolate->GetCurrentContext()) : 0; diff --git a/chromium/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.h b/chromium/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.h index 2d3e39244de..b53595fcb88 100644 --- a/chromium/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.h +++ b/chromium/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.h @@ -120,6 +120,7 @@ public: void enableStackCapturingIfNeeded(); void disableStackCapturingIfNeeded(); V8ConsoleMessageStorage* ensureConsoleMessageStorage(int contextGroupId); + bool hasConsoleMessageStorage(int contextGroupId); // V8Debugger implementation std::unique_ptr<V8InspectorSession> connect(int contextGroupId, protocol::FrontendChannel*, V8InspectorSessionClient*, const String16* state) override; diff --git a/chromium/ui/arc/notification/arc_custom_notification_view.cc b/chromium/ui/arc/notification/arc_custom_notification_view.cc index 8e0c9c9068d..c07204509d2 100644 --- a/chromium/ui/arc/notification/arc_custom_notification_view.cc +++ b/chromium/ui/arc/notification/arc_custom_notification_view.cc @@ -186,6 +186,9 @@ void ArcCustomNotificationView::SetSurface(exo::NotificationSurface* surface) { if (surface_ == surface) return; + // Reset |floating_close_button_widget_| when |surface_| is changed. + floating_close_button_widget_.reset(); + if (surface_ && surface_->window()) { surface_->window()->RemoveObserver(this); surface_->window()->RemovePreTargetHandler(event_forwarder_.get()); @@ -200,7 +203,8 @@ void ArcCustomNotificationView::SetSurface(exo::NotificationSurface* surface) { if (GetWidget()) AttachSurface(); - UpdatePinnedState(); + if (item_) + UpdatePinnedState(); } } @@ -238,6 +242,8 @@ void ArcCustomNotificationView::UpdateCloseButtonVisiblity() { } void ArcCustomNotificationView::UpdatePinnedState() { + DCHECK(item_); + if (item_->pinned() && floating_close_button_widget_) { floating_close_button_widget_.reset(); } else if (!item_->pinned() && !floating_close_button_widget_) { diff --git a/chromium/ui/gl/gl_image_ozone_native_pixmap.cc b/chromium/ui/gl/gl_image_ozone_native_pixmap.cc index 207a83e2488..86e13b25b86 100644 --- a/chromium/ui/gl/gl_image_ozone_native_pixmap.cc +++ b/chromium/ui/gl/gl_image_ozone_native_pixmap.cc @@ -167,6 +167,8 @@ bool GLImageOzoneNativePixmap::Initialize(ui::NativePixmap* pixmap, attrs_plane < gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat()); ++attrs_plane) { + attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + attrs_plane * 3); + size_t pixmap_plane = attrs_plane; // TODO(dcastagna): Intel mesa flips V and U when the fourcc format is a diff --git a/chromium/v8/include/v8-version.h b/chromium/v8/include/v8-version.h index 4cde6ffa55a..d8480178868 100644 --- a/chromium/v8/include/v8-version.h +++ b/chromium/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 5 #define V8_MINOR_VERSION 3 #define V8_BUILD_NUMBER 332 -#define V8_PATCH_LEVEL 45 +#define V8_PATCH_LEVEL 47 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/chromium/v8/src/compiler/ast-loop-assignment-analyzer.cc b/chromium/v8/src/compiler/ast-loop-assignment-analyzer.cc index 334c5978a86..97da140b81c 100644 --- a/chromium/v8/src/compiler/ast-loop-assignment-analyzer.cc +++ b/chromium/v8/src/compiler/ast-loop-assignment-analyzer.cc @@ -254,10 +254,12 @@ void ALAA::VisitForStatement(ForStatement* loop) { void ALAA::VisitForInStatement(ForInStatement* loop) { + Expression* l = loop->each(); Enter(loop); - Visit(loop->each()); + Visit(l); Visit(loop->subject()); Visit(loop->body()); + if (l->IsVariableProxy()) AnalyzeAssignment(l->AsVariableProxy()->var()); Exit(loop); } diff --git a/chromium/v8/src/heap/heap.cc b/chromium/v8/src/heap/heap.cc index c59a8d3d373..2bb74c0b55c 100644 --- a/chromium/v8/src/heap/heap.cc +++ b/chromium/v8/src/heap/heap.cc @@ -2378,6 +2378,7 @@ bool Heap::CreateInitialMaps() { ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, hash_table) ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, ordered_hash_table) + ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, unseeded_number_dictionary) ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, function_context) ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, catch_context) diff --git a/chromium/v8/src/heap/heap.h b/chromium/v8/src/heap/heap.h index ed1e65253e8..46f4e3885da 100644 --- a/chromium/v8/src/heap/heap.h +++ b/chromium/v8/src/heap/heap.h @@ -87,6 +87,7 @@ using v8::MemoryPressureLevel; V(Map, fixed_double_array_map, FixedDoubleArrayMap) \ V(Map, mutable_heap_number_map, MutableHeapNumberMap) \ V(Map, ordered_hash_table_map, OrderedHashTableMap) \ + V(Map, unseeded_number_dictionary_map, UnseededNumberDictionaryMap) \ V(Map, sloppy_arguments_elements_map, SloppyArgumentsElementsMap) \ V(Map, message_object_map, JSMessageObjectMap) \ V(Map, neander_map, NeanderMap) \ diff --git a/chromium/v8/src/objects-inl.h b/chromium/v8/src/objects-inl.h index e1df2b662dd..58441d38536 100644 --- a/chromium/v8/src/objects-inl.h +++ b/chromium/v8/src/objects-inl.h @@ -851,9 +851,8 @@ bool Object::IsSeededNumberDictionary() const { return IsDictionary(); } - -bool Object::IsUnseededNumberDictionary() const { - return IsDictionary(); +bool HeapObject::IsUnseededNumberDictionary() const { + return map() == GetHeap()->unseeded_number_dictionary_map(); } bool HeapObject::IsStringTable() const { return IsHashTable(); } @@ -3065,6 +3064,10 @@ void HashTableBase::SetNumberOfDeletedElements(int nod) { set(kNumberOfDeletedElementsIndex, Smi::FromInt(nod)); } +template <typename Key> +Map* BaseShape<Key>::GetMap(Isolate* isolate) { + return isolate->heap()->hash_table_map(); +} template <typename Derived, typename Shape, typename Key> int HashTable<Derived, Shape, Key>::FindEntry(Key key) { @@ -7457,14 +7460,16 @@ void BaseDictionaryShape<Key>::SetEntry(Dictionary* dict, int entry, Handle<Object> key, Handle<Object> value, PropertyDetails details) { - STATIC_ASSERT(Dictionary::kEntrySize == 3); + STATIC_ASSERT(Dictionary::kEntrySize == 2 || Dictionary::kEntrySize == 3); DCHECK(!key->IsName() || details.dictionary_index() > 0); int index = dict->EntryToIndex(entry); DisallowHeapAllocation no_gc; WriteBarrierMode mode = dict->GetWriteBarrierMode(no_gc); dict->set(index + Dictionary::kEntryKeyIndex, *key, mode); dict->set(index + Dictionary::kEntryValueIndex, *value, mode); - dict->set(index + Dictionary::kEntryDetailsIndex, details.AsSmi()); + if (Dictionary::kEntrySize == 3) { + dict->set(index + Dictionary::kEntryDetailsIndex, details.AsSmi()); + } } @@ -7501,6 +7506,9 @@ uint32_t UnseededNumberDictionaryShape::HashForObject(uint32_t key, return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), 0); } +Map* UnseededNumberDictionaryShape::GetMap(Isolate* isolate) { + return *isolate->factory()->unseeded_number_dictionary_map(); +} uint32_t SeededNumberDictionaryShape::SeededHash(uint32_t key, uint32_t seed) { return ComputeIntegerHash(key, seed); diff --git a/chromium/v8/src/objects.cc b/chromium/v8/src/objects.cc index fb5bb5e589a..16cf07d03f9 100644 --- a/chromium/v8/src/objects.cc +++ b/chromium/v8/src/objects.cc @@ -16177,7 +16177,7 @@ Handle<Derived> HashTable<Derived, Shape, Key>::New( Factory* factory = isolate->factory(); int length = EntryToIndex(capacity); Handle<FixedArray> array = factory->NewFixedArray(length, pretenure); - array->set_map_no_write_barrier(*factory->hash_table_map()); + array->set_map_no_write_barrier(Shape::GetMap(isolate)); Handle<Derived> table = Handle<Derived>::cast(array); table->SetNumberOfElements(0); diff --git a/chromium/v8/src/objects.h b/chromium/v8/src/objects.h index e37b9bdb1d8..acd95fd41b9 100644 --- a/chromium/v8/src/objects.h +++ b/chromium/v8/src/objects.h @@ -982,6 +982,7 @@ template <class C> inline bool Is(Object* obj); V(JSRegExp) \ V(HashTable) \ V(Dictionary) \ + V(UnseededNumberDictionary) \ V(StringTable) \ V(StringSet) \ V(NormalizedMapCache) \ @@ -1079,7 +1080,6 @@ class Object { INLINE(bool IsNameDictionary() const); INLINE(bool IsGlobalDictionary() const); INLINE(bool IsSeededNumberDictionary() const); - INLINE(bool IsUnseededNumberDictionary() const); INLINE(bool IsOrderedHashSet() const); INLINE(bool IsOrderedHashMap() const); @@ -3124,6 +3124,7 @@ class BaseShape { DCHECK(UsesSeed); return HashForObject(key, object); } + static inline Map* GetMap(Isolate* isolate); }; @@ -3642,7 +3643,6 @@ class NumberDictionaryShape : public BaseDictionaryShape<uint32_t> { public: static inline bool IsMatch(uint32_t key, Object* other); static inline Handle<Object> AsHandle(Isolate* isolate, uint32_t key); - static const int kEntrySize = 3; static const bool kIsEnumerable = false; }; @@ -3651,6 +3651,7 @@ class SeededNumberDictionaryShape : public NumberDictionaryShape { public: static const bool UsesSeed = true; static const int kPrefixSize = 2; + static const int kEntrySize = 3; static inline uint32_t SeededHash(uint32_t key, uint32_t seed); static inline uint32_t SeededHashForObject(uint32_t key, @@ -3662,9 +3663,24 @@ class SeededNumberDictionaryShape : public NumberDictionaryShape { class UnseededNumberDictionaryShape : public NumberDictionaryShape { public: static const int kPrefixSize = 0; + static const int kEntrySize = 2; static inline uint32_t Hash(uint32_t key); static inline uint32_t HashForObject(uint32_t key, Object* object); + + template <typename Dictionary> + static inline PropertyDetails DetailsAt(Dictionary* dict, int entry) { + UNREACHABLE(); + return PropertyDetails::Empty(); + } + + template <typename Dictionary> + static inline void DetailsAtPut(Dictionary* dict, int entry, + PropertyDetails value) { + UNREACHABLE(); + } + + static inline Map* GetMap(Isolate* isolate); }; diff --git a/chromium/v8/src/type-feedback-vector.cc b/chromium/v8/src/type-feedback-vector.cc index bc2f1c288bc..661aa2feac4 100644 --- a/chromium/v8/src/type-feedback-vector.cc +++ b/chromium/v8/src/type-feedback-vector.cc @@ -39,20 +39,13 @@ FeedbackVectorSlotKind TypeFeedbackMetadata::GetKind( String* TypeFeedbackMetadata::GetName(FeedbackVectorSlot slot) const { DCHECK(SlotRequiresName(GetKind(slot))); - FixedArray* names = FixedArray::cast(get(kNamesTableIndex)); - // TODO(ishell): consider using binary search here or even Dictionary when we - // have more ICs with names. - Smi* key = Smi::FromInt(slot.ToInt()); - for (int entry = 0; entry < names->length(); entry += kNameTableEntrySize) { - Object* current_key = names->get(entry + kNameTableSlotIndex); - if (current_key == key) { - Object* name = names->get(entry + kNameTableNameIndex); - DCHECK(name->IsString()); - return String::cast(name); - } - } - UNREACHABLE(); - return nullptr; + UnseededNumberDictionary* names = + UnseededNumberDictionary::cast(get(kNamesTableIndex)); + int entry = names->FindEntry(GetIsolate(), slot.ToInt()); + CHECK_NE(UnseededNumberDictionary::kNotFound, entry); + Object* name = names->ValueAt(entry); + DCHECK(name->IsString()); + return String::cast(name); } void TypeFeedbackMetadata::SetKind(FeedbackVectorSlot slot, @@ -107,10 +100,9 @@ Handle<TypeFeedbackMetadata> TypeFeedbackMetadata::New(Isolate* isolate, // Add names to NamesTable. const int name_count = spec->name_count(); - Handle<FixedArray> names = - name_count == 0 - ? factory->empty_fixed_array() - : factory->NewFixedArray(name_count * kNameTableEntrySize); + Handle<UnseededNumberDictionary> names = + UnseededNumberDictionary::New(isolate, name_count); + int name_index = 0; for (int i = 0; i < slot_count; i++) { FeedbackVectorSlotKind kind = spec->GetKind(i); @@ -118,9 +110,7 @@ Handle<TypeFeedbackMetadata> TypeFeedbackMetadata::New(Isolate* isolate, if (SlotRequiresName(kind)) { Handle<String> name = spec->GetName(name_index); DCHECK(!name.is_null()); - int entry = name_index * kNameTableEntrySize; - names->set(entry + kNameTableSlotIndex, Smi::FromInt(i)); - names->set(entry + kNameTableNameIndex, *name); + names = UnseededNumberDictionary::AtNumberPut(names, i, name); name_index++; } } diff --git a/chromium/v8/src/type-info.cc b/chromium/v8/src/type-info.cc index 5f5c1e87311..61af125c47c 100644 --- a/chromium/v8/src/type-info.cc +++ b/chromium/v8/src/type-info.cc @@ -20,7 +20,7 @@ TypeFeedbackOracle::TypeFeedbackOracle( Handle<TypeFeedbackVector> feedback_vector, Handle<Context> native_context) : native_context_(native_context), isolate_(isolate), zone_(zone) { BuildDictionary(code); - DCHECK(dictionary_->IsDictionary()); + DCHECK(dictionary_->IsUnseededNumberDictionary()); // We make a copy of the feedback vector because a GC could clear // the type feedback info contained therein. // TODO(mvstanton): revisit the decision to copy when we weakly |