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

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

Issue 1261143004: Implement manifest icon downloader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix review comments Created 5 years, 4 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/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/task/cancelable_task_tracker.h" 9 #include "base/task/cancelable_task_tracker.h"
10 #include "base/timer/timer.h" 10 #include "base/timer/timer.h"
11 #include "chrome/browser/android/shortcut_info.h" 11 #include "chrome/browser/android/shortcut_info.h"
12 #include "chrome/common/web_application_info.h" 12 #include "chrome/common/web_application_info.h"
13 #include "components/favicon_base/favicon_types.h" 13 #include "components/favicon_base/favicon_types.h"
14 #include "content/public/browser/web_contents_observer.h" 14 #include "content/public/browser/web_contents_observer.h"
15 #include "content/public/common/manifest.h" 15 #include "content/public/common/manifest.h"
16 16
17 namespace content { 17 namespace content {
18 class WebContents; 18 class WebContents;
19 } // namespace content 19 } // namespace content
20 20
21 namespace IPC { 21 namespace IPC {
22 class Message; 22 class Message;
23 } 23 }
24 24
25 class GURL; 25 class GURL;
26 class ManifestIconDownloader;
mlamouri (slow - plz ping) 2015/08/21 13:34:18 nit: you no longer need this
Lalit Maganti 2015/08/21 13:45:51 Done.
26 27
27 // Aysnchronously fetches and processes data needed to create a shortcut for an 28 // Aysnchronously fetches and processes data needed to create a shortcut for an
28 // Android Home screen launcher. 29 // Android Home screen launcher.
29 // 30 //
30 // 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
31 // refcounted to prevent the class from being prematurely deleted. If the 32 // refcounted to prevent the class from being prematurely deleted. If the
32 // pointer to the ShortcutHelper becomes invalid, the pipeline should kill 33 // pointer to the ShortcutHelper becomes invalid, the pipeline should kill
33 // itself. 34 // itself.
34 class AddToHomescreenDataFetcher 35 class AddToHomescreenDataFetcher
35 : public base::RefCounted<AddToHomescreenDataFetcher>, 36 : public base::RefCounted<AddToHomescreenDataFetcher>,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 76
76 // Grabs the favicon for the current URL. 77 // Grabs the favicon for the current URL.
77 void FetchFavicon(); 78 void FetchFavicon();
78 void OnFaviconFetched( 79 void OnFaviconFetched(
79 const favicon_base::FaviconRawBitmapResult& bitmap_result); 80 const favicon_base::FaviconRawBitmapResult& bitmap_result);
80 81
81 // Creates the launcher icon from the given bitmap. 82 // Creates the launcher icon from the given bitmap.
82 void CreateLauncherIcon( 83 void CreateLauncherIcon(
83 const favicon_base::FaviconRawBitmapResult& bitmap_result); 84 const favicon_base::FaviconRawBitmapResult& bitmap_result);
84 85
85 // Callback run after an attempt to download manifest icon has been made. May 86 // Callback run after an attempt to download manifest icon has been made. May
86 // kick off the download of a favicon if it failed. 87 // kick off the download of a favicon if it failed (i.e. the bitmap is empty).
87 void OnManifestIconFetched(int id, 88 void OnManifestIconFetched(const SkBitmap& icon);
88 int http_status_code,
89 const GURL& url,
90 const std::vector<SkBitmap>& bitmaps,
91 const std::vector<gfx::Size>& sizes);
92 89
93 // Notifies the observer that the shortcut data is all available. 90 // Notifies the observer that the shortcut data is all available.
94 void NotifyObserver(const SkBitmap& icon); 91 void NotifyObserver(const SkBitmap& icon);
95 92
96 Observer* weak_observer_; 93 Observer* weak_observer_;
97 94
98 bool is_waiting_for_web_application_info_; 95 bool is_waiting_for_web_application_info_;
99 bool is_icon_saved_; 96 bool is_icon_saved_;
100 bool is_ready_; 97 bool is_ready_;
101 base::Timer icon_timeout_timer_; 98 base::Timer icon_timeout_timer_;
102 ShortcutInfo shortcut_info_; 99 ShortcutInfo shortcut_info_;
103 100
104 // The icon must only be set on the UI thread for thread safety. 101 // The icon must only be set on the UI thread for thread safety.
105 SkBitmap shortcut_icon_; 102 SkBitmap shortcut_icon_;
106 base::CancelableTaskTracker favicon_task_tracker_; 103 base::CancelableTaskTracker favicon_task_tracker_;
107 104
108 const int preferred_icon_size_in_px_; 105 const int preferred_icon_size_in_px_;
109 static const int kPreferredIconSizeInDp; 106 static const int kPreferredIconSizeInDp;
110 107
111 friend class base::RefCounted<AddToHomescreenDataFetcher>; 108 friend class base::RefCounted<AddToHomescreenDataFetcher>;
112 DISALLOW_COPY_AND_ASSIGN(AddToHomescreenDataFetcher); 109 DISALLOW_COPY_AND_ASSIGN(AddToHomescreenDataFetcher);
113 }; 110 };
114 111
115 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_ 112 #endif // CHROME_BROWSER_ANDROID_WEBAPPS_ADD_TO_HOMESCREEN_DATA_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698