OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chrome_url_data_manager.h" | 5 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/net/chrome_url_request_context.h" | 18 #include "chrome/browser/net/chrome_url_request_context.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/webui/chrome_url_data_manager_factory.h" | |
20 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" | 21 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" |
21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
22 #include "grit/platform_locale_settings.h" | 23 #include "grit/platform_locale_settings.h" |
23 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
24 | 25 |
25 #if defined (TOOLKIT_GTK) | 26 #if defined (TOOLKIT_GTK) |
26 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
27 #include "ui/gfx/font.h" | 28 #include "ui/gfx/font.h" |
28 #endif | 29 #endif |
29 | 30 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 } | 99 } |
99 if (schedule_delete) { | 100 if (schedule_delete) { |
100 // Schedule a task to delete the DataSource back on the UI thread. | 101 // Schedule a task to delete the DataSource back on the UI thread. |
101 BrowserThread::PostTask( | 102 BrowserThread::PostTask( |
102 BrowserThread::UI, FROM_HERE, | 103 BrowserThread::UI, FROM_HERE, |
103 base::Bind(&ChromeURLDataManager::DeleteDataSources)); | 104 base::Bind(&ChromeURLDataManager::DeleteDataSources)); |
104 } | 105 } |
105 } | 106 } |
106 | 107 |
107 // static | 108 // static |
109 void ChromeURLDataManager::AddDataSource(Profile *profile, DataSource* source) { | |
Evan Stade
2012/04/24 21:22:14
star on the left
Kyle Horimoto
2012/04/24 22:17:49
Done.
| |
110 ChromeURLDataManagerFactory::GetForProfile(profile)->AddDataSource(source); | |
111 } | |
112 | |
113 // static | |
108 bool ChromeURLDataManager::IsScheduledForDeletion( | 114 bool ChromeURLDataManager::IsScheduledForDeletion( |
109 const DataSource* data_source) { | 115 const DataSource* data_source) { |
110 base::AutoLock lock(g_delete_lock.Get()); | 116 base::AutoLock lock(g_delete_lock.Get()); |
111 if (!data_sources_) | 117 if (!data_sources_) |
112 return false; | 118 return false; |
113 return std::find(data_sources_->begin(), data_sources_->end(), data_source) != | 119 return std::find(data_sources_->begin(), data_sources_->end(), data_source) != |
114 data_sources_->end(); | 120 data_sources_->end(); |
115 } | 121 } |
116 | 122 |
117 ChromeURLDataManager::DataSource::DataSource(const std::string& source_name, | 123 ChromeURLDataManager::DataSource::DataSource(const std::string& source_name, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 base::i18n::IsRTL() ? "rtl" : "ltr"); | 192 base::i18n::IsRTL() ? "rtl" : "ltr"); |
187 } | 193 } |
188 | 194 |
189 void ChromeURLDataManager::DataSource::SendResponseOnIOThread( | 195 void ChromeURLDataManager::DataSource::SendResponseOnIOThread( |
190 int request_id, | 196 int request_id, |
191 scoped_refptr<RefCountedMemory> bytes) { | 197 scoped_refptr<RefCountedMemory> bytes) { |
192 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
193 if (backend_) | 199 if (backend_) |
194 backend_->DataAvailable(request_id, bytes); | 200 backend_->DataAvailable(request_id, bytes); |
195 } | 201 } |
OLD | NEW |