OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 public net::URLRequest::Delegate { | 151 public net::URLRequest::Delegate { |
152 public: | 152 public: |
153 static PluginRequestHandler* FromCPRequest(CPRequest* request) { | 153 static PluginRequestHandler* FromCPRequest(CPRequest* request) { |
154 return ScopableCPRequest::GetData<PluginRequestHandler*>(request); | 154 return ScopableCPRequest::GetData<PluginRequestHandler*>(request); |
155 } | 155 } |
156 | 156 |
157 PluginRequestHandler(ChromePluginLib* plugin, ScopableCPRequest* cprequest) | 157 PluginRequestHandler(ChromePluginLib* plugin, ScopableCPRequest* cprequest) |
158 : PluginHelper(plugin), cprequest_(cprequest), user_buffer_(NULL) { | 158 : PluginHelper(plugin), cprequest_(cprequest), user_buffer_(NULL) { |
159 cprequest_->data = this; // see FromCPRequest(). | 159 cprequest_->data = this; // see FromCPRequest(). |
160 | 160 |
161 URLRequestContext* context = CPBrowsingContextManager::GetInstance()-> | 161 net::URLRequestContext* context = CPBrowsingContextManager::GetInstance()-> |
162 ToURLRequestContext(cprequest_->context); | 162 ToURLRequestContext(cprequest_->context); |
163 // TODO(mpcomplete): remove fallback case when Gears support is prevalent. | 163 // TODO(mpcomplete): remove fallback case when Gears support is prevalent. |
164 if (!context) | 164 if (!context) |
165 context = Profile::GetDefaultRequestContext()->GetURLRequestContext(); | 165 context = Profile::GetDefaultRequestContext()->GetURLRequestContext(); |
166 | 166 |
167 GURL gurl(cprequest_->url); | 167 GURL gurl(cprequest_->url); |
168 request_.reset(new net::URLRequest(gurl, this)); | 168 request_.reset(new net::URLRequest(gurl, this)); |
169 request_->set_context(context); | 169 request_->set_context(context); |
170 request_->set_method(cprequest_->method); | 170 request_->set_method(cprequest_->method); |
171 request_->set_load_flags(PluginResponseUtils::CPLoadFlagsToNetFlags(0)); | 171 request_->set_load_flags(PluginResponseUtils::CPLoadFlagsToNetFlags(0)); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 // Generic functions | 381 // Generic functions |
382 // | 382 // |
383 | 383 |
384 void STDCALL CPB_SetKeepProcessAlive(CPID id, CPBool keep_alive) { | 384 void STDCALL CPB_SetKeepProcessAlive(CPID id, CPBool keep_alive) { |
385 // This is a no-op in the main browser process | 385 // This is a no-op in the main browser process |
386 } | 386 } |
387 | 387 |
388 CPError STDCALL CPB_GetCookies(CPID id, CPBrowsingContext bcontext, | 388 CPError STDCALL CPB_GetCookies(CPID id, CPBrowsingContext bcontext, |
389 const char* url, char** cookies) { | 389 const char* url, char** cookies) { |
390 CHECK(ChromePluginLib::IsPluginThread()); | 390 CHECK(ChromePluginLib::IsPluginThread()); |
391 URLRequestContext* context = CPBrowsingContextManager::GetInstance()-> | 391 net::URLRequestContext* context = CPBrowsingContextManager::GetInstance()-> |
392 ToURLRequestContext(bcontext); | 392 ToURLRequestContext(bcontext); |
393 // TODO(mpcomplete): remove fallback case when Gears support is prevalent. | 393 // TODO(mpcomplete): remove fallback case when Gears support is prevalent. |
394 if (!context) { | 394 if (!context) { |
395 context = Profile::GetDefaultRequestContext()->GetURLRequestContext(); | 395 context = Profile::GetDefaultRequestContext()->GetURLRequestContext(); |
396 if (!context) | 396 if (!context) |
397 return CPERR_FAILURE; | 397 return CPERR_FAILURE; |
398 } | 398 } |
399 std::string cookies_str = context->cookie_store()->GetCookies(GURL(url)); | 399 std::string cookies_str = context->cookie_store()->GetCookies(GURL(url)); |
400 *cookies = CPB_StringDup(CPB_Alloc, cookies_str); | 400 *cookies = CPB_StringDup(CPB_Alloc, cookies_str); |
401 return CPERR_SUCCESS; | 401 return CPERR_SUCCESS; |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 CPBrowsingContext context) { | 827 CPBrowsingContext context) { |
828 // Sadly if we try and pass context through, we seem to break cl's little | 828 // Sadly if we try and pass context through, we seem to break cl's little |
829 // brain trying to compile the Tuple3 ctor. This cast works. | 829 // brain trying to compile the Tuple3 ctor. This cast works. |
830 int32 context_as_int32 = static_cast<int32>(context); | 830 int32 context_as_int32 = static_cast<int32>(context); |
831 // Plugins can only be accessed on the IO thread. | 831 // Plugins can only be accessed on the IO thread. |
832 BrowserThread::PostTask( | 832 BrowserThread::PostTask( |
833 BrowserThread::IO, FROM_HERE, | 833 BrowserThread::IO, FROM_HERE, |
834 NewRunnableFunction(PluginCommandHandler::HandleCommand, | 834 NewRunnableFunction(PluginCommandHandler::HandleCommand, |
835 command, data, context_as_int32)); | 835 command, data, context_as_int32)); |
836 } | 836 } |
OLD | NEW |