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, | |
40 SYNC_ERROR, | 39 SYNC_ERROR, |
41 }; | 40 }; |
42 // Helper to invoke the |syncMessageChanged| JS function on the new tab page. | 41 // Helper to invoke the |syncMessageChanged| JS function on the new tab page. |
43 void SendSyncMessageToPage(MessageType type, | 42 void SendSyncMessageToPage(MessageType type, |
44 std::string msg, std::string linktext); | 43 std::string msg, std::string linktext); |
45 | 44 |
46 // Helper to query the sync service and figure out what to send to | 45 // Helper to query the sync service and figure out what to send to |
47 // the page, and send it via SendSyncMessageToPage. | 46 // the page, and send it via SendSyncMessageToPage. |
48 // NOTE: precondition: sync must be enabled. | 47 // NOTE: precondition: sync must be enabled. |
49 void BuildAndSendSyncStatus(); | 48 void BuildAndSendSyncStatus(); |
50 | 49 |
51 // Helper to send a message to the NNTP which hides the sync section. | 50 // Helper to send a message to the NNTP which hides the sync section. |
52 void HideSyncStatusSection(); | 51 void HideSyncStatusSection(); |
53 | 52 |
54 // Helper to convert from a sync status message type to an NTP specific one. | 53 // Helper to convert from a sync status message type to an NTP specific one. |
55 static MessageType FromSyncStatusMessageType( | 54 static MessageType FromSyncStatusMessageType( |
56 SyncStatusUIHelper::MessageType type); | 55 SyncStatusUIHelper::MessageType type); |
57 | 56 |
58 // Cached pointer to ProfileSyncService. | 57 // Cached pointer to ProfileSyncService. |
59 ProfileSyncService* sync_service_; | 58 ProfileSyncService* sync_service_; |
60 | 59 |
61 // Used to make sure we don't register ourselves twice if the user refreshes | 60 // Used to make sure we don't register ourselves twice if the user refreshes |
62 // the new tab page. | 61 // the new tab page. |
63 bool waiting_for_initial_page_load_; | 62 bool waiting_for_initial_page_load_; |
64 | 63 |
65 DISALLOW_COPY_AND_ASSIGN(NewTabPageSyncHandler); | 64 DISALLOW_COPY_AND_ASSIGN(NewTabPageSyncHandler); |
66 }; | 65 }; |
67 | 66 |
68 #endif // CHROME_BROWSER_DOM_UI_NEW_TAB_PAGE_SYNC_HANDLER_H_ | 67 #endif // CHROME_BROWSER_DOM_UI_NEW_TAB_PAGE_SYNC_HANDLER_H_ |
OLD | NEW |