OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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_METRO_PIN_TAB_HELPER_WIN_H_ | |
6 #define CHROME_BROWSER_UI_METRO_PIN_TAB_HELPER_WIN_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/macros.h" | |
11 #include "content/public/browser/web_contents_observer.h" | |
12 #include "content/public/browser/web_contents_user_data.h" | |
13 #include "content/public/common/favicon_url.h" | |
14 #include "third_party/skia/include/core/SkBitmap.h" | |
15 #include "ui/gfx/image/image_skia.h" | |
16 | |
17 namespace gfx { | |
18 class Size; | |
19 } | |
20 | |
21 // Per-tab class to help manage metro pinning. | |
22 class MetroPinTabHelper | |
23 : public content::WebContentsObserver, | |
24 public content::WebContentsUserData<MetroPinTabHelper> { | |
25 public: | |
26 ~MetroPinTabHelper() override; | |
27 | |
28 bool IsPinned() const; | |
29 | |
30 void TogglePinnedToStartScreen(); | |
31 | |
32 // content::WebContentsObserver overrides: | |
33 void DidNavigateMainFrame( | |
34 const content::LoadCommittedDetails& details, | |
35 const content::FrameNavigateParams& params) override; | |
36 void DidUpdateFaviconURL( | |
37 const std::vector<content::FaviconURL>& candidates) override; | |
38 | |
39 private: | |
40 // The FaviconDownloader class handles downloading the favicons when a page | |
41 // is being pinned. After it has downloaded any available favicons it will | |
42 // continue on with the page pinning action. | |
43 class FaviconChooser; | |
44 | |
45 explicit MetroPinTabHelper(content::WebContents* web_contents); | |
46 friend class content::WebContentsUserData<MetroPinTabHelper>; | |
47 | |
48 // Favicon download callback. | |
49 void DidDownloadFavicon(int id, | |
50 int http_status_code, | |
51 const GURL& image_url, | |
52 const std::vector<SkBitmap>& bitmaps, | |
53 const std::vector<gfx::Size>& original_bitmap_sizes); | |
54 | |
55 void UnPinPageFromStartScreen(); | |
56 | |
57 // Called by the |favicon_chooser_| when it has finished. | |
58 void FaviconDownloaderFinished(); | |
59 | |
60 // Candidate Favicon URLs for the current page. | |
61 std::vector<content::FaviconURL> favicon_url_candidates_; | |
62 | |
63 // The currently active FaviconChooser, if there is one. | |
64 scoped_ptr<FaviconChooser> favicon_chooser_; | |
65 | |
66 | |
67 DISALLOW_COPY_AND_ASSIGN(MetroPinTabHelper); | |
68 }; | |
69 | |
70 #endif // CHROME_BROWSER_UI_METRO_PIN_TAB_HELPER_WIN_H_ | |
OLD | NEW |