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 "content/browser/webui/web_ui_data_source_impl.h" | 5 #include "content/browser/webui/web_ui_data_source_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // static | 23 // static |
24 WebUIDataSource* WebUIDataSource::Create(const std::string& source_name) { | 24 WebUIDataSource* WebUIDataSource::Create(const std::string& source_name) { |
25 return new WebUIDataSourceImpl(source_name); | 25 return new WebUIDataSourceImpl(source_name); |
26 } | 26 } |
27 | 27 |
28 #if defined(USE_MOJO) | 28 #if defined(USE_MOJO) |
29 // static | 29 // static |
30 WebUIDataSource* WebUIDataSource::AddMojoDataSource( | 30 WebUIDataSource* WebUIDataSource::AddMojoDataSource( |
31 BrowserContext* browser_context) { | 31 BrowserContext* browser_context) { |
32 WebUIDataSource* mojo_source = Create("mojo"); | 32 WebUIDataSource* mojo_source = Create("mojo"); |
33 mojo_source->AddResourcePath(mojo::kCodecModuleName, IDR_MOJO_CODEC_JS); | 33 |
34 mojo_source->AddResourcePath(mojo::kConnectorModuleName, | 34 static const struct { |
35 IDR_MOJO_CONNECTOR_JS); | 35 const char* path; |
| 36 int id; |
| 37 } resources[] = { |
| 38 { mojo::kCodecModuleName, IDR_MOJO_CODEC_JS }, |
| 39 { mojo::kConnectionModuleName, IDR_MOJO_CONNECTION_JS }, |
| 40 { mojo::kConnectorModuleName, IDR_MOJO_CONNECTOR_JS }, |
| 41 { mojo::kRouterModuleName, IDR_MOJO_ROUTER_JS }, |
| 42 }; |
| 43 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) |
| 44 mojo_source->AddResourcePath(resources[i].path, resources[i].id); |
| 45 |
36 URLDataManager::AddWebUIDataSource(browser_context, mojo_source); | 46 URLDataManager::AddWebUIDataSource(browser_context, mojo_source); |
37 return mojo_source; | 47 return mojo_source; |
38 } | 48 } |
39 #endif | 49 #endif |
40 | 50 |
41 // static | 51 // static |
42 void WebUIDataSource::Add(BrowserContext* browser_context, | 52 void WebUIDataSource::Add(BrowserContext* browser_context, |
43 WebUIDataSource* source) { | 53 WebUIDataSource* source) { |
44 URLDataManager::AddWebUIDataSource(browser_context, source); | 54 URLDataManager::AddWebUIDataSource(browser_context, source); |
45 } | 55 } |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 } | 254 } |
245 | 255 |
246 void WebUIDataSourceImpl::SendFromResourceBundle( | 256 void WebUIDataSourceImpl::SendFromResourceBundle( |
247 const URLDataSource::GotDataCallback& callback, int idr) { | 257 const URLDataSource::GotDataCallback& callback, int idr) { |
248 scoped_refptr<base::RefCountedStaticMemory> response( | 258 scoped_refptr<base::RefCountedStaticMemory> response( |
249 GetContentClient()->GetDataResourceBytes(idr)); | 259 GetContentClient()->GetDataResourceBytes(idr)); |
250 callback.Run(response.get()); | 260 callback.Run(response.get()); |
251 } | 261 } |
252 | 262 |
253 } // namespace content | 263 } // namespace content |
OLD | NEW |