OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_url_loader_factory.h" | 5 #include "content/browser/webui/web_ui_url_loader_factory.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
14 #include "content/browser/blob_storage/blob_internals_url_loader.h" | 14 #include "content/browser/blob_storage/blob_internals_url_loader.h" |
15 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 15 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
16 #include "content/browser/frame_host/frame_tree_node.h" | 16 #include "content/browser/frame_host/frame_tree_node.h" |
17 #include "content/browser/frame_host/render_frame_host_impl.h" | 17 #include "content/browser/frame_host/render_frame_host_impl.h" |
18 #include "content/browser/histogram_internals_url_loader.h" | 18 #include "content/browser/histogram_internals_url_loader.h" |
19 #include "content/browser/resource_context_impl.h" | 19 #include "content/browser/resource_context_impl.h" |
20 #include "content/browser/webui/url_data_manager_backend.h" | 20 #include "content/browser/webui/url_data_manager_backend.h" |
21 #include "content/browser/webui/url_data_source_impl.h" | 21 #include "content/browser/webui/url_data_source_impl.h" |
22 #include "content/common/network_service.mojom.h" | |
22 #include "content/public/browser/browser_context.h" | 23 #include "content/public/browser/browser_context.h" |
23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/render_process_host.h" | 25 #include "content/public/browser/render_process_host.h" |
25 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
27 #include "content/public/common/service_manager_connection.h" | |
28 #include "content/public/common/service_names.mojom.h" | |
26 #include "content/public/common/url_constants.h" | 29 #include "content/public/common/url_constants.h" |
27 #include "mojo/public/cpp/bindings/binding_set.h" | 30 #include "mojo/public/cpp/bindings/binding_set.h" |
31 #include "services/service_manager/public/cpp/connector.h" | |
28 #include "third_party/zlib/google/compression_utils.h" | 32 #include "third_party/zlib/google/compression_utils.h" |
29 #include "ui/base/template_expressions.h" | 33 #include "ui/base/template_expressions.h" |
30 | 34 |
31 namespace content { | 35 namespace content { |
32 | 36 |
33 namespace { | 37 namespace { |
34 | 38 |
35 class WebUIURLLoaderFactory; | 39 class WebUIURLLoaderFactory; |
36 base::LazyInstance<std::map<int, std::unique_ptr<WebUIURLLoaderFactory>>>::Leaky | 40 base::LazyInstance<std::map<int, std::unique_ptr<WebUIURLLoaderFactory>>>::Leaky |
37 g_factories = LAZY_INSTANCE_INITIALIZER; | 41 g_factories = LAZY_INSTANCE_INITIALIZER; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 } | 237 } |
234 | 238 |
235 // mojom::URLLoaderFactory implementation: | 239 // mojom::URLLoaderFactory implementation: |
236 void CreateLoaderAndStart(mojom::URLLoaderAssociatedRequest loader, | 240 void CreateLoaderAndStart(mojom::URLLoaderAssociatedRequest loader, |
237 int32_t routing_id, | 241 int32_t routing_id, |
238 int32_t request_id, | 242 int32_t request_id, |
239 uint32_t options, | 243 uint32_t options, |
240 const ResourceRequest& request, | 244 const ResourceRequest& request, |
241 mojom::URLLoaderClientPtr client) override { | 245 mojom::URLLoaderClientPtr client) override { |
242 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 246 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
243 if (request.url.host_piece() == kChromeUIBlobInternalsHost) { | 247 if (request.url.host_piece() == kChromeUINetworkViewCacheHost) { |
248 mojom::NetworkServicePtr network_service; | |
249 ServiceManagerConnection::GetForProcess()->GetConnector()->BindInterface( | |
250 mojom::kNetworkServiceName, &network_service); | |
251 network_service->HandleViewCacheRequest(request, std::move(client)); | |
252 return; | |
253 } else if (request.url.host_piece() == kChromeUIBlobInternalsHost) { | |
mmenke
2017/05/10 18:52:30
optional nit: I think the preferred style is not
jam
2017/05/10 22:02:53
Done.
| |
244 BrowserThread::PostTask( | 254 BrowserThread::PostTask( |
245 BrowserThread::IO, FROM_HERE, | 255 BrowserThread::IO, FROM_HERE, |
246 base::BindOnce( | 256 base::BindOnce( |
247 &StartBlobInternalsURLLoader, request, client.PassInterface(), | 257 &StartBlobInternalsURLLoader, request, client.PassInterface(), |
248 base::Unretained( | 258 base::Unretained( |
249 ChromeBlobStorageContext::GetFor(browser_context_)))); | 259 ChromeBlobStorageContext::GetFor(browser_context_)))); |
250 return; | 260 return; |
251 } else if (request.url.host_piece() == kChromeUIHistogramHost) { | 261 } else if (request.url.host_piece() == kChromeUIHistogramHost) { |
252 StartHistogramInternalsURLLoader(request, std::move(client)); | 262 StartHistogramInternalsURLLoader(request, std::move(client)); |
253 return; | 263 return; |
(...skipping 29 matching lines...) Expand all Loading... | |
283 } // namespace | 293 } // namespace |
284 | 294 |
285 mojom::URLLoaderFactoryPtr GetWebUIURLLoader(FrameTreeNode* node) { | 295 mojom::URLLoaderFactoryPtr GetWebUIURLLoader(FrameTreeNode* node) { |
286 int ftn_id = node->frame_tree_node_id(); | 296 int ftn_id = node->frame_tree_node_id(); |
287 if (g_factories.Get()[ftn_id].get() == nullptr) | 297 if (g_factories.Get()[ftn_id].get() == nullptr) |
288 g_factories.Get()[ftn_id] = base::MakeUnique<WebUIURLLoaderFactory>(node); | 298 g_factories.Get()[ftn_id] = base::MakeUnique<WebUIURLLoaderFactory>(node); |
289 return g_factories.Get()[ftn_id]->CreateBinding(); | 299 return g_factories.Get()[ftn_id]->CreateBinding(); |
290 } | 300 } |
291 | 301 |
292 } // namespace content | 302 } // namespace content |
OLD | NEW |