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