| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013 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. |
| 4 |
| 5 #include "android_webview/browser/aw_resource_context.h" |
| 6 |
| 7 #include "content/public/browser/browser_thread.h" |
| 8 #include "net/url_request/url_request_context.h" |
| 9 #include "net/url_request/url_request_context_getter.h" |
| 10 |
| 11 namespace android_webview { |
| 12 |
| 13 AwResourceContext::AwResourceContext(net::URLRequestContextGetter* getter) |
| 14 : getter_(getter) { |
| 15 DCHECK(getter_); |
| 16 } |
| 17 |
| 18 AwResourceContext::~AwResourceContext() { |
| 19 } |
| 20 |
| 21 net::HostResolver* AwResourceContext::GetHostResolver() { |
| 22 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 23 return getter_->GetURLRequestContext()->host_resolver(); |
| 24 } |
| 25 |
| 26 net::URLRequestContext* AwResourceContext::GetRequestContext() { |
| 27 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 28 return getter_->GetURLRequestContext(); |
| 29 } |
| 30 |
| 31 bool AwResourceContext::AllowMicAccess(const GURL& origin) { |
| 32 return false; |
| 33 } |
| 34 |
| 35 bool AwResourceContext::AllowCameraAccess(const GURL& origin) { |
| 36 return false; |
| 37 } |
| 38 |
| 39 void AwResourceContext::SetExtraHeaders(const GURL& url, std::string& headers) { |
| 40 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 41 if (!url.is_valid()) return; |
| 42 base::AutoLock scoped_lock(lock_); |
| 43 if (!headers.empty()) |
| 44 extra_headers_[url.spec()] = headers; |
| 45 else |
| 46 extra_headers_.erase(url.spec()); |
| 47 } |
| 48 |
| 49 std::string AwResourceContext::GetExtraHeaders(const GURL& url) { |
| 50 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 51 if (!url.is_valid()) return std::string(); |
| 52 base::AutoLock scoped_lock(lock_); |
| 53 std::map<std::string, std::string>::iterator iter = |
| 54 extra_headers_.find(url.spec()); |
| 55 return iter != extra_headers_.end() ? iter->second : std::string(); |
| 56 } |
| 57 |
| 58 } // namespace android_webview |
| OLD | NEW |