| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_MAC_H_ | 5 #ifndef CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_MAC_H_ |
| 6 #define CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_MAC_H_ | 6 #define CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_MAC_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "chrome/browser/shell_integration.h" | |
| 15 #include "chrome/browser/web_applications/web_app.h" | 14 #include "chrome/browser/web_applications/web_app.h" |
| 16 | 15 |
| 17 namespace web_app { | 16 namespace web_app { |
| 18 | 17 |
| 19 // Returns the full path of the .app shim that would be created by | 18 // Returns the full path of the .app shim that would be created by |
| 20 // web_app::CreateShortcuts(). | 19 // web_app::CreateShortcuts(). |
| 21 base::FilePath GetAppInstallPath( | 20 base::FilePath GetAppInstallPath( |
| 22 const ShellIntegration::ShortcutInfo& shortcut_info); | 21 const web_app::ShortcutInfo& shortcut_info); |
| 23 | 22 |
| 24 // If necessary, launch the shortcut for an app. | 23 // If necessary, launch the shortcut for an app. |
| 25 void MaybeLaunchShortcut(const ShellIntegration::ShortcutInfo& shortcut_info); | 24 void MaybeLaunchShortcut(const web_app::ShortcutInfo& shortcut_info); |
| 26 | 25 |
| 27 // Creates a shortcut for a web application. The shortcut is a stub app | 26 // Creates a shortcut for a web application. The shortcut is a stub app |
| 28 // that simply loads the browser framework and runs the given app. | 27 // that simply loads the browser framework and runs the given app. |
| 29 class WebAppShortcutCreator { | 28 class WebAppShortcutCreator { |
| 30 public: | 29 public: |
| 31 // Creates a new shortcut based on information in |shortcut_info|. | 30 // Creates a new shortcut based on information in |shortcut_info|. |
| 32 // A copy of the shortcut is placed in |app_data_dir|. | 31 // A copy of the shortcut is placed in |app_data_dir|. |
| 33 // |chrome_bundle_id| is the CFBundleIdentifier of the Chrome browser bundle. | 32 // |chrome_bundle_id| is the CFBundleIdentifier of the Chrome browser bundle. |
| 34 WebAppShortcutCreator( | 33 WebAppShortcutCreator( |
| 35 const base::FilePath& app_data_dir, | 34 const base::FilePath& app_data_dir, |
| 36 const ShellIntegration::ShortcutInfo& shortcut_info); | 35 const web_app::ShortcutInfo& shortcut_info); |
| 37 | 36 |
| 38 virtual ~WebAppShortcutCreator(); | 37 virtual ~WebAppShortcutCreator(); |
| 39 | 38 |
| 40 // Returns the base name for the shortcut. | 39 // Returns the base name for the shortcut. |
| 41 base::FilePath GetShortcutBasename() const; | 40 base::FilePath GetShortcutBasename() const; |
| 42 | 41 |
| 43 // Returns a path to the Chrome Apps folder in the relevant applications | 42 // Returns a path to the Chrome Apps folder in the relevant applications |
| 44 // folder. E.g. ~/Applications or /Applications. | 43 // folder. E.g. ~/Applications or /Applications. |
| 45 virtual base::FilePath GetApplicationsDirname() const; | 44 virtual base::FilePath GetApplicationsDirname() const; |
| 46 | 45 |
| 47 // The full path to the app bundle under the relevant Applications folder. | 46 // The full path to the app bundle under the relevant Applications folder. |
| 48 base::FilePath GetApplicationsShortcutPath() const; | 47 base::FilePath GetApplicationsShortcutPath() const; |
| 49 | 48 |
| 50 // The full path to the app bundle under the profile folder. | 49 // The full path to the app bundle under the profile folder. |
| 51 base::FilePath GetInternalShortcutPath() const; | 50 base::FilePath GetInternalShortcutPath() const; |
| 52 | 51 |
| 53 bool CreateShortcuts(ShortcutCreationReason creation_reason, | 52 bool CreateShortcuts(ShortcutCreationReason creation_reason, |
| 54 ShellIntegration::ShortcutLocations creation_locations); | 53 web_app::ShortcutLocations creation_locations); |
| 55 void DeleteShortcuts(); | 54 void DeleteShortcuts(); |
| 56 bool UpdateShortcuts(); | 55 bool UpdateShortcuts(); |
| 57 | 56 |
| 58 protected: | 57 protected: |
| 59 // Returns a path to an app bundle with the given id. Or an empty path if no | 58 // Returns a path to an app bundle with the given id. Or an empty path if no |
| 60 // matching bundle was found. | 59 // matching bundle was found. |
| 61 // Protected and virtual so it can be mocked out for testing. | 60 // Protected and virtual so it can be mocked out for testing. |
| 62 virtual base::FilePath GetAppBundleById(const std::string& bundle_id) const; | 61 virtual base::FilePath GetAppBundleById(const std::string& bundle_id) const; |
| 63 | 62 |
| 64 // Show the bundle we just generated in the Finder. | 63 // Show the bundle we just generated in the Finder. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 94 bool UpdatePlist(const base::FilePath& app_path) const; | 93 bool UpdatePlist(const base::FilePath& app_path) const; |
| 95 | 94 |
| 96 // Updates the icon for the shortcut. | 95 // Updates the icon for the shortcut. |
| 97 bool UpdateIcon(const base::FilePath& app_path) const; | 96 bool UpdateIcon(const base::FilePath& app_path) const; |
| 98 | 97 |
| 99 // Path to the data directory for this app. For example: | 98 // Path to the data directory for this app. For example: |
| 100 // ~/Library/Application Support/Chromium/Default/Web Applications/_crx_abc/ | 99 // ~/Library/Application Support/Chromium/Default/Web Applications/_crx_abc/ |
| 101 base::FilePath app_data_dir_; | 100 base::FilePath app_data_dir_; |
| 102 | 101 |
| 103 // Information about the app. | 102 // Information about the app. |
| 104 ShellIntegration::ShortcutInfo info_; | 103 web_app::ShortcutInfo info_; |
| 105 | 104 |
| 106 DISALLOW_COPY_AND_ASSIGN(WebAppShortcutCreator); | 105 DISALLOW_COPY_AND_ASSIGN(WebAppShortcutCreator); |
| 107 }; | 106 }; |
| 108 | 107 |
| 109 } // namespace web_app | 108 } // namespace web_app |
| 110 | 109 |
| 111 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_MAC_H_ | 110 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_MAC_H_ |
| OLD | NEW |