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 "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 const ShellIntegration::ShortcutInfo& shortcut_info); | 26 const ShellIntegration::ShortcutInfo& shortcut_info); |
| 27 | 27 |
| 28 // If necessary, launch the shortcut for an app. | 28 // If necessary, launch the shortcut for an app. |
| 29 void MaybeLaunchShortcut(const ShellIntegration::ShortcutInfo& shortcut_info); | 29 void MaybeLaunchShortcut(const ShellIntegration::ShortcutInfo& shortcut_info); |
| 30 | 30 |
| 31 // Creates a shortcut for a web application. The shortcut is a stub app | 31 // Creates a shortcut for a web application. The shortcut is a stub app |
| 32 // that simply loads the browser framework and runs the given app. | 32 // that simply loads the browser framework and runs the given app. |
| 33 class WebAppShortcutCreator { | 33 class WebAppShortcutCreator { |
| 34 public: | 34 public: |
| 35 // Creates a new shortcut based on information in |shortcut_info|. | 35 // Creates a new shortcut based on information in |shortcut_info|. |
| 36 // The shortcut stores its user data directory in |user_data_dir|. | 36 // A copy of the shortcut is placed in |web_app_path|. |
| 37 // |chrome_bundle_id| is the CFBundleIdentifier of the Chrome browser bundle. | 37 // |chrome_bundle_id| is the CFBundleIdentifier of the Chrome browser bundle. |
| 38 WebAppShortcutCreator( | 38 WebAppShortcutCreator( |
| 39 const base::FilePath& user_data_dir, | 39 const base::FilePath& web_app_path, |
|
benwells
2013/06/13 04:40:33
nit: web_app_path is a bad name. These aren't web
jackhou1
2013/06/14 03:31:27
Done.
| |
| 40 const ShellIntegration::ShortcutInfo& shortcut_info, | 40 const ShellIntegration::ShortcutInfo& shortcut_info, |
| 41 const string16& chrome_bundle_id); | 41 const string16& chrome_bundle_id); |
| 42 | 42 |
| 43 virtual ~WebAppShortcutCreator(); | 43 virtual ~WebAppShortcutCreator(); |
| 44 | 44 |
| 45 // Returns a path to the destination where the app should be written to. | 45 // Returns a path to the destination where the app should be written to. |
| 46 base::FilePath GetShortcutPath() const; | 46 base::FilePath GetShortcutPath() const; |
| 47 | 47 |
| 48 // Copies the app launcher template into place and fills in all relevant | 48 // Copies the app launcher template into place and fills in all relevant |
| 49 // information. | 49 // information. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 62 // Updates the icon for the shortcut. | 62 // Updates the icon for the shortcut. |
| 63 bool UpdateIcon(const base::FilePath& app_path) const; | 63 bool UpdateIcon(const base::FilePath& app_path) const; |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 FRIEND_TEST_ALL_PREFIXES(WebAppShortcutCreatorTest, UpdateIcon); | 66 FRIEND_TEST_ALL_PREFIXES(WebAppShortcutCreatorTest, UpdateIcon); |
| 67 | 67 |
| 68 // Updates the InfoPlist.string inside |app_path| with the display name for | 68 // Updates the InfoPlist.string inside |app_path| with the display name for |
| 69 // the app. | 69 // the app. |
| 70 bool UpdateDisplayName(const base::FilePath& app_path) const; | 70 bool UpdateDisplayName(const base::FilePath& app_path) const; |
| 71 | 71 |
| 72 // Path to the app's user data directory. For example: | |
| 73 // ~/Library/Application Support/Chromium/Default/Web Applications/_crx_abc/ | |
| 74 // Note, the user data directory is the parent of the profile directory. | |
| 75 base::FilePath user_data_dir_; | |
| 76 | |
| 77 // Returns the bundle identifier to use for this app bundle. | 72 // Returns the bundle identifier to use for this app bundle. |
| 78 // |plist| is a dictionary containg a copy of the template plist file to | 73 // |plist| is a dictionary containg a copy of the template plist file to |
| 79 // be used for creating the app bundle. | 74 // be used for creating the app bundle. |
| 80 NSString* GetBundleIdentifier(NSDictionary* plist) const; | 75 NSString* GetBundleIdentifier(NSDictionary* plist) const; |
| 81 | 76 |
| 82 // Show the bundle we just generated in the Finder. | 77 // Show the bundle we just generated in the Finder. |
| 83 virtual void RevealGeneratedBundleInFinder( | 78 virtual void RevealGeneratedBundleInFinder( |
| 84 const base::FilePath& generated_bundle) const; | 79 const base::FilePath& generated_bundle) const; |
| 85 | 80 |
| 81 // Path to the data directory for this app. For example: | |
| 82 // ~/Library/Application Support/Chromium/Default/Web Applications/_crx_abc/ | |
| 83 base::FilePath web_app_path_; | |
| 84 | |
| 86 // Information about the app. | 85 // Information about the app. |
| 87 ShellIntegration::ShortcutInfo info_; | 86 ShellIntegration::ShortcutInfo info_; |
| 88 | 87 |
| 89 // The CFBundleIdentifier of the Chrome browser bundle. | 88 // The CFBundleIdentifier of the Chrome browser bundle. |
| 90 string16 chrome_bundle_id_; | 89 string16 chrome_bundle_id_; |
| 91 }; | 90 }; |
| 92 | 91 |
| 93 } // namespace web_app | 92 } // namespace web_app |
| 94 | 93 |
| 95 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_MAC_H_ | 94 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_MAC_H_ |
| OLD | NEW |