Merge lp:~abreu-alexandre/oxide/add-quota-permission-context-support into lp:~oxide-developers/oxide/oxide.trunk

Proposed by Alexandre Abreu on 2014-12-02
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
Reviewer Review Type Date Requested Status
Chris Coulson 2014-12-02 Needs Fixing on 2015-11-17
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:

https://git.launchpad.net/~abreu-alexandre/oxide/+git/chromium/commit/?h=expose-frame-id-quota&id=21f76382023aab780d211d5efad3c35690fc8ddc

To post a comment you must log in.
Chris Coulson (chrisccoulson) wrote :

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).

review: Needs Fixing
Chris Coulson (chrisccoulson) wrote :

I've added some comments inline for this

review: Needs Fixing
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?

review: Needs Fixing
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, QuotaPermissionRequest is deleted without a response).

I still don't know what happens if a page in an incognito webview requests a persistent storage quota. Did you find out?

review: Needs Fixing
Alexandre Abreu (abreu-alexandre) wrote :

created a expose-quota-frame-id branch in ~oxide-developers/oxide/+git/chromium to track the patches that add the frame id to the storage quota request,

1283. By Chris Coulson on 2015-11-26

Use Qt::PrimaryOrientation 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:

https://git.launchpad.net/~oxide-developers/oxide/+git/chromium/tree/storage/browser/quota/quota_manager.cc#n51

and

https://git.launchpad.net/~oxide-developers/oxide/+git/chromium/tree/storage/browser/quota/quota_manager.cc#n320

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 on 2015-11-27

QCoreApplication::applicationName() 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 on 2015-12-04

Build with 'use_ash: 0' as this seems to be pulling in dependencies from //chrome, resulting in random mis-builds

1286. By Chris Coulson on 2015-12-09

Bump Chromium rev to 0fcc1746 (48.0.2564.22)

1287. By Chris Coulson on 2015-12-09

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 on 2015-12-11

Don't require libhybris-dev to be installed when building without ENABLE_HYBRIS_CAMERA

1289. By Chris Coulson on 2015-12-16

Merge from lp:oxide/crmaster

1290. By Chris Coulson on 2015-12-16

Bump qt version to 1.13

1291. By Chris Coulson on 2015-12-17

Bump Chromium rev to dee8b819 (49.0.2587.3)

1292. By Chris Coulson on 2015-12-19

Fix OxideQCertificateError::isMainFrame to work with Chromium 49

1293. By Chris Coulson on 2015-12-22

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 on 2016-01-04

Merge r1067 from lp:oxide/crmaster

1295. By Chris Coulson on 2016-01-04

Bump Chromium rev to 8af47bb2 (49.0.2593.0)

1296. By Chris Coulson on 2016-01-04

Bump Chromium rev to a6f2995b to pick up build fix

1297. By Chris Coulson on 2016-01-06

Pass StartParams by value and give it a move constructor - this makes it obvious that the StartParams passed to BrowserProcessMain::Start is no longer valid once the function returns

1298. By Chris Coulson on 2016-01-07

Merge r1072 from lp:oxide/crmaster

1299. By Chris Coulson on 2016-01-07

Bump Chromium rev to 3bbb11d8 (49.0.2612.0)

1300. By Chris Coulson on 2016-01-08

Check the return value from android_camera_get_device_info

1301. By Chris Coulson on 2016-01-08

Check the return of android_camera_get_device_info in another location

1302. By Chris Coulson on 2016-01-08

Fix an import failure in release.py

1303. By Chris Coulson on 2016-01-08

Update the exclude list and call init-checkout.py from release.py

1304. By Olivier Tilloy on 2016-01-08

Add missing revision qualifier to the WebView.hoveredUrl property.

1305. By Chris Coulson on 2016-01-08

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 on 2016-01-09

Expose value type enums to QML in Qt5.5

1307. By Olivier Tilloy on 2016-01-11

Update to oxide.qmltypes missed at revision 1304.

1308. By Chris Coulson on 2016-01-11

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 on 2016-01-12

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 on 2016-01-12

Make QFlags naming consistent betweeen qt/core/api and qt/quick/api

1311. By Chris Coulson on 2016-01-13

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 on 2016-01-13

Ensure we define OXIDE_QTQUICK_IMPLEMENTATION as part of the build

1313. By Chris Coulson on 2016-01-13

Remove SimplePermissionRequest

1314. By Chris Coulson on 2016-01-13

Register PermissionRequest and MediaAccessPermissionRequest

1315. By Chris Coulson on 2016-01-13

Add deprecation warnings for deprecated APIs

1316. By Chris Coulson on 2016-01-14

Add missing file

1317. By Chris Coulson on 2016-01-15

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 on 2016-01-18

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 on 2016-01-19

Use INTERFACE_LINK_LIBRARIES for OXIDE_LIB, and make some libraries linked in to OXIDE_QUICKLIB public

1320. By Chris Coulson on 2016-01-19

Merge r1085 from lp:oxide/crmaster

1321. By Chris Coulson on 2016-01-20

Bump Chromium rev to c51aaef (49.0.2623.0)

1322. By Chris Coulson on 2016-01-20

Unbreak cross-compiles and make sure we test the version of the correct module

1323. By Chris Coulson on 2016-01-21

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 on 2016-01-22

Safely handle event loop nesting from outside of Oxide

1325. By Chris Coulson on 2016-01-25

Bump Chromium rev to 37948b2 (49.0.2623.13)

1326. By Chris Coulson on 2016-01-26

Update the deprecation warning for loadingChanged and add a macro for doing this as well

1327. By Chris Coulson on 2016-01-27

Bump Chromium rev to 8e193e1 (49.0.2623.23)

1328. By Chris Coulson on 2016-01-28

Remove WebViewProxy::createHelpers - just export the relevant private classes and have OxideQQuickWebView use those directly

1329. By Chris Coulson on 2016-01-31

Bump qt version to 1.14

1330. By Chris Coulson on 2016-01-31

Rename development Chromium branches to oxide/dev/crXXXX

1331. By Chris Coulson on 2016-01-31

Merge r1097 from lp:oxide/crmaster

1332. By Chris Coulson on 2016-01-31

Bump Chromium rev to 0571636 (50.0.2633.3)

1333. By Alexandre Abreu on 2016-02-01

fix build failure with MediaHub specific code

1334. By Chris Coulson on 2016-02-07

Add support for drag and drop

1335. By Chris Coulson on 2016-02-08

Merge r1100 from lp:oxide/crmaster

1336. By Chris Coulson on 2016-02-08

Fix some test failures

1337. By Alexandre Abreu on 2016-02-08

Add support for quota permission context request.

1338. By Alexandre Abreu on 2016-02-08

Tweaks

Unmerged revisions

1338. By Alexandre Abreu on 2016-02-08

Tweaks

1337. By Alexandre Abreu on 2016-02-08

