Commit ac3a39e1 authored by Alexey Baskakov's avatar Alexey Baskakov Committed by Commit Bot

WebApp: Rename GetWebAppDataDirectory function.

Historically, we stored OS-specific shortcut files in a directory,
specified by GetWebAppDataDirectory function:

<ProfileDir>
    Web Applications
        _crx_<app_id>

From now, we have a clear separation between
Manifest Resources
vs.
OS-specific integration Resources.
(see https://chromium-review.googlesource.com/c/chromium/src/+/2084215)

We should rename GetWebAppDataDirectory function to
GetOsIntegrationResourcesDirectoryForApp to reflect this change.

We can't rename the underlying directory name: it would require a
migration for all existing user profiles in the wild.

This CL doesn't introduce any behavior changes.

Bug: 877898
Change-Id: I41a636b2a86afa4196d68e5cc3f236d3e813cdbc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2086459
Commit-Queue: Alexey Baskakov <loyso@chromium.org>
Reviewed-by: default avatarAlan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarccameron <ccameron@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747016}
parent 02decda8
...@@ -246,7 +246,8 @@ base::FilePath GetAppShimPath(Profile* profile, ...@@ -246,7 +246,8 @@ base::FilePath GetAppShimPath(Profile* profile,
std::unique_ptr<web_app::ShortcutInfo> shortcut_info = std::unique_ptr<web_app::ShortcutInfo> shortcut_info =
web_app::ShortcutInfoForExtensionAndProfile(app, profile); web_app::ShortcutInfoForExtensionAndProfile(app, profile);
web_app::WebAppShortcutCreator shortcut_creator( web_app::WebAppShortcutCreator shortcut_creator(
web_app::GetWebAppDataDirectory(profile->GetPath(), app->id(), GURL()), web_app::GetOsIntegrationResourcesDirectoryForApp(profile->GetPath(),
app->id(), GURL()),
shortcut_info.get()); shortcut_info.get());
return shortcut_creator.GetApplicationsShortcutPath(false); return shortcut_creator.GetApplicationsShortcutPath(false);
} }
...@@ -596,7 +597,8 @@ IN_PROC_BROWSER_TEST_F(AppShimInteractiveTest, MAYBE_RebuildShim) { ...@@ -596,7 +597,8 @@ IN_PROC_BROWSER_TEST_F(AppShimInteractiveTest, MAYBE_RebuildShim) {
std::unique_ptr<web_app::ShortcutInfo> shortcut_info = std::unique_ptr<web_app::ShortcutInfo> shortcut_info =
web_app::ShortcutInfoForExtensionAndProfile(app, profile()); web_app::ShortcutInfoForExtensionAndProfile(app, profile());
web_app::WebAppShortcutCreator shortcut_creator( web_app::WebAppShortcutCreator shortcut_creator(
web_app::GetWebAppDataDirectory(profile()->GetPath(), app->id(), GURL()), web_app::GetOsIntegrationResourcesDirectoryForApp(profile()->GetPath(),
app->id(), GURL()),
shortcut_info.get()); shortcut_info.get());
std::vector<base::FilePath> updated_paths; std::vector<base::FilePath> updated_paths;
shortcut_creator.UpdateShortcuts(false, &updated_paths); shortcut_creator.UpdateShortcuts(false, &updated_paths);
......
...@@ -130,8 +130,9 @@ void ValidateHostedAppWindowProperties(const Browser* browser, ...@@ -130,8 +130,9 @@ void ValidateHostedAppWindowProperties(const Browser* browser,
prop_var.Reset(); prop_var.Reset();
// The app icon should be set to the extension app icon. // The app icon should be set to the extension app icon.
base::FilePath web_app_dir = web_app::GetWebAppDataDirectory( base::FilePath web_app_dir =
browser->profile()->GetPath(), extension->id(), GURL()); web_app::GetOsIntegrationResourcesDirectoryForApp(
browser->profile()->GetPath(), extension->id(), GURL());
EXPECT_EQ(S_OK, EXPECT_EQ(S_OK,
pps->GetValue(PKEY_AppUserModel_RelaunchIconResource, pps->GetValue(PKEY_AppUserModel_RelaunchIconResource,
prop_var.Receive())); prop_var.Receive()));
......
...@@ -152,7 +152,7 @@ void RegisterFileHandlersWithOsTask( ...@@ -152,7 +152,7 @@ void RegisterFileHandlersWithOsTask(
const std::set<base::string16>& file_extensions, const std::set<base::string16>& file_extensions,
const base::string16& app_name_extension) { const base::string16& app_name_extension) {
base::FilePath web_app_path = base::FilePath web_app_path =
GetWebAppDataDirectory(profile_path, app_id, GURL()); GetOsIntegrationResourcesDirectoryForApp(profile_path, app_id, GURL());
base::string16 utf16_app_name = base::UTF8ToUTF16(app_name); base::string16 utf16_app_name = base::UTF8ToUTF16(app_name);
base::FilePath icon_path = base::FilePath icon_path =
internals::GetIconFilePath(web_app_path, utf16_app_name); internals::GetIconFilePath(web_app_path, utf16_app_name);
......
...@@ -173,8 +173,8 @@ class WebAppFileHandlerRegistrationWinTest : public testing::Test { ...@@ -173,8 +173,8 @@ class WebAppFileHandlerRegistrationWinTest : public testing::Test {
Profile* profile, Profile* profile,
const AppId app_id, const AppId app_id,
const std::string& sanitized_app_name) { const std::string& sanitized_app_name) {
base::FilePath web_app_dir( base::FilePath web_app_dir(GetOsIntegrationResourcesDirectoryForApp(
GetWebAppDataDirectory(profile->GetPath(), app_id, GURL())); profile->GetPath(), app_id, GURL()));
// Make sure web app dir exists. Normally installing an extension would // Make sure web app dir exists. Normally installing an extension would
// handle this. // handle this.
EXPECT_TRUE(base::CreateDirectory(web_app_dir)); EXPECT_TRUE(base::CreateDirectory(web_app_dir));
......
...@@ -91,9 +91,10 @@ std::string GenerateApplicationNameFromInfo(const ShortcutInfo& shortcut_info) { ...@@ -91,9 +91,10 @@ std::string GenerateApplicationNameFromInfo(const ShortcutInfo& shortcut_info) {
return GenerateApplicationNameFromAppId(shortcut_info.extension_id); return GenerateApplicationNameFromAppId(shortcut_info.extension_id);
} }
base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path, base::FilePath GetOsIntegrationResourcesDirectoryForApp(
const std::string& app_id, const base::FilePath& profile_path,
const GURL& url) { const std::string& app_id,
const GURL& url) {
DCHECK(!profile_path.empty()); DCHECK(!profile_path.empty());
base::FilePath app_data_dir(profile_path.Append(chrome::kWebAppDirname)); base::FilePath app_data_dir(profile_path.Append(chrome::kWebAppDirname));
...@@ -202,8 +203,9 @@ base::FilePath GetSanitizedFileName(const base::string16& name) { ...@@ -202,8 +203,9 @@ base::FilePath GetSanitizedFileName(const base::string16& name) {
} }
base::FilePath GetShortcutDataDir(const ShortcutInfo& shortcut_info) { base::FilePath GetShortcutDataDir(const ShortcutInfo& shortcut_info) {
return GetWebAppDataDirectory(shortcut_info.profile_path, return GetOsIntegrationResourcesDirectoryForApp(shortcut_info.profile_path,
shortcut_info.extension_id, shortcut_info.url); shortcut_info.extension_id,
shortcut_info.url);
} }
#if !defined(OS_MACOSX) #if !defined(OS_MACOSX)
......
...@@ -105,11 +105,10 @@ std::string GenerateApplicationNameFromInfo(const ShortcutInfo& shortcut_info); ...@@ -105,11 +105,10 @@ std::string GenerateApplicationNameFromInfo(const ShortcutInfo& shortcut_info);
// //
// The path for the directory is based on |app_id|. If |app_id| is empty then // The path for the directory is based on |app_id|. If |app_id| is empty then
// |url| is used to construct a unique ID. // |url| is used to construct a unique ID.
// TODO(crbug.com/877898): Rename this function to base::FilePath GetOsIntegrationResourcesDirectoryForApp(
// GetOsIntegrationDataDirectoryForApp(). const base::FilePath& profile_path,
base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path, const std::string& app_id,
const std::string& app_id, const GURL& url);
const GURL& url);
// Callback made when CreateShortcuts has finished trying to create the // Callback made when CreateShortcuts has finished trying to create the
// platform shortcuts indicating whether or not they were successfully // platform shortcuts indicating whether or not they were successfully
......
...@@ -10,7 +10,8 @@ namespace web_app { ...@@ -10,7 +10,8 @@ namespace web_app {
TEST(WebAppShortcutTest, AppDirWithId) { TEST(WebAppShortcutTest, AppDirWithId) {
base::FilePath profile_path(FILE_PATH_LITERAL("profile")); base::FilePath profile_path(FILE_PATH_LITERAL("profile"));
base::FilePath result(GetWebAppDataDirectory(profile_path, "123", GURL())); base::FilePath result(
GetOsIntegrationResourcesDirectoryForApp(profile_path, "123", GURL()));
base::FilePath expected = base::FilePath expected =
profile_path.AppendASCII("Web Applications").AppendASCII("_crx_123"); profile_path.AppendASCII("Web Applications").AppendASCII("_crx_123");
EXPECT_EQ(expected, result); EXPECT_EQ(expected, result);
...@@ -18,8 +19,8 @@ TEST(WebAppShortcutTest, AppDirWithId) { ...@@ -18,8 +19,8 @@ TEST(WebAppShortcutTest, AppDirWithId) {
TEST(WebAppShortcutTest, AppDirWithUrl) { TEST(WebAppShortcutTest, AppDirWithUrl) {
base::FilePath profile_path(FILE_PATH_LITERAL("profile")); base::FilePath profile_path(FILE_PATH_LITERAL("profile"));
base::FilePath result(GetWebAppDataDirectory(profile_path, std::string(), base::FilePath result(GetOsIntegrationResourcesDirectoryForApp(
GURL("http://example.com"))); profile_path, std::string(), GURL("http://example.com")));
base::FilePath expected = profile_path.AppendASCII("Web Applications") base::FilePath expected = profile_path.AppendASCII("Web Applications")
.AppendASCII("example.com") .AppendASCII("example.com")
.AppendASCII("http_80"); .AppendASCII("http_80");
......
...@@ -375,9 +375,9 @@ void OnShortcutInfoLoadedForSetRelaunchDetails( ...@@ -375,9 +375,9 @@ void OnShortcutInfoLoadedForSetRelaunchDetails(
// Set window's icon to the one we're about to create/update in the web app // Set window's icon to the one we're about to create/update in the web app
// path. The icon cache will refresh on icon creation. // path. The icon cache will refresh on icon creation.
base::FilePath web_app_path = base::FilePath web_app_path = GetOsIntegrationResourcesDirectoryForApp(
GetWebAppDataDirectory(shortcut_info->profile_path, shortcut_info->profile_path, shortcut_info->extension_id,
shortcut_info->extension_id, shortcut_info->url); shortcut_info->url);
base::FilePath icon_file = base::FilePath icon_file =
web_app::internals::GetIconFilePath(web_app_path, shortcut_info->title); web_app::internals::GetIconFilePath(web_app_path, shortcut_info->title);
......
...@@ -47,8 +47,8 @@ base::FilePath GetWebAppsRootDirectory(Profile* profile); ...@@ -47,8 +47,8 @@ base::FilePath GetWebAppsRootDirectory(Profile* profile);
// OS-independent manner. Use GetManifestResourcesDirectoryForApp function to // OS-independent manner. Use GetManifestResourcesDirectoryForApp function to
// get per-app manifest resources directory. // get per-app manifest resources directory.
// //
// To store OS-specific integration data, use GetWebAppDataDirectory declared in // To store OS-specific integration data, use
// web_app_shortcut.h. // GetOsIntegrationResourcesDirectoryForApp declared in web_app_shortcut.h.
base::FilePath GetManifestResourcesDirectory( base::FilePath GetManifestResourcesDirectory(
const base::FilePath& web_apps_root_directory); const base::FilePath& web_apps_root_directory);
base::FilePath GetManifestResourcesDirectory(Profile* profile); base::FilePath GetManifestResourcesDirectory(Profile* profile);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment