| 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 void AwResourceContext::SetExtraHeaders( |
| 22 const GURL& url, const std::string& headers) { |
| 23 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 24 if (!url.is_valid()) return; |
| 25 base::AutoLock scoped_lock(extra_headers_lock_); |
| 26 if (!headers.empty()) |
| 27 extra_headers_[url.spec()] = headers; |
| 28 else |
| 29 extra_headers_.erase(url.spec()); |
| 30 } |
| 31 |
| 32 std::string AwResourceContext::GetExtraHeaders(const GURL& url) { |
| 33 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 34 if (!url.is_valid()) return std::string(); |
| 35 base::AutoLock scoped_lock(extra_headers_lock_); |
| 36 std::map<std::string, std::string>::iterator iter = |
| 37 extra_headers_.find(url.spec()); |
| 38 return iter != extra_headers_.end() ? iter->second : std::string(); |
| 39 } |
| 40 |
| 41 net::HostResolver* AwResourceContext::GetHostResolver() { |
| 42 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 43 return getter_->GetURLRequestContext()->host_resolver(); |
| 44 } |
| 45 |
| 46 net::URLRequestContext* AwResourceContext::GetRequestContext() { |
| 47 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 48 return getter_->GetURLRequestContext(); |
| 49 } |
| 50 |
| 51 bool AwResourceContext::AllowMicAccess(const GURL& origin) { |
| 52 return false; |
| 53 } |
| 54 |
| 55 bool AwResourceContext::AllowCameraAccess(const GURL& origin) { |
| 56 return false; |
| 57 } |
| 58 |
| 59 } // namespace android_webview |
| OLD | NEW |