Add support for quota permission context request.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'qt/build/system.gyp'
--- qt/build/system.gyp 2015-10-28 19:09:39 +0000
+++ qt/build/system.gyp 2016-02-08 19:32:31 +0000
@@ -107,5 +107,22 @@
107 ],107 ],
108 },108 },
109 },109 },
110 {
111 'target_name': 'Qt5Feedback',
112 'type': 'none',
113 'direct_dependent_settings': {
114 'cflags_cc': [
115 '<!@(<(pkg_config) --cflags Qt5Feedback)'
116 ]
117 },
118 'link_settings': {
119 'ldflags': [
120 '<!@(<(pkg_config) --libs-only-L --libs-only-other Qt5Feedback)',
121 ],
122 'libraries': [
123 '<!@(<(pkg_config) --libs-only-l Qt5Feedback)',
124 ],
125 },
126 },
110 ],127 ],
111}128}
112129
=== modified file 'qt/core/api/oxideqpermissionrequest.cc'
--- qt/core/api/oxideqpermissionrequest.cc 2016-01-26 16:47:06 +0000
+++ qt/core/api/oxideqpermissionrequest.cc 2016-02-08 19:32:31 +0000
@@ -105,6 +105,18 @@
105 ~OxideQMediaAccessPermissionRequestPrivate() {}105 ~OxideQMediaAccessPermissionRequestPrivate() {}
106106
107// static107// static
108OxideQQuotaPermissionRequest*
109OxideQQuotaPermissionRequestPrivate::Create(
110 quint64 requested_size,
111 scoped_ptr<oxide::PermissionRequest> request) {
112 DCHECK(request);
113 return new OxideQQuotaPermissionRequest(
114 *new OxideQQuotaPermissionRequestPrivate(
115 requested_size,
116 std::move(request)));
117}
118
119// static
108OxideQMediaAccessPermissionRequest*120OxideQMediaAccessPermissionRequest*
109OxideQMediaAccessPermissionRequestPrivate::Create(121OxideQMediaAccessPermissionRequestPrivate::Create(
110 scoped_ptr<oxide::MediaAccessPermissionRequest> request) {122 scoped_ptr<oxide::MediaAccessPermissionRequest> request) {
@@ -114,6 +126,32 @@
114 *new OxideQMediaAccessPermissionRequestPrivate(std::move(request)));126 *new OxideQMediaAccessPermissionRequestPrivate(std::move(request)));
115}127}
116128
129OxideQQuotaPermissionRequestPrivate::OxideQQuotaPermissionRequestPrivate(
130 quint64 requested_size,
131 scoped_ptr<oxide::PermissionRequest> request)
132 : OxideQPermissionRequestPrivate(std::move(request)),
133 requested_size_(requested_size) {}
134
135OxideQQuotaPermissionRequestPrivate::~OxideQQuotaPermissionRequestPrivate() {}
136
137bool OxideQQuotaPermissionRequestPrivate::canRespond() const {
138 if (request_->is_cancelled()) {
139 qWarning() <<
140 "OxideQQuotaPermissionRequestPrivate: Can't respond to a cancelled "
141 "permission request";
142 return false;
143 }
144
145 if (!request_->IsPending()) {
146 qWarning() <<
147 "OxideQQuotaPermissionRequestPrivate: Can only respond once to a "
148 "permission request";
149 return false;
150 }
151
152 return true;
153}
154
117OxideQPermissionRequest::OxideQPermissionRequest(155OxideQPermissionRequest::OxideQPermissionRequest(
118 OxideQPermissionRequestPrivate& dd)156 OxideQPermissionRequestPrivate& dd)
119 : d_ptr(&dd) {157 : d_ptr(&dd) {
@@ -206,3 +244,15 @@
206244
207 return d->request()->video_requested();245 return d->request()->video_requested();
208}246}
247
248OxideQQuotaPermissionRequest::OxideQQuotaPermissionRequest(
249 OxideQQuotaPermissionRequestPrivate& dd)
250 : OxideQPermissionRequest(dd) {}
251
252OxideQQuotaPermissionRequest::~OxideQQuotaPermissionRequest() {}
253
254quint64 OxideQQuotaPermissionRequest::requestedSize() const {
255 Q_D(const OxideQQuotaPermissionRequest);
256
257 return d->requested_size_;
258}
209259
=== modified file 'qt/core/api/oxideqpermissionrequest.h'
--- qt/core/api/oxideqpermissionrequest.h 2016-01-13 18:54:13 +0000
+++ qt/core/api/oxideqpermissionrequest.h 2016-02-08 19:32:31 +0000
@@ -28,6 +28,8 @@
28class OxideQGeolocationPermissionRequestPrivate;28class OxideQGeolocationPermissionRequestPrivate;
29class OxideQMediaAccessPermissionRequestPrivate;29class OxideQMediaAccessPermissionRequestPrivate;
30class OxideQPermissionRequestPrivate;30class OxideQPermissionRequestPrivate;
31class OxideQQuotaPermissionRequestPrivate;
32class OxideQSimplePermissionRequestPrivate;
3133
32class OXIDE_QTCORE_EXPORT OxideQPermissionRequest : public QObject {34class OXIDE_QTCORE_EXPORT OxideQPermissionRequest : public QObject {
33 Q_OBJECT35 Q_OBJECT
@@ -106,4 +108,24 @@
106 OxideQMediaAccessPermissionRequestPrivate& dd);108 OxideQMediaAccessPermissionRequestPrivate& dd);
107};109};
108110
111class OXIDE_QTCORE_EXPORT OxideQQuotaPermissionRequest :
112 public OxideQPermissionRequest {
113 Q_OBJECT
114
115 Q_PROPERTY(quint64 requestedSize READ requestedSize CONSTANT)
116
117 Q_DECLARE_PRIVATE(OxideQQuotaPermissionRequest)
118 Q_DISABLE_COPY(OxideQQuotaPermissionRequest)
119
120 public:
121
122 ~OxideQQuotaPermissionRequest();
123
124 quint64 requestedSize() const;
125
126 private:
127 OxideQQuotaPermissionRequest(
128 OxideQQuotaPermissionRequestPrivate& dd);
129};
130
109#endif // OXIDE_QTCORE_PERMISSION_REQUEST131#endif // OXIDE_QTCORE_PERMISSION_REQUEST
110132
=== modified file 'qt/core/api/oxideqpermissionrequest_p.h'
--- qt/core/api/oxideqpermissionrequest_p.h 2016-01-13 18:54:13 +0000
+++ qt/core/api/oxideqpermissionrequest_p.h 2016-02-08 19:32:31 +0000
@@ -66,6 +66,26 @@
66 scoped_ptr<oxide::PermissionRequest> request);66 scoped_ptr<oxide::PermissionRequest> request);
67};67};
6868
69class OxideQQuotaPermissionRequestPrivate
70 : public OxideQPermissionRequestPrivate {
71 public:
72 ~OxideQQuotaPermissionRequestPrivate();
73
74 static OxideQQuotaPermissionRequest* Create(
75 quint64 requested_size,
76 scoped_ptr<oxide::PermissionRequest> request);
77
78 private:
79 OxideQQuotaPermissionRequestPrivate(
80 quint64 requested_size,
81 scoped_ptr<oxide::PermissionRequest> request);
82
83 friend class OxideQQuotaPermissionRequest;
84
85 bool canRespond() const;
86 quint64 requested_size_;
87};
88
69class OxideQMediaAccessPermissionRequestPrivate89class OxideQMediaAccessPermissionRequestPrivate
70 : public OxideQPermissionRequestPrivate {90 : public OxideQPermissionRequestPrivate {
71 public:91 public:
7292
=== modified file 'qt/core/browser/oxide_qt_web_view.cc'
--- qt/core/browser/oxide_qt_web_view.cc 2016-02-05 16:17:52 +0000
+++ qt/core/browser/oxide_qt_web_view.cc 2016-02-08 19:32:31 +0000
@@ -46,8 +46,10 @@
46#include "content/common/cursors/webcursor.h"46#include "content/common/cursors/webcursor.h"
47#include "content/public/browser/native_web_keyboard_event.h"47#include "content/public/browser/native_web_keyboard_event.h"
48#include "content/public/browser/navigation_controller.h"48#include "content/public/browser/navigation_controller.h"
49#include "content/public/browser/storage_partition.h"
49#include "content/browser/web_contents/web_contents_impl.h"50#include "content/browser/web_contents/web_contents_impl.h"
50#include "net/base/net_errors.h"51#include "net/base/net_errors.h"
52#include "storage/browser/quota/quota_manager.h"
51#include "third_party/WebKit/public/platform/WebCursorInfo.h"53#include "third_party/WebKit/public/platform/WebCursorInfo.h"
52#include "third_party/WebKit/public/platform/WebTopControlsState.h"54#include "third_party/WebKit/public/platform/WebTopControlsState.h"
53#include "third_party/WebKit/public/web/WebDragOperation.h"55#include "third_party/WebKit/public/web/WebDragOperation.h"
@@ -341,6 +343,15 @@
341 return true;343 return true;
342}344}
343345
346void ClearQuotaPermissionDataDoneCallback(
347 QObject* callbackReceiver,
348 storage::QuotaStatusCode result,
349 int64_t quota) {
350 QMetaObject::invokeMethod(
351 callbackReceiver,
352 "cleared");
353}
354
344}355}
345356
346class CompositorFrameHandleImpl : public CompositorFrameHandle {357class CompositorFrameHandleImpl : public CompositorFrameHandle {
@@ -1510,6 +1521,17 @@
1510 frame_tree_torn_down_ = true;1521 frame_tree_torn_down_ = true;
1511}1522}
15121523
1524void WebView::clearQuotaPermissionData(const QString& origin, QObject* callbackReceiver) {
1525 view_->GetWebContents()
1526 ->GetRenderProcessHost()
1527 ->GetStoragePartition()
1528 ->GetQuotaManager()
1529 ->SetPersistentHostQuota(
1530 origin.toStdString(),
1531 1,
1532 base::Bind(ClearQuotaPermissionDataDoneCallback, callbackReceiver));
1533}
1534
1513WebView::WebView(WebViewProxyClient* client,1535WebView::WebView(WebViewProxyClient* client,
1514 QObject* native_view,1536 QObject* native_view,
1515 OxideQFindController* find_controller,1537 OxideQFindController* find_controller,
@@ -1599,6 +1621,16 @@
1599 return WebContext::FromBrowserContext(view_->GetBrowserContext());1621 return WebContext::FromBrowserContext(view_->GetBrowserContext());
1600}1622}
16011623
1624void WebView::RequestQuotaPermission(
1625 uint64_t requested_size,
1626 scoped_ptr<oxide::PermissionRequest> request) {
1627 scoped_ptr<OxideQQuotaPermissionRequest> req(
1628 OxideQQuotaPermissionRequestPrivate::Create(
1629 requested_size,
1630 std::move(request)));
1631 client_->RequestQuotaPermission(req.release());
1632}
1633
1602const oxide::SecurityStatus& WebView::GetSecurityStatus() const {1634const oxide::SecurityStatus& WebView::GetSecurityStatus() const {
1603 return view_->security_status();1635 return view_->security_status();
1604}1636}
16051637
=== modified file 'qt/core/browser/oxide_qt_web_view.h'
--- qt/core/browser/oxide_qt_web_view.h 2016-02-05 16:17:52 +0000
+++ qt/core/browser/oxide_qt_web_view.h 2016-02-08 19:32:31 +0000
@@ -192,6 +192,9 @@
192 scoped_ptr<oxide::PermissionRequest> request) override;192 scoped_ptr<oxide::PermissionRequest> request) override;
193 void RequestMediaAccessPermission(193 void RequestMediaAccessPermission(
194 scoped_ptr<oxide::MediaAccessPermissionRequest> request) override;194 scoped_ptr<oxide::MediaAccessPermissionRequest> request) override;
195 void RequestQuotaPermission(
196 uint64_t requested_size,
197 scoped_ptr<oxide::PermissionRequest> request) override;
195198
196 // oxide::WebFrameTreeObserver implementation199 // oxide::WebFrameTreeObserver implementation
197 void FrameCreated(oxide::WebFrame* frame) override;200 void FrameCreated(oxide::WebFrame* frame) override;
@@ -303,6 +306,8 @@
303306
304 void teardownFrameTree() override;307 void teardownFrameTree() override;
305308
309 void clearQuotaPermissionData(const QString& origin, QObject* callbackReceiver);
310
306 // This must outlive |view_|311 // This must outlive |view_|
307 scoped_ptr<InputMethodContext> input_method_context_;312 scoped_ptr<InputMethodContext> input_method_context_;
308313
309314
=== modified file 'qt/core/core.gyp'
--- qt/core/core.gyp 2016-02-05 16:17:52 +0000
+++ qt/core/core.gyp 2016-02-08 19:32:31 +0000
@@ -27,6 +27,7 @@
27 'dependencies': [27 'dependencies': [
28 '../build/system.gyp:Qt5Core',28 '../build/system.gyp:Qt5Core',
29 '../build/system.gyp:Qt5Core-private',29 '../build/system.gyp:Qt5Core-private',
30 '../build/system.gyp:Qt5Feedback',
30 '../build/system.gyp:Qt5Gui',31 '../build/system.gyp:Qt5Gui',
31 '../build/system.gyp:Qt5Gui-private',32 '../build/system.gyp:Qt5Gui-private',
32 '../build/system.gyp:Qt5Network',33 '../build/system.gyp:Qt5Network',
3334
=== modified file 'qt/core/glue/oxide_qt_web_view_proxy.h'
--- qt/core/glue/oxide_qt_web_view_proxy.h 2016-02-05 16:17:52 +0000
+++ qt/core/glue/oxide_qt_web_view_proxy.h 2016-02-08 19:32:31 +0000
@@ -251,6 +251,8 @@
251 virtual void locationBarShow(bool animate) = 0;251 virtual void locationBarShow(bool animate) = 0;
252 virtual void locationBarHide(bool animate) = 0;252 virtual void locationBarHide(bool animate) = 0;
253253
254 virtual void clearQuotaPermissionData(const QString& origin, QObject* callbackReceiver) = 0;
255
254 virtual WebProcessStatus webProcessStatus() const = 0;256 virtual WebProcessStatus webProcessStatus() const = 0;
255257
256 virtual void executeEditingCommand(EditingCommands command) const = 0;258 virtual void executeEditingCommand(EditingCommands command) const = 0;
257259
=== modified file 'qt/core/glue/oxide_qt_web_view_proxy_client.h'
--- qt/core/glue/oxide_qt_web_view_proxy_client.h 2016-01-08 06:38:22 +0000
+++ qt/core/glue/oxide_qt_web_view_proxy_client.h 2016-02-08 19:32:31 +0000
@@ -34,6 +34,7 @@
34class OxideQNavigationRequest;34class OxideQNavigationRequest;
35class OxideQNewViewRequest;35class OxideQNewViewRequest;
36class OxideQPermissionRequest;36class OxideQPermissionRequest;
37class OxideQQuotaPermissionRequest;
3738
38QT_BEGIN_NAMESPACE39QT_BEGIN_NAMESPACE
39class QCursor;40class QCursor;
@@ -158,6 +159,9 @@
158 virtual void TargetURLChanged() = 0;159 virtual void TargetURLChanged() = 0;
159 160
160 virtual void OnEditingCapabilitiesChanged() = 0;161 virtual void OnEditingCapabilitiesChanged() = 0;
162
163 virtual void RequestQuotaPermission(
164 OxideQQuotaPermissionRequest* request) = 0;
161};165};
162166
163} // namespace qt167} // namespace qt
164168
=== modified file 'qt/qmlplugin/oxide.qmltypes'
--- qt/qmlplugin/oxide.qmltypes 2016-01-12 11:45:54 +0000
+++ qt/qmlplugin/oxide.qmltypes 2016-02-08 19:32:31 +0000
@@ -4,7 +4,7 @@
4// It is used for QML tooling purposes only.4// It is used for QML tooling purposes only.
5//5//
6// This file was auto-generated by:6// This file was auto-generated by:
7// 'qmlplugindump -v -noinstantiate com.canonical.Oxide 1.12 com/canonical/Oxide'7// 'qmlplugindump -v -noinstantiate com.canonical.Oxide 1.13 com/canonical/Oxide'
88
9Module {9Module {
10 Component {10 Component {
@@ -54,11 +54,10 @@
54 }54 }
55 Component {55 Component {
56 name: "OxideQGeolocationPermissionRequest"56 name: "OxideQGeolocationPermissionRequest"
57 prototype: "OxideQSimplePermissionRequest"57 prototype: "OxideQPermissionRequest"
58 exports: ["GeolocationPermissionRequest 1.0"]58 exports: ["GeolocationPermissionRequest 1.0"]
59 isCreatable: false59 isCreatable: false
60 exportMetaObjectRevisions: [0]60 exportMetaObjectRevisions: [0]
61 Property { name: "origin"; type: "QUrl"; isReadonly: true }
62 Method { name: "accept" }61 Method { name: "accept" }
63 }62 }
64 Component {63 Component {
@@ -78,6 +77,15 @@
78 Method { name: "deny" }77 Method { name: "deny" }
79 }78 }
80 Component {79 Component {
80 name: "OxideQMediaAccessPermissionRequest"
81 prototype: "OxideQPermissionRequest"
82 exports: ["MediaAccessPermissionRequest 1.0"]
83 isCreatable: false
84 exportMetaObjectRevisions: [0]
85 Property { name: "isForAudio"; type: "bool"; isReadonly: true }
86 Property { name: "isForVideo"; type: "bool"; isReadonly: true }
87 }
88 Component {
81 name: "OxideQNavigationRequest"89 name: "OxideQNavigationRequest"
82 prototype: "QObject"90 prototype: "QObject"
83 exports: ["NavigationRequest 1.0"]91 exports: ["NavigationRequest 1.0"]
@@ -127,11 +135,16 @@
127 Component {135 Component {
128 name: "OxideQPermissionRequest"136 name: "OxideQPermissionRequest"
129 prototype: "QObject"137 prototype: "QObject"
138 exports: ["PermissionRequest 1.0"]
139 isCreatable: false
140 exportMetaObjectRevisions: [0]
130 Property { name: "origin"; type: "QUrl"; isReadonly: true }141 Property { name: "origin"; type: "QUrl"; isReadonly: true }
131 Property { name: "embedder"; type: "QUrl"; isReadonly: true }142 Property { name: "embedder"; type: "QUrl"; isReadonly: true }
132 Property { name: "isCancelled"; type: "bool"; isReadonly: true }143 Property { name: "isCancelled"; type: "bool"; isReadonly: true }
133 Property { name: "url"; type: "QUrl"; isReadonly: true }144 Property { name: "url"; type: "QUrl"; isReadonly: true }
134 Signal { name: "cancelled" }145 Signal { name: "cancelled" }
146 Method { name: "allow" }
147 Method { name: "deny" }
135 }148 }
136 Component {149 Component {
137 name: "OxideQQuickCookieManager"150 name: "OxideQQuickCookieManager"
@@ -480,13 +493,14 @@
480 "WebView 1.0",493 "WebView 1.0",
481 "WebView 1.11",494 "WebView 1.11",
482 "WebView 1.12",495 "WebView 1.12",
496 "WebView 1.13",
483 "WebView 1.3",497 "WebView 1.3",
484 "WebView 1.4",498 "WebView 1.4",
485 "WebView 1.5",499 "WebView 1.5",
486 "WebView 1.8",500 "WebView 1.8",
487 "WebView 1.9"501 "WebView 1.9"
488 ]502 ]
489 exportMetaObjectRevisions: [0, 6, 7, 1, 2, 3, 4, 5]503 exportMetaObjectRevisions: [0, 6, 7, 8, 1, 2, 3, 4, 5]
490 attachedType: "OxideQQuickWebViewAttached"504 attachedType: "OxideQQuickWebViewAttached"
491 Enum {505 Enum {
492 name: "LogMessageSeverityLevel"506 name: "LogMessageSeverityLevel"
@@ -718,6 +732,11 @@
718 Signal { name: "hoveredUrlChanged"; revision: 7 }732 Signal { name: "hoveredUrlChanged"; revision: 7 }
719 Signal { name: "editingCapabilitiesChanged"; revision: 7 }733 Signal { name: "editingCapabilitiesChanged"; revision: 7 }
720 Signal {734 Signal {
735 name: "quotaPermissionRequested"
736 revision: 8
737 Parameter { name: "request"; type: "QJSValue" }
738 }
739 Signal {
721 name: "loadingChanged"740 name: "loadingChanged"
722 Parameter { name: "loadEvent"; type: "OxideQLoadEvent" }741 Parameter { name: "loadEvent"; type: "OxideQLoadEvent" }
723 }742 }
@@ -763,6 +782,14 @@
763 Property { name: "view"; type: "OxideQQuickWebView"; isReadonly: true; isPointer: true }782 Property { name: "view"; type: "OxideQQuickWebView"; isReadonly: true; isPointer: true }
764 }783 }
765 Component {784 Component {
785 name: "OxideQQuotaPermissionRequest"
786 prototype: "OxideQPermissionRequest"
787 exports: ["QuotaPermissionRequest 1.13"]
788 isCreatable: false
789 exportMetaObjectRevisions: [0]
790 Property { name: "requestedSize"; type: "qulonglong"; isReadonly: true }
791 }
792 Component {
766 name: "OxideQSecurityStatus"793 name: "OxideQSecurityStatus"
767 prototype: "QObject"794 prototype: "QObject"
768 exports: ["SecurityStatus 1.0"]795 exports: ["SecurityStatus 1.0"]
@@ -779,7 +806,7 @@
779 }806 }
780 }807 }
781 Enum {808 Enum {
782 name: "ContentStatusFlags"809 name: "ContentStatus"
783 values: {810 values: {
784 "ContentStatusNormal": 0,811 "ContentStatusNormal": 0,
785 "ContentStatusDisplayedInsecure": 1,812 "ContentStatusDisplayedInsecure": 1,
@@ -787,7 +814,7 @@
787 }814 }
788 }815 }
789 Enum {816 Enum {
790 name: "CertStatusFlags"817 name: "CertStatus"
791 values: {818 values: {
792 "CertStatusOk": 0,819 "CertStatusOk": 0,
793 "CertStatusBadIdentity": 1,820 "CertStatusBadIdentity": 1,
@@ -802,17 +829,11 @@
802 }829 }
803 }830 }
804 Property { name: "securityLevel"; type: "SecurityLevel"; isReadonly: true }831 Property { name: "securityLevel"; type: "SecurityLevel"; isReadonly: true }
805 Property { name: "contentStatus"; type: "ContentStatusFlags"; isReadonly: true }832 Property { name: "contentStatus"; type: "ContentStatus"; isReadonly: true }
806 Property { name: "certStatus"; type: "CertStatusFlags"; isReadonly: true }833 Property { name: "certStatus"; type: "CertStatus"; isReadonly: true }
807 Property { name: "certificate"; type: "QVariant"; isReadonly: true }834 Property { name: "certificate"; type: "QVariant"; isReadonly: true }
808 }835 }
809 Component {836 Component {
810 name: "OxideQSimplePermissionRequest"
811 prototype: "OxideQPermissionRequest"
812 Method { name: "allow" }
813 Method { name: "deny" }
814 }
815 Component {
816 name: "OxideQWebPreferences"837 name: "OxideQWebPreferences"
817 prototype: "QObject"838 prototype: "QObject"
818 exports: ["WebPreferences 1.0"]839 exports: ["WebPreferences 1.0"]
819840
=== modified file 'qt/qmlplugin/oxide_qml_plugin.cc'
--- qt/qmlplugin/oxide_qml_plugin.cc 2016-01-13 19:05:43 +0000
+++ qt/qmlplugin/oxide_qml_plugin.cc 2016-02-08 19:32:31 +0000
@@ -187,6 +187,7 @@
187 qmlRegisterType<OxideQQuickWebView, 4>(uri, 1, 8, "WebView");187 qmlRegisterType<OxideQQuickWebView, 4>(uri, 1, 8, "WebView");
188188
189 qmlRegisterType<OxideQQuickWebContext, 3>(uri, 1, 9, "WebContext");189 qmlRegisterType<OxideQQuickWebContext, 3>(uri, 1, 9, "WebContext");
190
190 qmlRegisterUncreatableType<OxideQHttpAuthenticationRequest>(191 qmlRegisterUncreatableType<OxideQHttpAuthenticationRequest>(
191 uri, 1, 9, "HttpAuthenticationRequest",192 uri, 1, 9, "HttpAuthenticationRequest",
192 "HttpAuthenticationRequest is delivered by "193 "HttpAuthenticationRequest is delivered by "
@@ -199,7 +200,14 @@
199 uri, 1, 12, "TouchSelectionController",200 uri, 1, 12, "TouchSelectionController",
200 "TouchSelectionController is accessed via "201 "TouchSelectionController is accessed via "
201 "WebView.touchSelectionController");202 "WebView.touchSelectionController");
203
202 qmlRegisterType<OxideQQuickWebView, 7>(uri, 1, 12, "WebView");204 qmlRegisterType<OxideQQuickWebView, 7>(uri, 1, 12, "WebView");
205
206 qmlRegisterUncreatableType<OxideQQuotaPermissionRequest>(uri, 1, 13,
207 "QuotaPermissionRequest",
208 "QuotaPermissionRequest is delivered by WebView.quotaPermissionRequested");
209
210 qmlRegisterType<OxideQQuickWebView, 8>(uri, 1, 13, "WebView");
203 }211 }
204};212};
205213
206214
=== modified file 'qt/quick/api/oxideqquickwebview.cc'
--- qt/quick/api/oxideqquickwebview.cc 2016-02-05 16:17:52 +0000
+++ qt/quick/api/oxideqquickwebview.cc 2016-02-08 19:32:31 +0000
@@ -637,6 +637,30 @@
637 engine->collectGarbage();637 engine->collectGarbage();
638}638}
639639
640void OxideQQuickWebViewPrivate::RequestQuotaPermission(
641 OxideQQuotaPermissionRequest* request) {
642 Q_Q(OxideQQuickWebView);
643
644 // See OxideQQuickWebViewPrivate::RequestGeolocationPermission
645 QQmlEngine* engine = qmlEngine(q);
646 if (!engine) {
647 delete request;
648 return;
649 }
650
651 {
652 QJSValue val = engine->newQObject(request);
653 if (!val.isQObject()) {
654 delete request;
655 return;
656 }
657
658 emit q->quotaPermissionRequested(val);
659 }
660
661 engine->collectGarbage();
662}
663
640void OxideQQuickWebViewPrivate::ContentBlocked() {664void OxideQQuickWebViewPrivate::ContentBlocked() {
641 Q_Q(OxideQQuickWebView);665 Q_Q(OxideQQuickWebView);
642666
@@ -1065,6 +1089,12 @@
1065 return proxy()->getNavigationEntryTimestamp(index);1089 return proxy()->getNavigationEntryTimestamp(index);
1066}1090}
10671091
1092void OxideQQuickWebViewPrivate::clearQuotaPermissionData(
1093 const QString& origin,
1094 QObject* callbackReceiver) {
1095 proxy()->clearQuotaPermissionData(origin, callbackReceiver);
1096}
1097
1068void OxideQQuickWebView::connectNotify(const QMetaMethod& signal) {1098void OxideQQuickWebView::connectNotify(const QMetaMethod& signal) {
1069 Q_D(OxideQQuickWebView);1099 Q_D(OxideQQuickWebView);
10701100
10711101
=== modified file 'qt/quick/api/oxideqquickwebview.h'
--- qt/quick/api/oxideqquickwebview.h 2016-02-05 16:17:52 +0000
+++ qt/quick/api/oxideqquickwebview.h 2016-02-08 19:32:31 +0000
@@ -36,6 +36,7 @@
36class OxideQLoadEvent;36class OxideQLoadEvent;
37class OxideQNavigationRequest;37class OxideQNavigationRequest;
38class OxideQNewViewRequest;38class OxideQNewViewRequest;
39class OxideQQuotaPermissionRequest;
39class OxideQWebPreferences;40class OxideQWebPreferences;
40class OxideQQuickLocationBarController;41class OxideQQuickLocationBarController;
41class OxideQQuickNavigationHistory;42class OxideQQuickNavigationHistory;
@@ -366,6 +367,7 @@
366 Q_REVISION(5) void httpAuthenticationRequested(const QJSValue& request);367 Q_REVISION(5) void httpAuthenticationRequested(const QJSValue& request);
367 Q_REVISION(7) void hoveredUrlChanged();368 Q_REVISION(7) void hoveredUrlChanged();
368 Q_REVISION(7) void editingCapabilitiesChanged();369 Q_REVISION(7) void editingCapabilitiesChanged();
370 Q_REVISION(8) void quotaPermissionRequested(const QJSValue& request);
369371
370 // Deprecated since 1.3372 // Deprecated since 1.3
371 void loadingChanged(const OxideQLoadEvent& loadEvent);373 void loadingChanged(const OxideQLoadEvent& loadEvent);
372374
=== modified file 'qt/quick/api/oxideqquickwebview_p.h'
--- qt/quick/api/oxideqquickwebview_p.h 2016-01-13 18:16:11 +0000
+++ qt/quick/api/oxideqquickwebview_p.h 2016-02-08 19:32:31 +0000
@@ -78,6 +78,10 @@
78 QString getNavigationEntryTitle(int index) const;78 QString getNavigationEntryTitle(int index) const;
79 QDateTime getNavigationEntryTimestamp(int index) const;79 QDateTime getNavigationEntryTimestamp(int index) const;
8080
81 void clearQuotaPermissionData(
82 const QString& origin,
83 QObject* callbackReceiver);
84
81 private:85 private:
82 friend class UpdatePaintNodeScope;86 friend class UpdatePaintNodeScope;
8387
@@ -148,6 +152,8 @@
148 void CloseRequested() override;152 void CloseRequested() override;
149 void TargetURLChanged() override;153 void TargetURLChanged() override;
150 void OnEditingCapabilitiesChanged() override;154 void OnEditingCapabilitiesChanged() override;
155 void RequestQuotaPermission(
156 OxideQQuotaPermissionRequest* request) override;
151157
152 oxide::qt::WebViewProxy* proxy() const {158 oxide::qt::WebViewProxy* proxy() const {
153 return oxide::qt::WebViewProxyHandle::proxy();159 return oxide::qt::WebViewProxyHandle::proxy();
154160
=== modified file 'qt/tests/qmltests/TestWebView.qml'
--- qt/tests/qmltests/TestWebView.qml 2015-09-25 22:30:19 +0000
+++ qt/tests/qmltests/TestWebView.qml 2016-02-08 19:32:31 +0000
@@ -1,6 +1,6 @@
1import QtQuick 2.01import QtQuick 2.0
2import QtTest 1.02import QtTest 1.0
3import com.canonical.Oxide 1.113import com.canonical.Oxide 1.12
4import com.canonical.Oxide.Testing 1.0 as Testing4import com.canonical.Oxide.Testing 1.0 as Testing
5import "TestUtils.js" as TestUtils5import "TestUtils.js" as TestUtils
66
77
=== added file 'qt/tests/qmltests/api/tst_WebView_quotaPermission.html'
--- qt/tests/qmltests/api/tst_WebView_quotaPermission.html 1970-01-01 00:00:00 +0000
+++ qt/tests/qmltests/api/tst_WebView_quotaPermission.html 2016-02-08 19:32:31 +0000
@@ -0,0 +1,49 @@
1<html>
2<body>
3<span id="requested_size"></span>
4</body>
5<script>
6
7window.onload = function() {
8 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
9
10 var requestedSizeElement = document.getElementById('requested_size')
11
12 var observer = new MutationObserver(function(mutations) {
13 var size = requestedSizeElement.innerHTML
14 if (size !== '') {
15 requestQuota(parseInt(size))
16 }
17 });
18 observer.observe(requestedSizeElement,
19 {childList: true, subtree: true });
20
21 function requestQuota(requested_size) {
22 function dispatchEventWith(results) {
23 var e = new CustomEvent(
24 "oxideQuotaResult",
25 { bubbles: true, detail: results });
26 if (window === top) {
27 document.documentElement.dispatchEvent(e);
28 } else {
29 parent.document.documentElement.dispatchEvent(e);
30 }
31 }
32
33 var succeeded = function(bytes) {
34 dispatchEventWith({success: true, quota: bytes})
35 };
36
37 var failed = function(error) {
38 dispatchEventWith({success: false, error: error.toString()})
39 };
40
41 navigator.webkitPersistentStorage.requestQuota(
42 requested_size,
43 succeeded,
44 failed);
45 }
46}
47
48</script>
49</html>
050
=== added file 'qt/tests/qmltests/api/tst_WebView_quotaPermission.qml'
--- qt/tests/qmltests/api/tst_WebView_quotaPermission.qml 1970-01-01 00:00:00 +0000
+++ qt/tests/qmltests/api/tst_WebView_quotaPermission.qml 2016-02-08 19:32:31 +0000
@@ -0,0 +1,202 @@
1import QtQuick 2.0
2import QtTest 1.0
3import com.canonical.Oxide 1.12
4import com.canonical.Oxide.Testing 1.0
5
6TestWebView {
7 id: webView
8 width: 200
9 height: 200
10
11 property var lastQuotaRequest: null
12
13 SignalSpy {
14 id: spy
15 target: webView
16 signalName: "quotaPermissionRequested"
17 }
18
19 SignalSpy {
20 id: cancelSpy
21 signalName: "cancelled"
22 }
23
24 Item {
25 id: quotaDatabaseClearedCallbackReceiver
26 signal cleared()
27 }
28
29 SignalSpy {
30 id: quotaDatabaseClearedCallbackReceiverSpy
31 target: quotaDatabaseClearedCallbackReceiver
32 signalName: "cleared"
33 }
34
35 onQuotaPermissionRequested: {
36 lastQuotaRequest = request;
37 }
38
39 property var lastStatus: -1
40 property var lastQuota: -1
41
42 messageHandlers: [
43 ScriptMessageHandler {
44 msgId: "QUOTA-REQUEST-RESPONSE"
45 contexts: [ "oxide://testutils/" ]
46 callback: function(msg) {
47 webView.lastStatus = msg.args.status;
48 webView.lastQuota = msg.args.lastQuota
49 }
50 }
51 ]
52
53 TestCase {
54 id: test
55 name: "WebView_QuotaPermissionRequest"
56 when: windowShown
57
58 function init() {
59 spy.clear();
60 cancelSpy.clear();
61 webView.lastQuotaRequest = null;
62 webView.lastStatus = -1;
63 Utils.clearQuotaPermissionData(
64 "testsuite",
65 webView,
66 quotaDatabaseClearedCallbackReceiver);
67 quotaDatabaseClearedCallbackReceiverSpy.wait()
68 }
69
70 function _test_allow() {
71 webView.lastQuotaRequest.allow();
72 }
73
74 function _test_deny() {
75 webView.lastQuotaRequest.deny();
76 }
77
78 function test_QuotaPermissionRequest_data() {
79 return [
80 { url: "http://testsuite/tst_WebView_quotaPermission.html", function: _test_allow, expected: true, requested_quota: 1024*1024*10, current_quota: 1024*1024*10 },
81 { url: "http://testsuite/tst_WebView_quotaPermission.html", function: _test_deny, expected: true, requested_quota: 1024*1024*10, current_quota: 1 },
82 { url: "http://testsuite/tst_WebView_quotaPermission_iframe.html", function: _test_allow, expected: true, requested_quota: 1024*1024*10, current_quota: 1024*1024*10 },
83 ];
84 }
85
86 function test_QuotaPermissionRequest(data) {
87 webView.url = data.url
88 verify(webView.waitForLoadSucceeded(),
89 "Timed out waiting for successful load");
90
91 var is_iframe = (data.url.indexOf('_iframe') > 0)
92 var documentAccessPrefix = "document"
93 if (is_iframe) {
94 documentAccessPrefix = "document.getElementById('childframe').contentWindow.document"
95 }
96
97 webView.getTestApi().evaluateCode(
98 "document.addEventListener(\"oxideQuotaResult\", function(event) {
99 oxide.sendMessage(\"QUOTA-REQUEST-RESPONSE\", { status: event.detail.success, lastQuota: event.detail.quota });
100});", true);
101 webView.getTestApi().evaluateCode(
102 documentAccessPrefix +
103 ".getElementById('requested_size').innerHTML" +
104 " = "
105 + String(data.requested_quota))
106
107 if (!webView.lastQuotaRequest) {
108 spy.wait();
109 }
110
111 compare(webView.lastQuotaRequest.embedder, "http://testsuite/");
112 compare(webView.lastQuotaRequest.origin, "http://testsuite/");
113 compare(webView.lastQuotaRequest.isCancelled, false);
114
115 data.function();
116
117 verify(TestUtils.waitFor(function() { return webView.lastStatus != -1; }),
118 "Timed out waiting for quota response");
119 compare(webView.lastStatus, data.expected);
120 compare(webView.lastQuota, data.current_quota);
121 }
122
123 function test_QuotaPermissionRequest_main_frame_navigation_cancel() {
124 webView.url = "http://testsuite/tst_WebView_quotaPermission.html";
125 verify(webView.waitForLoadSucceeded(),
126 "Timed out waiting for successful load");
127
128 webView.getTestApi().evaluateCode(
129 "document.getElementById('requested_size').innerHTML" +
130 " = "
131 + String(10*1024*1024))
132
133 if (!webView.lastQuotaRequest) {
134 spy.wait();
135 }
136
137 cancelSpy.target = webView.lastQuotaRequest;
138
139 webView.clearLoadEventCounters();
140 webView.getTestApi().evaluateCode(
141 "window.location = \"http://testsuite/empty.html\";", false);
142 verify(webView.waitForLoadCommitted());
143
144 verify(webView.lastQuotaRequest.isCancelled);
145 compare(cancelSpy.count, 1) << "Pending request should have been cancelled";
146 }
147
148 function test_QuotaPermissionRequest_subframe_navigation_cancel() {
149 webView.url = "http://testsuite/tst_WebView_quotaPermission_iframe.html";
150 verify(webView.waitForLoadSucceeded(),
151 "Timed out waiting for successful load");
152
153 webView.getTestApi().evaluateCode(
154 "document.getElementById('childframe').contentWindow.document
155.getElementById('requested_size').innerHTML" +
156 " = "
157 + String(10*1024*1024))
158
159 if (!webView.lastQuotaRequest) {
160 spy.wait();
161 }
162
163 cancelSpy.target = webView.lastQuotaRequest;
164
165 webView.clearLoadEventCounters();
166 webView.getTestApiForFrame(webView.rootFrame.childFrames[0]).evaluateCode(
167 "window.location = \"http://testsuite/empty.html\";", false);
168
169 cancelSpy.wait();
170
171 compare(cancelSpy.count, 1) << "Pending request should have been cancelled";
172 verify(webView.lastQuotaRequest.isCancelled);
173 }
174
175 function test_QuotaPermissionRequest_subframe_delete_cancel() {
176 webView.url = "http://testsuite/tst_WebView_quotaPermission_iframe.html";
177 verify(webView.waitForLoadSucceeded(),
178 "Timed out waiting for successful load");
179
180 webView.getTestApi().evaluateCode(
181 "document.getElementById('childframe').contentWindow.document
182.getElementById('requested_size').innerHTML" +
183 " = "
184 + String(10*1024*1024))
185 if (!webView.lastQuotaRequest) {
186 spy.wait();
187 }
188
189 cancelSpy.target = webView.lastQuotaRequest;
190
191 webView.getTestApi().evaluateCode("
192var f = document.getElementById('childframe');
193f.parentElement.removeChild(f);", true);
194
195 cancelSpy.wait();
196
197 compare(cancelSpy.count, 1) << "Pending request should have been cancelled";
198 verify(webView.lastQuotaRequest.isCancelled);
199 }
200
201 }
202}
0203
=== added file 'qt/tests/qmltests/api/tst_WebView_quotaPermission_iframe.html'
--- qt/tests/qmltests/api/tst_WebView_quotaPermission_iframe.html 1970-01-01 00:00:00 +0000
+++ qt/tests/qmltests/api/tst_WebView_quotaPermission_iframe.html 2016-02-08 19:32:31 +0000
@@ -0,0 +1,5 @@
1<html>
2<body>
3 <iframe id="childframe" src="http://testsuite/tst_WebView_quotaPermission.html"></iframe>
4</body>
5</html>
06
=== modified file 'qt/tests/qmltests/oxide_qml_testing_plugin.cc'
--- qt/tests/qmltests/oxide_qml_testing_plugin.cc 2016-01-13 18:16:11 +0000
+++ qt/tests/qmltests/oxide_qml_testing_plugin.cc 2016-02-08 19:32:31 +0000
@@ -37,6 +37,8 @@
3737
38#include "qt/quick/api/oxideqquickwebcontext.h"38#include "qt/quick/api/oxideqquickwebcontext.h"
39#include "qt/quick/api/oxideqquickwebcontext_p.h"39#include "qt/quick/api/oxideqquickwebcontext_p.h"
40#include "qt/quick/api/oxideqquickwebview.h"
41#include "qt/quick/api/oxideqquickwebview_p.h"
4042
41namespace {43namespace {
4244
@@ -218,6 +220,14 @@
218 QGuiApplication::clipboard()->clear();220 QGuiApplication::clipboard()->clear();
219 }221 }
220222
223 Q_INVOKABLE void clearQuotaPermissionData(
224 const QString& origin,
225 OxideQQuickWebView* webview,
226 QObject* callbackReceiver) {
227 OxideQQuickWebViewPrivate::get(webview)
228 ->clearQuotaPermissionData(origin, callbackReceiver);
229 }
230
221 Q_INVOKABLE void clearTemporarySavedPermissionStatuses(231 Q_INVOKABLE void clearTemporarySavedPermissionStatuses(
222 OxideQQuickWebContext* context) {232 OxideQQuickWebContext* context) {
223 OxideQQuickWebContextPrivate::get(context)233 OxideQQuickWebContextPrivate::get(context)
224234
=== added file 'shared/browser/oxide_quota_permission_context.cc'
--- shared/browser/oxide_quota_permission_context.cc 1970-01-01 00:00:00 +0000
+++ shared/browser/oxide_quota_permission_context.cc 2016-02-08 19:32:31 +0000
@@ -0,0 +1,116 @@
1// vim:expandtab:shiftwidth=2:tabstop=2:
2// Copyright (C) 2014 Canonical Ltd.
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18#include "oxide_quota_permission_context.h"
19
20#include "content/public/browser/browser_thread.h"
21#include "content/public/browser/quota_permission_context.h"
22#include "content/public/browser/render_view_host.h"
23#include "storage/common/quota/quota_types.h"
24
25#include "permissions/oxide_permission_request.h"
26
27#include "oxide_web_view.h"
28
29namespace {
30
31/**
32 * Simple helper used to have the appearance of a PermissionRequest
33 * callback, by currying it w/ a QuotaPermissionCallback.
34 * Also makes sure that the callback is on the right thread.
35 */
36void QuotaPermissionRequestCallback(
37 const content::QuotaPermissionContext::PermissionCallback& cb,
38 oxide::PermissionRequestResponse result) {
39 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) {
40 content::BrowserThread::PostTask(
41 content::BrowserThread::IO,
42 FROM_HERE,
43 base::Bind(&QuotaPermissionRequestCallback, cb, result));
44 return;
45 }
46 cb.Run(result == oxide::PERMISSION_REQUEST_RESPONSE_ALLOW ?
47 content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW :
48 content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_DISALLOW);
49}
50
51}
52
53namespace oxide {
54
55QuotaPermissionContext::QuotaPermissionContext() {
56}
57
58QuotaPermissionContext::~QuotaPermissionContext() {
59}
60
61void QuotaPermissionContext::RequestQuotaPermission(
62 const content::StorageQuotaParams& params,
63 int render_process_id,
64 const content::QuotaPermissionContext::PermissionCallback& callback) {
65 if (params.storage_type != storage::kStorageTypePersistent) {
66 callback.Run(content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_DISALLOW);
67 return;
68 }
69
70 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
71 content::BrowserThread::PostTask(
72 content::BrowserThread::UI,
73 FROM_HERE,
74 base::Bind(&QuotaPermissionContext::RequestQuotaPermission,
75 this, params, render_process_id, callback));
76 return;
77 }
78
79 content::RenderViewHost* rvh =
80 content::RenderViewHost::FromID(render_process_id, params.render_view_id);
81 if (!rvh) {
82 QuotaPermissionRequestCallback(
83 callback,
84 oxide::PERMISSION_REQUEST_RESPONSE_DENY);
85 return;
86 }
87
88 WebView* webview = WebView::FromRenderViewHost(rvh);
89 if (!webview || !webview->GetWebContents()) {
90 QuotaPermissionRequestCallback(
91 callback,
92 oxide::PERMISSION_REQUEST_RESPONSE_DENY);
93 return;
94 }
95
96 content::RenderFrameHost* render_frame_host =
97 content::RenderFrameHost::FromID(
98 webview->GetWebContents()->GetRenderProcessHost()->GetID(),
99 params.render_frame_id);
100 if (!render_frame_host) {
101 QuotaPermissionRequestCallback(
102 callback,
103 oxide::PERMISSION_REQUEST_RESPONSE_DENY);
104 return;
105 }
106
107 PermissionRequestDispatcher::FromWebContents(webview->GetWebContents())
108 ->RequestQuotaPermission(
109 render_frame_host,
110 params.origin_url,
111 params.requested_size,
112 base::Bind(&QuotaPermissionRequestCallback, callback));
113}
114
115} // namespace oxide
116
0117
=== removed file 'shared/browser/oxide_quota_permission_context.cc'
--- shared/browser/oxide_quota_permission_context.cc 2015-01-20 17:58:10 +0000
+++ shared/browser/oxide_quota_permission_context.cc 1970-01-01 00:00:00 +0000
@@ -1,36 +0,0 @@
1// vim:expandtab:shiftwidth=2:tabstop=2:
2// Copyright (C) 2014 Canonical Ltd.
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18#include "oxide_quota_permission_context.h"
19
20namespace oxide {
21
22QuotaPermissionContext::QuotaPermissionContext() {
23}
24
25QuotaPermissionContext::~QuotaPermissionContext() {
26}
27
28void QuotaPermissionContext::RequestQuotaPermission(
29 const content::StorageQuotaParams& params,
30 int render_process_id,
31 const content::QuotaPermissionContext::PermissionCallback& callback) {
32 callback.Run(QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_DISALLOW);
33}
34
35} // namespace oxide
36
370
=== added file 'shared/browser/oxide_quota_permission_context.h'
--- shared/browser/oxide_quota_permission_context.h 1970-01-01 00:00:00 +0000
+++ shared/browser/oxide_quota_permission_context.h 2016-02-08 19:32:31 +0000
@@ -0,0 +1,45 @@
1// vim:expandtab:shiftwidth=2:tabstop=2:
2// Copyright (C) 2014 Canonical Ltd.
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18#ifndef _OXIDE_SHARED_BROWSER_QUOTA_PERMISSION_CONTEXT_H_
19#define _OXIDE_SHARED_BROWSER_QUOTA_PERMISSION_CONTEXT_H_
20
21#include "content/public/browser/quota_permission_context.h"
22#include "storage/common/quota/quota_types.h"
23
24namespace oxide {
25
26class QuotaPermissionContext final :
27 public content::QuotaPermissionContext {
28 public:
29 QuotaPermissionContext();
30 ~QuotaPermissionContext();
31
32 private:
33
34 void RequestQuotaPermission(
35 const content::StorageQuotaParams& params,
36 int render_process_id,
37 const content::QuotaPermissionContext::PermissionCallback& callback) final;
38
39 DISALLOW_COPY_AND_ASSIGN(QuotaPermissionContext);
40};
41
42} // namespace oxide
43
44#endif // _OXIDE_SHARED_BROWSER_QUOTA_PERMISSION_CONTEXT_H_
45
046
=== removed file 'shared/browser/oxide_quota_permission_context.h'
--- shared/browser/oxide_quota_permission_context.h 2015-01-20 17:58:10 +0000
+++ shared/browser/oxide_quota_permission_context.h 1970-01-01 00:00:00 +0000
@@ -1,45 +0,0 @@
1// vim:expandtab:shiftwidth=2:tabstop=2:
2// Copyright (C) 2014 Canonical Ltd.
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18#ifndef _OXIDE_SHARED_BROWSER_QUOTA_PERMISSION_CONTEXT_H_
19#define _OXIDE_SHARED_BROWSER_QUOTA_PERMISSION_CONTEXT_H_
20
21#include "content/public/browser/quota_permission_context.h"
22#include "storage/common/quota/quota_types.h"
23
24namespace oxide {
25
26class QuotaPermissionContext final :
27 public content::QuotaPermissionContext {
28 public:
29 QuotaPermissionContext();
30 ~QuotaPermissionContext();
31
32 void RequestQuotaPermission(
33 const content::StorageQuotaParams& params,
34 int render_process_id,
35 const content::QuotaPermissionContext::PermissionCallback& callback) final;
36
37 private:
38
39 DISALLOW_COPY_AND_ASSIGN(QuotaPermissionContext);
40};
41
42} // namespace oxide
43
44#endif // _OXIDE_SHARED_BROWSER_QUOTA_PERMISSION_CONTEXT_H_
45
460
=== modified file 'shared/browser/permissions/oxide_permission_request_dispatcher.cc'
--- shared/browser/permissions/oxide_permission_request_dispatcher.cc 2016-01-13 18:54:13 +0000
+++ shared/browser/permissions/oxide_permission_request_dispatcher.cc 2016-02-08 19:32:31 +0000
@@ -250,4 +250,31 @@
250 return request_id;250 return request_id;
251}251}
252252
253int PermissionRequestDispatcher::RequestQuotaPermission(
254 content::RenderFrameHost* render_frame_host,
255 const GURL& requesting_origin,
256 uint64_t requested_size,
257 const PermissionRequestCallback& callback) {
258 if (!client_) {
259 callback.Run(PERMISSION_REQUEST_RESPONSE_CANCEL);
260 return -1;
261 }
262
263 int request_id = next_request_id_++;
264 scoped_ptr<PermissionRequest> request(
265 new PermissionRequest(
266 request_id,
267 RenderFrameHostID(render_frame_host),
268 requesting_origin,
269 web_contents()->GetLastCommittedURL().GetOrigin(),
270 callback));
271 AddPendingRequest(request.get());
272
273 client_->RequestQuotaPermission(
274 requested_size,
275 std::move(request));
276
277 return request_id;
278}
279
253} // namespace oxide280} // namespace oxide
254281
=== modified file 'shared/browser/permissions/oxide_permission_request_dispatcher.h'
--- shared/browser/permissions/oxide_permission_request_dispatcher.h 2015-10-07 18:07:40 +0000
+++ shared/browser/permissions/oxide_permission_request_dispatcher.h 2016-02-08 19:32:31 +0000
@@ -76,6 +76,12 @@
76 bool video,76 bool video,
77 const PermissionRequestCallback& callback);77 const PermissionRequestCallback& callback);
7878
79 // Request permission for storage size quota
80 int RequestQuotaPermission(content::RenderFrameHost* render_frame_host,
81 const GURL& requesting_origin,
82 uint64_t requested_size,
83 const PermissionRequestCallback& callback);
84
79 private:85 private:
80 friend class content::WebContentsUserData<PermissionRequestDispatcher>;86 friend class content::WebContentsUserData<PermissionRequestDispatcher>;
81 friend class PermissionRequest;87 friend class PermissionRequest;
8288
=== modified file 'shared/browser/permissions/oxide_permission_request_dispatcher_client.h'
--- shared/browser/permissions/oxide_permission_request_dispatcher_client.h 2016-01-13 18:54:13 +0000
+++ shared/browser/permissions/oxide_permission_request_dispatcher_client.h 2016-02-08 19:32:31 +0000
@@ -41,6 +41,10 @@
4141
42 virtual void RequestNotificationPermission(42 virtual void RequestNotificationPermission(
43 scoped_ptr<PermissionRequest> request) {}43 scoped_ptr<PermissionRequest> request) {}
44
45 virtual void RequestQuotaPermission(
46 uint64_t requested_size,
47 scoped_ptr<PermissionRequest> request) {}
44};48};
4549
46} // namespace oxide50} // namespace oxide

Subscribers

People subscribed via source and target branches