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

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

Issue 6735004: Move extension messages to their own file and add a RenderViewObserver to start moving the extens... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/ref_counted.h" 10 #include "base/ref_counted.h"
11 #include "base/task.h" 11 #include "base/task.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/js_arg_list.h" 15 #include "chrome/browser/sync/js_arg_list.h"
16 #include "chrome/browser/sync/js_frontend.h" 16 #include "chrome/browser/sync/js_frontend.h"
17 #include "chrome/browser/sync/profile_sync_service.h" 17 #include "chrome/browser/sync/profile_sync_service.h"
18 #include "chrome/browser/sync/sync_ui_util.h" 18 #include "chrome/browser/sync/sync_ui_util.h"
19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
20 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 20 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
21 #include "chrome/browser/ui/webui/sync_internals_html_source.h" 21 #include "chrome/browser/ui/webui/sync_internals_html_source.h"
22 #include "chrome/common/render_messages_params.h" 22 #include "chrome/common/extensions/extension_messages.h"
23 #include "content/browser/browser_thread.h" 23 #include "content/browser/browser_thread.h"
24 24
25 SyncInternalsUI::SyncInternalsUI(TabContents* contents) 25 SyncInternalsUI::SyncInternalsUI(TabContents* contents)
26 : WebUI(contents) { 26 : WebUI(contents) {
27 browser_sync::JsFrontend* backend = GetJsFrontend(); 27 browser_sync::JsFrontend* backend = GetJsFrontend();
28 if (backend) { 28 if (backend) {
29 backend->AddHandler(this); 29 backend->AddHandler(this);
30 } 30 }
31 // If this PostTask() call fails, it's most likely because this is 31 // If this PostTask() call fails, it's most likely because this is
32 // being run from a unit test. The created objects will be cleaned 32 // being run from a unit test. The created objects will be cleaned
33 // up, anyway. 33 // up, anyway.
34 contents->profile()->GetChromeURLDataManager()->AddDataSource( 34 contents->profile()->GetChromeURLDataManager()->AddDataSource(
35 new SyncInternalsHTMLSource()); 35 new SyncInternalsHTMLSource());
36 } 36 }
37 37
38 SyncInternalsUI::~SyncInternalsUI() { 38 SyncInternalsUI::~SyncInternalsUI() {
39 browser_sync::JsFrontend* backend = GetJsFrontend(); 39 browser_sync::JsFrontend* backend = GetJsFrontend();
40 if (backend) { 40 if (backend) {
41 backend->RemoveHandler(this); 41 backend->RemoveHandler(this);
42 } 42 }
43 } 43 }
44 44
45 void SyncInternalsUI::ProcessWebUIMessage( 45 void SyncInternalsUI::ProcessWebUIMessage(
46 const ViewHostMsg_DomMessage_Params& params) { 46 const ExtensionHostMsg_DomMessage_Params& params) {
47 const std::string& name = params.name; 47 const std::string& name = params.name;
48 browser_sync::JsArgList args(params.arguments); 48 browser_sync::JsArgList args(params.arguments);
49 VLOG(1) << "Received message: " << name << " with args " 49 VLOG(1) << "Received message: " << name << " with args "
50 << args.ToString(); 50 << args.ToString();
51 // We handle this case directly because it needs to work even if 51 // We handle this case directly because it needs to work even if
52 // the sync service doesn't exist. 52 // the sync service doesn't exist.
53 if (name == "getAboutInfo") { 53 if (name == "getAboutInfo") {
54 ListValue args; 54 ListValue args;
55 DictionaryValue* about_info = new DictionaryValue(); 55 DictionaryValue* about_info = new DictionaryValue();
56 args.Append(about_info); 56 args.Append(about_info);
(...skipping 18 matching lines...) Expand all
75 std::vector<const Value*> arg_list(args.Get().begin(), args.Get().end()); 75 std::vector<const Value*> arg_list(args.Get().begin(), args.Get().end());
76 CallJavascriptFunction(name, arg_list); 76 CallJavascriptFunction(name, arg_list);
77 } 77 }
78 78
79 browser_sync::JsFrontend* SyncInternalsUI::GetJsFrontend() { 79 browser_sync::JsFrontend* SyncInternalsUI::GetJsFrontend() {
80 // If this returns NULL that means that sync is disabled for 80 // If this returns NULL that means that sync is disabled for
81 // whatever reason. 81 // whatever reason.
82 ProfileSyncService* sync_service = GetProfile()->GetProfileSyncService(); 82 ProfileSyncService* sync_service = GetProfile()->GetProfileSyncService();
83 return sync_service ? sync_service->GetJsFrontend() : NULL; 83 return sync_service ? sync_service->GetJsFrontend() : NULL;
84 } 84 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sync_internals_ui.h ('k') | chrome/browser/ui/webui/sync_internals_ui_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698