| 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/common/favicon_url.h" | 10 #include "chrome/common/favicon_url.h" |
| 11 #include "content/public/browser/web_contents_observer.h" | 11 #include "content/public/browser/web_contents_observer.h" |
| 12 #include "content/public/browser/web_contents_user_data.h" | 12 #include "content/public/browser/web_contents_user_data.h" |
| 13 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
| 14 #include "ui/gfx/image/image_skia.h" | 14 #include "ui/gfx/image/image_skia.h" |
| 15 | 15 |
| 16 // Per-tab class to help manage metro pinning. | 16 // Per-tab class to help manage metro pinning. |
| 17 class MetroPinTabHelper | 17 class MetroPinTabHelper |
| 18 : public content::WebContentsObserver, | 18 : public content::WebContentsObserver, |
| 19 public content::WebContentsUserData<MetroPinTabHelper> { | 19 public content::WebContentsUserData<MetroPinTabHelper> { |
| 20 public: | 20 public: |
| 21 virtual ~MetroPinTabHelper(); | 21 virtual ~MetroPinTabHelper(); |
| 22 | 22 |
| 23 bool is_pinned() const { return is_pinned_; } | 23 bool IsPinned() const; |
| 24 | 24 |
| 25 void TogglePinnedToStartScreen(); | 25 void TogglePinnedToStartScreen(); |
| 26 | 26 |
| 27 // content::WebContentsObserver overrides: | 27 // content::WebContentsObserver overrides: |
| 28 virtual void DidNavigateMainFrame( | 28 virtual void DidNavigateMainFrame( |
| 29 const content::LoadCommittedDetails& details, | 29 const content::LoadCommittedDetails& details, |
| 30 const content::FrameNavigateParams& params) OVERRIDE; | 30 const content::FrameNavigateParams& params) OVERRIDE; |
| 31 | 31 |
| 32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 // The FaviconDownloader class handles downloading the favicons when a page | 35 // The FaviconDownloader class handles downloading the favicons when a page |
| 36 // 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 |
| 37 // continue on with the page pinning action. | 37 // continue on with the page pinning action. |
| 38 class FaviconDownloader; | 38 class FaviconDownloader; |
| 39 | 39 |
| 40 explicit MetroPinTabHelper(content::WebContents* tab_contents); | 40 explicit MetroPinTabHelper(content::WebContents* tab_contents); |
| 41 friend class content::WebContentsUserData<MetroPinTabHelper>; | 41 friend class content::WebContentsUserData<MetroPinTabHelper>; |
| 42 | 42 |
| 43 // Message Handlers. | 43 // Message Handlers. |
| 44 void OnUpdateFaviconURL(int32 page_id, | 44 void OnUpdateFaviconURL(int32 page_id, |
| 45 const std::vector<FaviconURL>& candidates); | 45 const std::vector<FaviconURL>& candidates); |
| 46 void OnDidDownloadFavicon(int id, | 46 void OnDidDownloadFavicon(int id, |
| 47 const GURL& image_url, | 47 const GURL& image_url, |
| 48 bool errored, | 48 bool errored, |
| 49 int requested_size, | 49 int requested_size, |
| 50 const std::vector<SkBitmap>& bitmaps); | 50 const std::vector<SkBitmap>& bitmaps); |
| 51 | 51 |
| 52 // Queries the metro driver about the pinned state of the current URL. | |
| 53 void UpdatePinnedStateForCurrentURL(); | |
| 54 | |
| 55 void UnPinPageFromStartScreen(); | 52 void UnPinPageFromStartScreen(); |
| 56 | 53 |
| 57 // Called by the |favicon_downloader_| when it has finished. | 54 // Called by the |favicon_downloader_| when it has finished. |
| 58 void FaviconDownloaderFinished(); | 55 void FaviconDownloaderFinished(); |
| 59 | 56 |
| 60 // Whether the current URL is pinned to the metro start screen. | |
| 61 bool is_pinned_; | |
| 62 | |
| 63 // Candidate Favicon URLs for the current page. | 57 // Candidate Favicon URLs for the current page. |
| 64 std::vector<FaviconURL> favicon_url_candidates_; | 58 std::vector<FaviconURL> favicon_url_candidates_; |
| 65 | 59 |
| 66 // The currently active FaviconDownloader, if there is one. | 60 // The currently active FaviconDownloader, if there is one. |
| 67 scoped_ptr<FaviconDownloader> favicon_downloader_; | 61 scoped_ptr<FaviconDownloader> favicon_downloader_; |
| 68 | 62 |
| 69 DISALLOW_COPY_AND_ASSIGN(MetroPinTabHelper); | 63 DISALLOW_COPY_AND_ASSIGN(MetroPinTabHelper); |
| 70 }; | 64 }; |
| 71 | 65 |
| 72 #endif // CHROME_BROWSER_UI_METRO_PIN_TAB_HELPER_WIN_H_ | 66 #endif // CHROME_BROWSER_UI_METRO_PIN_TAB_HELPER_WIN_H_ |
| OLD | NEW |