| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_ui.h" | 5 #include "chrome/browser/ui/webui/sync_internals_ui.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 ListValue return_args; | 106 ListValue return_args; |
| 107 DictionaryValue* about_info = new DictionaryValue(); | 107 DictionaryValue* about_info = new DictionaryValue(); |
| 108 return_args.Append(about_info); | 108 return_args.Append(about_info); |
| 109 ProfileSyncService* service = GetProfileSyncService(GetProfile()); | 109 ProfileSyncService* service = GetProfileSyncService(GetProfile()); |
| 110 sync_ui_util::ConstructAboutInformation(service, about_info); | 110 sync_ui_util::ConstructAboutInformation(service, about_info); |
| 111 HandleJsReply(name, JsArgList(&return_args)); | 111 HandleJsReply(name, JsArgList(&return_args)); |
| 112 } else { | 112 } else { |
| 113 if (js_controller_.get()) { | 113 if (js_controller_.get()) { |
| 114 js_controller_->ProcessJsMessage( | 114 js_controller_->ProcessJsMessage( |
| 115 name, args, | 115 name, args, |
| 116 WeakHandle<JsReplyHandler>(weak_ptr_factory_.GetWeakPtr())); | 116 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr())); |
| 117 } else { | 117 } else { |
| 118 LOG(WARNING) << "No sync service; dropping message " << name | 118 LOG(WARNING) << "No sync service; dropping message " << name |
| 119 << " with args " << args.ToString(); | 119 << " with args " << args.ToString(); |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 void SyncInternalsUI::HandleJsEvent( | 124 void SyncInternalsUI::HandleJsEvent( |
| 125 const std::string& name, const JsEventDetails& details) { | 125 const std::string& name, const JsEventDetails& details) { |
| 126 VLOG(1) << "Handling event: " << name << " with details " | 126 VLOG(1) << "Handling event: " << name << " with details " |
| 127 << details.ToString(); | 127 << details.ToString(); |
| 128 const std::string& event_handler = "chrome.sync." + name + ".fire"; | 128 const std::string& event_handler = "chrome.sync." + name + ".fire"; |
| 129 std::vector<const Value*> arg_list(1, &details.Get()); | 129 std::vector<const Value*> arg_list(1, &details.Get()); |
| 130 CallJavascriptFunction(event_handler, arg_list); | 130 CallJavascriptFunction(event_handler, arg_list); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void SyncInternalsUI::HandleJsReply( | 133 void SyncInternalsUI::HandleJsReply( |
| 134 const std::string& name, const JsArgList& args) { | 134 const std::string& name, const JsArgList& args) { |
| 135 VLOG(1) << "Handling reply for " << name << " message with args " | 135 VLOG(1) << "Handling reply for " << name << " message with args " |
| 136 << args.ToString(); | 136 << args.ToString(); |
| 137 const std::string& reply_handler = "chrome.sync." + name + ".handleReply"; | 137 const std::string& reply_handler = "chrome.sync." + name + ".handleReply"; |
| 138 std::vector<const Value*> arg_list(args.Get().begin(), args.Get().end()); | 138 std::vector<const Value*> arg_list(args.Get().begin(), args.Get().end()); |
| 139 CallJavascriptFunction(reply_handler, arg_list); | 139 CallJavascriptFunction(reply_handler, arg_list); |
| 140 } | 140 } |
| OLD | NEW |