OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_WEBUI_NTP_NEW_TAB_PAGE_SYNC_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_SYNC_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_SYNC_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_SYNC_HANDLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
| 10 #include "chrome/browser/signin/signin_pref_observer.h" |
10 #include "chrome/browser/sync/profile_sync_service.h" | 11 #include "chrome/browser/sync/profile_sync_service.h" |
11 #include "chrome/browser/sync/sync_ui_util.h" | 12 #include "chrome/browser/sync/sync_ui_util.h" |
12 #include "content/public/browser/web_ui_message_handler.h" | 13 #include "content/public/browser/web_ui_message_handler.h" |
13 | 14 |
| 15 class SigninPrefObserver; |
| 16 |
14 namespace base { | 17 namespace base { |
15 class ListValue; | 18 class ListValue; |
16 } | 19 } |
17 | 20 |
18 // Sends sync-state changes to the New Tab Page for UI updating and forwards | 21 // Sends sync-state changes to the New Tab Page for UI updating and forwards |
19 // link clicks on the page to the sync service. | 22 // link clicks on the page to the sync service. |
20 class NewTabPageSyncHandler : public content::WebUIMessageHandler, | 23 class NewTabPageSyncHandler : public content::WebUIMessageHandler, |
21 public ProfileSyncServiceObserver { | 24 public ProfileSyncServiceObserver, |
| 25 public SigninPrefObserver { |
22 public: | 26 public: |
23 NewTabPageSyncHandler(); | 27 NewTabPageSyncHandler(); |
24 virtual ~NewTabPageSyncHandler(); | 28 virtual ~NewTabPageSyncHandler(); |
25 | 29 |
26 // WebUIMessageHandler implementation. | 30 // WebUIMessageHandler implementation. |
27 virtual void RegisterMessages() OVERRIDE; | 31 virtual void RegisterMessages() OVERRIDE; |
28 | 32 |
29 // Callback for "GetSyncMessage". | 33 // Callback for "GetSyncMessage". |
30 void HandleGetSyncMessage(const base::ListValue* args); | 34 void HandleGetSyncMessage(const base::ListValue* args); |
31 // Callback for "SyncLinkClicked". | 35 // Callback for "SyncLinkClicked". |
32 void HandleSyncLinkClicked(const base::ListValue* args); | 36 void HandleSyncLinkClicked(const base::ListValue* args); |
33 | 37 |
34 // ProfileSyncServiceObserver | 38 // ProfileSyncServiceObserver |
35 virtual void OnStateChanged() OVERRIDE; | 39 virtual void OnStateChanged() OVERRIDE; |
36 | 40 |
| 41 // SigninPrefObserver |
| 42 virtual void OnSigninAllowedPrefChange(bool signin_allowed) OVERRIDE; |
| 43 |
37 private: | 44 private: |
38 enum MessageType { | 45 enum MessageType { |
39 HIDE, | 46 HIDE, |
40 SYNC_ERROR, | 47 SYNC_ERROR, |
41 SYNC_PROMO | 48 SYNC_PROMO |
42 }; | 49 }; |
43 // Helper to invoke the |syncMessageChanged| JS function on the new tab page. | 50 // Helper to invoke the |syncMessageChanged| JS function on the new tab page. |
44 void SendSyncMessageToPage(MessageType type, | 51 void SendSyncMessageToPage(MessageType type, |
45 std::string msg, std::string linktext); | 52 std::string msg, std::string linktext); |
46 | 53 |
(...skipping 13 matching lines...) Expand all Loading... |
60 ProfileSyncService* sync_service_; | 67 ProfileSyncService* sync_service_; |
61 | 68 |
62 // Used to make sure we don't register ourselves twice if the user refreshes | 69 // Used to make sure we don't register ourselves twice if the user refreshes |
63 // the new tab page. | 70 // the new tab page. |
64 bool waiting_for_initial_page_load_; | 71 bool waiting_for_initial_page_load_; |
65 | 72 |
66 DISALLOW_COPY_AND_ASSIGN(NewTabPageSyncHandler); | 73 DISALLOW_COPY_AND_ASSIGN(NewTabPageSyncHandler); |
67 }; | 74 }; |
68 | 75 |
69 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_SYNC_HANDLER_H_ | 76 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_SYNC_HANDLER_H_ |
OLD | NEW |