| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/tracked_objects.h" | 12 #include "base/tracked_objects.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/sync/about_sync_util.h" |
| 15 #include "chrome/browser/sync/profile_sync_service.h" | 16 #include "chrome/browser/sync/profile_sync_service.h" |
| 16 #include "chrome/browser/sync/profile_sync_service_factory.h" | 17 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 17 #include "chrome/browser/sync/sync_ui_util.h" | 18 #include "chrome/browser/sync/sync_ui_util.h" |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 19 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 20 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 20 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 21 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
| 21 #include "chrome/common/extensions/extension_messages.h" | 22 #include "chrome/common/extensions/extension_messages.h" |
| 22 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 23 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 24 #include "content/public/browser/web_ui.h" | 25 #include "content/public/browser/web_ui.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 const std::string& name, | 103 const std::string& name, |
| 103 const ListValue& content) { | 104 const ListValue& content) { |
| 104 scoped_ptr<ListValue> content_copy(content.DeepCopy()); | 105 scoped_ptr<ListValue> content_copy(content.DeepCopy()); |
| 105 JsArgList args(content_copy.get()); | 106 JsArgList args(content_copy.get()); |
| 106 VLOG(1) << "Received message: " << name << " with args " | 107 VLOG(1) << "Received message: " << name << " with args " |
| 107 << args.ToString(); | 108 << args.ToString(); |
| 108 // We handle this case directly because it needs to work even if | 109 // We handle this case directly because it needs to work even if |
| 109 // the sync service doesn't exist. | 110 // the sync service doesn't exist. |
| 110 if (name == "getAboutInfo") { | 111 if (name == "getAboutInfo") { |
| 111 ListValue return_args; | 112 ListValue return_args; |
| 112 DictionaryValue* about_info = new DictionaryValue(); | |
| 113 return_args.Append(about_info); | |
| 114 Profile* profile = Profile::FromWebUI(web_ui()); | 113 Profile* profile = Profile::FromWebUI(web_ui()); |
| 115 ProfileSyncService* service = GetProfileSyncService(profile); | 114 ProfileSyncService* service = GetProfileSyncService(profile); |
| 116 sync_ui_util::ConstructAboutInformation(service, about_info); | 115 return_args.Append( |
| 116 sync_ui_util::ConstructAboutInformation(service).release()); |
| 117 HandleJsReply(name, JsArgList(&return_args)); | 117 HandleJsReply(name, JsArgList(&return_args)); |
| 118 } else { | 118 } else { |
| 119 if (js_controller_.get()) { | 119 if (js_controller_.get()) { |
| 120 js_controller_->ProcessJsMessage( | 120 js_controller_->ProcessJsMessage( |
| 121 name, args, | 121 name, args, |
| 122 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr())); | 122 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr())); |
| 123 } else { | 123 } else { |
| 124 LOG(WARNING) << "No sync service; dropping message " << name | 124 LOG(WARNING) << "No sync service; dropping message " << name |
| 125 << " with args " << args.ToString(); | 125 << " with args " << args.ToString(); |
| 126 } | 126 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 138 } | 138 } |
| 139 | 139 |
| 140 void SyncInternalsUI::HandleJsReply( | 140 void SyncInternalsUI::HandleJsReply( |
| 141 const std::string& name, const JsArgList& args) { | 141 const std::string& name, const JsArgList& args) { |
| 142 VLOG(1) << "Handling reply for " << name << " message with args " | 142 VLOG(1) << "Handling reply for " << name << " message with args " |
| 143 << args.ToString(); | 143 << args.ToString(); |
| 144 const std::string& reply_handler = "chrome.sync." + name + ".handleReply"; | 144 const std::string& reply_handler = "chrome.sync." + name + ".handleReply"; |
| 145 std::vector<const Value*> arg_list(args.Get().begin(), args.Get().end()); | 145 std::vector<const Value*> arg_list(args.Get().begin(), args.Get().end()); |
| 146 web_ui()->CallJavascriptFunction(reply_handler, arg_list); | 146 web_ui()->CallJavascriptFunction(reply_handler, arg_list); |
| 147 } | 147 } |
| OLD | NEW |