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

Side by Side Diff: extensions/shell/browser/shell_browser_context.cc

Issue 1862203005: Remove ContentBrowserClient::CreateRequestContext & CreateRequestContextForStoragePartition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/shell/browser/shell_browser_context.h" 5 #include "extensions/shell/browser/shell_browser_context.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "components/guest_view/browser/guest_view_manager.h" 10 #include "components/guest_view/browser/guest_view_manager.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/common/content_switches.h" 12 #include "content/public/common/content_switches.h"
13 #include "extensions/browser/extension_protocols.h"
14 #include "extensions/common/constants.h"
15 #include "extensions/shell/browser/shell_browser_main_parts.h"
16 #include "extensions/shell/browser/shell_extension_system.h"
13 #include "extensions/shell/browser/shell_network_delegate.h" 17 #include "extensions/shell/browser/shell_network_delegate.h"
14 #include "extensions/shell/browser/shell_special_storage_policy.h" 18 #include "extensions/shell/browser/shell_special_storage_policy.h"
15 #include "extensions/shell/browser/shell_url_request_context_getter.h" 19 #include "extensions/shell/browser/shell_url_request_context_getter.h"
16 20
17 namespace extensions { 21 namespace extensions {
18 22
19 namespace { 23 namespace {
20 24
21 bool IgnoreCertificateErrors() { 25 bool IgnoreCertificateErrors() {
22 return base::CommandLine::ForCurrentProcess()->HasSwitch( 26 return base::CommandLine::ForCurrentProcess()->HasSwitch(
23 ::switches::kIgnoreCertificateErrors); 27 ::switches::kIgnoreCertificateErrors);
24 } 28 }
25 29
26 } // namespace 30 } // namespace
27 31
28 // Create a normal recording browser context. If we used an incognito context 32 // Create a normal recording browser context. If we used an incognito context
29 // then app_shell would also have to create a normal context and manage both. 33 // then app_shell would also have to create a normal context and manage both.
30 ShellBrowserContext::ShellBrowserContext() 34 ShellBrowserContext::ShellBrowserContext(
35 ShellBrowserMainParts* browser_main_parts)
31 : content::ShellBrowserContext(false /* off_the_record */, 36 : content::ShellBrowserContext(false /* off_the_record */,
32 nullptr /* net_log */), 37 nullptr /* net_log */),
33 storage_policy_(new ShellSpecialStoragePolicy) { 38 storage_policy_(new ShellSpecialStoragePolicy),
39 browser_main_parts_(browser_main_parts) {
34 } 40 }
35 41
36 ShellBrowserContext::~ShellBrowserContext() { 42 ShellBrowserContext::~ShellBrowserContext() {
37 } 43 }
38 44
39 content::BrowserPluginGuestManager* ShellBrowserContext::GetGuestManager() { 45 content::BrowserPluginGuestManager* ShellBrowserContext::GetGuestManager() {
40 return guest_view::GuestViewManager::FromBrowserContext(this); 46 return guest_view::GuestViewManager::FromBrowserContext(this);
41 } 47 }
42 48
43 storage::SpecialStoragePolicy* ShellBrowserContext::GetSpecialStoragePolicy() { 49 storage::SpecialStoragePolicy* ShellBrowserContext::GetSpecialStoragePolicy() {
44 return storage_policy_.get(); 50 return storage_policy_.get();
45 } 51 }
46 52
47 net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext( 53 net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext(
48 content::ProtocolHandlerMap* protocol_handlers, 54 content::ProtocolHandlerMap* protocol_handlers,
49 content::URLRequestInterceptorScopedVector request_interceptors, 55 content::URLRequestInterceptorScopedVector request_interceptors) {
50 InfoMap* extension_info_map) {
51 DCHECK(!url_request_context_getter()); 56 DCHECK(!url_request_context_getter());
57 // Handle only chrome-extension:// requests. app_shell does not support
58 // chrome-extension-resource:// requests (it does not store shared extension
59 // data in its installation directory).
60 InfoMap* extension_info_map =
61 browser_main_parts_->extension_system()->info_map();
62 (*protocol_handlers)[kExtensionScheme] =
63 linked_ptr<net::URLRequestJobFactory::ProtocolHandler>(
Avi (use Gerrit) 2016/04/07 19:10:05 ditto
64 CreateExtensionProtocolHandler(false /* is_incognito */,
65 extension_info_map)
66 .release());
67
52 set_url_request_context_getter(new ShellURLRequestContextGetter( 68 set_url_request_context_getter(new ShellURLRequestContextGetter(
53 this, IgnoreCertificateErrors(), GetPath(), 69 this, IgnoreCertificateErrors(), GetPath(),
54 content::BrowserThread::GetMessageLoopProxyForThread( 70 content::BrowserThread::GetMessageLoopProxyForThread(
55 content::BrowserThread::IO), 71 content::BrowserThread::IO),
56 content::BrowserThread::GetMessageLoopProxyForThread( 72 content::BrowserThread::GetMessageLoopProxyForThread(
57 content::BrowserThread::FILE), 73 content::BrowserThread::FILE),
58 protocol_handlers, std::move(request_interceptors), nullptr /* net_log */, 74 protocol_handlers, std::move(request_interceptors), nullptr /* net_log */,
59 extension_info_map)); 75 extension_info_map));
60 resource_context_->set_url_request_context_getter( 76 resource_context_->set_url_request_context_getter(
61 url_request_context_getter()); 77 url_request_context_getter());
62 content::BrowserThread::PostTask( 78 content::BrowserThread::PostTask(
63 content::BrowserThread::IO, 79 content::BrowserThread::IO,
64 FROM_HERE, 80 FROM_HERE,
65 base::Bind( 81 base::Bind(
66 &ShellBrowserContext::InitURLRequestContextOnIOThread, 82 &ShellBrowserContext::InitURLRequestContextOnIOThread,
67 base::Unretained(this))); 83 base::Unretained(this)));
68 return url_request_context_getter(); 84 return url_request_context_getter();
69 } 85 }
70 86
71 void ShellBrowserContext::InitURLRequestContextOnIOThread() { 87 void ShellBrowserContext::InitURLRequestContextOnIOThread() {
72 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 88 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
73 89
74 // GetURLRequestContext() will create a URLRequestContext if it isn't 90 // GetURLRequestContext() will create a URLRequestContext if it isn't
75 // initialized. 91 // initialized.
76 url_request_context_getter()->GetURLRequestContext(); 92 url_request_context_getter()->GetURLRequestContext();
77 } 93 }
78 94
79 } // namespace extensions 95 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698