| OLD | NEW |
| 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/dom_ui/sync_internals_ui.h" | 5 #include "chrome/browser/dom_ui/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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 SyncInternalsUI::SyncInternalsUI(TabContents* contents) | 24 SyncInternalsUI::SyncInternalsUI(TabContents* contents) |
| 25 : DOMUI(contents) { | 25 : DOMUI(contents) { |
| 26 browser_sync::JsFrontend* backend = GetJsFrontend(); | 26 browser_sync::JsFrontend* backend = GetJsFrontend(); |
| 27 if (backend) { | 27 if (backend) { |
| 28 backend->AddHandler(this); | 28 backend->AddHandler(this); |
| 29 } | 29 } |
| 30 // If this PostTask() call fails, it's most likely because this is | 30 // If this PostTask() call fails, it's most likely because this is |
| 31 // being run from a unit test. The created objects will be cleaned | 31 // being run from a unit test. The created objects will be cleaned |
| 32 // up, anyway. | 32 // up, anyway. |
| 33 contents->profile()->GetChromeURLDataManager()->AddDataSource( | 33 (void)BrowserThread::PostTask( |
| 34 new SyncInternalsHTMLSource()); | 34 BrowserThread::IO, FROM_HERE, |
| 35 NewRunnableMethod( |
| 36 ChromeURLDataManager::GetInstance(), |
| 37 &ChromeURLDataManager::AddDataSource, |
| 38 make_scoped_refptr(new SyncInternalsHTMLSource()))); |
| 35 } | 39 } |
| 36 | 40 |
| 37 SyncInternalsUI::~SyncInternalsUI() { | 41 SyncInternalsUI::~SyncInternalsUI() { |
| 38 browser_sync::JsFrontend* backend = GetJsFrontend(); | 42 browser_sync::JsFrontend* backend = GetJsFrontend(); |
| 39 if (backend) { | 43 if (backend) { |
| 40 backend->RemoveHandler(this); | 44 backend->RemoveHandler(this); |
| 41 } | 45 } |
| 42 } | 46 } |
| 43 | 47 |
| 44 void SyncInternalsUI::ProcessDOMUIMessage( | 48 void SyncInternalsUI::ProcessDOMUIMessage( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 74 std::vector<const Value*> arg_list(args.Get().begin(), args.Get().end()); | 78 std::vector<const Value*> arg_list(args.Get().begin(), args.Get().end()); |
| 75 CallJavascriptFunction(UTF8ToWide(name), arg_list); | 79 CallJavascriptFunction(UTF8ToWide(name), arg_list); |
| 76 } | 80 } |
| 77 | 81 |
| 78 browser_sync::JsFrontend* SyncInternalsUI::GetJsFrontend() { | 82 browser_sync::JsFrontend* SyncInternalsUI::GetJsFrontend() { |
| 79 // If this returns NULL that means that sync is disabled for | 83 // If this returns NULL that means that sync is disabled for |
| 80 // whatever reason. | 84 // whatever reason. |
| 81 ProfileSyncService* sync_service = GetProfile()->GetProfileSyncService(); | 85 ProfileSyncService* sync_service = GetProfile()->GetProfileSyncService(); |
| 82 return sync_service ? sync_service->GetJsFrontend() : NULL; | 86 return sync_service ? sync_service->GetJsFrontend() : NULL; |
| 83 } | 87 } |
| OLD | NEW |