Remove ExtensionPrefs::SetDidExtensionEscalatePermissions.
[chromium-blink-merge.git] / extensions / shell / browser / shell_browser_context.cc
blob745770b5d3b1bdeab48656514689e3d70d34af1e
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
3 // found in the LICENSE file.
5 #include "extensions/shell/browser/shell_browser_context.h"
7 #include "base/command_line.h"
8 #include "components/guest_view/browser/guest_view_manager.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/common/content_switches.h"
11 #include "extensions/shell/browser/shell_network_delegate.h"
12 #include "extensions/shell/browser/shell_special_storage_policy.h"
13 #include "extensions/shell/browser/shell_url_request_context_getter.h"
15 namespace extensions {
17 namespace {
19 bool IgnoreCertificateErrors() {
20 return base::CommandLine::ForCurrentProcess()->HasSwitch(
21 ::switches::kIgnoreCertificateErrors);
24 } // namespace
26 // Create a normal recording browser context. If we used an incognito context
27 // then app_shell would also have to create a normal context and manage both.
28 ShellBrowserContext::ShellBrowserContext()
29 : content::ShellBrowserContext(false /* off_the_record */,
30 nullptr /* net_log */),
31 storage_policy_(new ShellSpecialStoragePolicy) {
34 ShellBrowserContext::~ShellBrowserContext() {
37 content::BrowserPluginGuestManager* ShellBrowserContext::GetGuestManager() {
38 return guest_view::GuestViewManager::FromBrowserContext(this);
41 storage::SpecialStoragePolicy* ShellBrowserContext::GetSpecialStoragePolicy() {
42 return storage_policy_.get();
45 net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext(
46 content::ProtocolHandlerMap* protocol_handlers,
47 content::URLRequestInterceptorScopedVector request_interceptors,
48 InfoMap* extension_info_map) {
49 DCHECK(!url_request_context_getter());
50 set_url_request_context_getter(
51 new ShellURLRequestContextGetter(
52 this,
53 IgnoreCertificateErrors(),
54 GetPath(),
55 content::BrowserThread::UnsafeGetMessageLoopForThread(
56 content::BrowserThread::IO),
57 content::BrowserThread::UnsafeGetMessageLoopForThread(
58 content::BrowserThread::FILE),
59 protocol_handlers,
60 request_interceptors.Pass(),
61 nullptr /* net_log */,
62 extension_info_map));
63 resource_context_->set_url_request_context_getter(
64 url_request_context_getter());
65 content::BrowserThread::PostTask(
66 content::BrowserThread::IO,
67 FROM_HERE,
68 base::Bind(
69 &ShellBrowserContext::InitURLRequestContextOnIOThread,
70 base::Unretained(this)));
71 return url_request_context_getter();
74 void ShellBrowserContext::InitURLRequestContextOnIOThread() {
75 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
77 // GetURLRequestContext() will create a URLRequestContext if it isn't
78 // initialized.
79 url_request_context_getter()->GetURLRequestContext();
82 } // namespace extensions