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

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

Issue 2064943002: Pass in extra parameters to WebApkBuilder#buildWebApkAsync() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' into webapk_manifest Created 4 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
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 // Converts the icon into one that can be used on the Android Home screen. 44 // 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 45 // |is_generated| is an out-param that indicates whether the icon was
46 // generated by Chrome. 46 // generated by Chrome.
47 virtual SkBitmap FinalizeLauncherIcon(const SkBitmap& icon, 47 virtual SkBitmap FinalizeLauncherIcon(const SkBitmap& icon,
48 const GURL& url, 48 const GURL& url,
49 bool* is_generated) = 0; 49 bool* is_generated) = 0;
50 50
51 // Called when all the data needed to create a shortcut is available. 51 // Called when all the data needed to create a shortcut is available.
52 virtual void OnDataAvailable(const ShortcutInfo& info, 52 virtual void OnDataAvailable(const ShortcutInfo& info,
53 const GURL& icon_url,
53 const SkBitmap& icon) = 0; 54 const SkBitmap& icon) = 0;
54 }; 55 };
55 56
56 // Initialize the fetcher by requesting the information about the page to the 57 // Initialize the fetcher by requesting the information about the page to the
57 // renderer process. The initialization is asynchronous and 58 // renderer process. The initialization is asynchronous and
58 // OnDidGetWebApplicationInfo is expected to be called when finished. 59 // OnDidGetWebApplicationInfo is expected to be called when finished.
59 AddToHomescreenDataFetcher(content::WebContents* web_contents, 60 AddToHomescreenDataFetcher(content::WebContents* web_contents,
60 int ideal_icon_size_in_dp, 61 int ideal_icon_size_in_dp,
61 int minimum_icon_size_in_dp, 62 int minimum_icon_size_in_dp,
62 int ideal_splash_image_size_in_dp, 63 int ideal_splash_image_size_in_dp,
63 int minimum_splash_image_size_in_dp, 64 int minimum_splash_image_size_in_dp,
64 Observer* observer); 65 Observer* observer);
65 66
66 // Returns a callback which fetches the splash screen image to be stored for 67 // Returns a callback which fetches the splash screen image to be stored for
67 // the webapp with the specified |id|. 68 // the webapp with the specified |id|.
68 base::Closure FetchSplashScreenImageCallback(const std::string& id); 69 base::Closure FetchSplashScreenImageCallback(const std::string& id);
69 70
70 // IPC message received when the initialization is finished. 71 // IPC message received when the initialization is finished.
71 void OnDidGetWebApplicationInfo(const WebApplicationInfo& web_app_info); 72 void OnDidGetWebApplicationInfo(const WebApplicationInfo& web_app_info);
72 73
73 // Called when the Manifest has been parsed, or if no Manifest was found. 74 // Called when the Manifest has been parsed, or if no Manifest was found.
74 void OnDidGetManifest(const content::Manifest& manifest); 75 void OnDidGetManifest(const content::Manifest& manifest);
75 76
76 // Accessors, etc. 77 // Accessors, etc.
77 void set_weak_observer(Observer* observer) { weak_observer_ = observer; } 78 void set_weak_observer(Observer* observer) { weak_observer_ = observer; }
78 bool is_ready() { return is_ready_; } 79 bool is_ready() { return is_ready_; }
79 ShortcutInfo& shortcut_info() { return shortcut_info_; } 80 ShortcutInfo& shortcut_info() { return shortcut_info_; }
81 const GURL& shortcut_icon_url() { return shortcut_icon_url_; }
80 const SkBitmap& shortcut_icon() { return shortcut_icon_; } 82 const SkBitmap& shortcut_icon() { return shortcut_icon_; }
81 83
82 // WebContentsObserver 84 // WebContentsObserver
83 bool OnMessageReceived(const IPC::Message& message) override; 85 bool OnMessageReceived(const IPC::Message& message) override;
84 86
85 private: 87 private:
86 ~AddToHomescreenDataFetcher() override; 88 ~AddToHomescreenDataFetcher() override;
87 89
88 // Grabs the favicon for the current URL. 90 // Grabs the favicon for the current URL.
89 void FetchFavicon(); 91 void FetchFavicon();
90 void OnFaviconFetched( 92 void OnFaviconFetched(
91 const favicon_base::FaviconRawBitmapResult& bitmap_result); 93 const favicon_base::FaviconRawBitmapResult& bitmap_result);
92 94
93 // Creates the launcher icon from the given bitmap. 95 // Creates the launcher icon from the given bitmap.
94 void CreateLauncherIcon( 96 void CreateLauncherIcon(
95 const favicon_base::FaviconRawBitmapResult& bitmap_result); 97 const favicon_base::FaviconRawBitmapResult& bitmap_result);
96 98
97 // Callback run after an attempt to download manifest icon has been made. May 99 // Callback run after an attempt to download manifest icon has been made. May
98 // kick off the download of a favicon if it failed (i.e. the bitmap is empty). 100 // kick off the download of a favicon if it failed (i.e. the bitmap is empty).
99 void OnManifestIconFetched(const SkBitmap& icon); 101 void OnManifestIconFetched(const GURL& icon_url, const SkBitmap& icon);
100 102
101 // Notifies the observer that the shortcut data is all available. 103 // Notifies the observer that the shortcut data is all available.
102 void NotifyObserver(const SkBitmap& icon, bool is_generated); 104 void NotifyObserver(const GURL& icon_url, const SkBitmap& icon);
103 105
104 // Looks up the original, online URL of the site requested. The URL from the 106 // Looks up the original, online URL of the site requested. The URL from the
105 // WebContents may be an offline page or a distilled article which is not 107 // WebContents may be an offline page or a distilled article which is not
106 // appropriate for a home screen shortcut. 108 // appropriate for a home screen shortcut.
107 GURL GetShortcutUrl(const GURL& original_url); 109 GURL GetShortcutUrl(const GURL& original_url);
108 110
109 Observer* weak_observer_; 111 Observer* weak_observer_;
110 112
111 bool is_waiting_for_web_application_info_; 113 bool is_waiting_for_web_application_info_;
112 bool is_icon_saved_; 114 bool is_icon_saved_;
113 bool is_ready_; 115 bool is_ready_;
114 base::Timer icon_timeout_timer_; 116 base::Timer icon_timeout_timer_;
115 ShortcutInfo shortcut_info_; 117 ShortcutInfo shortcut_info_;
116 GURL splash_screen_url_; 118 GURL splash_screen_url_;
117 119
118 // The icon must only be set on the UI thread for thread safety. 120 // The icon must only be set on the UI thread for thread safety.
121 GURL shortcut_icon_url_;
dominickn 2016/06/16 21:16:36 Instead of this being a member variable on the fet
119 SkBitmap shortcut_icon_; 122 SkBitmap shortcut_icon_;
120 base::CancelableTaskTracker favicon_task_tracker_; 123 base::CancelableTaskTracker favicon_task_tracker_;
121 124
122 const int ideal_icon_size_in_dp_; 125 const int ideal_icon_size_in_dp_;
123 const int minimum_icon_size_in_dp_; 126 const int minimum_icon_size_in_dp_;
124 const int ideal_splash_image_size_in_dp_; 127 const int ideal_splash_image_size_in_dp_;
125 const int minimum_splash_image_size_in_dp_; 128 const int minimum_splash_image_size_in_dp_;
126 129
127 friend class base::RefCounted<AddToHomescreenDataFetcher>; 130 friend class base::RefCounted<AddToHomescreenDataFetcher>;
128 DISALLOW_COPY_AND_ASSIGN(AddToHomescreenDataFetcher); 131 DISALLOW_COPY_AND_ASSIGN(AddToHomescreenDataFetcher);
129 }; 132 };
130 133
131 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ 134 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698