| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifdef CHROME_PERSONALIZATION | 5 #ifdef CHROME_PERSONALIZATION |
| 6 | 6 |
| 7 #ifndef CHROME_BROWSER_DOM_UI_NEW_TAB_PAGE_SYNC_HANDLER_H_ | 7 #ifndef CHROME_BROWSER_DOM_UI_NEW_TAB_PAGE_SYNC_HANDLER_H_ |
| 8 #define CHROME_BROWSER_DOM_UI_NEW_TAB_PAGE_SYNC_HANDLER_H_ | 8 #define CHROME_BROWSER_DOM_UI_NEW_TAB_PAGE_SYNC_HANDLER_H_ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 // Callback for "GetSyncMessage". | 30 // Callback for "GetSyncMessage". |
| 31 void HandleGetSyncMessage(const Value* value); | 31 void HandleGetSyncMessage(const Value* value); |
| 32 // Callback for "SyncLinkClicked". | 32 // Callback for "SyncLinkClicked". |
| 33 void HandleSyncLinkClicked(const Value* value); | 33 void HandleSyncLinkClicked(const Value* value); |
| 34 | 34 |
| 35 // ProfileSyncServiceObserver | 35 // ProfileSyncServiceObserver |
| 36 virtual void OnStateChanged(); | 36 virtual void OnStateChanged(); |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 enum MessageType { |
| 40 HIDE, |
| 41 PROMOTION, |
| 42 SYNC_ERROR, |
| 43 }; |
| 39 // Helper to invoke the |syncMessageChanged| JS function on the new tab page. | 44 // Helper to invoke the |syncMessageChanged| JS function on the new tab page. |
| 40 void SendSyncMessageToPage(SyncStatusUIHelper::MessageType type, | 45 void SendSyncMessageToPage(MessageType type, |
| 41 std::string msg, std::string linktext); | 46 std::string msg, std::string linktext); |
| 42 | 47 |
| 43 // Helper to query the sync service and figure out what to send to | 48 // Helper to query the sync service and figure out what to send to |
| 44 // the page, and send it via SendSyncMessageToPage. | 49 // the page, and send it via SendSyncMessageToPage. |
| 45 // NOTE: precondition: sync must be enabled. | 50 // NOTE: precondition: sync must be enabled. |
| 46 void BuildAndSendSyncStatus(); | 51 void BuildAndSendSyncStatus(); |
| 47 | 52 |
| 48 // Helper to send a message to the NNTP which hides the sync section. | 53 // Helper to send a message to the NNTP which hides the sync section. |
| 49 void HideSyncStatusSection(); | 54 void HideSyncStatusSection(); |
| 50 | 55 |
| 56 // Helper to convert from a sync status message type to an NTP specific one. |
| 57 static MessageType FromSyncStatusMessageType( |
| 58 SyncStatusUIHelper::MessageType type); |
| 59 |
| 51 // Cached pointer to ProfileSyncService. | 60 // Cached pointer to ProfileSyncService. |
| 52 ProfileSyncService* sync_service_; | 61 ProfileSyncService* sync_service_; |
| 53 | 62 |
| 54 // Used to make sure we don't register ourselves twice if the user refreshes | 63 // Used to make sure we don't register ourselves twice if the user refreshes |
| 55 // the new tab page. | 64 // the new tab page. |
| 56 bool waiting_for_initial_page_load_; | 65 bool waiting_for_initial_page_load_; |
| 57 | 66 |
| 58 DISALLOW_COPY_AND_ASSIGN(NewTabPageSyncHandler); | 67 DISALLOW_COPY_AND_ASSIGN(NewTabPageSyncHandler); |
| 59 }; | 68 }; |
| 60 | 69 |
| 61 #endif // CHROME_BROWSER_DOM_UI_NEW_TAB_PAGE_SYNC_HANDLER_H_ | 70 #endif // CHROME_BROWSER_DOM_UI_NEW_TAB_PAGE_SYNC_HANDLER_H_ |
| 62 #endif // CHROME_PERSONALIZATION | 71 #endif // CHROME_PERSONALIZATION |
| OLD | NEW |