OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_EXTENSIONS_BOOKMARK_APP_HELPER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_BOOKMARK_APP_HELPER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_BOOKMARK_APP_HELPER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_BOOKMARK_APP_HELPER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // This function updates |web_app_info| with the image data of any icon from | 91 // This function updates |web_app_info| with the image data of any icon from |
92 // |bitmap_map| that has a URL and size matching that in |web_app_info|, as | 92 // |bitmap_map| that has a URL and size matching that in |web_app_info|, as |
93 // well as adding any new images from |bitmap_map| that have no URL. | 93 // well as adding any new images from |bitmap_map| that have no URL. |
94 static void UpdateWebAppIconsWithoutChangingLinks( | 94 static void UpdateWebAppIconsWithoutChangingLinks( |
95 std::map<int, BookmarkAppHelper::BitmapAndSource> bitmap_map, | 95 std::map<int, BookmarkAppHelper::BitmapAndSource> bitmap_map, |
96 WebApplicationInfo* web_app_info); | 96 WebApplicationInfo* web_app_info); |
97 | 97 |
98 // Begins the asynchronous bookmark app creation. | 98 // Begins the asynchronous bookmark app creation. |
99 void Create(const CreateBookmarkAppCallback& callback); | 99 void Create(const CreateBookmarkAppCallback& callback); |
100 | 100 |
| 101 // Begins the asynchronous bookmark app creation from an app banner. |
| 102 void CreateFromAppBanner(const CreateBookmarkAppCallback& callback, |
| 103 const content::Manifest& manifest); |
| 104 |
101 private: | 105 private: |
102 friend class TestBookmarkAppHelper; | 106 friend class TestBookmarkAppHelper; |
103 | 107 |
104 // Called by the WebContents when the manifest has been downloaded. If there | 108 // Called by the WebContents when the manifest has been downloaded. If there |
105 // is no manifest, or the WebContents is destroyed before the manifest could | 109 // is no manifest, or the WebContents is destroyed before the manifest could |
106 // be downloaded, this is called with an empty manifest. | 110 // be downloaded, this is called with an empty manifest. |
107 void OnDidGetManifest(const content::Manifest& manifest); | 111 void OnDidGetManifest(const content::Manifest& manifest); |
108 | 112 |
109 // Performs post icon download tasks including installing the bookmark app. | 113 // Performs post icon download tasks including installing the bookmark app. |
110 void OnIconsDownloaded(bool success, | 114 void OnIconsDownloaded(bool success, |
111 const std::map<GURL, std::vector<SkBitmap> >& bitmaps); | 115 const std::map<GURL, std::vector<SkBitmap> >& bitmaps); |
112 | 116 |
113 // Called after the bubble has been shown, and the user has either accepted or | 117 // Called after the bubble has been shown, and the user has either accepted or |
114 // the dialog was dismissed. | 118 // the dialog was dismissed. |
115 void OnBubbleCompleted(bool user_accepted, | 119 void OnBubbleCompleted(bool user_accepted, |
116 const WebApplicationInfo& web_app_info); | 120 const WebApplicationInfo& web_app_info); |
117 | 121 |
118 // Called when the installation of the app is complete to perform the final | 122 // Called when the installation of the app is complete to perform the final |
119 // installation steps. | 123 // installation steps. |
120 void FinishInstallation(const Extension* extension); | 124 void FinishInstallation(const Extension* extension); |
121 | 125 |
122 // Overridden from content::NotificationObserver: | 126 // Overridden from content::NotificationObserver: |
123 void Observe(int type, | 127 void Observe(int type, |
124 const content::NotificationSource& source, | 128 const content::NotificationSource& source, |
125 const content::NotificationDetails& details) override; | 129 const content::NotificationDetails& details) override; |
126 | 130 |
| 131 // Display the bubble requesting user confirmation. Called when creating a |
| 132 // bookmark app via an add to shelf infobar. |
| 133 void ShowBookmarkAppBubble(); |
| 134 |
127 // The profile that the bookmark app is being added to. | 135 // The profile that the bookmark app is being added to. |
128 Profile* profile_; | 136 Profile* profile_; |
129 | 137 |
130 // The web contents that the bookmark app is being created for. | 138 // The web contents that the bookmark app is being created for. |
131 content::WebContents* contents_; | 139 content::WebContents* contents_; |
132 | 140 |
133 // The WebApplicationInfo that the bookmark app is being created for. | 141 // The WebApplicationInfo that the bookmark app is being created for. |
134 WebApplicationInfo web_app_info_; | 142 WebApplicationInfo web_app_info_; |
135 | 143 |
136 // Called on app creation or failure. | 144 // Called on app creation or failure. |
(...skipping 22 matching lines...) Expand all Loading... |
159 content::BrowserContext* browser_context, | 167 content::BrowserContext* browser_context, |
160 const extensions::Extension* extension, | 168 const extensions::Extension* extension, |
161 const base::Callback<void(const WebApplicationInfo&)> callback); | 169 const base::Callback<void(const WebApplicationInfo&)> callback); |
162 | 170 |
163 // Returns whether the given |url| is a valid bookmark app url. | 171 // Returns whether the given |url| is a valid bookmark app url. |
164 bool IsValidBookmarkAppUrl(const GURL& url); | 172 bool IsValidBookmarkAppUrl(const GURL& url); |
165 | 173 |
166 } // namespace extensions | 174 } // namespace extensions |
167 | 175 |
168 #endif // CHROME_BROWSER_EXTENSIONS_BOOKMARK_APP_HELPER_H_ | 176 #endif // CHROME_BROWSER_EXTENSIONS_BOOKMARK_APP_HELPER_H_ |
OLD | NEW |