OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/chrome_plugin_host.h" | 5 #include "chrome/browser/chrome_plugin_host.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // is being persisted across unit tests. As a result, each time we get | 102 // is being persisted across unit tests. As a result, each time we get |
103 // poked on a different thread, but never from more than one thread at a | 103 // poked on a different thread, but never from more than one thread at a |
104 // time. We need a way to have the URLRequestJobManager get reset between | 104 // time. We need a way to have the URLRequestJobManager get reset between |
105 // unit tests. | 105 // unit tests. |
106 // DCHECK(CalledOnValidThread()); | 106 // DCHECK(CalledOnValidThread()); |
107 | 107 |
108 if (!IsHandledProtocol(request->url().scheme())) | 108 if (!IsHandledProtocol(request->url().scheme())) |
109 return NULL; | 109 return NULL; |
110 | 110 |
111 CPBrowsingContext context = | 111 CPBrowsingContext context = |
112 CPBrowsingContextManager::Instance()->Lookup(request->context()); | 112 CPBrowsingContextManager::GetInstance()->Lookup(request->context()); |
113 scoped_ptr<ScopableCPRequest> cprequest( | 113 scoped_ptr<ScopableCPRequest> cprequest( |
114 new ScopableCPRequest(request->url().spec().c_str(), | 114 new ScopableCPRequest(request->url().spec().c_str(), |
115 request->method().c_str(), | 115 request->method().c_str(), |
116 context)); | 116 context)); |
117 | 117 |
118 PerfTimer timer; | 118 PerfTimer timer; |
119 if (!plugin_->functions().should_intercept_request(cprequest.get())) { | 119 if (!plugin_->functions().should_intercept_request(cprequest.get())) { |
120 LogInterceptMissTime(timer.Elapsed()); | 120 LogInterceptMissTime(timer.Elapsed()); |
121 return NULL; | 121 return NULL; |
122 } | 122 } |
(...skipping 26 matching lines...) Expand all Loading... |
149 public net::URLRequest::Delegate { | 149 public net::URLRequest::Delegate { |
150 public: | 150 public: |
151 static PluginRequestHandler* FromCPRequest(CPRequest* request) { | 151 static PluginRequestHandler* FromCPRequest(CPRequest* request) { |
152 return ScopableCPRequest::GetData<PluginRequestHandler*>(request); | 152 return ScopableCPRequest::GetData<PluginRequestHandler*>(request); |
153 } | 153 } |
154 | 154 |
155 PluginRequestHandler(ChromePluginLib* plugin, ScopableCPRequest* cprequest) | 155 PluginRequestHandler(ChromePluginLib* plugin, ScopableCPRequest* cprequest) |
156 : PluginHelper(plugin), cprequest_(cprequest), user_buffer_(NULL) { | 156 : PluginHelper(plugin), cprequest_(cprequest), user_buffer_(NULL) { |
157 cprequest_->data = this; // see FromCPRequest(). | 157 cprequest_->data = this; // see FromCPRequest(). |
158 | 158 |
159 URLRequestContext* context = CPBrowsingContextManager::Instance()-> | 159 URLRequestContext* context = CPBrowsingContextManager::GetInstance()-> |
160 ToURLRequestContext(cprequest_->context); | 160 ToURLRequestContext(cprequest_->context); |
161 // TODO(mpcomplete): remove fallback case when Gears support is prevalent. | 161 // TODO(mpcomplete): remove fallback case when Gears support is prevalent. |
162 if (!context) | 162 if (!context) |
163 context = Profile::GetDefaultRequestContext()->GetURLRequestContext(); | 163 context = Profile::GetDefaultRequestContext()->GetURLRequestContext(); |
164 | 164 |
165 GURL gurl(cprequest_->url); | 165 GURL gurl(cprequest_->url); |
166 request_.reset(new net::URLRequest(gurl, this)); | 166 request_.reset(new net::URLRequest(gurl, this)); |
167 request_->set_context(context); | 167 request_->set_context(context); |
168 request_->set_method(cprequest_->method); | 168 request_->set_method(cprequest_->method); |
169 request_->set_load_flags(PluginResponseUtils::CPLoadFlagsToNetFlags(0)); | 169 request_->set_load_flags(PluginResponseUtils::CPLoadFlagsToNetFlags(0)); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 // Generic functions | 379 // Generic functions |
380 // | 380 // |
381 | 381 |
382 void STDCALL CPB_SetKeepProcessAlive(CPID id, CPBool keep_alive) { | 382 void STDCALL CPB_SetKeepProcessAlive(CPID id, CPBool keep_alive) { |
383 // This is a no-op in the main browser process | 383 // This is a no-op in the main browser process |
384 } | 384 } |
385 | 385 |
386 CPError STDCALL CPB_GetCookies(CPID id, CPBrowsingContext bcontext, | 386 CPError STDCALL CPB_GetCookies(CPID id, CPBrowsingContext bcontext, |
387 const char* url, char** cookies) { | 387 const char* url, char** cookies) { |
388 CHECK(ChromePluginLib::IsPluginThread()); | 388 CHECK(ChromePluginLib::IsPluginThread()); |
389 URLRequestContext* context = CPBrowsingContextManager::Instance()-> | 389 URLRequestContext* context = CPBrowsingContextManager::GetInstance()-> |
390 ToURLRequestContext(bcontext); | 390 ToURLRequestContext(bcontext); |
391 // TODO(mpcomplete): remove fallback case when Gears support is prevalent. | 391 // TODO(mpcomplete): remove fallback case when Gears support is prevalent. |
392 if (!context) { | 392 if (!context) { |
393 context = Profile::GetDefaultRequestContext()->GetURLRequestContext(); | 393 context = Profile::GetDefaultRequestContext()->GetURLRequestContext(); |
394 if (!context) | 394 if (!context) |
395 return CPERR_FAILURE; | 395 return CPERR_FAILURE; |
396 } | 396 } |
397 std::string cookies_str = context->cookie_store()->GetCookies(GURL(url)); | 397 std::string cookies_str = context->cookie_store()->GetCookies(GURL(url)); |
398 *cookies = CPB_StringDup(CPB_Alloc, cookies_str); | 398 *cookies = CPB_StringDup(CPB_Alloc, cookies_str); |
399 return CPERR_SUCCESS; | 399 return CPERR_SUCCESS; |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 CPBrowsingContext context) { | 825 CPBrowsingContext context) { |
826 // Sadly if we try and pass context through, we seem to break cl's little | 826 // Sadly if we try and pass context through, we seem to break cl's little |
827 // brain trying to compile the Tuple3 ctor. This cast works. | 827 // brain trying to compile the Tuple3 ctor. This cast works. |
828 int32 context_as_int32 = static_cast<int32>(context); | 828 int32 context_as_int32 = static_cast<int32>(context); |
829 // Plugins can only be accessed on the IO thread. | 829 // Plugins can only be accessed on the IO thread. |
830 BrowserThread::PostTask( | 830 BrowserThread::PostTask( |
831 BrowserThread::IO, FROM_HERE, | 831 BrowserThread::IO, FROM_HERE, |
832 NewRunnableFunction(PluginCommandHandler::HandleCommand, | 832 NewRunnableFunction(PluginCommandHandler::HandleCommand, |
833 command, data, context_as_int32)); | 833 command, data, context_as_int32)); |
834 } | 834 } |
OLD | NEW |