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 "content/public/browser/web_contents_observer.h" | 8 #include "content/public/browser/web_contents_observer.h" |
9 | 9 |
10 // Per-tab class to help manage metro pinning. | 10 // Per-tab class to help manage metro pinning. |
11 class MetroPinTabHelper : public content::WebContentsObserver { | 11 class MetroPinTabHelper : public content::WebContentsObserver { |
12 public: | 12 public: |
13 explicit MetroPinTabHelper(content::WebContents* tab_contents); | 13 // Objects implement this interface to get notified about changes in the |
14 // metro pinned state. | |
15 class Delegate { | |
sky
2012/07/20 16:46:41
Move this into its own file.
benwells
2012/07/23 08:03:43
Done.
| |
16 public: | |
17 // Notification that the pinned state of the current URL changed. | |
18 virtual void IsPinnedChanged(content::WebContents* source, bool pinned) = 0; | |
19 | |
20 protected: | |
21 virtual ~Delegate(); | |
22 }; | |
23 explicit MetroPinTabHelper(content::WebContents* web_contents); | |
14 virtual ~MetroPinTabHelper(); | 24 virtual ~MetroPinTabHelper(); |
15 | 25 |
16 bool is_pinned() const { return is_pinned_; } | 26 bool is_pinned() const { return is_pinned_; } |
17 | 27 |
28 void set_delegate(Delegate* delegate) { delegate_ = delegate; } | |
29 | |
18 void TogglePinnedToStartScreen(); | 30 void TogglePinnedToStartScreen(); |
19 | 31 |
20 // content::WebContentsObserver overrides: | 32 // content::WebContentsObserver overrides: |
21 virtual void DidNavigateMainFrame( | 33 virtual void DidNavigateMainFrame( |
22 const content::LoadCommittedDetails& details, | 34 const content::LoadCommittedDetails& details, |
23 const content::FrameNavigateParams& params) OVERRIDE; | 35 const content::FrameNavigateParams& params) OVERRIDE; |
24 | 36 |
25 private: | 37 private: |
26 // Queries the metro driver about the pinned state of the current URL. | 38 // Queries the metro driver about the pinned state of the current URL. |
27 void UpdatePinnedStateForCurrentURL(); | 39 void UpdatePinnedStateForCurrentURL(); |
28 | 40 |
41 // Update the pinned state and notify the delegate. | |
42 void SetIsPinned(bool is_pinned); | |
43 | |
29 // Whether the current URL is pinned to the metro start screen. | 44 // Whether the current URL is pinned to the metro start screen. |
30 bool is_pinned_; | 45 bool is_pinned_; |
31 | 46 |
47 // The delegate that we inform when the is_pinned_ state changes. | |
48 Delegate* delegate_; | |
49 | |
32 DISALLOW_COPY_AND_ASSIGN(MetroPinTabHelper); | 50 DISALLOW_COPY_AND_ASSIGN(MetroPinTabHelper); |
33 }; | 51 }; |
34 | 52 |
35 #endif // CHROME_BROWSER_UI_METRO_PIN_TAB_HELPER_H_ | 53 #endif // CHROME_BROWSER_UI_METRO_PIN_TAB_HELPER_H_ |
OLD | NEW |