| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/string16.h" |
| 11 #include "chrome/browser/shell_integration.h" | 12 #include "chrome/browser/shell_integration.h" |
| 12 | 13 |
| 14 #ifdef __OBJC__ |
| 15 @class NSDictionary; |
| 16 @class NSString; |
| 17 #else // __OBJC__ |
| 18 class NSDictionary; |
| 19 class NSString; |
| 20 #endif // __OBJC__ |
| 21 |
| 13 namespace web_app { | 22 namespace web_app { |
| 14 | 23 |
| 15 // Creates a shortcut for a web application. The shortcut is a stub app | 24 // Creates a shortcut for a web application. The shortcut is a stub app |
| 16 // that simply loads the browser framework and runs the given app. | 25 // that simply loads the browser framework and runs the given app. |
| 17 class WebAppShortcutCreator { | 26 class WebAppShortcutCreator { |
| 18 public: | 27 public: |
| 19 // Creates a new shortcut based on information in |shortcut_info|. | 28 // Creates a new shortcut based on information in |shortcut_info|. |
| 20 // The shortcut stores its user data directory in |user_data_dir|. | 29 // The shortcut stores its user data directory in |user_data_dir|. |
| 21 explicit WebAppShortcutCreator( | 30 // |chrome_bundle_id| is the CFBundleIdentifier of the Chrome browser bundle. |
| 31 WebAppShortcutCreator( |
| 22 const FilePath& user_data_dir, | 32 const FilePath& user_data_dir, |
| 23 const ShellIntegration::ShortcutInfo& shortcut_info); | 33 const ShellIntegration::ShortcutInfo& shortcut_info, |
| 34 const string16& chrome_bundle_id); |
| 35 |
| 24 virtual ~WebAppShortcutCreator(); | 36 virtual ~WebAppShortcutCreator(); |
| 25 | 37 |
| 26 // Creates a shortcut. | 38 // Copies the app launcher template into place and fills in all relevant |
| 39 // information. |
| 27 bool CreateShortcut(); | 40 bool CreateShortcut(); |
| 28 | 41 |
| 29 protected: | 42 protected: |
| 30 // Returns a path to the app loader. | 43 // Returns a path to the app loader. |
| 31 FilePath GetAppLoaderPath() const; | 44 FilePath GetAppLoaderPath() const; |
| 32 | 45 |
| 33 // Returns a path to the destination where the app should be written to. | 46 // Returns a path to the destination where the app should be written to. |
| 34 virtual FilePath GetDestinationPath(const FilePath& app_file_name) const; | 47 virtual FilePath GetDestinationPath(const FilePath& app_file_name) const; |
| 35 | 48 |
| 36 // Updates the plist inside |app_path| with information about the app. | 49 // Updates the plist inside |app_path| with information about the app. |
| 37 bool UpdatePlist(const FilePath& app_path) const; | 50 bool UpdatePlist(const FilePath& app_path) const; |
| 38 | 51 |
| 39 // Updates the icon for the shortcut. | 52 // Updates the icon for the shortcut. |
| 40 bool UpdateIcon(const FilePath& app_path) const; | 53 bool UpdateIcon(const FilePath& app_path) const; |
| 41 | 54 |
| 42 private: | 55 private: |
| 43 FRIEND_TEST_ALL_PREFIXES(WebAppShortcutCreatorTest, UpdateIcon); | 56 FRIEND_TEST_ALL_PREFIXES(WebAppShortcutCreatorTest, UpdateIcon); |
| 44 | 57 |
| 45 // Path to the app's user data directory. For example: | 58 // Path to the app's user data directory. For example: |
| 46 // ~/Library/Application Support/Chromium/Default/Web Applications/_crx_abc/ | 59 // ~/Library/Application Support/Chromium/Default/Web Applications/_crx_abc/ |
| 47 // Note, the user data directory is the parent of the profile directory. | 60 // Note, the user data directory is the parent of the profile directory. |
| 48 FilePath user_data_dir_; | 61 FilePath user_data_dir_; |
| 49 | 62 |
| 63 // Returns the bundle identifier to use for this app bundle. |
| 64 // |plist| is a dictionary containg a copy of the template plist file to |
| 65 // be used for creating the app bundle. |
| 66 NSString* GetBundleIdentifier(NSDictionary* plist) const; |
| 67 |
| 50 // Information about the app. | 68 // Information about the app. |
| 51 ShellIntegration::ShortcutInfo info_; | 69 ShellIntegration::ShortcutInfo info_; |
| 70 |
| 71 // The CFBundleIdentifier of the Chrome browser bundle. |
| 72 string16 chrome_bundle_id_; |
| 52 }; | 73 }; |
| 53 | 74 |
| 54 } // namespace web_app | 75 } // namespace web_app |
| 55 | 76 |
| 56 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_MAC_H_ | 77 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_MAC_H_ |
| OLD | NEW |