Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: chrome/browser/ui/webui/sync_internals_message_handler.cc

Issue 134443004: sync: Remove some WebUI debug functions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/ui/webui/sync_internals_message_handler.h" 5 #include "chrome/browser/ui/webui/sync_internals_message_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/sync/about_sync_util.h" 11 #include "chrome/browser/sync/about_sync_util.h"
12 #include "chrome/browser/sync/profile_sync_service.h" 12 #include "chrome/browser/sync/profile_sync_service.h"
13 #include "chrome/browser/sync/profile_sync_service_factory.h" 13 #include "chrome/browser/sync/profile_sync_service_factory.h"
14 #include "content/public/browser/web_ui.h" 14 #include "content/public/browser/web_ui.h"
15 #include "sync/internal_api/public/util/weak_handle.h" 15 #include "sync/internal_api/public/util/weak_handle.h"
16 #include "sync/js/js_arg_list.h" 16 #include "sync/js/js_arg_list.h"
17 #include "sync/js/js_event_details.h" 17 #include "sync/js/js_event_details.h"
18 18
19 using syncer::JsArgList; 19 using syncer::JsArgList;
20 using syncer::JsEventDetails; 20 using syncer::JsEventDetails;
21 using syncer::JsReplyHandler; 21 using syncer::JsReplyHandler;
22 using syncer::ModelTypeSet;
22 using syncer::WeakHandle; 23 using syncer::WeakHandle;
23 24
24 SyncInternalsMessageHandler::SyncInternalsMessageHandler() 25 SyncInternalsMessageHandler::SyncInternalsMessageHandler()
25 : weak_ptr_factory_(this) {} 26 : weak_ptr_factory_(this) {}
26 27
27 SyncInternalsMessageHandler::~SyncInternalsMessageHandler() { 28 SyncInternalsMessageHandler::~SyncInternalsMessageHandler() {
28 if (js_controller_) 29 if (js_controller_)
29 js_controller_->RemoveJsEventHandler(this); 30 js_controller_->RemoveJsEventHandler(this);
30 } 31 }
31 32
32 void SyncInternalsMessageHandler::RegisterMessages() { 33 void SyncInternalsMessageHandler::RegisterMessages() {
33 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 34 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
34 35
35 // Init our link to the JsController. 36 // Init our link to the JsController.
36 ProfileSyncService* service = GetProfileSyncService(); 37 ProfileSyncService* service = GetProfileSyncService();
37 if (service) 38 if (service)
38 js_controller_ = service->GetJsController(); 39 js_controller_ = service->GetJsController();
39 if (js_controller_) 40 if (js_controller_)
40 js_controller_->AddJsEventHandler(this); 41 js_controller_->AddJsEventHandler(this);
41 42
42 web_ui()->RegisterMessageCallback( 43 web_ui()->RegisterMessageCallback(
43 "getAboutInfo", 44 "getAboutInfo",
44 base::Bind(&SyncInternalsMessageHandler::OnGetAboutInfo, 45 base::Bind(&SyncInternalsMessageHandler::OnGetAboutInfo,
45 base::Unretained(this))); 46 base::Unretained(this)));
46 47
48 web_ui()->RegisterMessageCallback(
49 "getListOfTypes",
50 base::Bind(&SyncInternalsMessageHandler::OnGetListOfTypes,
51 base::Unretained(this)));
52
47 RegisterJsControllerCallback("getNotificationState"); 53 RegisterJsControllerCallback("getNotificationState");
48 RegisterJsControllerCallback("getNotificationInfo"); 54 RegisterJsControllerCallback("getNotificationInfo");
49 RegisterJsControllerCallback("getRootNodeDetails");
50 RegisterJsControllerCallback("getNodeSummariesById");
51 RegisterJsControllerCallback("getNodeDetailsById");
52 RegisterJsControllerCallback("getAllNodes"); 55 RegisterJsControllerCallback("getAllNodes");
53 RegisterJsControllerCallback("getChildNodeIds");
54 RegisterJsControllerCallback("getClientServerTraffic"); 56 RegisterJsControllerCallback("getClientServerTraffic");
55 } 57 }
56 58
57 void SyncInternalsMessageHandler::OnGetAboutInfo(const base::ListValue* args) { 59 void SyncInternalsMessageHandler::OnGetAboutInfo(const base::ListValue* args) {
58 // TODO(rlarocque): We should DCHECK(!args) here. 60 // TODO(rlarocque): We should DCHECK(!args) here. See crbug.com/334431.
59 scoped_ptr<base::DictionaryValue> value = 61 scoped_ptr<base::DictionaryValue> value =
60 sync_ui_util::ConstructAboutInformation(GetProfileSyncService()); 62 sync_ui_util::ConstructAboutInformation(GetProfileSyncService());
61 web_ui()->CallJavascriptFunction( 63 web_ui()->CallJavascriptFunction(
62 "chrome.sync.getAboutInfo.handleReply", 64 "chrome.sync.getAboutInfo.handleReply",
63 *value); 65 *value);
64 } 66 }
65 67
68 void SyncInternalsMessageHandler::OnGetListOfTypes(
69 const base::ListValue* args) {
70 // TODO(rlarocque): We should DCHECK(!args) here. See crbug.com/334431.
71 base::ListValue type_list;
72 ModelTypeSet protocol_types = syncer::ProtocolTypes();
73 for (ModelTypeSet::Iterator it = protocol_types.First();
74 it.Good(); it.Inc()) {
75 type_list.Append(new base::StringValue(ModelTypeToString(it.Get())));
76 }
77 web_ui()->CallJavascriptFunction(
78 "chrome.sync.getListOfTypes.handleReply",
79 type_list);
80 }
81
66 void SyncInternalsMessageHandler::HandleJsReply( 82 void SyncInternalsMessageHandler::HandleJsReply(
67 const std::string& name, const JsArgList& args) { 83 const std::string& name, const JsArgList& args) {
68 DVLOG(1) << "Handling reply for " << name << " message" 84 DVLOG(1) << "Handling reply for " << name << " message"
69 << " with args " << args.ToString(); 85 << " with args " << args.ToString();
70 const std::string& reply_handler = "chrome.sync." + name + ".handleReply"; 86 const std::string& reply_handler = "chrome.sync." + name + ".handleReply";
71 std::vector<const base::Value*> arg_list(args.Get().begin(), 87 std::vector<const base::Value*> arg_list(args.Get().begin(),
72 args.Get().end()); 88 args.Get().end());
73 web_ui()->CallJavascriptFunction(reply_handler, arg_list); 89 web_ui()->CallJavascriptFunction(reply_handler, arg_list);
74 } 90 }
75 91
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 123 }
108 124
109 // Gets the ProfileSyncService of the underlying original profile. 125 // Gets the ProfileSyncService of the underlying original profile.
110 // May return NULL (e.g., if sync is disabled on the command line). 126 // May return NULL (e.g., if sync is disabled on the command line).
111 ProfileSyncService* SyncInternalsMessageHandler::GetProfileSyncService() { 127 ProfileSyncService* SyncInternalsMessageHandler::GetProfileSyncService() {
112 Profile* profile = Profile::FromWebUI(web_ui()); 128 Profile* profile = Profile::FromWebUI(web_ui());
113 ProfileSyncServiceFactory* factory = ProfileSyncServiceFactory::GetInstance(); 129 ProfileSyncServiceFactory* factory = ProfileSyncServiceFactory::GetInstance();
114 return factory->GetForProfile(profile->GetOriginalProfile()); 130 return factory->GetForProfile(profile->GetOriginalProfile());
115 } 131 }
116 132
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sync_internals_message_handler.h ('k') | chrome/browser/ui/webui/sync_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698