Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: chrome/browser/web_applications/web_app_mac.h

Issue 15724019: Recreate shortcuts on app update. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Include profile dir in bundle id. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <vector>
9
8 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
9 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
10 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
11 #include "chrome/browser/shell_integration.h" 13 #include "chrome/browser/shell_integration.h"
12 14
13 #ifdef __OBJC__ 15 #ifdef __OBJC__
14 @class NSDictionary; 16 @class NSDictionary;
15 @class NSString; 17 @class NSString;
16 #else // __OBJC__ 18 #else // __OBJC__
17 class NSDictionary; 19 class NSDictionary;
(...skipping 13 matching lines...) Expand all
31 // Creates a shortcut for a web application. The shortcut is a stub app 33 // 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. 34 // that simply loads the browser framework and runs the given app.
33 class WebAppShortcutCreator { 35 class WebAppShortcutCreator {
34 public: 36 public:
35 // Creates a new shortcut based on information in |shortcut_info|. 37 // Creates a new shortcut based on information in |shortcut_info|.
36 // The shortcut stores its user data directory in |user_data_dir|. 38 // The shortcut stores its user data directory in |user_data_dir|.
37 // |chrome_bundle_id| is the CFBundleIdentifier of the Chrome browser bundle. 39 // |chrome_bundle_id| is the CFBundleIdentifier of the Chrome browser bundle.
38 WebAppShortcutCreator( 40 WebAppShortcutCreator(
39 const base::FilePath& user_data_dir, 41 const base::FilePath& user_data_dir,
40 const ShellIntegration::ShortcutInfo& shortcut_info, 42 const ShellIntegration::ShortcutInfo& shortcut_info,
41 const string16& chrome_bundle_id); 43 const std::string& chrome_bundle_id);
42 44
43 virtual ~WebAppShortcutCreator(); 45 virtual ~WebAppShortcutCreator();
44 46
45 // Returns a path to the destination where the app should be written to. 47 // Returns the base name for the shortcut.
46 base::FilePath GetShortcutPath() const; 48 base::FilePath GetShortcutName() const;
47 49
48 // Copies the app launcher template into place and fills in all relevant 50 // Returns a path to the Chrome Apps folder.
tapted 2013/06/18 06:54:59 maybe mention that it's a subfolder of /Applicatio
jackhou1 2013/06/18 08:32:40 Done.
49 // information. 51 virtual base::FilePath GetDestinationPath() const;
52
53 // Creates shortcuts for the given shortcut info.
tapted 2013/06/18 06:54:59 I don't think these comments on FooShortcut[s]() a
jackhou1 2013/06/18 08:32:40 Removed.
50 bool CreateShortcut(); 54 bool CreateShortcut();
tapted 2013/06/18 06:54:59 make this plural to be consistent? (also, it's tru
jackhou1 2013/06/18 08:32:40 Done.
51 55
56 // Deletes shortcuts for the given shortcut info.
57 void DeleteShortcuts();
58
59 // Updates shortcuts for the given shortcut info.
60 bool UpdateShortcuts();
61
52 protected: 62 protected:
53 // Returns a path to the app loader. 63 // Returns a path to the app loader.
54 base::FilePath GetAppLoaderPath() const; 64 base::FilePath GetAppLoaderPath() const;
55 65
56 // Returns a path to the destination where the app should be written to.
57 virtual base::FilePath GetDestinationPath() const;
58
59 // Updates the plist inside |app_path| with information about the app. 66 // Updates the plist inside |app_path| with information about the app.
60 bool UpdatePlist(const base::FilePath& app_path) const; 67 bool UpdatePlist(const base::FilePath& app_path) const;
61 68
62 // Updates the icon for the shortcut. 69 // Updates the icon for the shortcut.
63 bool UpdateIcon(const base::FilePath& app_path) const; 70 bool UpdateIcon(const base::FilePath& app_path) const;
64 71
72 // Returns a path to an app bundle with the given id. Or an empty path if no
73 // matching bundle was found.
74 // Here so it can be mocked out for testing.
tapted 2013/06/18 06:54:59 nit: "Here" -> Protected and virtual
jackhou1 2013/06/18 08:32:40 Done.
75 virtual base::FilePath GetAppBundleById(const std::string& bundle_id) const;
76
65 private: 77 private:
66 FRIEND_TEST_ALL_PREFIXES(WebAppShortcutCreatorTest, UpdateIcon); 78 FRIEND_TEST_ALL_PREFIXES(WebAppShortcutCreatorTest, UpdateIcon);
79 FRIEND_TEST_ALL_PREFIXES(WebAppShortcutCreatorTest, UpdateShortcuts);
80
81 // Copies the app loader template into a temporary directory and fills in all
82 // relevant information.
83 bool BuildShortcut(const base::FilePath& staging_path) const;
84
85 // Builds a shortcut and copies it into the given destination folders.
86 bool CreateShortcutsIn(const std::vector<base::FilePath>& folders) const;
67 87
68 // Updates the InfoPlist.string inside |app_path| with the display name for 88 // Updates the InfoPlist.string inside |app_path| with the display name for
69 // the app. 89 // the app.
70 bool UpdateDisplayName(const base::FilePath& app_path) const; 90 bool UpdateDisplayName(const base::FilePath& app_path) const;
71 91
72 // Path to the app's user data directory. For example: 92 // Path to the app's user data directory. For example:
73 // ~/Library/Application Support/Chromium/Default/Web Applications/_crx_abc/ 93 // ~/Library/Application Support/Chromium/Default/Web Applications/_crx_abc/
74 // Note, the user data directory is the parent of the profile directory. 94 // Note, the user data directory is the parent of the profile directory.
75 base::FilePath user_data_dir_; 95 base::FilePath user_data_dir_;
tapted 2013/06/18 06:54:59 has the change that moved this landed?. rebase?
jackhou1 2013/06/18 08:32:40 Done.
76 96
77 // Returns the bundle identifier to use for this app bundle. 97 // Returns the bundle identifier to use for this app bundle.
78 // |plist| is a dictionary containg a copy of the template plist file to 98 std::string GetBundleIdentifier() const;
79 // be used for creating the app bundle.
80 NSString* GetBundleIdentifier(NSDictionary* plist) const;
81 99
82 // Show the bundle we just generated in the Finder. 100 // Show the bundle we just generated in the Finder.
83 virtual void RevealGeneratedBundleInFinder( 101 virtual void RevealAppShimInFinder() const;
84 const base::FilePath& generated_bundle) const;
85 102
86 // Information about the app. 103 // Information about the app.
87 ShellIntegration::ShortcutInfo info_; 104 ShellIntegration::ShortcutInfo info_;
88 105
89 // The CFBundleIdentifier of the Chrome browser bundle. 106 // The CFBundleIdentifier of the Chrome browser bundle.
90 string16 chrome_bundle_id_; 107 std::string chrome_bundle_id_;
91 }; 108 };
92 109
93 } // namespace web_app 110 } // namespace web_app
94 111
95 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_MAC_H_ 112 #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_MAC_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/web_applications/web_app_mac.mm » ('j') | chrome/browser/web_applications/web_app_mac.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698