| 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/profile_sync_service.h" | 15 #include "chrome/browser/sync/profile_sync_service.h" |
| 16 #include "chrome/browser/sync/profile_sync_service_factory.h" | 16 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 17 #include "chrome/browser/sync/sync_ui_util.h" | 17 #include "chrome/browser/sync/sync_ui_util.h" |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 19 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 19 #include "chrome/browser/ui/webui/chrome_url_data_manager_factory.h" |
| 20 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 20 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
| 21 #include "chrome/common/extensions/extension_messages.h" | 21 #include "chrome/common/extensions/extension_messages.h" |
| 22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
| 23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 24 #include "content/public/browser/web_ui.h" | 24 #include "content/public/browser/web_ui.h" |
| 25 #include "grit/sync_internals_resources.h" | 25 #include "grit/sync_internals_resources.h" |
| 26 #include "sync/js/js_arg_list.h" | 26 #include "sync/js/js_arg_list.h" |
| 27 #include "sync/js/js_controller.h" | 27 #include "sync/js/js_controller.h" |
| 28 #include "sync/js/js_event_details.h" | 28 #include "sync/js/js_event_details.h" |
| 29 #include "sync/util/weak_handle.h" | 29 #include "sync/util/weak_handle.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 profile->GetOriginalProfile()); | 75 profile->GetOriginalProfile()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 } // namespace | 78 } // namespace |
| 79 | 79 |
| 80 SyncInternalsUI::SyncInternalsUI(content::WebUI* web_ui) | 80 SyncInternalsUI::SyncInternalsUI(content::WebUI* web_ui) |
| 81 : WebUIController(web_ui), | 81 : WebUIController(web_ui), |
| 82 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 82 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 83 // TODO(akalin): Fix. | 83 // TODO(akalin): Fix. |
| 84 Profile* profile = Profile::FromWebUI(web_ui); | 84 Profile* profile = Profile::FromWebUI(web_ui); |
| 85 profile->GetChromeURLDataManager()->AddDataSource( | 85 ChromeURLDataManagerFactory::GetForProfile(profile)-> |
| 86 CreateSyncInternalsHTMLSource()); | 86 AddDataSource(CreateSyncInternalsHTMLSource()); |
| 87 ProfileSyncService* sync_service = GetProfileSyncService(profile); | 87 ProfileSyncService* sync_service = GetProfileSyncService(profile); |
| 88 if (sync_service) { | 88 if (sync_service) { |
| 89 js_controller_ = sync_service->GetJsController(); | 89 js_controller_ = sync_service->GetJsController(); |
| 90 } | 90 } |
| 91 if (js_controller_.get()) { | 91 if (js_controller_.get()) { |
| 92 js_controller_->AddJsEventHandler(this); | 92 js_controller_->AddJsEventHandler(this); |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 SyncInternalsUI::~SyncInternalsUI() { | 96 SyncInternalsUI::~SyncInternalsUI() { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 139 } |
| 140 | 140 |
| 141 void SyncInternalsUI::HandleJsReply( | 141 void SyncInternalsUI::HandleJsReply( |
| 142 const std::string& name, const JsArgList& args) { | 142 const std::string& name, const JsArgList& args) { |
| 143 VLOG(1) << "Handling reply for " << name << " message with args " | 143 VLOG(1) << "Handling reply for " << name << " message with args " |
| 144 << args.ToString(); | 144 << args.ToString(); |
| 145 const std::string& reply_handler = "chrome.sync." + name + ".handleReply"; | 145 const std::string& reply_handler = "chrome.sync." + name + ".handleReply"; |
| 146 std::vector<const Value*> arg_list(args.Get().begin(), args.Get().end()); | 146 std::vector<const Value*> arg_list(args.Get().begin(), args.Get().end()); |
| 147 web_ui()->CallJavascriptFunction(reply_handler, arg_list); | 147 web_ui()->CallJavascriptFunction(reply_handler, arg_list); |
| 148 } | 148 } |
| OLD | NEW |