Chromium Code Reviews| 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 "base/memory/scoped_ptr.h" | |
| 14 #include "chrome/browser/web_applications/web_app.h" | 15 #include "chrome/browser/web_applications/web_app.h" |
| 15 #include "extensions/common/manifest_handlers/file_handler_info.h" | 16 #include "extensions/common/manifest_handlers/file_handler_info.h" |
| 16 | 17 |
| 17 namespace base { | 18 namespace base { |
| 18 class CommandLine; | 19 class CommandLine; |
| 19 } | 20 } |
| 20 | 21 |
| 21 // Whether to enable update and launch of app shims in tests. (Normally shims | 22 // Whether to enable update and launch of app shims in tests. (Normally shims |
| 22 // are never created or launched in tests). Note that update only creates | 23 // are never created or launched in tests). Note that update only creates |
| 23 // internal shim bundles, i.e. it does not create new shims in ~/Applications. | 24 // internal shim bundles, i.e. it does not create new shims in ~/Applications. |
| 24 extern bool g_app_shims_allow_update_and_launch_in_tests; | 25 extern bool g_app_shims_allow_update_and_launch_in_tests; |
| 25 | 26 |
| 26 namespace web_app { | 27 namespace web_app { |
| 27 | 28 |
| 28 // Returns the full path of the .app shim that would be created by | 29 // Returns the full path of the .app shim that would be created by |
| 29 // CreateShortcuts(). | 30 // CreateShortcuts(). |
| 30 base::FilePath GetAppInstallPath(const ShortcutInfo& shortcut_info); | 31 base::FilePath GetAppInstallPath(const ShortcutInfo& shortcut_info); |
| 31 | 32 |
| 32 // If necessary, launch the shortcut for an app. | 33 // If necessary, launch the shortcut for an app. |
| 33 void MaybeLaunchShortcut(const ShortcutInfo& shortcut_info); | 34 void MaybeLaunchShortcut(scoped_ptr<ShortcutInfo> shortcut_info); |
| 34 | 35 |
| 35 // Rebuild the shortcut and relaunch it. | 36 // Rebuild the shortcut and relaunch it. |
| 36 bool MaybeRebuildShortcut(const base::CommandLine& command_line); | 37 bool MaybeRebuildShortcut(const base::CommandLine& command_line); |
| 37 | 38 |
| 38 // Reveals app shim in Finder given a profile and app. | 39 // Reveals app shim in Finder given a profile and app. |
| 39 // Calls RevealAppShimInFinderForAppOnFileThread and schedules it | 40 // Calls RevealAppShimInFinderForAppOnFileThread and schedules it |
| 40 // on the FILE thread. | 41 // on the FILE thread. |
| 41 void RevealAppShimInFinderForApp(Profile* profile, | 42 void RevealAppShimInFinderForApp(Profile* profile, |
| 42 const extensions::Extension* app); | 43 const extensions::Extension* app); |
| 43 | 44 |
| 44 // Creates a shortcut for a web application. The shortcut is a stub app | 45 // Creates a shortcut for a web application. The shortcut is a stub app |
| 45 // that simply loads the browser framework and runs the given app. | 46 // that simply loads the browser framework and runs the given app. |
| 46 class WebAppShortcutCreator { | 47 class WebAppShortcutCreator { |
| 47 public: | 48 public: |
| 48 // Creates a new shortcut based on information in |shortcut_info|. | 49 // Creates a new shortcut based on information in |shortcut_info|. |
| 49 // A copy of the shortcut is placed in |app_data_dir|. | 50 // A copy of the shortcut is placed in |app_data_dir|. |
| 50 // |chrome_bundle_id| is the CFBundleIdentifier of the Chrome browser bundle. | 51 // |chrome_bundle_id| is the CFBundleIdentifier of the Chrome browser bundle. |
| 52 // Retains a reference to |shortcut_info|; the ShortcutInfo object must | |
| 53 // outlive the WebAppShortcutCreator. | |
|
benwells
2015/04/01 02:01:33
This is unfortunate. Do you need much info from th
Matt Giuca
2015/04/01 03:31:47
Well, you do need |favicon|, which is the reason i
Matt Giuca
2015/04/01 03:54:26
As discussed, not doing this.
| |
| 51 WebAppShortcutCreator(const base::FilePath& app_data_dir, | 54 WebAppShortcutCreator(const base::FilePath& app_data_dir, |
| 52 const ShortcutInfo& shortcut_info, | 55 const ShortcutInfo& shortcut_info, |
| 53 const extensions::FileHandlersInfo& file_handlers_info); | 56 const extensions::FileHandlersInfo& file_handlers_info); |
| 54 | 57 |
| 55 virtual ~WebAppShortcutCreator(); | 58 virtual ~WebAppShortcutCreator(); |
| 56 | 59 |
| 57 // Returns the base name for the shortcut. | 60 // Returns the base name for the shortcut. |
| 58 base::FilePath GetShortcutBasename() const; | 61 base::FilePath GetShortcutBasename() const; |
| 59 | 62 |
| 60 // Returns a path to the Chrome Apps folder in the relevant applications | 63 // Returns a path to the Chrome Apps folder in the relevant applications |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 // Updates the plist inside |app_path| with information about the app. | 113 // Updates the plist inside |app_path| with information about the app. |
| 111 bool UpdatePlist(const base::FilePath& app_path) const; | 114 bool UpdatePlist(const base::FilePath& app_path) const; |
| 112 | 115 |
| 113 // Updates the icon for the shortcut. | 116 // Updates the icon for the shortcut. |
| 114 bool UpdateIcon(const base::FilePath& app_path) const; | 117 bool UpdateIcon(const base::FilePath& app_path) const; |
| 115 | 118 |
| 116 // Path to the data directory for this app. For example: | 119 // Path to the data directory for this app. For example: |
| 117 // ~/Library/Application Support/Chromium/Default/Web Applications/_crx_abc/ | 120 // ~/Library/Application Support/Chromium/Default/Web Applications/_crx_abc/ |
| 118 base::FilePath app_data_dir_; | 121 base::FilePath app_data_dir_; |
| 119 | 122 |
| 120 // Information about the app. | 123 // Information about the app. Owned by the caller of the constructor. |
| 121 ShortcutInfo info_; | 124 const ShortcutInfo& info_; |
|
benwells
2015/04/01 02:01:33
Maybe it would be better to use a raw pointer here
Matt Giuca
2015/04/01 03:31:47
OK, I'll do that if you agree that we should still
Matt Giuca
2015/04/01 03:54:26
Done.
| |
| 122 | 125 |
| 123 // The app's file handlers. | 126 // The app's file handlers. |
| 124 extensions::FileHandlersInfo file_handlers_info_; | 127 extensions::FileHandlersInfo file_handlers_info_; |
| 125 | 128 |
| 126 DISALLOW_COPY_AND_ASSIGN(WebAppShortcutCreator); | 129 DISALLOW_COPY_AND_ASSIGN(WebAppShortcutCreator); |
| 127 }; | 130 }; |
| 128 | 131 |
| 129 } // namespace web_app | 132 } // namespace web_app |
| 130 | 133 |
| 131 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_MAC_H_ | 134 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_MAC_H_ |
| OLD | NEW |