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

Side by Side Diff: chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h

Issue 2124513002: Introduce ManifestUpgradeDetector for WebAPK to detect web manifest changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Introduce manifest upgrade detector. Created 4 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ 5 #ifndef CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_
6 #define CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ 6 #define CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_
7 7
8 #include "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/task/cancelable_task_tracker.h" 10 #include "base/task/cancelable_task_tracker.h"
(...skipping 20 matching lines...) Expand all
31 // Because of the various asynchronous calls made by this class, it is 31 // Because of the various asynchronous calls made by this class, it is
32 // refcounted to prevent the class from being prematurely deleted. If the 32 // refcounted to prevent the class from being prematurely deleted. If the
33 // pointer to the ShortcutHelper becomes invalid, the pipeline should kill 33 // pointer to the ShortcutHelper becomes invalid, the pipeline should kill
34 // itself. 34 // itself.
35 class AddToHomescreenDataFetcher 35 class AddToHomescreenDataFetcher
36 : public base::RefCounted<AddToHomescreenDataFetcher>, 36 : public base::RefCounted<AddToHomescreenDataFetcher>,
37 public content::WebContentsObserver { 37 public content::WebContentsObserver {
38 public: 38 public:
39 class Observer { 39 class Observer {
40 public: 40 public:
41 virtual void OnDidHasManifest(bool has_manifest) = 0;
42
41 // Called when the title of the page is available. 43 // Called when the title of the page is available.
42 virtual void OnUserTitleAvailable(const base::string16& title) = 0; 44 virtual void OnUserTitleAvailable(const base::string16& title) = 0;
43 45
44 // Converts the icon into one that can be used on the Android Home screen. 46 // Converts the icon into one that can be used on the Android Home screen.
45 // |is_generated| is an out-param that indicates whether the icon was 47 // |is_generated| is an out-param that indicates whether the icon was
46 // generated by Chrome. 48 // generated by Chrome.
47 virtual SkBitmap FinalizeLauncherIcon(const SkBitmap& icon, 49 virtual SkBitmap FinalizeLauncherIcon(const SkBitmap& icon,
48 const GURL& url, 50 const GURL& url,
49 bool* is_generated) = 0; 51 bool* is_generated) = 0;
50 52
51 // Called when all the data needed to create a shortcut is available. 53 // Called when all the data needed to create a shortcut is available.
52 virtual void OnDataAvailable(const ShortcutInfo& info, 54 virtual void OnDataAvailable(const ShortcutInfo& info,
53 const SkBitmap& icon) = 0; 55 const SkBitmap& icon,
56 const std::vector<std::string>& icon_urls) = 0;
54 }; 57 };
55 58
56 // Initialize the fetcher by requesting the information about the page to the 59 // Initialize the fetcher by requesting the information about the page to the
57 // renderer process. The initialization is asynchronous and 60 // renderer process. The initialization is asynchronous and
58 // OnDidGetWebApplicationInfo is expected to be called when finished. 61 // OnDidGetWebApplicationInfo is expected to be called when finished.
59 AddToHomescreenDataFetcher(content::WebContents* web_contents, 62 AddToHomescreenDataFetcher(content::WebContents* web_contents,
60 int ideal_icon_size_in_dp, 63 int ideal_icon_size_in_dp,
61 int minimum_icon_size_in_dp, 64 int minimum_icon_size_in_dp,
62 int ideal_splash_image_size_in_dp, 65 int ideal_splash_image_size_in_dp,
63 int minimum_splash_image_size_in_dp, 66 int minimum_splash_image_size_in_dp,
67 bool stop_fetch_when_no_manifest,
64 Observer* observer); 68 Observer* observer);
65 69
70 // Replaces the WebContents that is being observed.
71 void ReplaceWebContents(content::WebContents* web_contents);
72
66 // Returns a callback which fetches the splash screen image to be stored for 73 // Returns a callback which fetches the splash screen image to be stored for
67 // the webapp with the specified |id|. 74 // the webapp with the specified |id|.
68 base::Closure FetchSplashScreenImageCallback(const std::string& id); 75 base::Closure FetchSplashScreenImageCallback(const std::string& id);
69 76
70 // IPC message received when the initialization is finished. 77 // IPC message received when the initialization is finished.
71 void OnDidGetWebApplicationInfo(const WebApplicationInfo& web_app_info); 78 void OnDidGetWebApplicationInfo(const WebApplicationInfo& web_app_info);
72 79
80 void OnDidHasManifest(bool has_manifest);
81
73 // Called when the Manifest has been parsed, or if no Manifest was found. 82 // Called when the Manifest has been parsed, or if no Manifest was found.
74 void OnDidGetManifest(const GURL& manifest_url, 83 void OnDidGetManifest(const GURL& manifest_url,
75 const content::Manifest& manifest); 84 const content::Manifest& manifest);
76 85
77 // Accessors, etc. 86 // Accessors, etc.
78 void set_weak_observer(Observer* observer) { weak_observer_ = observer; } 87 void set_weak_observer(Observer* observer) { weak_observer_ = observer; }
79 bool is_ready() { return is_ready_; } 88 bool is_ready() { return is_ready_; }
80 ShortcutInfo& shortcut_info() { return shortcut_info_; } 89 ShortcutInfo& shortcut_info() { return shortcut_info_; }
81 const SkBitmap& shortcut_icon() { return shortcut_icon_; } 90 const SkBitmap& shortcut_icon() { return shortcut_icon_; }
82 91
(...skipping 26 matching lines...) Expand all
109 118
110 Observer* weak_observer_; 119 Observer* weak_observer_;
111 120
112 bool is_waiting_for_web_application_info_; 121 bool is_waiting_for_web_application_info_;
113 bool is_icon_saved_; 122 bool is_icon_saved_;
114 bool is_ready_; 123 bool is_ready_;
115 base::Timer icon_timeout_timer_; 124 base::Timer icon_timeout_timer_;
116 ShortcutInfo shortcut_info_; 125 ShortcutInfo shortcut_info_;
117 GURL splash_screen_url_; 126 GURL splash_screen_url_;
118 127
128 std::vector<std::string> icon_urls_;
119 // The icon must only be set on the UI thread for thread safety. 129 // The icon must only be set on the UI thread for thread safety.
120 SkBitmap shortcut_icon_; 130 SkBitmap shortcut_icon_;
121 base::CancelableTaskTracker favicon_task_tracker_; 131 base::CancelableTaskTracker favicon_task_tracker_;
122 132
123 const int ideal_icon_size_in_dp_; 133 const int ideal_icon_size_in_dp_;
124 const int minimum_icon_size_in_dp_; 134 const int minimum_icon_size_in_dp_;
125 const int ideal_splash_image_size_in_dp_; 135 const int ideal_splash_image_size_in_dp_;
126 const int minimum_splash_image_size_in_dp_; 136 const int minimum_splash_image_size_in_dp_;
127 137
138 const bool stop_fetch_when_no_manifest_;
139
128 friend class base::RefCounted<AddToHomescreenDataFetcher>; 140 friend class base::RefCounted<AddToHomescreenDataFetcher>;
129 DISALLOW_COPY_AND_ASSIGN(AddToHomescreenDataFetcher); 141 DISALLOW_COPY_AND_ASSIGN(AddToHomescreenDataFetcher);
130 }; 142 };
131 143
132 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ 144 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698