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