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