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

Side by Side Diff: chrome/browser/webui/chrome_url_data_manager.cc

Issue 6546078: Makes a handful of DataSources not replace the existing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 10 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/webui/chrome_url_data_manager.h" 5 #include "chrome/browser/webui/chrome_url_data_manager.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 30 matching lines...) Expand all
41 41
42 ChromeURLDataManager::ChromeURLDataManager(Profile* profile) 42 ChromeURLDataManager::ChromeURLDataManager(Profile* profile)
43 : profile_(profile) { 43 : profile_(profile) {
44 } 44 }
45 45
46 ChromeURLDataManager::~ChromeURLDataManager() { 46 ChromeURLDataManager::~ChromeURLDataManager() {
47 } 47 }
48 48
49 void ChromeURLDataManager::AddDataSource(DataSource* source) { 49 void ChromeURLDataManager::AddDataSource(DataSource* source) {
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
51 registered_source_names_.insert(source->source_name());
52 BrowserThread::PostTask( 51 BrowserThread::PostTask(
53 BrowserThread::IO, FROM_HERE, 52 BrowserThread::IO, FROM_HERE,
54 NewRunnableFunction(AddDataSourceOnIOThread, 53 NewRunnableFunction(AddDataSourceOnIOThread,
55 make_scoped_refptr(profile_->GetRequestContext()), 54 make_scoped_refptr(profile_->GetRequestContext()),
56 make_scoped_refptr(source))); 55 make_scoped_refptr(source)));
57 } 56 }
58 57
59 bool ChromeURLDataManager::IsRegistered(const std::string& name) {
60 return registered_source_names_.find(name) != registered_source_names_.end();
61 }
62
63 // static 58 // static
64 void ChromeURLDataManager::DeleteDataSources() { 59 void ChromeURLDataManager::DeleteDataSources() {
65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
66 DataSources sources; 61 DataSources sources;
67 { 62 {
68 base::AutoLock lock(delete_lock_); 63 base::AutoLock lock(delete_lock_);
69 if (!data_sources_) 64 if (!data_sources_)
70 return; 65 return;
71 data_sources_->swap(sources); 66 data_sources_->swap(sources);
72 } 67 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 BrowserThread::IO, FROM_HERE, 137 BrowserThread::IO, FROM_HERE,
143 NewRunnableMethod(this, &DataSource::SendResponseOnIOThread, 138 NewRunnableMethod(this, &DataSource::SendResponseOnIOThread,
144 request_id, make_scoped_refptr(bytes))); 139 request_id, make_scoped_refptr(bytes)));
145 } 140 }
146 141
147 MessageLoop* ChromeURLDataManager::DataSource::MessageLoopForRequestPath( 142 MessageLoop* ChromeURLDataManager::DataSource::MessageLoopForRequestPath(
148 const std::string& path) const { 143 const std::string& path) const {
149 return message_loop_; 144 return message_loop_;
150 } 145 }
151 146
147 bool ChromeURLDataManager::DataSource::ShouldReplaceExistingSource() const {
148 return true;
149 }
150
152 // static 151 // static
153 void ChromeURLDataManager::DataSource::SetFontAndTextDirection( 152 void ChromeURLDataManager::DataSource::SetFontAndTextDirection(
154 DictionaryValue* localized_strings) { 153 DictionaryValue* localized_strings) {
155 localized_strings->SetString("fontfamily", 154 localized_strings->SetString("fontfamily",
156 l10n_util::GetStringUTF16(IDS_WEB_FONT_FAMILY)); 155 l10n_util::GetStringUTF16(IDS_WEB_FONT_FAMILY));
157 156
158 int web_font_size_id = IDS_WEB_FONT_SIZE; 157 int web_font_size_id = IDS_WEB_FONT_SIZE;
159 #if defined(OS_WIN) 158 #if defined(OS_WIN)
160 // Some fonts used for some languages changed a lot in terms of the font 159 // Some fonts used for some languages changed a lot in terms of the font
161 // metric in Vista. So, we need to use different size before Vista. 160 // metric in Vista. So, we need to use different size before Vista.
162 if (base::win::GetVersion() < base::win::VERSION_VISTA) 161 if (base::win::GetVersion() < base::win::VERSION_VISTA)
163 web_font_size_id = IDS_WEB_FONT_SIZE_XP; 162 web_font_size_id = IDS_WEB_FONT_SIZE_XP;
164 #endif 163 #endif
165 localized_strings->SetString("fontsize", 164 localized_strings->SetString("fontsize",
166 l10n_util::GetStringUTF16(web_font_size_id)); 165 l10n_util::GetStringUTF16(web_font_size_id));
167 166
168 localized_strings->SetString("textdirection", 167 localized_strings->SetString("textdirection",
169 base::i18n::IsRTL() ? "rtl" : "ltr"); 168 base::i18n::IsRTL() ? "rtl" : "ltr");
170 } 169 }
171 170
172 void ChromeURLDataManager::DataSource::SendResponseOnIOThread( 171 void ChromeURLDataManager::DataSource::SendResponseOnIOThread(
173 int request_id, 172 int request_id,
174 scoped_refptr<RefCountedMemory> bytes) { 173 scoped_refptr<RefCountedMemory> bytes) {
175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
176 if (backend_) 175 if (backend_)
177 backend_->DataAvailable(request_id, bytes); 176 backend_->DataAvailable(request_id, bytes);
178 } 177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698