| 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> |
| 9 |
| 10 #include "chrome/common/favicon_url.h" |
| 8 #include "content/public/browser/web_contents_observer.h" | 11 #include "content/public/browser/web_contents_observer.h" |
| 9 #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" |
| 10 #include "ui/gfx/image/image_skia.h" | 14 #include "ui/gfx/image/image_skia.h" |
| 11 | 15 |
| 12 // Per-tab class to help manage metro pinning. | 16 // Per-tab class to help manage metro pinning. |
| 13 class MetroPinTabHelper | 17 class MetroPinTabHelper |
| 14 : public content::WebContentsObserver, | 18 : public content::WebContentsObserver, |
| 15 public content::WebContentsUserData<MetroPinTabHelper> { | 19 public content::WebContentsUserData<MetroPinTabHelper> { |
| 16 public: | 20 public: |
| 17 virtual ~MetroPinTabHelper(); | 21 virtual ~MetroPinTabHelper(); |
| 18 | 22 |
| 19 bool is_pinned() const { return is_pinned_; } | 23 bool is_pinned() const { return is_pinned_; } |
| 20 | 24 |
| 21 void TogglePinnedToStartScreen(); | 25 void TogglePinnedToStartScreen(); |
| 22 | 26 |
| 23 // content::WebContentsObserver overrides: | 27 // content::WebContentsObserver overrides: |
| 24 virtual void DidNavigateMainFrame( | 28 virtual void DidNavigateMainFrame( |
| 25 const content::LoadCommittedDetails& details, | 29 const content::LoadCommittedDetails& details, |
| 26 const content::FrameNavigateParams& params) OVERRIDE; | 30 const content::FrameNavigateParams& params) OVERRIDE; |
| 27 | 31 |
| 32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 33 |
| 28 private: | 34 private: |
| 29 // The TaskRunner handles running tasks for this helper on the FILE thread. | 35 // The PagePinner handles running tasks required to pin pages, such as |
| 30 class TaskRunner; | 36 // downloading favicons and generating tile icons. |
| 37 class PagePinner; |
| 31 | 38 |
| 32 explicit MetroPinTabHelper(content::WebContents* tab_contents); | 39 explicit MetroPinTabHelper(content::WebContents* tab_contents); |
| 33 friend class content::WebContentsUserData<MetroPinTabHelper>; | 40 friend class content::WebContentsUserData<MetroPinTabHelper>; |
| 34 | 41 |
| 42 // Message Handlers. |
| 43 void OnUpdateFaviconURL(int32 page_id, |
| 44 const std::vector<FaviconURL>& candidates); |
| 45 void OnDidDownloadFavicon(int id, |
| 46 const GURL& image_url, |
| 47 bool errored, |
| 48 int requested_size, |
| 49 const std::vector<SkBitmap>& bitmaps); |
| 50 |
| 35 // Queries the metro driver about the pinned state of the current URL. | 51 // Queries the metro driver about the pinned state of the current URL. |
| 36 void UpdatePinnedStateForCurrentURL(); | 52 void UpdatePinnedStateForCurrentURL(); |
| 37 | 53 |
| 38 void UnPinPageFromStartScreen(); | 54 void UnPinPageFromStartScreen(); |
| 39 | 55 |
| 40 // Whether the current URL is pinned to the metro start screen. | 56 // Whether the current URL is pinned to the metro start screen. |
| 41 bool is_pinned_; | 57 bool is_pinned_; |
| 42 | 58 |
| 43 // The task runner for the helper, which runs things for it on the FILE | 59 // The page pinner for the helper. |
| 44 // thread. | 60 scoped_refptr<PagePinner> page_pinner_; |
| 45 scoped_refptr<TaskRunner> task_runner_; | |
| 46 | 61 |
| 47 DISALLOW_COPY_AND_ASSIGN(MetroPinTabHelper); | 62 DISALLOW_COPY_AND_ASSIGN(MetroPinTabHelper); |
| 48 }; | 63 }; |
| 49 | 64 |
| 50 #endif // CHROME_BROWSER_UI_METRO_PIN_TAB_HELPER_WIN_H_ | 65 #endif // CHROME_BROWSER_UI_METRO_PIN_TAB_HELPER_WIN_H_ |
| OLD | NEW |