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

Side by Side Diff: content/renderer/media/android/media_info_loader.cc

Issue 408873004: Fix for cross-origin video check for webgl on android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing kbr's comments Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/media/android/media_info_loader.h" 5 #include "content/renderer/media/android/media_info_loader.h"
6 6
7 #include "base/bits.h" 7 #include "base/bits.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "third_party/WebKit/public/platform/WebURLError.h" 10 #include "third_party/WebKit/public/platform/WebURLError.h"
(...skipping 11 matching lines...) Expand all
22 namespace content { 22 namespace content {
23 23
24 static const int kHttpOK = 200; 24 static const int kHttpOK = 200;
25 25
26 MediaInfoLoader::MediaInfoLoader( 26 MediaInfoLoader::MediaInfoLoader(
27 const GURL& url, 27 const GURL& url,
28 blink::WebMediaPlayer::CORSMode cors_mode, 28 blink::WebMediaPlayer::CORSMode cors_mode,
29 const ReadyCB& ready_cb) 29 const ReadyCB& ready_cb)
30 : loader_failed_(false), 30 : loader_failed_(false),
31 url_(url), 31 url_(url),
32 allow_stored_credentials_(false),
32 cors_mode_(cors_mode), 33 cors_mode_(cors_mode),
33 single_origin_(true), 34 single_origin_(true),
34 ready_cb_(ready_cb) {} 35 ready_cb_(ready_cb) {}
35 36
36 MediaInfoLoader::~MediaInfoLoader() {} 37 MediaInfoLoader::~MediaInfoLoader() {}
37 38
38 void MediaInfoLoader::Start(blink::WebFrame* frame) { 39 void MediaInfoLoader::Start(blink::WebFrame* frame) {
39 // Make sure we have not started. 40 // Make sure we have not started.
40 DCHECK(!ready_cb_.is_null()); 41 DCHECK(!ready_cb_.is_null());
41 CHECK(frame); 42 CHECK(frame);
42 43
43 start_time_ = base::TimeTicks::Now(); 44 start_time_ = base::TimeTicks::Now();
45 first_party_url_ = frame->document().firstPartyForCookies();
44 46
45 // Prepare the request. 47 // Prepare the request.
46 WebURLRequest request(url_); 48 WebURLRequest request(url_);
47 // TODO(mkwst): Split this into video/audio. 49 // TODO(mkwst): Split this into video/audio.
48 request.setRequestContext(WebURLRequest::RequestContextVideo); 50 request.setRequestContext(WebURLRequest::RequestContextVideo);
49 frame->setReferrerForRequest(request, blink::WebURL()); 51 frame->setReferrerForRequest(request, blink::WebURL());
50 52
51 scoped_ptr<WebURLLoader> loader; 53 scoped_ptr<WebURLLoader> loader;
52 if (test_loader_) { 54 if (test_loader_) {
53 loader = test_loader_.Pass(); 55 loader = test_loader_.Pass();
54 } else { 56 } else {
55 WebURLLoaderOptions options; 57 WebURLLoaderOptions options;
56 if (cors_mode_ == blink::WebMediaPlayer::CORSModeUnspecified) { 58 if (cors_mode_ == blink::WebMediaPlayer::CORSModeUnspecified) {
57 options.allowCredentials = true; 59 options.allowCredentials = true;
58 options.crossOriginRequestPolicy = 60 options.crossOriginRequestPolicy =
59 WebURLLoaderOptions::CrossOriginRequestPolicyAllow; 61 WebURLLoaderOptions::CrossOriginRequestPolicyAllow;
62 allow_stored_credentials_ = true;
60 } else { 63 } else {
61 options.exposeAllResponseHeaders = true; 64 options.exposeAllResponseHeaders = true;
62 // The author header set is empty, no preflight should go ahead. 65 // The author header set is empty, no preflight should go ahead.
63 options.preflightPolicy = WebURLLoaderOptions::PreventPreflight; 66 options.preflightPolicy = WebURLLoaderOptions::PreventPreflight;
64 options.crossOriginRequestPolicy = 67 options.crossOriginRequestPolicy =
65 WebURLLoaderOptions::CrossOriginRequestPolicyUseAccessControl; 68 WebURLLoaderOptions::CrossOriginRequestPolicyUseAccessControl;
66 if (cors_mode_ == blink::WebMediaPlayer::CORSModeUseCredentials) 69 if (cors_mode_ == blink::WebMediaPlayer::CORSModeUseCredentials) {
67 options.allowCredentials = true; 70 options.allowCredentials = true;
71 allow_stored_credentials_ = true;
72 }
68 } 73 }
69 loader.reset(frame->createAssociatedURLLoader(options)); 74 loader.reset(frame->createAssociatedURLLoader(options));
70 } 75 }
71 76
72 // Start the resource loading. 77 // Start the resource loading.
73 loader->loadAsynchronously(request, this); 78 loader->loadAsynchronously(request, this);
74 active_loader_.reset(new ActiveLoader(loader.Pass())); 79 active_loader_.reset(new ActiveLoader(loader.Pass()));
75 } 80 }
76 81
77 ///////////////////////////////////////////////////////////////////////////// 82 /////////////////////////////////////////////////////////////////////////////
78 // blink::WebURLLoaderClient implementation. 83 // blink::WebURLLoaderClient implementation.
79 void MediaInfoLoader::willSendRequest( 84 void MediaInfoLoader::willSendRequest(
80 WebURLLoader* loader, 85 WebURLLoader* loader,
81 WebURLRequest& newRequest, 86 WebURLRequest& newRequest,
82 const WebURLResponse& redirectResponse) { 87 const WebURLResponse& redirectResponse) {
83 // The load may have been stopped and |ready_cb| is destroyed. 88 // The load may have been stopped and |ready_cb| is destroyed.
84 // In this case we shouldn't do anything. 89 // In this case we shouldn't do anything.
85 if (ready_cb_.is_null()) { 90 if (ready_cb_.is_null()) {
86 // Set the url in the request to an invalid value (empty url). 91 // Set the url in the request to an invalid value (empty url).
87 newRequest.setURL(blink::WebURL()); 92 newRequest.setURL(blink::WebURL());
88 return; 93 return;
89 } 94 }
90 95
91 // Only allow |single_origin_| if we haven't seen a different origin yet. 96 // Only allow |single_origin_| if we haven't seen a different origin yet.
92 if (single_origin_) 97 if (single_origin_)
93 single_origin_ = url_.GetOrigin() == GURL(newRequest.url()).GetOrigin(); 98 single_origin_ = url_.GetOrigin() == GURL(newRequest.url()).GetOrigin();
Ken Russell (switch to Gerrit) 2014/07/30 20:44:05 Are we 100% sure that this (preexisting) code comp
qinmin 2014/07/30 23:46:05 hmm... I am not very familiar with the CORS stuff.
scherkus (not reviewing) 2014/07/31 01:15:46 kbr: I think you're right. I thought that this wa
94 99
95 url_ = newRequest.url(); 100 url_ = newRequest.url();
101 first_party_url_ = newRequest.firstPartyForCookies();
102 allow_stored_credentials_ = newRequest.allowStoredCredentials();
Ken Russell (switch to Gerrit) 2014/07/30 20:44:05 Are you 100% sure that these pieces of state are b
96 } 103 }
97 104
98 void MediaInfoLoader::didSendData( 105 void MediaInfoLoader::didSendData(
99 WebURLLoader* loader, 106 WebURLLoader* loader,
100 unsigned long long bytes_sent, 107 unsigned long long bytes_sent,
101 unsigned long long total_bytes_to_be_sent) { 108 unsigned long long total_bytes_to_be_sent) {
102 NOTIMPLEMENTED(); 109 NOTIMPLEMENTED();
103 } 110 }
104 111
105 void MediaInfoLoader::didReceiveResponse( 112 void MediaInfoLoader::didReceiveResponse(
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 188 }
182 189
183 ///////////////////////////////////////////////////////////////////////////// 190 /////////////////////////////////////////////////////////////////////////////
184 // Helper methods. 191 // Helper methods.
185 192
186 void MediaInfoLoader::DidBecomeReady(Status status) { 193 void MediaInfoLoader::DidBecomeReady(Status status) {
187 UMA_HISTOGRAM_TIMES("Media.InfoLoadDelay", 194 UMA_HISTOGRAM_TIMES("Media.InfoLoadDelay",
188 base::TimeTicks::Now() - start_time_); 195 base::TimeTicks::Now() - start_time_);
189 active_loader_.reset(); 196 active_loader_.reset();
190 if (!ready_cb_.is_null()) 197 if (!ready_cb_.is_null())
191 base::ResetAndReturn(&ready_cb_).Run(status); 198 base::ResetAndReturn(&ready_cb_).Run(status, url_, first_party_url_,
199 allow_stored_credentials_);
Ken Russell (switch to Gerrit) 2014/07/30 20:44:05 Are we 100% sure that these are the right pieces o
192 } 200 }
193 201
194 } // namespace content 202 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698