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

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

Issue 9188056: Start splitting out WebUI into an implementation class and an interface that each page implements... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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
OLDNEW
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 // Gets the ProfileSyncService of the underlying original profile. 67 // Gets the ProfileSyncService of the underlying original profile.
68 // May return NULL (e.g., if sync is disabled on the command line). 68 // May return NULL (e.g., if sync is disabled on the command line).
69 ProfileSyncService* GetProfileSyncService(Profile* profile) { 69 ProfileSyncService* GetProfileSyncService(Profile* profile) {
70 return profile->GetOriginalProfile()->GetProfileSyncService(); 70 return profile->GetOriginalProfile()->GetProfileSyncService();
71 } 71 }
72 72
73 } // namespace 73 } // namespace
74 74
75 SyncInternalsUI::SyncInternalsUI(WebContents* contents) 75 SyncInternalsUI::SyncInternalsUI(WebContents* contents)
76 : WebUI(contents), 76 : WebUI(contents, this),
77 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 77 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
78 // TODO(akalin): Fix. 78 // TODO(akalin): Fix.
79 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); 79 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
80 profile->GetChromeURLDataManager()->AddDataSource( 80 profile->GetChromeURLDataManager()->AddDataSource(
81 CreateSyncInternalsHTMLSource()); 81 CreateSyncInternalsHTMLSource());
82 ProfileSyncService* sync_service = GetProfileSyncService(profile); 82 ProfileSyncService* sync_service = GetProfileSyncService(profile);
83 if (sync_service) { 83 if (sync_service) {
84 js_controller_ = sync_service->GetJsController(); 84 js_controller_ = sync_service->GetJsController();
85 } 85 }
86 if (js_controller_.get()) { 86 if (js_controller_.get()) {
87 js_controller_->AddJsEventHandler(this); 87 js_controller_->AddJsEventHandler(this);
88 } 88 }
89 } 89 }
90 90
91 SyncInternalsUI::~SyncInternalsUI() { 91 SyncInternalsUI::~SyncInternalsUI() {
92 if (js_controller_.get()) { 92 if (js_controller_.get()) {
93 js_controller_->RemoveJsEventHandler(this); 93 js_controller_->RemoveJsEventHandler(this);
94 } 94 }
95 } 95 }
96 96
97 void SyncInternalsUI::OnWebUISend(const GURL& source_url, 97 void SyncInternalsUI::HandleWebUIMessage(const GURL& source_url,
98 const std::string& name, 98 const std::string& name,
99 const ListValue& content) { 99 const ListValue& content,
100 bool* overridden) {
101 *overridden = true;
100 scoped_ptr<ListValue> content_copy(content.DeepCopy()); 102 scoped_ptr<ListValue> content_copy(content.DeepCopy());
101 JsArgList args(content_copy.get()); 103 JsArgList args(content_copy.get());
102 VLOG(1) << "Received message: " << name << " with args " 104 VLOG(1) << "Received message: " << name << " with args "
103 << args.ToString(); 105 << args.ToString();
104 // We handle this case directly because it needs to work even if 106 // We handle this case directly because it needs to work even if
105 // the sync service doesn't exist. 107 // the sync service doesn't exist.
106 if (name == "getAboutInfo") { 108 if (name == "getAboutInfo") {
107 ListValue return_args; 109 ListValue return_args;
108 DictionaryValue* about_info = new DictionaryValue(); 110 DictionaryValue* about_info = new DictionaryValue();
109 return_args.Append(about_info); 111 return_args.Append(about_info);
(...skipping 24 matching lines...) Expand all
134 } 136 }
135 137
136 void SyncInternalsUI::HandleJsReply( 138 void SyncInternalsUI::HandleJsReply(
137 const std::string& name, const JsArgList& args) { 139 const std::string& name, const JsArgList& args) {
138 VLOG(1) << "Handling reply for " << name << " message with args " 140 VLOG(1) << "Handling reply for " << name << " message with args "
139 << args.ToString(); 141 << args.ToString();
140 const std::string& reply_handler = "chrome.sync." + name + ".handleReply"; 142 const std::string& reply_handler = "chrome.sync." + name + ".handleReply";
141 std::vector<const Value*> arg_list(args.Get().begin(), args.Get().end()); 143 std::vector<const Value*> arg_list(args.Get().begin(), args.Get().end());
142 CallJavascriptFunction(reply_handler, arg_list); 144 CallJavascriptFunction(reply_handler, arg_list);
143 } 145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698