| OLD | NEW |
| 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" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 std::vector<const base::Value*> arg_list(args.Get().begin(), | 88 std::vector<const base::Value*> arg_list(args.Get().begin(), |
| 89 args.Get().end()); | 89 args.Get().end()); |
| 90 web_ui()->CallJavascriptFunction(reply_handler, arg_list); | 90 web_ui()->CallJavascriptFunction(reply_handler, arg_list); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void SyncInternalsMessageHandler::HandleJsEvent( | 93 void SyncInternalsMessageHandler::HandleJsEvent( |
| 94 const std::string& name, | 94 const std::string& name, |
| 95 const JsEventDetails& details) { | 95 const JsEventDetails& details) { |
| 96 DVLOG(1) << "Handling event: " << name | 96 DVLOG(1) << "Handling event: " << name |
| 97 << " with details " << details.ToString(); | 97 << " with details " << details.ToString(); |
| 98 const std::string& event_handler = "chrome.sync." + name + ".fire"; | 98 web_ui()->CallJavascriptFunction("chrome.sync.dispatchEvent", |
| 99 std::vector<const base::Value*> arg_list(1, &details.Get()); | 99 base::StringValue(name), |
| 100 web_ui()->CallJavascriptFunction(event_handler, arg_list); | 100 details.Get()); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void SyncInternalsMessageHandler::RegisterJsControllerCallback( | 103 void SyncInternalsMessageHandler::RegisterJsControllerCallback( |
| 104 const std::string& name) { | 104 const std::string& name) { |
| 105 web_ui()->RegisterMessageCallback( | 105 web_ui()->RegisterMessageCallback( |
| 106 name, | 106 name, |
| 107 base::Bind(&SyncInternalsMessageHandler::ForwardToJsController, | 107 base::Bind(&SyncInternalsMessageHandler::ForwardToJsController, |
| 108 base::Unretained(this), | 108 base::Unretained(this), |
| 109 name)); | 109 name)); |
| 110 } | 110 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 124 } | 124 } |
| 125 | 125 |
| 126 // Gets the ProfileSyncService of the underlying original profile. | 126 // Gets the ProfileSyncService of the underlying original profile. |
| 127 // May return NULL (e.g., if sync is disabled on the command line). | 127 // May return NULL (e.g., if sync is disabled on the command line). |
| 128 ProfileSyncService* SyncInternalsMessageHandler::GetProfileSyncService() { | 128 ProfileSyncService* SyncInternalsMessageHandler::GetProfileSyncService() { |
| 129 Profile* profile = Profile::FromWebUI(web_ui()); | 129 Profile* profile = Profile::FromWebUI(web_ui()); |
| 130 ProfileSyncServiceFactory* factory = ProfileSyncServiceFactory::GetInstance(); | 130 ProfileSyncServiceFactory* factory = ProfileSyncServiceFactory::GetInstance(); |
| 131 return factory->GetForProfile(profile->GetOriginalProfile()); | 131 return factory->GetForProfile(profile->GetOriginalProfile()); |
| 132 } | 132 } |
| 133 | 133 |
| OLD | NEW |