Merge lp:~abreu-alexandre/oxide/add-quota-permission-context-support into lp:~oxide-developers/oxide/oxide.trunk
- add-quota-permission-context-support
- Merge into oxide.trunk
Status: | Needs review |
---|---|
Proposed branch: | lp:~abreu-alexandre/oxide/add-quota-permission-context-support |
Merge into: | lp:~oxide-developers/oxide/oxide.trunk |
Diff against target: |
1203 lines (+538/-96) 24 files modified
qt/build/system.gyp (+17/-0) qt/core/api/oxideqpermissionrequest.cc (+50/-0) qt/core/api/oxideqpermissionrequest.h (+22/-0) qt/core/api/oxideqpermissionrequest_p.h (+20/-0) qt/core/browser/oxide_qt_web_view.cc (+32/-0) qt/core/browser/oxide_qt_web_view.h (+5/-0) qt/core/core.gyp (+1/-0) qt/core/glue/oxide_qt_web_view_proxy.h (+2/-0) qt/core/glue/oxide_qt_web_view_proxy_client.h (+4/-0) qt/qmlplugin/oxide.qmltypes (+35/-14) qt/qmlplugin/oxide_qml_plugin.cc (+8/-0) qt/quick/api/oxideqquickwebview.cc (+30/-0) qt/quick/api/oxideqquickwebview.h (+2/-0) qt/quick/api/oxideqquickwebview_p.h (+6/-0) qt/tests/qmltests/TestWebView.qml (+1/-1) qt/tests/qmltests/api/tst_WebView_quotaPermission.html (+49/-0) qt/tests/qmltests/api/tst_WebView_quotaPermission.qml (+202/-0) qt/tests/qmltests/api/tst_WebView_quotaPermission_iframe.html (+5/-0) qt/tests/qmltests/oxide_qml_testing_plugin.cc (+10/-0) shared/browser/oxide_quota_permission_context.cc (+0/-36) shared/browser/oxide_quota_permission_context.h (+0/-45) shared/browser/permissions/oxide_permission_request_dispatcher.cc (+27/-0) shared/browser/permissions/oxide_permission_request_dispatcher.h (+6/-0) shared/browser/permissions/oxide_permission_request_dispatcher_client.h (+4/-0) |
To merge this branch: | bzr merge lp:~abreu-alexandre/oxide/add-quota-permission-context-support |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Coulson | Needs Fixing | ||
Review via email: mp+243351@code.launchpad.net |
Commit message
Add support for quota permission context request.
Description of the change
Add support for quota permission context request.
A patch branch for chromium is needed for that change:
Chris Coulson (chrisccoulson) wrote : | # |
I've added some comments inline for this
Chris Coulson (chrisccoulson) wrote : | # |
I've left some comments inline again.
Also, how does this API behave if a site requests persistent storage in an incognito webview?
Chris Coulson (chrisccoulson) wrote : | # |
I've left some comments inline.
And the tests are still missing quite a few cases:
- It's not testing if requests from subframes behave correctly.
- It doesn't test if requests are cancelled on navigation.
- It doesn't verify that the request is denied if the application ignores it (ie, QuotaPermission
I still don't know what happens if a page in an incognito webview requests a persistent storage quota. Did you find out?
Alexandre Abreu (abreu-alexandre) wrote : | # |
created a expose-
- 1283. By Chris Coulson
-
Use Qt::PrimaryOrie
ntation rather than passing in QScreen's own primary orientation
Alexandre Abreu (abreu-alexandre) wrote : | # |
Also about you question, for incognito webviews the request still goes through except that for those the maximum quota is set to a lower threshold, see:
and
which is the control flow for a regular storage quota request with the case of a webview being incognito being handled as a max threshold case.
- 1284. By Chris Coulson
-
QCoreApplicatio
n::applicationN ame() isn't really thread-safe - cache it to protect against accessing this whilst the application is modifying it (although we don't really expect this to change) - 1285. By Chris Coulson
-
Build with 'use_ash: 0' as this seems to be pulling in dependencies from //chrome, resulting in random mis-builds
- 1286. By Chris Coulson
-
Bump Chromium rev to 0fcc1746 (48.0.2564.22)
- 1287. By Chris Coulson
-
Add support for the camera on the phone. Note this requires changes to libhybris that aren't approved yet, so some bits may change. It's also hidden behind a build option (ENABLE_
HYBRIS_ CAMERA) - 1288. By Chris Coulson
-
Don't require libhybris-dev to be installed when building without ENABLE_
HYBRIS_ CAMERA - 1289. By Chris Coulson
-
Merge from lp:oxide/crmaster
- 1290. By Chris Coulson
-
Bump qt version to 1.13
- 1291. By Chris Coulson
-
Bump Chromium rev to dee8b819 (49.0.2587.3)
- 1292. By Chris Coulson
-
Fix OxideQCertifica
teError: :isMainFrame to work with Chromium 49 - 1293. By Chris Coulson
-
Don't build qt/core/api in a separate target with different build options. This means we can stop linking unconditionally with --gc-sections. It also means that the public API no longer has RTTI enabled - if we need this in the future, we'll have to split it out again and plumb it through a proxy layer like we do with qt/quick/api
- 1294. By Chris Coulson
-
Merge r1067 from lp:oxide/crmaster
- 1295. By Chris Coulson
-
Bump Chromium rev to 8af47bb2 (49.0.2593.0)
- 1296. By Chris Coulson
-
Bump Chromium rev to a6f2995b to pick up build fix
- 1297. By Chris Coulson
-
Pass StartParams by value and give it a move constructor - this makes it obvious that the StartParams passed to BrowserProcessM
ain::Start is no longer valid once the function returns - 1298. By Chris Coulson
-
Merge r1072 from lp:oxide/crmaster
- 1299. By Chris Coulson
-
Bump Chromium rev to 3bbb11d8 (49.0.2612.0)
- 1300. By Chris Coulson
-
Check the return value from android_
camera_ get_device_ info - 1301. By Chris Coulson
-
Check the return of android_
camera_ get_device_ info in another location - 1302. By Chris Coulson
-
Fix an import failure in release.py
- 1303. By Chris Coulson
-
Update the exclude list and call init-checkout.py from release.py
- 1304. By Olivier Tilloy
-
Add missing revision qualifier to the WebView.hoveredUrl property.
- 1305. By Chris Coulson
-
Be a bit more intelligent when detecting whether the hybris camera compatibility layer is available, or whether we're running on the Android EGL stack
- 1306. By Chris Coulson
-
Expose value type enums to QML in Qt5.5
- 1307. By Olivier Tilloy
-
Update to oxide.qmltypes missed at revision 1304.
- 1308. By Chris Coulson
-
Don't include .git/index files anywhere in the tarball. This was added way back in r640 but doesn't actually fix anything, and instead causes LP: #1490868 to be reintroduced in official builds where we don't install git
- 1309. By Olivier Tilloy
-
Add a touch selection API, to allow embedders to display handles for resizing the current selection, and contextual actions for it.
- 1310. By Chris Coulson
-
Make QFlags naming consistent betweeen qt/core/api and qt/quick/api
- 1311. By Chris Coulson
-
Various clean-ups in soon-to-be-public headers. Also, we rename header files based on whether they're going to be public or not
- 1312. By Chris Coulson
-
Ensure we define OXIDE_QTQUICK_
IMPLEMENTATION as part of the build - 1313. By Chris Coulson
-
Remove SimplePermissio
nRequest - 1314. By Chris Coulson
-
Register PermissionRequest and MediaAccessPerm
issionRequest - 1315. By Chris Coulson
-
Add deprecation warnings for deprecated APIs
- 1316. By Chris Coulson
-
Add missing file
- 1317. By Chris Coulson
-
Disable the unprivileged namespace sandbox and fallback to the suid sandbox until we've figured out how it fits in with application confinement
- 1318. By Chris Coulson
-
Make a few changes to the build system:
- package is renamed to test-package, as the former is a reserved target in cmake. This gets rid of a warning.
- Use the built-in option command.
- Move a bunch of stuff from qt/CMakeLists.txt to CMakeLists.txt - 1319. By Chris Coulson
-
Use INTERFACE_
LINK_LIBRARIES for OXIDE_LIB, and make some libraries linked in to OXIDE_QUICKLIB public - 1320. By Chris Coulson
-
Merge r1085 from lp:oxide/crmaster
- 1321. By Chris Coulson
-
Bump Chromium rev to c51aaef (49.0.2623.0)
- 1322. By Chris Coulson
-
Unbreak cross-compiles and make sure we test the version of the correct module
- 1323. By Chris Coulson
-
Merge in various build changes:
- Split out some code in to CMake modules
- Use CMake's PROJECT_VERSION properties rather than our own OXIDE_VERSION
- Install public header files
- Create and install CMake package config files - 1324. By Chris Coulson
-
Safely handle event loop nesting from outside of Oxide
- 1325. By Chris Coulson
-
Bump Chromium rev to 37948b2 (49.0.2623.13)
- 1326. By Chris Coulson
-
Update the deprecation warning for loadingChanged and add a macro for doing this as well
- 1327. By Chris Coulson
-
Bump Chromium rev to 8e193e1 (49.0.2623.23)
- 1328. By Chris Coulson
-
Remove WebViewProxy:
:createHelpers - just export the relevant private classes and have OxideQQuickWebView use those directly - 1329. By Chris Coulson
-
Bump qt version to 1.14
- 1330. By Chris Coulson
-
Rename development Chromium branches to oxide/dev/crXXXX
- 1331. By Chris Coulson
-
Merge r1097 from lp:oxide/crmaster
- 1332. By Chris Coulson
-
Bump Chromium rev to 0571636 (50.0.2633.3)
- 1333. By Alexandre Abreu
-
fix build failure with MediaHub specific code
- 1334. By Chris Coulson
-
Add support for drag and drop
- 1335. By Chris Coulson
-
Merge r1100 from lp:oxide/crmaster
- 1336. By Chris Coulson
-
Fix some test failures
- 1337. By Alexandre Abreu
-
Add support for quota permission context request.
- 1338. By Alexandre Abreu
-
Tweaks
Unmerged revisions
- 1338. By Alexandre Abreu
-
Tweaks
- 1337. By Alexandre Abreu
-
Add support for quota permission context request.
Preview Diff
1 | === modified file 'qt/build/system.gyp' |
2 | --- qt/build/system.gyp 2015-10-28 19:09:39 +0000 |
3 | +++ qt/build/system.gyp 2016-02-08 19:32:31 +0000 |
4 | @@ -107,5 +107,22 @@ |
5 | ], |
6 | }, |
7 | }, |
8 | + { |
9 | + 'target_name': 'Qt5Feedback', |
10 | + 'type': 'none', |
11 | + 'direct_dependent_settings': { |
12 | + 'cflags_cc': [ |
13 | + '<!@(<(pkg_config) --cflags Qt5Feedback)' |
14 | + ] |
15 | + }, |
16 | + 'link_settings': { |
17 | + 'ldflags': [ |
18 | + '<!@(<(pkg_config) --libs-only-L --libs-only-other Qt5Feedback)', |
19 | + ], |
20 | + 'libraries': [ |
21 | + '<!@(<(pkg_config) --libs-only-l Qt5Feedback)', |
22 | + ], |
23 | + }, |
24 | + }, |
25 | ], |
26 | } |
27 | |
28 | === modified file 'qt/core/api/oxideqpermissionrequest.cc' |
29 | --- qt/core/api/oxideqpermissionrequest.cc 2016-01-26 16:47:06 +0000 |
30 | +++ qt/core/api/oxideqpermissionrequest.cc 2016-02-08 19:32:31 +0000 |
31 | @@ -105,6 +105,18 @@ |
32 | ~OxideQMediaAccessPermissionRequestPrivate() {} |
33 | |
34 | // static |
35 | +OxideQQuotaPermissionRequest* |
36 | +OxideQQuotaPermissionRequestPrivate::Create( |
37 | + quint64 requested_size, |
38 | + scoped_ptr<oxide::PermissionRequest> request) { |
39 | + DCHECK(request); |
40 | + return new OxideQQuotaPermissionRequest( |
41 | + *new OxideQQuotaPermissionRequestPrivate( |
42 | + requested_size, |
43 | + std::move(request))); |
44 | +} |
45 | + |
46 | +// static |
47 | OxideQMediaAccessPermissionRequest* |
48 | OxideQMediaAccessPermissionRequestPrivate::Create( |
49 | scoped_ptr<oxide::MediaAccessPermissionRequest> request) { |
50 | @@ -114,6 +126,32 @@ |
51 | *new OxideQMediaAccessPermissionRequestPrivate(std::move(request))); |
52 | } |
53 | |
54 | +OxideQQuotaPermissionRequestPrivate::OxideQQuotaPermissionRequestPrivate( |
55 | + quint64 requested_size, |
56 | + scoped_ptr<oxide::PermissionRequest> request) |
57 | + : OxideQPermissionRequestPrivate(std::move(request)), |
58 | + requested_size_(requested_size) {} |
59 | + |
60 | +OxideQQuotaPermissionRequestPrivate::~OxideQQuotaPermissionRequestPrivate() {} |
61 | + |
62 | +bool OxideQQuotaPermissionRequestPrivate::canRespond() const { |
63 | + if (request_->is_cancelled()) { |
64 | + qWarning() << |
65 | + "OxideQQuotaPermissionRequestPrivate: Can't respond to a cancelled " |
66 | + "permission request"; |
67 | + return false; |
68 | + } |
69 | + |
70 | + if (!request_->IsPending()) { |
71 | + qWarning() << |
72 | + "OxideQQuotaPermissionRequestPrivate: Can only respond once to a " |
73 | + "permission request"; |
74 | + return false; |
75 | + } |
76 | + |
77 | + return true; |
78 | +} |
79 | + |
80 | OxideQPermissionRequest::OxideQPermissionRequest( |
81 | OxideQPermissionRequestPrivate& dd) |
82 | : d_ptr(&dd) { |
83 | @@ -206,3 +244,15 @@ |
84 | |
85 | return d->request()->video_requested(); |
86 | } |
87 | + |
88 | +OxideQQuotaPermissionRequest::OxideQQuotaPermissionRequest( |
89 | + OxideQQuotaPermissionRequestPrivate& dd) |
90 | + : OxideQPermissionRequest(dd) {} |
91 | + |
92 | +OxideQQuotaPermissionRequest::~OxideQQuotaPermissionRequest() {} |
93 | + |
94 | +quint64 OxideQQuotaPermissionRequest::requestedSize() const { |
95 | + Q_D(const OxideQQuotaPermissionRequest); |
96 | + |
97 | + return d->requested_size_; |
98 | +} |
99 | |
100 | === modified file 'qt/core/api/oxideqpermissionrequest.h' |
101 | --- qt/core/api/oxideqpermissionrequest.h 2016-01-13 18:54:13 +0000 |
102 | +++ qt/core/api/oxideqpermissionrequest.h 2016-02-08 19:32:31 +0000 |
103 | @@ -28,6 +28,8 @@ |
104 | class OxideQGeolocationPermissionRequestPrivate; |
105 | class OxideQMediaAccessPermissionRequestPrivate; |
106 | class OxideQPermissionRequestPrivate; |
107 | +class OxideQQuotaPermissionRequestPrivate; |
108 | +class OxideQSimplePermissionRequestPrivate; |
109 | |
110 | class OXIDE_QTCORE_EXPORT OxideQPermissionRequest : public QObject { |
111 | Q_OBJECT |
112 | @@ -106,4 +108,24 @@ |
113 | OxideQMediaAccessPermissionRequestPrivate& dd); |
114 | }; |
115 | |
116 | +class OXIDE_QTCORE_EXPORT OxideQQuotaPermissionRequest : |
117 | + public OxideQPermissionRequest { |
118 | + Q_OBJECT |
119 | + |
120 | + Q_PROPERTY(quint64 requestedSize READ requestedSize CONSTANT) |
121 | + |
122 | + Q_DECLARE_PRIVATE(OxideQQuotaPermissionRequest) |
123 | + Q_DISABLE_COPY(OxideQQuotaPermissionRequest) |
124 | + |
125 | + public: |
126 | + |
127 | + ~OxideQQuotaPermissionRequest(); |
128 | + |
129 | + quint64 requestedSize() const; |
130 | + |
131 | + private: |
132 | + OxideQQuotaPermissionRequest( |
133 | + OxideQQuotaPermissionRequestPrivate& dd); |
134 | +}; |
135 | + |
136 | #endif // OXIDE_QTCORE_PERMISSION_REQUEST |
137 | |
138 | === modified file 'qt/core/api/oxideqpermissionrequest_p.h' |
139 | --- qt/core/api/oxideqpermissionrequest_p.h 2016-01-13 18:54:13 +0000 |
140 | +++ qt/core/api/oxideqpermissionrequest_p.h 2016-02-08 19:32:31 +0000 |
141 | @@ -66,6 +66,26 @@ |
142 | scoped_ptr<oxide::PermissionRequest> request); |
143 | }; |
144 | |
145 | +class OxideQQuotaPermissionRequestPrivate |
146 | + : public OxideQPermissionRequestPrivate { |
147 | + public: |
148 | + ~OxideQQuotaPermissionRequestPrivate(); |
149 | + |
150 | + static OxideQQuotaPermissionRequest* Create( |
151 | + quint64 requested_size, |
152 | + scoped_ptr<oxide::PermissionRequest> request); |
153 | + |
154 | + private: |
155 | + OxideQQuotaPermissionRequestPrivate( |
156 | + quint64 requested_size, |
157 | + scoped_ptr<oxide::PermissionRequest> request); |
158 | + |
159 | + friend class OxideQQuotaPermissionRequest; |
160 | + |
161 | + bool canRespond() const; |
162 | + quint64 requested_size_; |
163 | +}; |
164 | + |
165 | class OxideQMediaAccessPermissionRequestPrivate |
166 | : public OxideQPermissionRequestPrivate { |
167 | public: |
168 | |
169 | === modified file 'qt/core/browser/oxide_qt_web_view.cc' |
170 | --- qt/core/browser/oxide_qt_web_view.cc 2016-02-05 16:17:52 +0000 |
171 | +++ qt/core/browser/oxide_qt_web_view.cc 2016-02-08 19:32:31 +0000 |
172 | @@ -46,8 +46,10 @@ |
173 | #include "content/common/cursors/webcursor.h" |
174 | #include "content/public/browser/native_web_keyboard_event.h" |
175 | #include "content/public/browser/navigation_controller.h" |
176 | +#include "content/public/browser/storage_partition.h" |
177 | #include "content/browser/web_contents/web_contents_impl.h" |
178 | #include "net/base/net_errors.h" |
179 | +#include "storage/browser/quota/quota_manager.h" |
180 | #include "third_party/WebKit/public/platform/WebCursorInfo.h" |
181 | #include "third_party/WebKit/public/platform/WebTopControlsState.h" |
182 | #include "third_party/WebKit/public/web/WebDragOperation.h" |
183 | @@ -341,6 +343,15 @@ |
184 | return true; |
185 | } |
186 | |
187 | +void ClearQuotaPermissionDataDoneCallback( |
188 | + QObject* callbackReceiver, |
189 | + storage::QuotaStatusCode result, |
190 | + int64_t quota) { |
191 | + QMetaObject::invokeMethod( |
192 | + callbackReceiver, |
193 | + "cleared"); |
194 | +} |
195 | + |
196 | } |
197 | |
198 | class CompositorFrameHandleImpl : public CompositorFrameHandle { |
199 | @@ -1510,6 +1521,17 @@ |
200 | frame_tree_torn_down_ = true; |
201 | } |
202 | |
203 | +void WebView::clearQuotaPermissionData(const QString& origin, QObject* callbackReceiver) { |
204 | + view_->GetWebContents() |
205 | + ->GetRenderProcessHost() |
206 | + ->GetStoragePartition() |
207 | + ->GetQuotaManager() |
208 | + ->SetPersistentHostQuota( |
209 | + origin.toStdString(), |
210 | + 1, |
211 | + base::Bind(ClearQuotaPermissionDataDoneCallback, callbackReceiver)); |
212 | +} |
213 | + |
214 | WebView::WebView(WebViewProxyClient* client, |
215 | QObject* native_view, |
216 | OxideQFindController* find_controller, |
217 | @@ -1599,6 +1621,16 @@ |
218 | return WebContext::FromBrowserContext(view_->GetBrowserContext()); |
219 | } |
220 | |
221 | +void WebView::RequestQuotaPermission( |
222 | + uint64_t requested_size, |
223 | + scoped_ptr<oxide::PermissionRequest> request) { |
224 | + scoped_ptr<OxideQQuotaPermissionRequest> req( |
225 | + OxideQQuotaPermissionRequestPrivate::Create( |
226 | + requested_size, |
227 | + std::move(request))); |
228 | + client_->RequestQuotaPermission(req.release()); |
229 | +} |
230 | + |
231 | const oxide::SecurityStatus& WebView::GetSecurityStatus() const { |
232 | return view_->security_status(); |
233 | } |
234 | |
235 | === modified file 'qt/core/browser/oxide_qt_web_view.h' |
236 | --- qt/core/browser/oxide_qt_web_view.h 2016-02-05 16:17:52 +0000 |
237 | +++ qt/core/browser/oxide_qt_web_view.h 2016-02-08 19:32:31 +0000 |
238 | @@ -192,6 +192,9 @@ |
239 | scoped_ptr<oxide::PermissionRequest> request) override; |
240 | void RequestMediaAccessPermission( |
241 | scoped_ptr<oxide::MediaAccessPermissionRequest> request) override; |
242 | + void RequestQuotaPermission( |
243 | + uint64_t requested_size, |
244 | + scoped_ptr<oxide::PermissionRequest> request) override; |
245 | |
246 | // oxide::WebFrameTreeObserver implementation |
247 | void FrameCreated(oxide::WebFrame* frame) override; |
248 | @@ -303,6 +306,8 @@ |
249 | |
250 | void teardownFrameTree() override; |
251 | |
252 | + void clearQuotaPermissionData(const QString& origin, QObject* callbackReceiver); |
253 | + |
254 | // This must outlive |view_| |
255 | scoped_ptr<InputMethodContext> input_method_context_; |
256 | |
257 | |
258 | === modified file 'qt/core/core.gyp' |
259 | --- qt/core/core.gyp 2016-02-05 16:17:52 +0000 |
260 | +++ qt/core/core.gyp 2016-02-08 19:32:31 +0000 |
261 | @@ -27,6 +27,7 @@ |
262 | 'dependencies': [ |
263 | '../build/system.gyp:Qt5Core', |
264 | '../build/system.gyp:Qt5Core-private', |
265 | + '../build/system.gyp:Qt5Feedback', |
266 | '../build/system.gyp:Qt5Gui', |
267 | '../build/system.gyp:Qt5Gui-private', |
268 | '../build/system.gyp:Qt5Network', |
269 | |
270 | === modified file 'qt/core/glue/oxide_qt_web_view_proxy.h' |
271 | --- qt/core/glue/oxide_qt_web_view_proxy.h 2016-02-05 16:17:52 +0000 |
272 | +++ qt/core/glue/oxide_qt_web_view_proxy.h 2016-02-08 19:32:31 +0000 |
273 | @@ -251,6 +251,8 @@ |
274 | virtual void locationBarShow(bool animate) = 0; |
275 | virtual void locationBarHide(bool animate) = 0; |
276 | |
277 | + virtual void clearQuotaPermissionData(const QString& origin, QObject* callbackReceiver) = 0; |
278 | + |
279 | virtual WebProcessStatus webProcessStatus() const = 0; |
280 | |
281 | virtual void executeEditingCommand(EditingCommands command) const = 0; |
282 | |
283 | === modified file 'qt/core/glue/oxide_qt_web_view_proxy_client.h' |
284 | --- qt/core/glue/oxide_qt_web_view_proxy_client.h 2016-01-08 06:38:22 +0000 |
285 | +++ qt/core/glue/oxide_qt_web_view_proxy_client.h 2016-02-08 19:32:31 +0000 |
286 | @@ -34,6 +34,7 @@ |
287 | class OxideQNavigationRequest; |
288 | class OxideQNewViewRequest; |
289 | class OxideQPermissionRequest; |
290 | +class OxideQQuotaPermissionRequest; |
291 | |
292 | QT_BEGIN_NAMESPACE |
293 | class QCursor; |
294 | @@ -158,6 +159,9 @@ |
295 | virtual void TargetURLChanged() = 0; |
296 | |
297 | virtual void OnEditingCapabilitiesChanged() = 0; |
298 | + |
299 | + virtual void RequestQuotaPermission( |
300 | + OxideQQuotaPermissionRequest* request) = 0; |
301 | }; |
302 | |
303 | } // namespace qt |
304 | |
305 | === modified file 'qt/qmlplugin/oxide.qmltypes' |
306 | --- qt/qmlplugin/oxide.qmltypes 2016-01-12 11:45:54 +0000 |
307 | +++ qt/qmlplugin/oxide.qmltypes 2016-02-08 19:32:31 +0000 |
308 | @@ -4,7 +4,7 @@ |
309 | // It is used for QML tooling purposes only. |
310 | // |
311 | // This file was auto-generated by: |
312 | -// 'qmlplugindump -v -noinstantiate com.canonical.Oxide 1.12 com/canonical/Oxide' |
313 | +// 'qmlplugindump -v -noinstantiate com.canonical.Oxide 1.13 com/canonical/Oxide' |
314 | |
315 | Module { |
316 | Component { |
317 | @@ -54,11 +54,10 @@ |
318 | } |
319 | Component { |
320 | name: "OxideQGeolocationPermissionRequest" |
321 | - prototype: "OxideQSimplePermissionRequest" |
322 | + prototype: "OxideQPermissionRequest" |
323 | exports: ["GeolocationPermissionRequest 1.0"] |
324 | isCreatable: false |
325 | exportMetaObjectRevisions: [0] |
326 | - Property { name: "origin"; type: "QUrl"; isReadonly: true } |
327 | Method { name: "accept" } |
328 | } |
329 | Component { |
330 | @@ -78,6 +77,15 @@ |
331 | Method { name: "deny" } |
332 | } |
333 | Component { |
334 | + name: "OxideQMediaAccessPermissionRequest" |
335 | + prototype: "OxideQPermissionRequest" |
336 | + exports: ["MediaAccessPermissionRequest 1.0"] |
337 | + isCreatable: false |
338 | + exportMetaObjectRevisions: [0] |
339 | + Property { name: "isForAudio"; type: "bool"; isReadonly: true } |
340 | + Property { name: "isForVideo"; type: "bool"; isReadonly: true } |
341 | + } |
342 | + Component { |
343 | name: "OxideQNavigationRequest" |
344 | prototype: "QObject" |
345 | exports: ["NavigationRequest 1.0"] |
346 | @@ -127,11 +135,16 @@ |
347 | Component { |
348 | name: "OxideQPermissionRequest" |
349 | prototype: "QObject" |
350 | + exports: ["PermissionRequest 1.0"] |
351 | + isCreatable: false |
352 | + exportMetaObjectRevisions: [0] |
353 | Property { name: "origin"; type: "QUrl"; isReadonly: true } |
354 | Property { name: "embedder"; type: "QUrl"; isReadonly: true } |
355 | Property { name: "isCancelled"; type: "bool"; isReadonly: true } |
356 | Property { name: "url"; type: "QUrl"; isReadonly: true } |
357 | Signal { name: "cancelled" } |
358 | + Method { name: "allow" } |
359 | + Method { name: "deny" } |
360 | } |
361 | Component { |
362 | name: "OxideQQuickCookieManager" |
363 | @@ -480,13 +493,14 @@ |
364 | "WebView 1.0", |
365 | "WebView 1.11", |
366 | "WebView 1.12", |
367 | + "WebView 1.13", |
368 | "WebView 1.3", |
369 | "WebView 1.4", |
370 | "WebView 1.5", |
371 | "WebView 1.8", |
372 | "WebView 1.9" |
373 | ] |
374 | - exportMetaObjectRevisions: [0, 6, 7, 1, 2, 3, 4, 5] |
375 | + exportMetaObjectRevisions: [0, 6, 7, 8, 1, 2, 3, 4, 5] |
376 | attachedType: "OxideQQuickWebViewAttached" |
377 | Enum { |
378 | name: "LogMessageSeverityLevel" |
379 | @@ -718,6 +732,11 @@ |
380 | Signal { name: "hoveredUrlChanged"; revision: 7 } |
381 | Signal { name: "editingCapabilitiesChanged"; revision: 7 } |
382 | Signal { |
383 | + name: "quotaPermissionRequested" |
384 | + revision: 8 |
385 | + Parameter { name: "request"; type: "QJSValue" } |
386 | + } |
387 | + Signal { |
388 | name: "loadingChanged" |
389 | Parameter { name: "loadEvent"; type: "OxideQLoadEvent" } |
390 | } |
391 | @@ -763,6 +782,14 @@ |
392 | Property { name: "view"; type: "OxideQQuickWebView"; isReadonly: true; isPointer: true } |
393 | } |
394 | Component { |
395 | + name: "OxideQQuotaPermissionRequest" |
396 | + prototype: "OxideQPermissionRequest" |
397 | + exports: ["QuotaPermissionRequest 1.13"] |
398 | + isCreatable: false |
399 | + exportMetaObjectRevisions: [0] |
400 | + Property { name: "requestedSize"; type: "qulonglong"; isReadonly: true } |
401 | + } |
402 | + Component { |
403 | name: "OxideQSecurityStatus" |
404 | prototype: "QObject" |
405 | exports: ["SecurityStatus 1.0"] |
406 | @@ -779,7 +806,7 @@ |
407 | } |
408 | } |
409 | Enum { |
410 | - name: "ContentStatusFlags" |
411 | + name: "ContentStatus" |
412 | values: { |
413 | "ContentStatusNormal": 0, |
414 | "ContentStatusDisplayedInsecure": 1, |
415 | @@ -787,7 +814,7 @@ |
416 | } |
417 | } |
418 | Enum { |
419 | - name: "CertStatusFlags" |
420 | + name: "CertStatus" |
421 | values: { |
422 | "CertStatusOk": 0, |
423 | "CertStatusBadIdentity": 1, |
424 | @@ -802,17 +829,11 @@ |
425 | } |
426 | } |
427 | Property { name: "securityLevel"; type: "SecurityLevel"; isReadonly: true } |
428 | - Property { name: "contentStatus"; type: "ContentStatusFlags"; isReadonly: true } |
429 | - Property { name: "certStatus"; type: "CertStatusFlags"; isReadonly: true } |
430 | + Property { name: "contentStatus"; type: "ContentStatus"; isReadonly: true } |
431 | + Property { name: "certStatus"; type: "CertStatus"; isReadonly: true } |
432 | Property { name: "certificate"; type: "QVariant"; isReadonly: true } |
433 | } |
434 | Component { |
435 | - name: "OxideQSimplePermissionRequest" |
436 | - prototype: "OxideQPermissionRequest" |
437 | - Method { name: "allow" } |
438 | - Method { name: "deny" } |
439 | - } |
440 | - Component { |
441 | name: "OxideQWebPreferences" |
442 | prototype: "QObject" |
443 | exports: ["WebPreferences 1.0"] |
444 | |
445 | === modified file 'qt/qmlplugin/oxide_qml_plugin.cc' |
446 | --- qt/qmlplugin/oxide_qml_plugin.cc 2016-01-13 19:05:43 +0000 |
447 | +++ qt/qmlplugin/oxide_qml_plugin.cc 2016-02-08 19:32:31 +0000 |
448 | @@ -187,6 +187,7 @@ |
449 | qmlRegisterType<OxideQQuickWebView, 4>(uri, 1, 8, "WebView"); |
450 | |
451 | qmlRegisterType<OxideQQuickWebContext, 3>(uri, 1, 9, "WebContext"); |
452 | + |
453 | qmlRegisterUncreatableType<OxideQHttpAuthenticationRequest>( |
454 | uri, 1, 9, "HttpAuthenticationRequest", |
455 | "HttpAuthenticationRequest is delivered by " |
456 | @@ -199,7 +200,14 @@ |
457 | uri, 1, 12, "TouchSelectionController", |
458 | "TouchSelectionController is accessed via " |
459 | "WebView.touchSelectionController"); |
460 | + |
461 | qmlRegisterType<OxideQQuickWebView, 7>(uri, 1, 12, "WebView"); |
462 | + |
463 | + qmlRegisterUncreatableType<OxideQQuotaPermissionRequest>(uri, 1, 13, |
464 | + "QuotaPermissionRequest", |
465 | + "QuotaPermissionRequest is delivered by WebView.quotaPermissionRequested"); |
466 | + |
467 | + qmlRegisterType<OxideQQuickWebView, 8>(uri, 1, 13, "WebView"); |
468 | } |
469 | }; |
470 | |
471 | |
472 | === modified file 'qt/quick/api/oxideqquickwebview.cc' |
473 | --- qt/quick/api/oxideqquickwebview.cc 2016-02-05 16:17:52 +0000 |
474 | +++ qt/quick/api/oxideqquickwebview.cc 2016-02-08 19:32:31 +0000 |
475 | @@ -637,6 +637,30 @@ |
476 | engine->collectGarbage(); |
477 | } |
478 | |
479 | +void OxideQQuickWebViewPrivate::RequestQuotaPermission( |
480 | + OxideQQuotaPermissionRequest* request) { |
481 | + Q_Q(OxideQQuickWebView); |
482 | + |
483 | + // See OxideQQuickWebViewPrivate::RequestGeolocationPermission |
484 | + QQmlEngine* engine = qmlEngine(q); |
485 | + if (!engine) { |
486 | + delete request; |
487 | + return; |
488 | + } |
489 | + |
490 | + { |
491 | + QJSValue val = engine->newQObject(request); |
492 | + if (!val.isQObject()) { |
493 | + delete request; |
494 | + return; |
495 | + } |
496 | + |
497 | + emit q->quotaPermissionRequested(val); |
498 | + } |
499 | + |
500 | + engine->collectGarbage(); |
501 | +} |
502 | + |
503 | void OxideQQuickWebViewPrivate::ContentBlocked() { |
504 | Q_Q(OxideQQuickWebView); |
505 | |
506 | @@ -1065,6 +1089,12 @@ |
507 | return proxy()->getNavigationEntryTimestamp(index); |
508 | } |
509 | |
510 | +void OxideQQuickWebViewPrivate::clearQuotaPermissionData( |
511 | + const QString& origin, |
512 | + QObject* callbackReceiver) { |
513 | + proxy()->clearQuotaPermissionData(origin, callbackReceiver); |
514 | +} |
515 | + |
516 | void OxideQQuickWebView::connectNotify(const QMetaMethod& signal) { |
517 | Q_D(OxideQQuickWebView); |
518 | |
519 | |
520 | === modified file 'qt/quick/api/oxideqquickwebview.h' |
521 | --- qt/quick/api/oxideqquickwebview.h 2016-02-05 16:17:52 +0000 |
522 | +++ qt/quick/api/oxideqquickwebview.h 2016-02-08 19:32:31 +0000 |
523 | @@ -36,6 +36,7 @@ |
524 | class OxideQLoadEvent; |
525 | class OxideQNavigationRequest; |
526 | class OxideQNewViewRequest; |
527 | +class OxideQQuotaPermissionRequest; |
528 | class OxideQWebPreferences; |
529 | class OxideQQuickLocationBarController; |
530 | class OxideQQuickNavigationHistory; |
531 | @@ -366,6 +367,7 @@ |
532 | Q_REVISION(5) void httpAuthenticationRequested(const QJSValue& request); |
533 | Q_REVISION(7) void hoveredUrlChanged(); |
534 | Q_REVISION(7) void editingCapabilitiesChanged(); |
535 | + Q_REVISION(8) void quotaPermissionRequested(const QJSValue& request); |
536 | |
537 | // Deprecated since 1.3 |
538 | void loadingChanged(const OxideQLoadEvent& loadEvent); |
539 | |
540 | === modified file 'qt/quick/api/oxideqquickwebview_p.h' |
541 | --- qt/quick/api/oxideqquickwebview_p.h 2016-01-13 18:16:11 +0000 |
542 | +++ qt/quick/api/oxideqquickwebview_p.h 2016-02-08 19:32:31 +0000 |
543 | @@ -78,6 +78,10 @@ |
544 | QString getNavigationEntryTitle(int index) const; |
545 | QDateTime getNavigationEntryTimestamp(int index) const; |
546 | |
547 | + void clearQuotaPermissionData( |
548 | + const QString& origin, |
549 | + QObject* callbackReceiver); |
550 | + |
551 | private: |
552 | friend class UpdatePaintNodeScope; |
553 | |
554 | @@ -148,6 +152,8 @@ |
555 | void CloseRequested() override; |
556 | void TargetURLChanged() override; |
557 | void OnEditingCapabilitiesChanged() override; |
558 | + void RequestQuotaPermission( |
559 | + OxideQQuotaPermissionRequest* request) override; |
560 | |
561 | oxide::qt::WebViewProxy* proxy() const { |
562 | return oxide::qt::WebViewProxyHandle::proxy(); |
563 | |
564 | === modified file 'qt/tests/qmltests/TestWebView.qml' |
565 | --- qt/tests/qmltests/TestWebView.qml 2015-09-25 22:30:19 +0000 |
566 | +++ qt/tests/qmltests/TestWebView.qml 2016-02-08 19:32:31 +0000 |
567 | @@ -1,6 +1,6 @@ |
568 | import QtQuick 2.0 |
569 | import QtTest 1.0 |
570 | -import com.canonical.Oxide 1.11 |
571 | +import com.canonical.Oxide 1.12 |
572 | import com.canonical.Oxide.Testing 1.0 as Testing |
573 | import "TestUtils.js" as TestUtils |
574 | |
575 | |
576 | === added file 'qt/tests/qmltests/api/tst_WebView_quotaPermission.html' |
577 | --- qt/tests/qmltests/api/tst_WebView_quotaPermission.html 1970-01-01 00:00:00 +0000 |
578 | +++ qt/tests/qmltests/api/tst_WebView_quotaPermission.html 2016-02-08 19:32:31 +0000 |
579 | @@ -0,0 +1,49 @@ |
580 | +<html> |
581 | +<body> |
582 | +<span id="requested_size"></span> |
583 | +</body> |
584 | +<script> |
585 | + |
586 | +window.onload = function() { |
587 | + var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; |
588 | + |
589 | + var requestedSizeElement = document.getElementById('requested_size') |
590 | + |
591 | + var observer = new MutationObserver(function(mutations) { |
592 | + var size = requestedSizeElement.innerHTML |
593 | + if (size !== '') { |
594 | + requestQuota(parseInt(size)) |
595 | + } |
596 | + }); |
597 | + observer.observe(requestedSizeElement, |
598 | + {childList: true, subtree: true }); |
599 | + |
600 | + function requestQuota(requested_size) { |
601 | + function dispatchEventWith(results) { |
602 | + var e = new CustomEvent( |
603 | + "oxideQuotaResult", |
604 | + { bubbles: true, detail: results }); |
605 | + if (window === top) { |
606 | + document.documentElement.dispatchEvent(e); |
607 | + } else { |
608 | + parent.document.documentElement.dispatchEvent(e); |
609 | + } |
610 | + } |
611 | + |
612 | + var succeeded = function(bytes) { |
613 | + dispatchEventWith({success: true, quota: bytes}) |
614 | + }; |
615 | + |
616 | + var failed = function(error) { |
617 | + dispatchEventWith({success: false, error: error.toString()}) |
618 | + }; |
619 | + |
620 | + navigator.webkitPersistentStorage.requestQuota( |
621 | + requested_size, |
622 | + succeeded, |
623 | + failed); |
624 | + } |
625 | +} |
626 | + |
627 | +</script> |
628 | +</html> |
629 | |
630 | === added file 'qt/tests/qmltests/api/tst_WebView_quotaPermission.qml' |
631 | --- qt/tests/qmltests/api/tst_WebView_quotaPermission.qml 1970-01-01 00:00:00 +0000 |
632 | +++ qt/tests/qmltests/api/tst_WebView_quotaPermission.qml 2016-02-08 19:32:31 +0000 |
633 | @@ -0,0 +1,202 @@ |
634 | +import QtQuick 2.0 |
635 | +import QtTest 1.0 |
636 | +import com.canonical.Oxide 1.12 |
637 | +import com.canonical.Oxide.Testing 1.0 |
638 | + |
639 | +TestWebView { |
640 | + id: webView |
641 | + width: 200 |
642 | + height: 200 |
643 | + |
644 | + property var lastQuotaRequest: null |
645 | + |
646 | + SignalSpy { |
647 | + id: spy |
648 | + target: webView |
649 | + signalName: "quotaPermissionRequested" |
650 | + } |
651 | + |
652 | + SignalSpy { |
653 | + id: cancelSpy |
654 | + signalName: "cancelled" |
655 | + } |
656 | + |
657 | + Item { |
658 | + id: quotaDatabaseClearedCallbackReceiver |
659 | + signal cleared() |
660 | + } |
661 | + |
662 | + SignalSpy { |
663 | + id: quotaDatabaseClearedCallbackReceiverSpy |
664 | + target: quotaDatabaseClearedCallbackReceiver |
665 | + signalName: "cleared" |
666 | + } |
667 | + |
668 | + onQuotaPermissionRequested: { |
669 | + lastQuotaRequest = request; |
670 | + } |
671 | + |
672 | + property var lastStatus: -1 |
673 | + property var lastQuota: -1 |
674 | + |
675 | + messageHandlers: [ |
676 | + ScriptMessageHandler { |
677 | + msgId: "QUOTA-REQUEST-RESPONSE" |
678 | + contexts: [ "oxide://testutils/" ] |
679 | + callback: function(msg) { |
680 | + webView.lastStatus = msg.args.status; |
681 | + webView.lastQuota = msg.args.lastQuota |
682 | + } |
683 | + } |
684 | + ] |
685 | + |
686 | + TestCase { |
687 | + id: test |
688 | + name: "WebView_QuotaPermissionRequest" |
689 | + when: windowShown |
690 | + |
691 | + function init() { |
692 | + spy.clear(); |
693 | + cancelSpy.clear(); |
694 | + webView.lastQuotaRequest = null; |
695 | + webView.lastStatus = -1; |
696 | + Utils.clearQuotaPermissionData( |
697 | + "testsuite", |
698 | + webView, |
699 | + quotaDatabaseClearedCallbackReceiver); |
700 | + quotaDatabaseClearedCallbackReceiverSpy.wait() |
701 | + } |
702 | + |
703 | + function _test_allow() { |
704 | + webView.lastQuotaRequest.allow(); |
705 | + } |
706 | + |
707 | + function _test_deny() { |
708 | + webView.lastQuotaRequest.deny(); |
709 | + } |
710 | + |
711 | + function test_QuotaPermissionRequest_data() { |
712 | + return [ |
713 | + { url: "http://testsuite/tst_WebView_quotaPermission.html", function: _test_allow, expected: true, requested_quota: 1024*1024*10, current_quota: 1024*1024*10 }, |
714 | + { url: "http://testsuite/tst_WebView_quotaPermission.html", function: _test_deny, expected: true, requested_quota: 1024*1024*10, current_quota: 1 }, |
715 | + { url: "http://testsuite/tst_WebView_quotaPermission_iframe.html", function: _test_allow, expected: true, requested_quota: 1024*1024*10, current_quota: 1024*1024*10 }, |
716 | + ]; |
717 | + } |
718 | + |
719 | + function test_QuotaPermissionRequest(data) { |
720 | + webView.url = data.url |
721 | + verify(webView.waitForLoadSucceeded(), |
722 | + "Timed out waiting for successful load"); |
723 | + |
724 | + var is_iframe = (data.url.indexOf('_iframe') > 0) |
725 | + var documentAccessPrefix = "document" |
726 | + if (is_iframe) { |
727 | + documentAccessPrefix = "document.getElementById('childframe').contentWindow.document" |
728 | + } |
729 | + |
730 | + webView.getTestApi().evaluateCode( |
731 | + "document.addEventListener(\"oxideQuotaResult\", function(event) { |
732 | + oxide.sendMessage(\"QUOTA-REQUEST-RESPONSE\", { status: event.detail.success, lastQuota: event.detail.quota }); |
733 | +});", true); |
734 | + webView.getTestApi().evaluateCode( |
735 | + documentAccessPrefix + |
736 | + ".getElementById('requested_size').innerHTML" + |
737 | + " = " |
738 | + + String(data.requested_quota)) |
739 | + |
740 | + if (!webView.lastQuotaRequest) { |
741 | + spy.wait(); |
742 | + } |
743 | + |
744 | + compare(webView.lastQuotaRequest.embedder, "http://testsuite/"); |
745 | + compare(webView.lastQuotaRequest.origin, "http://testsuite/"); |
746 | + compare(webView.lastQuotaRequest.isCancelled, false); |
747 | + |
748 | + data.function(); |
749 | + |
750 | + verify(TestUtils.waitFor(function() { return webView.lastStatus != -1; }), |
751 | + "Timed out waiting for quota response"); |
752 | + compare(webView.lastStatus, data.expected); |
753 | + compare(webView.lastQuota, data.current_quota); |
754 | + } |
755 | + |
756 | + function test_QuotaPermissionRequest_main_frame_navigation_cancel() { |
757 | + webView.url = "http://testsuite/tst_WebView_quotaPermission.html"; |
758 | + verify(webView.waitForLoadSucceeded(), |
759 | + "Timed out waiting for successful load"); |
760 | + |
761 | + webView.getTestApi().evaluateCode( |
762 | + "document.getElementById('requested_size').innerHTML" + |
763 | + " = " |
764 | + + String(10*1024*1024)) |
765 | + |
766 | + if (!webView.lastQuotaRequest) { |
767 | + spy.wait(); |
768 | + } |
769 | + |
770 | + cancelSpy.target = webView.lastQuotaRequest; |
771 | + |
772 | + webView.clearLoadEventCounters(); |
773 | + webView.getTestApi().evaluateCode( |
774 | + "window.location = \"http://testsuite/empty.html\";", false); |
775 | + verify(webView.waitForLoadCommitted()); |
776 | + |
777 | + verify(webView.lastQuotaRequest.isCancelled); |
778 | + compare(cancelSpy.count, 1) << "Pending request should have been cancelled"; |
779 | + } |
780 | + |
781 | + function test_QuotaPermissionRequest_subframe_navigation_cancel() { |
782 | + webView.url = "http://testsuite/tst_WebView_quotaPermission_iframe.html"; |
783 | + verify(webView.waitForLoadSucceeded(), |
784 | + "Timed out waiting for successful load"); |
785 | + |
786 | + webView.getTestApi().evaluateCode( |
787 | + "document.getElementById('childframe').contentWindow.document |
788 | +.getElementById('requested_size').innerHTML" + |
789 | + " = " |
790 | + + String(10*1024*1024)) |
791 | + |
792 | + if (!webView.lastQuotaRequest) { |
793 | + spy.wait(); |
794 | + } |
795 | + |
796 | + cancelSpy.target = webView.lastQuotaRequest; |
797 | + |
798 | + webView.clearLoadEventCounters(); |
799 | + webView.getTestApiForFrame(webView.rootFrame.childFrames[0]).evaluateCode( |
800 | + "window.location = \"http://testsuite/empty.html\";", false); |
801 | + |
802 | + cancelSpy.wait(); |
803 | + |
804 | + compare(cancelSpy.count, 1) << "Pending request should have been cancelled"; |
805 | + verify(webView.lastQuotaRequest.isCancelled); |
806 | + } |
807 | + |
808 | + function test_QuotaPermissionRequest_subframe_delete_cancel() { |
809 | + webView.url = "http://testsuite/tst_WebView_quotaPermission_iframe.html"; |
810 | + verify(webView.waitForLoadSucceeded(), |
811 | + "Timed out waiting for successful load"); |
812 | + |
813 | + webView.getTestApi().evaluateCode( |
814 | + "document.getElementById('childframe').contentWindow.document |
815 | +.getElementById('requested_size').innerHTML" + |
816 | + " = " |
817 | + + String(10*1024*1024)) |
818 | + if (!webView.lastQuotaRequest) { |
819 | + spy.wait(); |
820 | + } |
821 | + |
822 | + cancelSpy.target = webView.lastQuotaRequest; |
823 | + |
824 | + webView.getTestApi().evaluateCode(" |
825 | +var f = document.getElementById('childframe'); |
826 | +f.parentElement.removeChild(f);", true); |
827 | + |
828 | + cancelSpy.wait(); |
829 | + |
830 | + compare(cancelSpy.count, 1) << "Pending request should have been cancelled"; |
831 | + verify(webView.lastQuotaRequest.isCancelled); |
832 | + } |
833 | + |
834 | + } |
835 | +} |
836 | |
837 | === added file 'qt/tests/qmltests/api/tst_WebView_quotaPermission_iframe.html' |
838 | --- qt/tests/qmltests/api/tst_WebView_quotaPermission_iframe.html 1970-01-01 00:00:00 +0000 |
839 | +++ qt/tests/qmltests/api/tst_WebView_quotaPermission_iframe.html 2016-02-08 19:32:31 +0000 |
840 | @@ -0,0 +1,5 @@ |
841 | +<html> |
842 | +<body> |
843 | + <iframe id="childframe" src="http://testsuite/tst_WebView_quotaPermission.html"></iframe> |
844 | +</body> |
845 | +</html> |
846 | |
847 | === modified file 'qt/tests/qmltests/oxide_qml_testing_plugin.cc' |
848 | --- qt/tests/qmltests/oxide_qml_testing_plugin.cc 2016-01-13 18:16:11 +0000 |
849 | +++ qt/tests/qmltests/oxide_qml_testing_plugin.cc 2016-02-08 19:32:31 +0000 |
850 | @@ -37,6 +37,8 @@ |
851 | |
852 | #include "qt/quick/api/oxideqquickwebcontext.h" |
853 | #include "qt/quick/api/oxideqquickwebcontext_p.h" |
854 | +#include "qt/quick/api/oxideqquickwebview.h" |
855 | +#include "qt/quick/api/oxideqquickwebview_p.h" |
856 | |
857 | namespace { |
858 | |
859 | @@ -218,6 +220,14 @@ |
860 | QGuiApplication::clipboard()->clear(); |
861 | } |
862 | |
863 | + Q_INVOKABLE void clearQuotaPermissionData( |
864 | + const QString& origin, |
865 | + OxideQQuickWebView* webview, |
866 | + QObject* callbackReceiver) { |
867 | + OxideQQuickWebViewPrivate::get(webview) |
868 | + ->clearQuotaPermissionData(origin, callbackReceiver); |
869 | + } |
870 | + |
871 | Q_INVOKABLE void clearTemporarySavedPermissionStatuses( |
872 | OxideQQuickWebContext* context) { |
873 | OxideQQuickWebContextPrivate::get(context) |
874 | |
875 | === added file 'shared/browser/oxide_quota_permission_context.cc' |
876 | --- shared/browser/oxide_quota_permission_context.cc 1970-01-01 00:00:00 +0000 |
877 | +++ shared/browser/oxide_quota_permission_context.cc 2016-02-08 19:32:31 +0000 |
878 | @@ -0,0 +1,116 @@ |
879 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
880 | +// Copyright (C) 2014 Canonical Ltd. |
881 | + |
882 | +// This library is free software; you can redistribute it and/or |
883 | +// modify it under the terms of the GNU Lesser General Public |
884 | +// License as published by the Free Software Foundation; either |
885 | +// version 2.1 of the License, or (at your option) any later version. |
886 | + |
887 | +// This library is distributed in the hope that it will be useful, |
888 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
889 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
890 | +// Lesser General Public License for more details. |
891 | + |
892 | +// You should have received a copy of the GNU Lesser General Public |
893 | +// License along with this library; if not, write to the Free Software |
894 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
895 | + |
896 | +#include "oxide_quota_permission_context.h" |
897 | + |
898 | +#include "content/public/browser/browser_thread.h" |
899 | +#include "content/public/browser/quota_permission_context.h" |
900 | +#include "content/public/browser/render_view_host.h" |
901 | +#include "storage/common/quota/quota_types.h" |
902 | + |
903 | +#include "permissions/oxide_permission_request.h" |
904 | + |
905 | +#include "oxide_web_view.h" |
906 | + |
907 | +namespace { |
908 | + |
909 | +/** |
910 | + * Simple helper used to have the appearance of a PermissionRequest |
911 | + * callback, by currying it w/ a QuotaPermissionCallback. |
912 | + * Also makes sure that the callback is on the right thread. |
913 | + */ |
914 | +void QuotaPermissionRequestCallback( |
915 | + const content::QuotaPermissionContext::PermissionCallback& cb, |
916 | + oxide::PermissionRequestResponse result) { |
917 | + if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { |
918 | + content::BrowserThread::PostTask( |
919 | + content::BrowserThread::IO, |
920 | + FROM_HERE, |
921 | + base::Bind(&QuotaPermissionRequestCallback, cb, result)); |
922 | + return; |
923 | + } |
924 | + cb.Run(result == oxide::PERMISSION_REQUEST_RESPONSE_ALLOW ? |
925 | + content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW : |
926 | + content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_DISALLOW); |
927 | +} |
928 | + |
929 | +} |
930 | + |
931 | +namespace oxide { |
932 | + |
933 | +QuotaPermissionContext::QuotaPermissionContext() { |
934 | +} |
935 | + |
936 | +QuotaPermissionContext::~QuotaPermissionContext() { |
937 | +} |
938 | + |
939 | +void QuotaPermissionContext::RequestQuotaPermission( |
940 | + const content::StorageQuotaParams& params, |
941 | + int render_process_id, |
942 | + const content::QuotaPermissionContext::PermissionCallback& callback) { |
943 | + if (params.storage_type != storage::kStorageTypePersistent) { |
944 | + callback.Run(content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_DISALLOW); |
945 | + return; |
946 | + } |
947 | + |
948 | + if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { |
949 | + content::BrowserThread::PostTask( |
950 | + content::BrowserThread::UI, |
951 | + FROM_HERE, |
952 | + base::Bind(&QuotaPermissionContext::RequestQuotaPermission, |
953 | + this, params, render_process_id, callback)); |
954 | + return; |
955 | + } |
956 | + |
957 | + content::RenderViewHost* rvh = |
958 | + content::RenderViewHost::FromID(render_process_id, params.render_view_id); |
959 | + if (!rvh) { |
960 | + QuotaPermissionRequestCallback( |
961 | + callback, |
962 | + oxide::PERMISSION_REQUEST_RESPONSE_DENY); |
963 | + return; |
964 | + } |
965 | + |
966 | + WebView* webview = WebView::FromRenderViewHost(rvh); |
967 | + if (!webview || !webview->GetWebContents()) { |
968 | + QuotaPermissionRequestCallback( |
969 | + callback, |
970 | + oxide::PERMISSION_REQUEST_RESPONSE_DENY); |
971 | + return; |
972 | + } |
973 | + |
974 | + content::RenderFrameHost* render_frame_host = |
975 | + content::RenderFrameHost::FromID( |
976 | + webview->GetWebContents()->GetRenderProcessHost()->GetID(), |
977 | + params.render_frame_id); |
978 | + if (!render_frame_host) { |
979 | + QuotaPermissionRequestCallback( |
980 | + callback, |
981 | + oxide::PERMISSION_REQUEST_RESPONSE_DENY); |
982 | + return; |
983 | + } |
984 | + |
985 | + PermissionRequestDispatcher::FromWebContents(webview->GetWebContents()) |
986 | + ->RequestQuotaPermission( |
987 | + render_frame_host, |
988 | + params.origin_url, |
989 | + params.requested_size, |
990 | + base::Bind(&QuotaPermissionRequestCallback, callback)); |
991 | +} |
992 | + |
993 | +} // namespace oxide |
994 | + |
995 | |
996 | === removed file 'shared/browser/oxide_quota_permission_context.cc' |
997 | --- shared/browser/oxide_quota_permission_context.cc 2015-01-20 17:58:10 +0000 |
998 | +++ shared/browser/oxide_quota_permission_context.cc 1970-01-01 00:00:00 +0000 |
999 | @@ -1,36 +0,0 @@ |
1000 | -// vim:expandtab:shiftwidth=2:tabstop=2: |
1001 | -// Copyright (C) 2014 Canonical Ltd. |
1002 | - |
1003 | -// This library is free software; you can redistribute it and/or |
1004 | -// modify it under the terms of the GNU Lesser General Public |
1005 | -// License as published by the Free Software Foundation; either |
1006 | -// version 2.1 of the License, or (at your option) any later version. |
1007 | - |
1008 | -// This library is distributed in the hope that it will be useful, |
1009 | -// but WITHOUT ANY WARRANTY; without even the implied warranty of |
1010 | -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1011 | -// Lesser General Public License for more details. |
1012 | - |
1013 | -// You should have received a copy of the GNU Lesser General Public |
1014 | -// License along with this library; if not, write to the Free Software |
1015 | -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
1016 | - |
1017 | -#include "oxide_quota_permission_context.h" |
1018 | - |
1019 | -namespace oxide { |
1020 | - |
1021 | -QuotaPermissionContext::QuotaPermissionContext() { |
1022 | -} |
1023 | - |
1024 | -QuotaPermissionContext::~QuotaPermissionContext() { |
1025 | -} |
1026 | - |
1027 | -void QuotaPermissionContext::RequestQuotaPermission( |
1028 | - const content::StorageQuotaParams& params, |
1029 | - int render_process_id, |
1030 | - const content::QuotaPermissionContext::PermissionCallback& callback) { |
1031 | - callback.Run(QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_DISALLOW); |
1032 | -} |
1033 | - |
1034 | -} // namespace oxide |
1035 | - |
1036 | |
1037 | === added file 'shared/browser/oxide_quota_permission_context.h' |
1038 | --- shared/browser/oxide_quota_permission_context.h 1970-01-01 00:00:00 +0000 |
1039 | +++ shared/browser/oxide_quota_permission_context.h 2016-02-08 19:32:31 +0000 |
1040 | @@ -0,0 +1,45 @@ |
1041 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
1042 | +// Copyright (C) 2014 Canonical Ltd. |
1043 | + |
1044 | +// This library is free software; you can redistribute it and/or |
1045 | +// modify it under the terms of the GNU Lesser General Public |
1046 | +// License as published by the Free Software Foundation; either |
1047 | +// version 2.1 of the License, or (at your option) any later version. |
1048 | + |
1049 | +// This library is distributed in the hope that it will be useful, |
1050 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
1051 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1052 | +// Lesser General Public License for more details. |
1053 | + |
1054 | +// You should have received a copy of the GNU Lesser General Public |
1055 | +// License along with this library; if not, write to the Free Software |
1056 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
1057 | + |
1058 | +#ifndef _OXIDE_SHARED_BROWSER_QUOTA_PERMISSION_CONTEXT_H_ |
1059 | +#define _OXIDE_SHARED_BROWSER_QUOTA_PERMISSION_CONTEXT_H_ |
1060 | + |
1061 | +#include "content/public/browser/quota_permission_context.h" |
1062 | +#include "storage/common/quota/quota_types.h" |
1063 | + |
1064 | +namespace oxide { |
1065 | + |
1066 | +class QuotaPermissionContext final : |
1067 | + public content::QuotaPermissionContext { |
1068 | + public: |
1069 | + QuotaPermissionContext(); |
1070 | + ~QuotaPermissionContext(); |
1071 | + |
1072 | + private: |
1073 | + |
1074 | + void RequestQuotaPermission( |
1075 | + const content::StorageQuotaParams& params, |
1076 | + int render_process_id, |
1077 | + const content::QuotaPermissionContext::PermissionCallback& callback) final; |
1078 | + |
1079 | + DISALLOW_COPY_AND_ASSIGN(QuotaPermissionContext); |
1080 | +}; |
1081 | + |
1082 | +} // namespace oxide |
1083 | + |
1084 | +#endif // _OXIDE_SHARED_BROWSER_QUOTA_PERMISSION_CONTEXT_H_ |
1085 | + |
1086 | |
1087 | === removed file 'shared/browser/oxide_quota_permission_context.h' |
1088 | --- shared/browser/oxide_quota_permission_context.h 2015-01-20 17:58:10 +0000 |
1089 | +++ shared/browser/oxide_quota_permission_context.h 1970-01-01 00:00:00 +0000 |
1090 | @@ -1,45 +0,0 @@ |
1091 | -// vim:expandtab:shiftwidth=2:tabstop=2: |
1092 | -// Copyright (C) 2014 Canonical Ltd. |
1093 | - |
1094 | -// This library is free software; you can redistribute it and/or |
1095 | -// modify it under the terms of the GNU Lesser General Public |
1096 | -// License as published by the Free Software Foundation; either |
1097 | -// version 2.1 of the License, or (at your option) any later version. |
1098 | - |
1099 | -// This library is distributed in the hope that it will be useful, |
1100 | -// but WITHOUT ANY WARRANTY; without even the implied warranty of |
1101 | -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1102 | -// Lesser General Public License for more details. |
1103 | - |
1104 | -// You should have received a copy of the GNU Lesser General Public |
1105 | -// License along with this library; if not, write to the Free Software |
1106 | -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
1107 | - |
1108 | -#ifndef _OXIDE_SHARED_BROWSER_QUOTA_PERMISSION_CONTEXT_H_ |
1109 | -#define _OXIDE_SHARED_BROWSER_QUOTA_PERMISSION_CONTEXT_H_ |
1110 | - |
1111 | -#include "content/public/browser/quota_permission_context.h" |
1112 | -#include "storage/common/quota/quota_types.h" |
1113 | - |
1114 | -namespace oxide { |
1115 | - |
1116 | -class QuotaPermissionContext final : |
1117 | - public content::QuotaPermissionContext { |
1118 | - public: |
1119 | - QuotaPermissionContext(); |
1120 | - ~QuotaPermissionContext(); |
1121 | - |
1122 | - void RequestQuotaPermission( |
1123 | - const content::StorageQuotaParams& params, |
1124 | - int render_process_id, |
1125 | - const content::QuotaPermissionContext::PermissionCallback& callback) final; |
1126 | - |
1127 | - private: |
1128 | - |
1129 | - DISALLOW_COPY_AND_ASSIGN(QuotaPermissionContext); |
1130 | -}; |
1131 | - |
1132 | -} // namespace oxide |
1133 | - |
1134 | -#endif // _OXIDE_SHARED_BROWSER_QUOTA_PERMISSION_CONTEXT_H_ |
1135 | - |
1136 | |
1137 | === modified file 'shared/browser/permissions/oxide_permission_request_dispatcher.cc' |
1138 | --- shared/browser/permissions/oxide_permission_request_dispatcher.cc 2016-01-13 18:54:13 +0000 |
1139 | +++ shared/browser/permissions/oxide_permission_request_dispatcher.cc 2016-02-08 19:32:31 +0000 |
1140 | @@ -250,4 +250,31 @@ |
1141 | return request_id; |
1142 | } |
1143 | |
1144 | +int PermissionRequestDispatcher::RequestQuotaPermission( |
1145 | + content::RenderFrameHost* render_frame_host, |
1146 | + const GURL& requesting_origin, |
1147 | + uint64_t requested_size, |
1148 | + const PermissionRequestCallback& callback) { |
1149 | + if (!client_) { |
1150 | + callback.Run(PERMISSION_REQUEST_RESPONSE_CANCEL); |
1151 | + return -1; |
1152 | + } |
1153 | + |
1154 | + int request_id = next_request_id_++; |
1155 | + scoped_ptr<PermissionRequest> request( |
1156 | + new PermissionRequest( |
1157 | + request_id, |
1158 | + RenderFrameHostID(render_frame_host), |
1159 | + requesting_origin, |
1160 | + web_contents()->GetLastCommittedURL().GetOrigin(), |
1161 | + callback)); |
1162 | + AddPendingRequest(request.get()); |
1163 | + |
1164 | + client_->RequestQuotaPermission( |
1165 | + requested_size, |
1166 | + std::move(request)); |
1167 | + |
1168 | + return request_id; |
1169 | +} |
1170 | + |
1171 | } // namespace oxide |
1172 | |
1173 | === modified file 'shared/browser/permissions/oxide_permission_request_dispatcher.h' |
1174 | --- shared/browser/permissions/oxide_permission_request_dispatcher.h 2015-10-07 18:07:40 +0000 |
1175 | +++ shared/browser/permissions/oxide_permission_request_dispatcher.h 2016-02-08 19:32:31 +0000 |
1176 | @@ -76,6 +76,12 @@ |
1177 | bool video, |
1178 | const PermissionRequestCallback& callback); |
1179 | |
1180 | + // Request permission for storage size quota |
1181 | + int RequestQuotaPermission(content::RenderFrameHost* render_frame_host, |
1182 | + const GURL& requesting_origin, |
1183 | + uint64_t requested_size, |
1184 | + const PermissionRequestCallback& callback); |
1185 | + |
1186 | private: |
1187 | friend class content::WebContentsUserData<PermissionRequestDispatcher>; |
1188 | friend class PermissionRequest; |
1189 | |
1190 | === modified file 'shared/browser/permissions/oxide_permission_request_dispatcher_client.h' |
1191 | --- shared/browser/permissions/oxide_permission_request_dispatcher_client.h 2016-01-13 18:54:13 +0000 |
1192 | +++ shared/browser/permissions/oxide_permission_request_dispatcher_client.h 2016-02-08 19:32:31 +0000 |
1193 | @@ -41,6 +41,10 @@ |
1194 | |
1195 | virtual void RequestNotificationPermission( |
1196 | scoped_ptr<PermissionRequest> request) {} |
1197 | + |
1198 | + virtual void RequestQuotaPermission( |
1199 | + uint64_t requested_size, |
1200 | + scoped_ptr<PermissionRequest> request) {} |
1201 | }; |
1202 | |
1203 | } // namespace oxide |
Thanks for working on this. I've added some comments inline.
This is also lacking tests - I'd start by looking at the geolocation permission tests (and also take in to consideration the points in bug 1399196). Note, cancellation when navigating subframes probably won't work for quota permissions like it should for geolocation (we have no indication of the frame on the browser side).