Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: content/renderer/pepper/pepper_plugin_instance_impl.cc

Issue 1063383002: Use the existing user gesture token for PPAPI URL requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/pepper/pepper_plugin_instance_impl.h" 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
(...skipping 3143 matching lines...) Expand 10 before | Expand all | Expand 10 after
3154 return PP_ERROR_FAILED; 3154 return PP_ERROR_FAILED;
3155 3155
3156 ppapi::URLRequestInfoData completed_request = request; 3156 ppapi::URLRequestInfoData completed_request = request;
3157 3157
3158 WebURLRequest web_request; 3158 WebURLRequest web_request;
3159 if (!CreateWebURLRequest( 3159 if (!CreateWebURLRequest(
3160 pp_instance_, &completed_request, frame, &web_request)) { 3160 pp_instance_, &completed_request, frame, &web_request)) {
3161 return PP_ERROR_FAILED; 3161 return PP_ERROR_FAILED;
3162 } 3162 }
3163 web_request.setFirstPartyForCookies(document.firstPartyForCookies()); 3163 web_request.setFirstPartyForCookies(document.firstPartyForCookies());
3164 web_request.setHasUserGesture(from_user_action); 3164 if (IsProcessingUserGesture())
3165 web_request.setHasUserGesture(true);
3165 3166
3166 GURL gurl(web_request.url()); 3167 GURL gurl(web_request.url());
3167 if (gurl.SchemeIs(url::kJavaScriptScheme)) { 3168 if (gurl.SchemeIs(url::kJavaScriptScheme)) {
3168 // In imitation of the NPAPI implementation, only |target_frame == frame| is 3169 // In imitation of the NPAPI implementation, only |target_frame == frame| is
3169 // allowed for security reasons. 3170 // allowed for security reasons.
3170 WebFrame* target_frame = 3171 WebFrame* target_frame =
3171 frame->view()->findFrameByName(WebString::fromUTF8(target), frame); 3172 frame->view()->findFrameByName(WebString::fromUTF8(target), frame);
3172 if (target_frame != frame) 3173 if (target_frame != frame)
3173 return PP_ERROR_NOACCESS; 3174 return PP_ERROR_NOACCESS;
3174 3175
3175 // TODO(viettrungluu): NPAPI sends the result back to the plugin -- do we 3176 // TODO(viettrungluu): NPAPI sends the result back to the plugin -- do we
3176 // need that? 3177 // need that?
3177 WebString result = container_->executeScriptURL(gurl, from_user_action); 3178 blink::WebScopedUserGesture user_gesture(CurrentUserGestureToken());
3179 WebString result = container_->executeScriptURL(gurl, false);
Mike West 2015/04/08 07:36:39 Nit: Can we drop the second argument?
3178 return result.isNull() ? PP_ERROR_FAILED : PP_OK; 3180 return result.isNull() ? PP_ERROR_FAILED : PP_OK;
3179 } 3181 }
3180 3182
3181 // Only GETs and POSTs are supported. 3183 // Only GETs and POSTs are supported.
3182 if (web_request.httpMethod() != "GET" && web_request.httpMethod() != "POST") 3184 if (web_request.httpMethod() != "GET" && web_request.httpMethod() != "POST")
3183 return PP_ERROR_BADARGUMENT; 3185 return PP_ERROR_BADARGUMENT;
3184 3186
3185 WebString target_str = WebString::fromUTF8(target); 3187 WebString target_str = WebString::fromUTF8(target);
3188 blink::WebScopedUserGesture user_gesture(CurrentUserGestureToken());
3186 container_->loadFrameRequest(web_request, target_str, false, NULL); 3189 container_->loadFrameRequest(web_request, target_str, false, NULL);
3187 return PP_OK; 3190 return PP_OK;
3188 } 3191 }
3189 3192
3190 int PepperPluginInstanceImpl::MakePendingFileRefRendererHost( 3193 int PepperPluginInstanceImpl::MakePendingFileRefRendererHost(
3191 const base::FilePath& path) { 3194 const base::FilePath& path) {
3192 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); 3195 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host();
3193 PepperFileRefRendererHost* file_ref_host( 3196 PepperFileRefRendererHost* file_ref_host(
3194 new PepperFileRefRendererHost(host_impl, pp_instance(), 0, path)); 3197 new PepperFileRefRendererHost(host_impl, pp_instance(), 0, path));
3195 return host_impl->GetPpapiHost()->AddPendingResourceHost( 3198 return host_impl->GetPpapiHost()->AddPendingResourceHost(
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
3336 3339
3337 void PepperPluginInstanceImpl::RecordFlashJavaScriptUse() { 3340 void PepperPluginInstanceImpl::RecordFlashJavaScriptUse() {
3338 if (initialized_ && !javascript_used_ && is_flash_plugin_) { 3341 if (initialized_ && !javascript_used_ && is_flash_plugin_) {
3339 javascript_used_ = true; 3342 javascript_used_ = true;
3340 RenderThread::Get()->RecordAction( 3343 RenderThread::Get()->RecordAction(
3341 base::UserMetricsAction("Flash.JavaScriptUsed")); 3344 base::UserMetricsAction("Flash.JavaScriptUsed"));
3342 } 3345 }
3343 } 3346 }
3344 3347
3345 } // namespace content 3348 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698