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 "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 FRIEND_TEST_ALL_PREFIXES(NewTabPageSyncHandlerBrowserTest, | 43 FRIEND_TEST_ALL_PREFIXES(NewTabPageSyncHandlerBrowserTest, |
44 ChangeSigninAllowedToFalse); | 44 ChangeSigninAllowedToFalse); |
45 | 45 |
46 enum MessageType { | 46 enum MessageType { |
47 HIDE, | 47 HIDE, |
48 SYNC_ERROR, | 48 SYNC_ERROR, |
49 SYNC_PROMO | 49 SYNC_PROMO |
50 }; | 50 }; |
51 // Helper to invoke the |syncMessageChanged| JS function on the new tab page. | 51 // Helper to invoke the |syncMessageChanged| JS function on the new tab page. |
52 virtual void SendSyncMessageToPage(MessageType type, | 52 virtual void SendSyncMessageToPage(MessageType type, |
53 std::string msg, std::string linktext); | 53 const std::string& msg, |
| 54 const std::string& linktext); |
54 | 55 |
55 // Helper to query the sync service and figure out what to send to | 56 // Helper to query the sync service and figure out what to send to |
56 // the page, and send it via SendSyncMessageToPage. | 57 // the page, and send it via SendSyncMessageToPage. |
57 // NOTE: precondition: sync must be enabled. | 58 // NOTE: precondition: sync must be enabled. |
58 void BuildAndSendSyncStatus(); | 59 void BuildAndSendSyncStatus(); |
59 | 60 |
60 // Helper to send a message to the NNTP which hides the sync section. | 61 // Helper to send a message to the NNTP which hides the sync section. |
61 void HideSyncStatusSection(); | 62 void HideSyncStatusSection(); |
62 | 63 |
63 // Helper to convert from a sync status message type to an NTP specific one. | 64 // Helper to convert from a sync status message type to an NTP specific one. |
64 static MessageType FromSyncStatusMessageType( | 65 static MessageType FromSyncStatusMessageType( |
65 sync_ui_util::MessageType type); | 66 sync_ui_util::MessageType type); |
66 | 67 |
67 // Cached pointer to ProfileSyncService. | 68 // Cached pointer to ProfileSyncService. |
68 ProfileSyncService* sync_service_; | 69 ProfileSyncService* sync_service_; |
69 | 70 |
70 PrefChangeRegistrar profile_pref_registrar_; | 71 PrefChangeRegistrar profile_pref_registrar_; |
71 | 72 |
72 // Used to make sure we don't register ourselves twice if the user refreshes | 73 // Used to make sure we don't register ourselves twice if the user refreshes |
73 // the new tab page. | 74 // the new tab page. |
74 bool waiting_for_initial_page_load_; | 75 bool waiting_for_initial_page_load_; |
75 | 76 |
76 DISALLOW_COPY_AND_ASSIGN(NewTabPageSyncHandler); | 77 DISALLOW_COPY_AND_ASSIGN(NewTabPageSyncHandler); |
77 }; | 78 }; |
78 | 79 |
79 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_SYNC_HANDLER_H_ | 80 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_SYNC_HANDLER_H_ |
OLD | NEW |