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

Side by Side Diff: webkit/media/android/media_info_loader_android.h

Issue 16327002: android: Implement single origin and CORS check for video (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added tests. Created 7 years, 6 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
(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 #ifndef WEBKIT_MEDIA_ANDROID_MEDIA_INFO_LOADER_ANDROID_H_
6 #define WEBKIT_MEDIA_ANDROID_MEDIA_INFO_LOADER_ANDROID_H_
7
8 #include <string>
9
10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "googleurl/src/gurl.h"
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLLoaderClient. h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h"
15 #include "webkit/media/active_loader.h"
16
17 namespace WebKit {
18 class WebFrame;
19 class WebURLLoader;
20 class WebURLRequest;
21 }
22
23 namespace webkit_media {
24
25 // This class provides additional information about a media URL. Currently it
26 // can be used to determine if a media URL has a single security origin and
27 // whether the URL passes a CORS access check.
28 class MediaInfoLoaderAndroid : private WebKit::WebURLLoaderClient {
29 public:
30 // Status codes for start operations on MediaInfoLoaderAndroid.
31 enum Status {
32 // The operation failed, which may have been due to:
33 // - Page navigation
34 // - Server replied 4xx/5xx
35 // - The response was invalid
36 // - Connection was terminated
37 //
38 // At this point you should delete the loader.
39 kFailed,
40
41 // Everything went as planned.
42 kOk,
43 };
44
45 // Start loading information about the given media URL.
46 // |url| - URL for the media resource to be loaded.
47 // |cors_mode| - HTML media element's crossorigin attribute.
48 // |ready_cb| - Called when media info has finished or failed loading.
49 typedef base::Callback<void(Status)> ReadyCB;
50 MediaInfoLoaderAndroid(
51 const GURL& url,
52 WebKit::WebMediaPlayer::CORSMode cors_mode,
53 const ReadyCB& ready_cb);
54 virtual ~MediaInfoLoaderAndroid();
qinmin 2013/06/03 16:55:59 does this needs to be virtual?
Sami 2013/06/03 17:12:56 It's virtual because the base class (WebURLLoaderC
55
56 // Start loading media info.
57 void Start(WebKit::WebFrame* frame);
58
59 // Returns true if the media resource has a single origin, false otherwise.
60 // Only valid to call after the loader becomes ready.
61 bool HasSingleOrigin() const;
62
63 // Returns true if the media resource passed a CORS access control check.
64 // Only valid to call after the loader becomes ready.
65 bool DidPassCORSAccessCheck() const;
66
67 private:
68 friend class MediaInfoLoaderAndroidTest;
69
70 // WebKit::WebURLLoaderClient implementation.
71 virtual void willSendRequest(
72 WebKit::WebURLLoader* loader,
73 WebKit::WebURLRequest& newRequest,
74 const WebKit::WebURLResponse& redirectResponse);
75 virtual void didSendData(
76 WebKit::WebURLLoader* loader,
77 unsigned long long bytesSent,
78 unsigned long long totalBytesToBeSent);
79 virtual void didReceiveResponse(
80 WebKit::WebURLLoader* loader,
81 const WebKit::WebURLResponse& response);
82 virtual void didDownloadData(
83 WebKit::WebURLLoader* loader,
84 int data_length);
85 virtual void didReceiveData(
86 WebKit::WebURLLoader* loader,
87 const char* data,
88 int data_length,
89 int encoded_data_length);
90 virtual void didReceiveCachedMetadata(
91 WebKit::WebURLLoader* loader,
92 const char* data, int dataLength);
93 virtual void didFinishLoading(
94 WebKit::WebURLLoader* loader,
95 double finishTime);
96 virtual void didFail(
97 WebKit::WebURLLoader* loader,
98 const WebKit::WebURLError&);
99
100 void DidBecomeReady(Status status);
101
102 // Injected WebURLLoader instance for testing purposes.
103 scoped_ptr<WebKit::WebURLLoader> test_loader_;
104
105 // Keeps track of an active WebURLLoader and associated state.
106 scoped_ptr<ActiveLoader> active_loader_;
107
108 bool loader_failed_;
109 GURL url_;
110 WebKit::WebMediaPlayer::CORSMode cors_mode_;
111 bool single_origin_;
112
113 ReadyCB ready_cb_;
114
115 DISALLOW_COPY_AND_ASSIGN(MediaInfoLoaderAndroid);
116 };
117
118 } // namespace webkit_media
119
120 #endif // WEBKIT_MEDIA_ANDROID_MEDIA_INFO_LOADER_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698