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

Side by Side Diff: chrome/browser/android/shortcut_data_fetcher.h

Issue 1261143004: Implement manifest icon downloader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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_SHORTCUT_DATA_FETCHER_H_ 5 #ifndef CHROME_BROWSER_ANDROID_SHORTCUT_DATA_FETCHER_H_
6 #define CHROME_BROWSER_ANDROID_SHORTCUT_DATA_FETCHER_H_ 6 #define CHROME_BROWSER_ANDROID_SHORTCUT_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;
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 ShortcutDataFetcher 35 class ShortcutDataFetcher
35 : public base::RefCounted<ShortcutDataFetcher>, 36 : public base::RefCounted<ShortcutDataFetcher>,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 75
75 // Grabs the favicon for the current URL. 76 // Grabs the favicon for the current URL.
76 void FetchFavicon(); 77 void FetchFavicon();
77 void OnFaviconFetched( 78 void OnFaviconFetched(
78 const favicon_base::FaviconRawBitmapResult& bitmap_result); 79 const favicon_base::FaviconRawBitmapResult& bitmap_result);
79 80
80 // Creates the launcher icon from the given bitmap. 81 // Creates the launcher icon from the given bitmap.
81 void CreateLauncherIcon( 82 void CreateLauncherIcon(
82 const favicon_base::FaviconRawBitmapResult& bitmap_result); 83 const favicon_base::FaviconRawBitmapResult& bitmap_result);
83 84
84 // Callback run after an attempt to download manifest icon has been made. May
85 // kick off the download of a favicon if it failed.
86 void OnManifestIconFetched(int id,
87 int http_status_code,
88 const GURL& url,
89 const std::vector<SkBitmap>& bitmaps,
90 const std::vector<gfx::Size>& sizes);
91
92 // Notifies the observer that the shortcut data is all available. 85 // Notifies the observer that the shortcut data is all available.
93 void NotifyObserver(const SkBitmap& icon); 86 void NotifyObserver(const SkBitmap& icon);
94 87
95 Observer* weak_observer_; 88 Observer* weak_observer_;
96 89
97 bool is_waiting_for_web_application_info_; 90 bool is_waiting_for_web_application_info_;
98 bool is_icon_saved_; 91 bool is_icon_saved_;
99 bool is_ready_; 92 bool is_ready_;
100 base::Timer icon_timeout_timer_; 93 base::Timer icon_timeout_timer_;
101 ShortcutInfo shortcut_info_; 94 ShortcutInfo shortcut_info_;
102 95
103 // The icon must only be set on the UI thread for thread safety. 96 // The icon must only be set on the UI thread for thread safety.
104 SkBitmap shortcut_icon_; 97 SkBitmap shortcut_icon_;
105 base::CancelableTaskTracker favicon_task_tracker_; 98 base::CancelableTaskTracker favicon_task_tracker_;
106 99
100 scoped_ptr<ManifestIconDownloader> icon_downloader_;
101
107 const int preferred_icon_size_in_px_; 102 const int preferred_icon_size_in_px_;
108 static const int kPreferredIconSizeInDp; 103 static const int kPreferredIconSizeInDp;
109 104
110 friend class base::RefCounted<ShortcutDataFetcher>; 105 friend class base::RefCounted<ShortcutDataFetcher>;
111 DISALLOW_COPY_AND_ASSIGN(ShortcutDataFetcher); 106 DISALLOW_COPY_AND_ASSIGN(ShortcutDataFetcher);
112 }; 107 };
113 108
114 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_DATA_FETCHER_H_ 109 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_DATA_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698