Home | History | Annotate | Download | only in webui
      1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_
      6 #define CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_
      7 
      8 #include <string>
      9 
     10 #include "base/basictypes.h"
     11 #include "base/compiler_specific.h"
     12 #include "base/memory/weak_ptr.h"
     13 #include "content/public/browser/web_ui_controller.h"
     14 #include "sync/js/js_event_handler.h"
     15 #include "sync/js/js_reply_handler.h"
     16 
     17 namespace syncer {
     18 class JsController;
     19 }  // namespace syncer
     20 
     21 // The implementation for the chrome://sync-internals page.
     22 class SyncInternalsUI : public content::WebUIController,
     23                         public syncer::JsEventHandler,
     24                         public syncer::JsReplyHandler {
     25  public:
     26   explicit SyncInternalsUI(content::WebUI* web_ui);
     27   virtual ~SyncInternalsUI();
     28 
     29   // WebUIController implementation.
     30   //
     31   // The following messages are processed:
     32   //
     33   // getAboutInfo():
     34   //   Immediately fires a onGetAboutInfoFinished() event with a
     35   //   dictionary of sync-related stats and info.
     36   //
     37   // All other messages are routed to the sync service if it exists,
     38   // and dropped otherwise.
     39   //
     40   // TODO(akalin): Add a simple isSyncEnabled() message and make
     41   // getAboutInfo() be handled by the sync service.
     42   virtual bool OverrideHandleWebUIMessage(const GURL& source_url,
     43                                           const std::string& name,
     44                                           const base::ListValue& args) OVERRIDE;
     45 
     46   // syncer::JsEventHandler implementation.
     47   virtual void HandleJsEvent(
     48       const std::string& name,
     49       const syncer::JsEventDetails& details) OVERRIDE;
     50 
     51   // syncer::JsReplyHandler implementation.
     52   virtual void HandleJsReply(
     53       const std::string& name,
     54       const syncer::JsArgList& args) OVERRIDE;
     55 
     56  private:
     57   base::WeakPtrFactory<SyncInternalsUI> weak_ptr_factory_;
     58   base::WeakPtr<syncer::JsController> js_controller_;
     59 
     60   DISALLOW_COPY_AND_ASSIGN(SyncInternalsUI);
     61 };
     62 
     63 #endif  // CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_
     64