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

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

Issue 160083002: Refactor about:sync's events framework (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add semicolons Created 6 years, 10 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
« no previous file with comments | « chrome/browser/ui/webui/sync_internals_browsertest.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sync_internals_browsertest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698