| 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 (void)BrowserThread::PostTask( | 33 contents->profile()->GetChromeURLDataManager()->AddDataSource( |
| 34 BrowserThread::IO, FROM_HERE, | 34 new SyncInternalsHTMLSource()); |
| 35 NewRunnableMethod( | |
| 36 ChromeURLDataManager::GetInstance(), | |
| 37 &ChromeURLDataManager::AddDataSource, | |
| 38 make_scoped_refptr(new SyncInternalsHTMLSource()))); | |
| 39 } | 35 } |
| 40 | 36 |
| 41 SyncInternalsUI::~SyncInternalsUI() { | 37 SyncInternalsUI::~SyncInternalsUI() { |
| 42 browser_sync::JsFrontend* backend = GetJsFrontend(); | 38 browser_sync::JsFrontend* backend = GetJsFrontend(); |
| 43 if (backend) { | 39 if (backend) { |
| 44 backend->RemoveHandler(this); | 40 backend->RemoveHandler(this); |
| 45 } | 41 } |
| 46 } | 42 } |
| 47 | 43 |
| 48 void SyncInternalsUI::ProcessDOMUIMessage( | 44 void SyncInternalsUI::ProcessDOMUIMessage( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 78 std::vector<const Value*> arg_list(args.Get().begin(), args.Get().end()); | 74 std::vector<const Value*> arg_list(args.Get().begin(), args.Get().end()); |
| 79 CallJavascriptFunction(UTF8ToWide(name), arg_list); | 75 CallJavascriptFunction(UTF8ToWide(name), arg_list); |
| 80 } | 76 } |
| 81 | 77 |
| 82 browser_sync::JsFrontend* SyncInternalsUI::GetJsFrontend() { | 78 browser_sync::JsFrontend* SyncInternalsUI::GetJsFrontend() { |
| 83 // If this returns NULL that means that sync is disabled for | 79 // If this returns NULL that means that sync is disabled for |
| 84 // whatever reason. | 80 // whatever reason. |
| 85 ProfileSyncService* sync_service = GetProfile()->GetProfileSyncService(); | 81 ProfileSyncService* sync_service = GetProfile()->GetProfileSyncService(); |
| 86 return sync_service ? sync_service->GetJsFrontend() : NULL; | 82 return sync_service ? sync_service->GetJsFrontend() : NULL; |
| 87 } | 83 } |
| OLD | NEW |