OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/shell/browser/shell_browser_context.h" | 5 #include "content/shell/browser/shell_browser_context.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 net::URLRequestContext* | 43 net::URLRequestContext* |
44 ShellBrowserContext::ShellResourceContext::GetRequestContext() { | 44 ShellBrowserContext::ShellResourceContext::GetRequestContext() { |
45 CHECK(getter_); | 45 CHECK(getter_); |
46 return getter_->GetURLRequestContext(); | 46 return getter_->GetURLRequestContext(); |
47 } | 47 } |
48 | 48 |
49 ShellBrowserContext::ShellBrowserContext(bool off_the_record, | 49 ShellBrowserContext::ShellBrowserContext(bool off_the_record, |
50 net::NetLog* net_log) | 50 net::NetLog* net_log) |
51 : resource_context_(new ShellResourceContext), | 51 : resource_context_(new ShellResourceContext), |
| 52 ignore_certificate_errors_(false), |
52 off_the_record_(off_the_record), | 53 off_the_record_(off_the_record), |
53 net_log_(net_log), | 54 net_log_(net_log), |
54 ignore_certificate_errors_(false), | |
55 guest_manager_(NULL) { | 55 guest_manager_(NULL) { |
56 InitWhileIOAllowed(); | 56 InitWhileIOAllowed(); |
57 } | 57 } |
58 | 58 |
59 ShellBrowserContext::~ShellBrowserContext() { | 59 ShellBrowserContext::~ShellBrowserContext() { |
60 if (resource_context_) { | 60 if (resource_context_) { |
61 BrowserThread::DeleteSoon( | 61 BrowserThread::DeleteSoon( |
62 BrowserThread::IO, FROM_HERE, resource_context_.release()); | 62 BrowserThread::IO, FROM_HERE, resource_context_.release()); |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 void ShellBrowserContext::InitWhileIOAllowed() { | 66 void ShellBrowserContext::InitWhileIOAllowed() { |
67 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 67 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
68 if (cmd_line->HasSwitch(switches::kIgnoreCertificateErrors) || | 68 if (cmd_line->HasSwitch(switches::kIgnoreCertificateErrors)) |
69 cmd_line->HasSwitch(switches::kDumpRenderTree)) { | |
70 ignore_certificate_errors_ = true; | 69 ignore_certificate_errors_ = true; |
71 } | |
72 if (cmd_line->HasSwitch(switches::kContentShellDataPath)) { | 70 if (cmd_line->HasSwitch(switches::kContentShellDataPath)) { |
73 path_ = cmd_line->GetSwitchValuePath(switches::kContentShellDataPath); | 71 path_ = cmd_line->GetSwitchValuePath(switches::kContentShellDataPath); |
74 return; | 72 return; |
75 } | 73 } |
76 #if defined(OS_WIN) | 74 #if defined(OS_WIN) |
77 CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &path_)); | 75 CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &path_)); |
78 path_ = path_.Append(std::wstring(L"content_shell")); | 76 path_ = path_.Append(std::wstring(L"content_shell")); |
79 #elif defined(OS_LINUX) | 77 #elif defined(OS_LINUX) |
80 scoped_ptr<base::Environment> env(base::Environment::Create()); | 78 scoped_ptr<base::Environment> env(base::Environment::Create()); |
81 base::FilePath config_dir( | 79 base::FilePath config_dir( |
(...skipping 17 matching lines...) Expand all Loading... |
99 | 97 |
100 base::FilePath ShellBrowserContext::GetPath() const { | 98 base::FilePath ShellBrowserContext::GetPath() const { |
101 return path_; | 99 return path_; |
102 } | 100 } |
103 | 101 |
104 bool ShellBrowserContext::IsOffTheRecord() const { | 102 bool ShellBrowserContext::IsOffTheRecord() const { |
105 return off_the_record_; | 103 return off_the_record_; |
106 } | 104 } |
107 | 105 |
108 DownloadManagerDelegate* ShellBrowserContext::GetDownloadManagerDelegate() { | 106 DownloadManagerDelegate* ShellBrowserContext::GetDownloadManagerDelegate() { |
109 DownloadManager* manager = BrowserContext::GetDownloadManager(this); | |
110 | |
111 if (!download_manager_delegate_.get()) { | 107 if (!download_manager_delegate_.get()) { |
112 download_manager_delegate_.reset(new ShellDownloadManagerDelegate()); | 108 download_manager_delegate_.reset(new ShellDownloadManagerDelegate()); |
113 download_manager_delegate_->SetDownloadManager(manager); | 109 download_manager_delegate_->SetDownloadManager( |
114 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 110 BrowserContext::GetDownloadManager(this)); |
115 if (cmd_line->HasSwitch(switches::kDumpRenderTree)) { | |
116 download_manager_delegate_->SetDownloadBehaviorForTesting( | |
117 path_.Append(FILE_PATH_LITERAL("downloads"))); | |
118 } | |
119 } | 111 } |
120 | 112 |
121 return download_manager_delegate_.get(); | 113 return download_manager_delegate_.get(); |
122 } | 114 } |
123 | 115 |
124 net::URLRequestContextGetter* ShellBrowserContext::GetRequestContext() { | 116 net::URLRequestContextGetter* ShellBrowserContext::GetRequestContext() { |
125 return GetDefaultStoragePartition(this)->GetURLRequestContext(); | 117 return GetDefaultStoragePartition(this)->GetURLRequestContext(); |
126 } | 118 } |
127 | 119 |
128 net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext( | 120 net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 180 |
189 PushMessagingService* ShellBrowserContext::GetPushMessagingService() { | 181 PushMessagingService* ShellBrowserContext::GetPushMessagingService() { |
190 return NULL; | 182 return NULL; |
191 } | 183 } |
192 | 184 |
193 SSLHostStateDelegate* ShellBrowserContext::GetSSLHostStateDelegate() { | 185 SSLHostStateDelegate* ShellBrowserContext::GetSSLHostStateDelegate() { |
194 return NULL; | 186 return NULL; |
195 } | 187 } |
196 | 188 |
197 } // namespace content | 189 } // namespace content |
OLD | NEW |