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

Side by Side Diff: content/browser/webui/web_ui_data_source_impl.cc

Issue 226213002: Removes use_mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge 2 trunk Created 6 years, 8 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) 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"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "content/public/common/content_client.h" 12 #include "content/public/common/content_client.h"
13 #include "grit/content_resources.h" 13 #include "grit/content_resources.h"
14 #include "mojo/public/js/bindings/constants.h"
14 #include "ui/base/webui/jstemplate_builder.h" 15 #include "ui/base/webui/jstemplate_builder.h"
15 #include "ui/base/webui/web_ui_util.h" 16 #include "ui/base/webui/web_ui_util.h"
16 17
17 #if defined(USE_MOJO)
18 #include "mojo/public/js/bindings/constants.h"
19 #endif
20
21 namespace content { 18 namespace content {
22 19
23 // static 20 // static
24 WebUIDataSource* WebUIDataSource::Create(const std::string& source_name) { 21 WebUIDataSource* WebUIDataSource::Create(const std::string& source_name) {
25 return new WebUIDataSourceImpl(source_name); 22 return new WebUIDataSourceImpl(source_name);
26 } 23 }
27 24
28 #if defined(USE_MOJO)
29 // static 25 // static
30 WebUIDataSource* WebUIDataSource::AddMojoDataSource( 26 WebUIDataSource* WebUIDataSource::AddMojoDataSource(
31 BrowserContext* browser_context) { 27 BrowserContext* browser_context) {
32 WebUIDataSource* mojo_source = Create("mojo"); 28 WebUIDataSource* mojo_source = Create("mojo");
33 29
34 static const struct { 30 static const struct {
35 const char* path; 31 const char* path;
36 int id; 32 int id;
37 } resources[] = { 33 } resources[] = {
38 { mojo::kCodecModuleName, IDR_MOJO_CODEC_JS }, 34 { mojo::kCodecModuleName, IDR_MOJO_CODEC_JS },
39 { mojo::kConnectionModuleName, IDR_MOJO_CONNECTION_JS }, 35 { mojo::kConnectionModuleName, IDR_MOJO_CONNECTION_JS },
40 { mojo::kConnectorModuleName, IDR_MOJO_CONNECTOR_JS }, 36 { mojo::kConnectorModuleName, IDR_MOJO_CONNECTOR_JS },
41 { mojo::kRouterModuleName, IDR_MOJO_ROUTER_JS }, 37 { mojo::kRouterModuleName, IDR_MOJO_ROUTER_JS },
42 }; 38 };
43 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) 39 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i)
44 mojo_source->AddResourcePath(resources[i].path, resources[i].id); 40 mojo_source->AddResourcePath(resources[i].path, resources[i].id);
45 41
46 URLDataManager::AddWebUIDataSource(browser_context, mojo_source); 42 URLDataManager::AddWebUIDataSource(browser_context, mojo_source);
47 return mojo_source; 43 return mojo_source;
48 } 44 }
49 #endif
50 45
51 // static 46 // static
52 void WebUIDataSource::Add(BrowserContext* browser_context, 47 void WebUIDataSource::Add(BrowserContext* browser_context,
53 WebUIDataSource* source) { 48 WebUIDataSource* source) {
54 URLDataManager::AddWebUIDataSource(browser_context, source); 49 URLDataManager::AddWebUIDataSource(browser_context, source);
55 } 50 }
56 51
57 // Internal class to hide the fact that WebUIDataSourceImpl implements 52 // Internal class to hide the fact that WebUIDataSourceImpl implements
58 // URLDataSource. 53 // URLDataSource.
59 class WebUIDataSourceImpl::InternalDataSource : public URLDataSource { 54 class WebUIDataSourceImpl::InternalDataSource : public URLDataSource {
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 249 }
255 250
256 void WebUIDataSourceImpl::SendFromResourceBundle( 251 void WebUIDataSourceImpl::SendFromResourceBundle(
257 const URLDataSource::GotDataCallback& callback, int idr) { 252 const URLDataSource::GotDataCallback& callback, int idr) {
258 scoped_refptr<base::RefCountedStaticMemory> response( 253 scoped_refptr<base::RefCountedStaticMemory> response(
259 GetContentClient()->GetDataResourceBytes(idr)); 254 GetContentClient()->GetDataResourceBytes(idr));
260 callback.Run(response.get()); 255 callback.Run(response.get());
261 } 256 }
262 257
263 } // namespace content 258 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.cc ('k') | content/common/content_message_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698