| // Copyright 2018 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_BROWSER_WEB_APPLICATIONS_COMPONENTS_WEB_APP_UTILS_H_ |
| #define CHROME_BROWSER_WEB_APPLICATIONS_COMPONENTS_WEB_APP_UTILS_H_ |
| |
| #include <string> |
| |
| #include "chrome/browser/web_applications/components/web_app_id.h" |
| |
| class Profile; |
| |
| namespace base { |
| class FilePath; |
| } |
| |
| namespace content { |
| class BrowserContext; |
| } |
| |
| namespace web_app { |
| |
| // These functions return true if the WebApp System or its subset is allowed |
| // for a given profile. |
| // |profile| can be original profile or its secondary off-the-record profile. |
| // Returns false if |profile| is nullptr. |
| // |
| // Is main WebApp System allowed (WebAppProvider exists): |
| bool AreWebAppsEnabled(Profile* profile); |
| // Is user allowed to install web apps from UI: |
| bool AreWebAppsUserInstallable(Profile* profile); |
| |
| // Get BrowserContext to use for a WebApp KeyedService creation. |
| content::BrowserContext* GetBrowserContextForWebApps( |
| content::BrowserContext* context); |
| content::BrowserContext* GetBrowserContextForWebAppMetrics( |
| content::BrowserContext* context); |
| |
| // Returns a root directory for all Web Apps themed data. |
| // |
| // All the related directory getters always require |web_apps_root_directory| as |
| // a first argument to avoid directory confusions. |
| base::FilePath GetWebAppsRootDirectory(Profile* profile); |
| |
| // Returns a directory to store local cached manifest resources in |
| // OS-independent manner. Use GetManifestResourcesDirectoryForApp function to |
| // get per-app manifest resources directory. |
| // |
| // 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); |
| |
| // Returns per-app directory name to store manifest resources. |
| base::FilePath GetManifestResourcesDirectoryForApp( |
| const base::FilePath& web_apps_root_directory, |
| const AppId& app_id); |
| |
| base::FilePath GetWebAppsTempDirectory( |
| const base::FilePath& web_apps_root_directory); |
| |
| // The return value (profile categories) are used to report metrics. They are |
| // persisted to logs and should not be renamed. If new names are added, update |
| // tool/metrics/histograms/histograms.xml: "SystemWebAppProfileCategory". |
| std::string GetProfileCategoryForLogging(Profile* profile); |
| |
| // Returns true if the WebApp should have `web_app::WebAppChromeOsData()`. |
| bool IsChromeOs(); |
| |
| } // namespace web_app |
| |
| #endif // CHROME_BROWSER_WEB_APPLICATIONS_COMPONENTS_WEB_APP_UTILS_H_ |