OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_WEB_APPLICATIONS_HOSTED_APP_TAB_HELPER_H_ | |
6 #define CHROME_BROWSER_UI_WEB_APPLICATIONS_HOSTED_APP_TAB_HELPER_H_ | |
7 | |
8 #include <set> | |
9 #include <vector> | |
10 | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "content/public/browser/web_contents_observer.h" | |
13 #include "content/public/browser/web_contents_user_data.h" | |
14 #include "ui/gfx/image/image_family.h" | |
15 | |
16 class HostedAppTabHelperDelegate; | |
17 class SkBitmap; | |
18 struct WebApplicationInfo; | |
19 | |
20 namespace content { | |
21 struct FaviconURL; | |
22 } | |
23 | |
24 namespace gfx { | |
25 class Size; | |
26 } | |
27 | |
28 // Per-tab class to help manage hosted app taskbar icons. | |
29 class HostedAppTabHelper | |
30 : public content::WebContentsObserver, | |
31 public content::WebContentsUserData<HostedAppTabHelper> { | |
32 public: | |
33 virtual ~HostedAppTabHelper(); | |
34 | |
35 // Creates a hosted app for |web_app_info| using the current tab's icons. | |
36 void CreateHostedApp(const WebApplicationInfo& web_app_info); | |
37 | |
38 const gfx::ImageFamily& icon_family() { | |
39 return icon_family_; | |
40 } | |
41 | |
42 void set_fetch_icons_immediately(bool fetch_icons_immediately) { | |
43 fetch_icons_immediately_ = fetch_icons_immediately; | |
tapted
2013/11/11 08:52:57
nit: remove extra space after `=`
calamity
2013/11/13 06:37:14
Done.
| |
44 } | |
45 | |
46 void set_delegate(HostedAppTabHelperDelegate* delegate) { | |
47 delegate_ = delegate; | |
48 } | |
49 | |
50 private: | |
51 explicit HostedAppTabHelper(content::WebContents* web_contents); | |
52 friend class content::WebContentsUserData<HostedAppTabHelper>; | |
53 | |
54 // Fetches the icons in |favicon_url_candidates_|. Downloads are handled in | |
55 // DidDownloadFavicon. | |
56 void FetchIcons(); | |
57 | |
58 // Fetches icons for creating the hosted app from |favicon_url_candidates| and | |
59 // |web_app_info_.icons|. FinishCreateHostedApp() is called on completion. | |
60 void FetchIconsIfNecessaryForCreateHostedApp(); | |
61 | |
62 // Creates and installs the hosted app for |web_app_info_|. | |
63 void FinishCreateHostedApp(); | |
64 | |
65 // Icon download callback. | |
66 void DidDownloadFavicon(int id, | |
67 int http_status_code, | |
68 const GURL& image_url, | |
69 const std::vector<SkBitmap>& bitmaps, | |
70 const std::vector<gfx::Size>& original_bitmap_sizes); | |
71 | |
72 // content::WebContentsObserver overrides: | |
73 virtual void DidNavigateMainFrame( | |
74 const content::LoadCommittedDetails& details, | |
75 const content::FrameNavigateParams& params) OVERRIDE; | |
76 virtual void DidUpdateFaviconURL( | |
77 int32 page_id, | |
78 const std::vector<content::FaviconURL>& candidates) OVERRIDE; | |
79 | |
80 // Candidate favicon URLs for the current page. Repopulated each page load. | |
81 scoped_ptr<std::set<GURL> > favicon_url_candidates_; | |
82 | |
83 // The current page's icons. This stores . Populated by FetchIcons(). | |
tapted
2013/11/11 08:52:57
there's a sentence fragment in the comment here
calamity
2013/11/13 06:37:14
Done.
| |
84 gfx::ImageFamily icon_family_; | |
tapted
2013/11/11 08:52:57
nit: perhaps call this image_family_? (icon_family
calamity
2013/11/13 06:37:14
Done.
| |
85 | |
86 // Request ids of in-progress requests. | |
87 std::set<int> in_progress_requests_; | |
88 | |
89 // Info of a web app to create a hosted app for. | |
90 scoped_ptr<WebApplicationInfo> web_app_info_; | |
91 | |
92 // Whether we should fetch icons as soon as the |favicon_url_candidates_| are | |
93 // updated. | |
94 bool fetch_icons_immediately_; | |
95 | |
96 HostedAppTabHelperDelegate* delegate_; | |
97 | |
98 DISALLOW_COPY_AND_ASSIGN(HostedAppTabHelper); | |
99 }; | |
100 | |
101 #endif // CHROME_BROWSER_UI_WEB_APPLICATIONS_HOSTED_APP_TAB_HELPER_H_ | |
OLD | NEW |