| OLD | NEW | 
| (Empty) |  | 
 |   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 | 
 |   3 // found in the LICENSE file. | 
 |   4  | 
 |   5 #ifdef CHROME_PERSONALIZATION | 
 |   6  | 
 |   7 #ifndef CHROME_BROWSER_DOM_UI_NEW_TAB_PAGE_SYNC_HANDLER_H_ | 
 |   8 #define CHROME_BROWSER_DOM_UI_NEW_TAB_PAGE_SYNC_HANDLER_H_ | 
 |   9  | 
 |  10 #include <string> | 
 |  11  | 
 |  12 #include "chrome/browser/dom_ui/dom_ui.h" | 
 |  13 #include "chrome/browser/sync/profile_sync_service.h" | 
 |  14 #include "chrome/browser/sync/sync_status_ui_helper.h" | 
 |  15  | 
 |  16 class Value; | 
 |  17  | 
 |  18 // Sends sync-state changes to the New Tab Page for UI updating and forwards | 
 |  19 // link clicks on the page to the sync service. | 
 |  20 class NewTabPageSyncHandler : public DOMMessageHandler, | 
 |  21                               public ProfileSyncServiceObserver { | 
 |  22  public: | 
 |  23   NewTabPageSyncHandler(); | 
 |  24   virtual ~NewTabPageSyncHandler(); | 
 |  25  | 
 |  26   // DOMMessageHandler implementation. | 
 |  27   virtual DOMMessageHandler* Attach(DOMUI* dom_ui); | 
 |  28   virtual void RegisterMessages(); | 
 |  29  | 
 |  30   // Callback for "GetSyncMessage". | 
 |  31   void HandleGetSyncMessage(const Value* value); | 
 |  32   // Callback for "SyncLinkClicked". | 
 |  33   void HandleSyncLinkClicked(const Value* value); | 
 |  34   // Callback for "ResizeP13N" | 
 |  35   void HandleResizeP13N(const Value* value); | 
 |  36  | 
 |  37   // ProfileSyncServiceObserver | 
 |  38   virtual void OnStateChanged(); | 
 |  39  | 
 |  40  private: | 
 |  41   // Helper to invoke |renderSyncMessage| JS function on the new tab page. | 
 |  42   void SendSyncMessageToPage(SyncStatusUIHelper::MessageType type, | 
 |  43                              std::string msg, const std::string& linktext); | 
 |  44  | 
 |  45   // Helper to query the sync service and figure out what to send to | 
 |  46   // the page, and send it via SendSyncMessageToPage. | 
 |  47   // NOTE: precondition: sync must be enabled. | 
 |  48   void BuildAndSendSyncStatus(); | 
 |  49  | 
 |  50   // Cached pointer to ProfileSyncService. | 
 |  51   ProfileSyncService* sync_service_; | 
 |  52  | 
 |  53   // Used to make sure we don't register ourselves twice if the user refreshes | 
 |  54   // the new tab page. | 
 |  55   bool waiting_for_initial_page_load_; | 
 |  56  | 
 |  57   DISALLOW_COPY_AND_ASSIGN(NewTabPageSyncHandler); | 
 |  58 }; | 
 |  59  | 
 |  60 #endif  // CHROME_BROWSER_DOM_UI_NEW_TAB_PAGE_SYNC_HANDLER_H_ | 
 |  61 #endif  // CHROME_PERSONALIZATION | 
| OLD | NEW |