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

Side by Side Diff: chrome/browser/extensions/bookmark_app_helper.h

Issue 899443002: Create bookmark apps at the end of the process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Hopefully last test Created 5 years, 10 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
OLDNEW
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>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "chrome/common/web_application_info.h" 15 #include "chrome/common/web_application_info.h"
16 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
18 #include "content/public/common/manifest.h" 18 #include "content/public/common/manifest.h"
19 19
20 class ExtensionService; 20 class ExtensionService;
21 class FaviconDownloader; 21 class FaviconDownloader;
22 class Profile;
22 class SkBitmap; 23 class SkBitmap;
23 24
24 namespace content { 25 namespace content {
25 class BrowserContext; 26 class BrowserContext;
26 class WebContents; 27 class WebContents;
27 } 28 }
28 29
29 namespace extensions { 30 namespace extensions {
30 class CrxInstaller; 31 class CrxInstaller;
31 class Extension; 32 class Extension;
32 33
33 // A helper class for creating bookmark apps from a WebContents. 34 // A helper class for creating bookmark apps from a WebContents.
34 class BookmarkAppHelper : public content::NotificationObserver { 35 class BookmarkAppHelper : public content::NotificationObserver {
35 public: 36 public:
36 typedef base::Callback<void(const Extension*, const WebApplicationInfo&)> 37 typedef base::Callback<void(const Extension*, const WebApplicationInfo&)>
37 CreateBookmarkAppCallback; 38 CreateBookmarkAppCallback;
38 39
39 // This helper class will create a bookmark app out of |web_app_info| and 40 // This helper class will create a bookmark app out of |web_app_info| and
40 // install it to |service|. Icons will be downloaded from the URLs in 41 // install it to |service|. Icons will be downloaded from the URLs in
41 // |web_app_info.icons| using |contents| if |contents| is not NULL. 42 // |web_app_info.icons| using |contents| if |contents| is not NULL.
42 // All existing icons from WebApplicationInfo will also be used. 43 // All existing icons from WebApplicationInfo will also be used.
calamity 2015/02/03 07:29:49 Mention that the dialog will be created.
benwells 2015/02/03 08:54:13 Done.
43 BookmarkAppHelper(ExtensionService* service, 44 BookmarkAppHelper(Profile* profile,
44 WebApplicationInfo web_app_info, 45 WebApplicationInfo web_app_info,
45 content::WebContents* contents); 46 content::WebContents* contents);
46 ~BookmarkAppHelper() override; 47 ~BookmarkAppHelper() override;
47 48
48 // Update the given WebApplicationInfo with information from the manifest. 49 // Update the given WebApplicationInfo with information from the manifest.
49 static void UpdateWebAppInfoFromManifest(const content::Manifest& manifest, 50 static void UpdateWebAppInfoFromManifest(const content::Manifest& manifest,
50 WebApplicationInfo* web_app_info); 51 WebApplicationInfo* web_app_info);
51 52
52 // This finds the closest not-smaller bitmap in |bitmaps| for each size in 53 // This finds the closest not-smaller bitmap in |bitmaps| for each size in
53 // |sizes| and resizes it to that size. This returns a map of sizes to bitmaps 54 // |sizes| and resizes it to that size. This returns a map of sizes to bitmaps
(...skipping 19 matching lines...) Expand all
73 74
74 // Called by the WebContents when the manifest has been downloaded. If there 75 // Called by the WebContents when the manifest has been downloaded. If there
75 // is no manifest, or the WebContents is destroyed before the manifest could 76 // is no manifest, or the WebContents is destroyed before the manifest could
76 // be downloaded, this is called with an empty manifest. 77 // be downloaded, this is called with an empty manifest.
77 void OnDidGetManifest(const content::Manifest& manifest); 78 void OnDidGetManifest(const content::Manifest& manifest);
78 79
79 // Performs post icon download tasks including installing the bookmark app. 80 // Performs post icon download tasks including installing the bookmark app.
80 void OnIconsDownloaded(bool success, 81 void OnIconsDownloaded(bool success,
81 const std::map<GURL, std::vector<SkBitmap> >& bitmaps); 82 const std::map<GURL, std::vector<SkBitmap> >& bitmaps);
82 83
84 // Called after the bubble has been shown, and the user has either accepted or
85 // the dialog was dismissed.
86 void OnBubbleCompleted(bool user_accepted,
87 const WebApplicationInfo& web_app_info);
88
89 // Called when the installation of the app is complete to perform the final
90 // installation steps.
91 void FinishInstallation(const Extension* extension);
92
83 // Overridden from content::NotificationObserver: 93 // Overridden from content::NotificationObserver:
84 void Observe(int type, 94 void Observe(int type,
85 const content::NotificationSource& source, 95 const content::NotificationSource& source,
86 const content::NotificationDetails& details) override; 96 const content::NotificationDetails& details) override;
87 97
98 // The profile that the bookmark app is being added to.
99 Profile* profile_;
100
88 // The web contents that the bookmark app is being created for. 101 // The web contents that the bookmark app is being created for.
89 content::WebContents* contents_; 102 content::WebContents* contents_;
90 103
91 // The WebApplicationInfo that the bookmark app is being created for. 104 // The WebApplicationInfo that the bookmark app is being created for.
92 WebApplicationInfo web_app_info_; 105 WebApplicationInfo web_app_info_;
93 106
94 // Called on app creation or failure. 107 // Called on app creation or failure.
95 CreateBookmarkAppCallback callback_; 108 CreateBookmarkAppCallback callback_;
96 109
97 // Downloads icons from the given WebApplicationInfo using the given 110 // Downloads icons from the given WebApplicationInfo using the given
(...skipping 19 matching lines...) Expand all
117 content::BrowserContext* browser_context, 130 content::BrowserContext* browser_context,
118 const extensions::Extension* extension, 131 const extensions::Extension* extension,
119 const base::Callback<void(const WebApplicationInfo&)> callback); 132 const base::Callback<void(const WebApplicationInfo&)> callback);
120 133
121 // Returns whether the given |url| is a valid bookmark app url. 134 // Returns whether the given |url| is a valid bookmark app url.
122 bool IsValidBookmarkAppUrl(const GURL& url); 135 bool IsValidBookmarkAppUrl(const GURL& url);
123 136
124 } // namespace extensions 137 } // namespace extensions
125 138
126 #endif // CHROME_BROWSER_EXTENSIONS_BOOKMARK_APP_HELPER_H_ 139 #endif // CHROME_BROWSER_EXTENSIONS_BOOKMARK_APP_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698