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,
std::unique_ptr<web_app::ShortcutInfo> shortcut_info =
web_app::ShortcutInfoForExtensionAndProfile(app, profile);
web_app::WebAppShortcutCreator shortcut_creator(
web_app::GetWebAppDataDirectory(profile->GetPath(), app->id(), GURL()),
web_app::GetOsIntegrationResourcesDirectoryForApp(profile->GetPath(),
app->id(), GURL()),
shortcut_info.get());
return shortcut_creator.GetApplicationsShortcutPath(false);
}
......@@ -596,7 +597,8 @@ IN_PROC_BROWSER_TEST_F(AppShimInteractiveTest, MAYBE_RebuildShim) {
std::unique_ptr<web_app::ShortcutInfo> shortcut_info =
web_app::ShortcutInfoForExtensionAndProfile(app, profile());
web_app::WebAppShortcutCreator shortcut_creator(
web_app::GetWebAppDataDirectory(profile()->GetPath(), app->id(), GURL()),
web_app::GetOsIntegrationResourcesDirectoryForApp(profile()->GetPath(),
app->id(), GURL()),
shortcut_info.get());
std::vector<base::FilePath> updated_paths;
shortcut_creator.UpdateShortcuts(false, &updated_paths);
......
......@@ -130,8 +130,9 @@ void ValidateHostedAppWindowProperties(const Browser* browser,
prop_var.Reset();
// The app icon should be set to the extension app icon.
base::FilePath web_app_dir = web_app::GetWebAppDataDirectory(
browser->profile()->GetPath(), extension->id(), GURL());
base::FilePath web_app_dir =
web_app::GetOsIntegrationResourcesDirectoryForApp(
browser->profile()->GetPath(), extension->id(), GURL());
EXPECT_EQ(S_OK,
pps->GetValue(PKEY_AppUserModel_RelaunchIconResource,
prop_var.Receive()));
......
......@@ -152,7 +152,7 @@ void RegisterFileHandlersWithOsTask(
const std::set<base::string16>& file_extensions,
const base::string16& app_name_extension) {
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::FilePath icon_path =
internals::GetIconFilePath(web_app_path, utf16_app_name);
......
......@@ -173,8 +173,8 @@ class WebAppFileHandlerRegistrationWinTest : public testing::Test {
Profile* profile,
const AppId app_id,
const std::string& sanitized_app_name) {
base::FilePath web_app_dir(
GetWebAppDataDirectory(profile->GetPath(), app_id, GURL()));
base::FilePath web_app_dir(GetOsIntegrationResourcesDirectoryForApp(
profile->GetPath(), app_id, GURL()));
// Make sure web app dir exists. Normally installing an extension would
// handle this.
EXPECT_TRUE(base::CreateDirectory(web_app_dir));
......
......@@ -91,9 +91,10 @@ std::string GenerateApplicationNameFromInfo(const ShortcutInfo& shortcut_info) {
return GenerateApplicationNameFromAppId(shortcut_info.extension_id);
}
base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path,
const std::string& app_id,
const GURL& url) {
base::FilePath GetOsIntegrationResourcesDirectoryForApp(
const base::FilePath& profile_path,
const std::string& app_id,
const GURL& url) {
DCHECK(!profile_path.empty());
base::FilePath app_data_dir(profile_path.Append(chrome::kWebAppDirname));
......@@ -202,8 +203,9 @@ base::FilePath GetSanitizedFileName(const base::string16& name) {
}
base::FilePath GetShortcutDataDir(const ShortcutInfo& shortcut_info) {
return GetWebAppDataDirectory(shortcut_info.profile_path,
shortcut_info.extension_id, shortcut_info.url);
return GetOsIntegrationResourcesDirectoryForApp(shortcut_info.profile_path,
shortcut_info.extension_id,
shortcut_info.url);
}
#if !defined(OS_MACOSX)
......
......@@ -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
// |url| is used to construct a unique ID.
// TODO(crbug.com/877898): Rename this function to
// GetOsIntegrationDataDirectoryForApp().
base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path,
const std::string& app_id,
const GURL& url);
base::FilePath GetOsIntegrationResourcesDirectoryForApp(
const base::FilePath& profile_path,
const std::string& app_id,
const GURL& url);
// Callback made when CreateShortcuts has finished trying to create the
// platform shortcuts indicating whether or not they were successfully
......
......@@ -10,7 +10,8 @@ namespace web_app {
TEST(WebAppShortcutTest, AppDirWithId) {
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 =
profile_path.AppendASCII("Web Applications").AppendASCII("_crx_123");
EXPECT_EQ(expected, result);
......@@ -18,8 +19,8 @@ TEST(WebAppShortcutTest, AppDirWithId) {
TEST(WebAppShortcutTest, AppDirWithUrl) {
base::FilePath profile_path(FILE_PATH_LITERAL("profile"));
base::FilePath result(GetWebAppDataDirectory(profile_path, std::string(),
GURL("http://example.com")));
base::FilePath result(GetOsIntegrationResourcesDirectoryForApp(
profile_path, std::string(), GURL("http://example.com")));
base::FilePath expected = profile_path.AppendASCII("Web Applications")
.AppendASCII("example.com")
.AppendASCII("http_80");
......
......@@ -375,9 +375,9 @@ void OnShortcutInfoLoadedForSetRelaunchDetails(
// 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.
base::FilePath web_app_path =
GetWebAppDataDirectory(shortcut_info->profile_path,
shortcut_info->extension_id, shortcut_info->url);
base::FilePath web_app_path = GetOsIntegrationResourcesDirectoryForApp(
shortcut_info->profile_path, shortcut_info->extension_id,
shortcut_info->url);
base::FilePath icon_file =
web_app::internals::GetIconFilePath(web_app_path, shortcut_info->title);
......
......@@ -47,8 +47,8 @@ base::FilePath GetWebAppsRootDirectory(Profile* profile);
// OS-independent manner. Use GetManifestResourcesDirectoryForApp function to
// get per-app manifest resources directory.
//
// To store OS-specific integration data, use GetWebAppDataDirectory declared in
// web_app_shortcut.h.
// To store OS-specific integration data, use
// GetOsIntegrationResourcesDirectoryForApp declared in web_app_shortcut.h.
base::FilePath GetManifestResourcesDirectory(
const base::FilePath& web_apps_root_directory);
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