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_H_ | 5 #ifndef CHROME_BROWSER_UI_METRO_PIN_TAB_HELPER_H_ |
6 #define CHROME_BROWSER_UI_METRO_PIN_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_UI_METRO_PIN_TAB_HELPER_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | |
8 #include "content/public/browser/web_contents_observer.h" | 9 #include "content/public/browser/web_contents_observer.h" |
9 #include "content/public/browser/web_contents_user_data.h" | 10 #include "content/public/browser/web_contents_user_data.h" |
11 #include "ui/gfx/image/image.h" | |
10 | 12 |
11 // Per-tab class to help manage metro pinning. | 13 // Per-tab class to help manage metro pinning. |
12 class MetroPinTabHelper | 14 class MetroPinTabHelper |
13 : public content::WebContentsObserver, | 15 : public content::WebContentsObserver, |
14 public content::WebContentsUserData<MetroPinTabHelper> { | 16 public content::WebContentsUserData<MetroPinTabHelper> { |
15 public: | 17 public: |
18 // The TaskRunner handles running tasks for this helper on the FILE thread. | |
sky
2012/10/22 21:18:00
Does this need to be public?
benwells
2012/10/23 10:34:25
No, made private.
| |
19 class TaskRunner : public base::RefCountedThreadSafe<TaskRunner> { | |
20 public: | |
21 TaskRunner(); | |
22 | |
23 void PinPageToStartScreen(const string16& title, | |
24 const string16& url, | |
25 const gfx::Image& image); | |
26 | |
27 private: | |
28 ~TaskRunner(); | |
29 | |
30 friend class base::RefCountedThreadSafe<TaskRunner>; | |
31 DISALLOW_COPY_AND_ASSIGN(TaskRunner); | |
32 }; | |
33 | |
16 virtual ~MetroPinTabHelper(); | 34 virtual ~MetroPinTabHelper(); |
17 | 35 |
18 bool is_pinned() const { return is_pinned_; } | 36 bool is_pinned() const { return is_pinned_; } |
19 | 37 |
20 void TogglePinnedToStartScreen(); | 38 void TogglePinnedToStartScreen(); |
21 | 39 |
22 // content::WebContentsObserver overrides: | 40 // content::WebContentsObserver overrides: |
23 virtual void DidNavigateMainFrame( | 41 virtual void DidNavigateMainFrame( |
24 const content::LoadCommittedDetails& details, | 42 const content::LoadCommittedDetails& details, |
25 const content::FrameNavigateParams& params) OVERRIDE; | 43 const content::FrameNavigateParams& params) OVERRIDE; |
26 | 44 |
27 private: | 45 private: |
28 explicit MetroPinTabHelper(content::WebContents* tab_contents); | 46 explicit MetroPinTabHelper(content::WebContents* tab_contents); |
29 friend class content::WebContentsUserData<MetroPinTabHelper>; | 47 friend class content::WebContentsUserData<MetroPinTabHelper>; |
30 | 48 |
31 // Queries the metro driver about the pinned state of the current URL. | 49 // Queries the metro driver about the pinned state of the current URL. |
32 void UpdatePinnedStateForCurrentURL(); | 50 void UpdatePinnedStateForCurrentURL(); |
33 | 51 |
52 void UnPinPageFromStartScreen(); | |
53 | |
34 // Whether the current URL is pinned to the metro start screen. | 54 // Whether the current URL is pinned to the metro start screen. |
35 bool is_pinned_; | 55 bool is_pinned_; |
36 | 56 |
57 // The task runner for the helper, which runs things for it on the FILE | |
58 // thread. | |
59 scoped_refptr<TaskRunner> task_runner_; | |
60 | |
37 DISALLOW_COPY_AND_ASSIGN(MetroPinTabHelper); | 61 DISALLOW_COPY_AND_ASSIGN(MetroPinTabHelper); |
38 }; | 62 }; |
39 | 63 |
40 #endif // CHROME_BROWSER_UI_METRO_PIN_TAB_HELPER_H_ | 64 #endif // CHROME_BROWSER_UI_METRO_PIN_TAB_HELPER_H_ |
OLD | NEW |