Merge lp:~zaspire/oxide/web-notifications_v2 into lp:~oxide-developers/oxide/oxide.trunk
- web-notifications_v2
- Merge into oxide.trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~zaspire/oxide/web-notifications_v2 |
Merge into: | lp:~oxide-developers/oxide/oxide.trunk |
Diff against target: |
948 lines (+664/-2) 24 files modified
build/system.gyp (+19/-0) qt/core/browser/oxide_qt_browser_platform_integration.cc (+5/-0) qt/core/browser/oxide_qt_browser_platform_integration.h (+1/-0) qt/core/browser/oxide_qt_web_view.cc (+10/-0) qt/core/browser/oxide_qt_web_view.h (+2/-0) qt/core/glue/oxide_qt_web_view_proxy_client.h (+3/-0) qt/qmlplugin/oxide_qml_plugin.cc (+1/-0) qt/quick/api/oxideqquickwebview.cc (+23/-0) qt/quick/api/oxideqquickwebview_p.h (+1/-0) qt/quick/api/oxideqquickwebview_p_p.h (+3/-0) qt/tests/qmltests/api/tst_WebNotificationPermissionRequest.html (+21/-0) qt/tests/qmltests/api/tst_WebNotificationPermissionRequest.js (+6/-0) qt/tests/qmltests/api/tst_WebNotificationPermissionRequest.qml (+198/-0) shared/browser/oxide_browser_platform_integration.h (+2/-0) shared/browser/oxide_content_browser_client.cc (+9/-1) shared/browser/oxide_content_browser_client.h (+1/-0) shared/browser/oxide_platform_notification_service.cc (+265/-0) shared/browser/oxide_platform_notification_service.h (+77/-0) shared/browser/oxide_web_view.cc (+1/-1) shared/browser/permissions/oxide_permission_manager.cc (+5/-0) shared/browser/permissions/oxide_permission_request_dispatcher.cc (+3/-0) shared/browser/permissions/oxide_permission_request_dispatcher_client.h (+3/-0) shared/browser/permissions/oxide_temporary_saved_permission_context.h (+1/-0) shared/shared.gyp (+4/-0) |
To merge this branch: | bzr merge lp:~zaspire/oxide/web-notifications_v2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Coulson | Needs Fixing | ||
Review via email: mp+255392@code.launchpad.net |
This proposal has been superseded by a proposal from 2015-06-19.
Commit message
Description of the change
depend on bug 1428754 (to implement session persistence)
- 1027. By Olivier Tilloy
-
LP: #1441777
- 1028. By Chris Coulson
-
Fix out-of-bounds read in CompositorOutpu
tSurfaceGL - 1029. By Chris Coulson
-
Clean up the interfaces in qt/core/glue. Hopefully this will make it more obvious where to place new code (ie, only interfaces in qt/core/glue now)
- 1030. By Chris Coulson
-
Bump Chromium rev to 43.0.2357.10
- 1031. By Chris Coulson
-
Set the minimum page scale to 0.25 on mobile (the default is 1, which is fine for desktop)
- 1032. By Chris Coulson
-
Fix crash when accessing ScriptMessage.frame if the frame has disappeared
- 1033. By Chris Coulson
-
Stack allocate the objects passed to WebContextDeleg
ateWorker - 1034. By Chris Coulson
-
Improve network callback tests
- 1035. By Chris Coulson
-
Use a ResourceThrottle for intercepting redirects
- 1036. By Chris Coulson
-
Added EGLFS QPA support
- 1037. By Olivier Tilloy
-
Use the simple backend for the network cache.
- 1038. By Chris Coulson
-
Bump Chromium rev to 43.0.2357.18
- 1039. By Chris Coulson
-
Add LocationBarCont
roller. show(), LocationBarCont roller. hide() and LocationBarCont roller. animated - 1040. By Chris Coulson
-
Bump Chromium rev to 44.0.2369.0 and Qt version to 1.8
- 1041. By Chris Coulson
-
Don't allow QObjects to be passed to WebContextDeleg
ateWorker - 1042. By Alexandre Abreu
-
tweak pak deps
- 1043. By Alexandre Abreu
-
update the blink resource name
- 1044. By Alexandre Abreu
-
fix build & mediahub link
- 1045. By Chris Coulson
-
GPU canvas + raster is enabled on Krillin in Chrome now, so we don't need a patch
- 1046. By Chris Coulson
-
Fix a parse error in the GPU blacklist
- 1047. By Chris Coulson
-
Make chrome://tracing/ work
- 1048. By Chris Coulson
-
Tidy up the navigator.userAgent override mechanism - an empty string is no override. The extra bool is redundant
- 1049. By Chris Coulson
-
Fix a test failure
- 1050. By Chris Coulson
-
Fix handling of JS values wrapped in QVariants with Qt 5.4
- 1051. By Chris Coulson
-
Add OxideQPermissio
nRequest: :origin (effectively undeprecating OxideQGeolocati onPermissionReq uest::origin) , given that recent changes in Chromium mean we get an origin in most cases. Let's use origin for all request types - 1052. By Chris Coulson
-
Bump Chromium rev to 44.0.2376.0
- 1053. By Chris Coulson
-
Replace remaining uses of USE_NSS with USE_NSS_CERTS
- 1054. By Chris Coulson
-
The webview compositor shouldn't be unthrottled
- 1055. By Chris Coulson
-
Disable one-copy rasterizer on the phone - it's currently disabled on Android anyway
- 1056. By Chris Coulson
-
Fix a memory corruption when the visibilty of a webview is changed
- 1057. By Chris Coulson
-
Don't crash when the frame tree is torn down during a process swap
- 1058. By Olivier Tilloy
-
Fix a crash when a popup menu is dismissed twice (by calling accept() and then cancel() on it).
- 1059. By Olivier Tilloy
-
Fix a crash when a JS dialog is dismissed twice (by calling accept() and then reject() on it).
- 1060. By Chris Coulson
-
Process all descendents in WebView:
:FrameDeleted, rather than just the immediate children - 1061. By Chris Coulson
-
Don't disable share-group usage if virtualized GL contexts are enabled on desktop. This sucks, as we can't really know why virtualized contexts are enabled - if it's due to performance issues, then using share-groups is ok (and better than the alternative - software compositing). If it's because of driver bugs / crashes, then we're screwed. We need to do this now because Chromium cananry enables virtualized contexts globally on desktop Linux
- 1062. By Chris Coulson
-
Don't run unload handlers on webviews that are script closed. Also, beef up the tests to catch this and work a bit more reliably
- 1063. By Chris Coulson
-
Bump Chromium rev to 44.0.2391.0
- 1064. By Olivier Tilloy
-
Add a WebView:
:webProcessStat us property to notify embedders when the renderer process crashed or was killed. - 1065. By Chris Coulson
-
Add WebView.
mediaAccessPerm issionRequested API - 1066. By Chris Coulson
-
Make comments more accurate
- 1067. By Chris Coulson
-
FrameTreeNode:
:frame_ tree_node_ id is an int rather than int64_t - 1068. By Chris Coulson
-
Remove a workaround for the old browser headerbar, used when scrolling the focused editable node in to view
- 1069. By Alexandre Abreu
-
Prevent a shutdown deadlock if the render process is killed whilst waiting for the close ACK
- 1070. By Chris Coulson
-
When deleting a WebContext, ensure that the service worker context is shut down to release references on the RenderProcessHost
- 1071. By Chris Coulson
-
Don't leak BrowserContext
- 1072. By Chris Coulson
-
Fix test failure in tst_OxideGlobal - it seems that the displayName doesn't have extra characters on some machines
- 1073. By Chris Coulson
-
Ensure we correctly shut down the OTR BrowserContext
- 1074. By Chris Coulson
-
Move gesture detection to RWHV, keep MotionEvent tracking on WebView (so that we keep it in sync with incoming touch events), and reset the gesture pipeline when navigating to a new page
- 1075. By Chris Coulson
-
Refactor ownership model of BrowserContext, and discard the OTR BrowserContext as soon as all incognito webviews using it have been deleted
- 1076. By Chris Coulson
-
Actually fix tst_OxideGlobal.qml
- 1077. By Chris Coulson
-
Don't create multiple WebContexts pointing at the same path in tst_UnloadHandl
ers.qml - 1078. By Riccardo Padovani
-
Add LoadEvent.
httpStatusCode property - 1079. By Chris Coulson
-
Bump Chromium rev to 44.0.2398.0
- 1080. By Chris Coulson
-
Revert a couple of changes that shouldn't have landed
- 1081. By Chris Coulson
-
Initialize handle_ for all Proxy objects
- 1082. By Chris Coulson
-
Flush profile data when the application goes in to the background
- 1083. By Chris Coulson
-
Generate a synthetic Suspended state on the phone
- 1084. By Chris Coulson
-
Remove spurious printf
- 1085. By Chris Coulson
-
Bump Chromium rev to 44.0.2403.0
- 1086. By Chris Coulson
-
Bump Chromium rev to 44.0.2403.4
- 1087. By Chris Coulson
-
Add a client interface for WebView, and implement that in qt/. This is the start of an attempt to split functionality out of WebView in to smaller classes
- 1088. By Ugo Riboni
-
Add WebView.
findController API - 1089. By Chris Coulson
-
Revert r1041 for causing LP: #1455371
- 1090. By Chris Coulson
-
Bump Chromium rev to 44.0.2403.9
Maxim Ermilov (zaspire) wrote : | # |
- 1091. By Chris Coulson
-
Remove the implementation of MessageLoop:
:TaskObserver from MessagePump - this fails in canary because there is no MessageLoop when MessagePump is constructed. Also remove the MessageLoopForUI class, which was always a bit of a mess - 1092. By Chris Coulson
-
DCHECK that the PowerSaveBlocker factory exists, given that it's set unconditionally in BrowserMainParts. It should never be null
- 1093. By Alexandre Abreu
-
Add clipboard support
- 1094. By Olivier Tilloy
-
Support for context menus.
- 1095. By Chris Coulson
-
Bump qt version to 1.9
- 1096. By Chris Coulson
-
Fix issues with mouse event handling, so that text selection works correctly
- 1097. By Chris Coulson
-
Move event / screen utils bits from common/ to browser/, where they belong
- 1098. By Chris Coulson
-
Kill the hidden input Item inside WebView
- 1099. By Chris Coulson
-
Stub out RenderViewHostD
elegateView: :StartDragging to cancel all drag starts, else the renderer hangs indefinitely - 1100. By Chris Coulson
-
Bump Chromium rev to 45.0.2415.0
- 1101. By Chris Coulson
-
Clean up MessagePump a bit:
- Refactor code that runs a task in to a separate function
- Keep track of when we've posted a work event to avoid posting lots of them
- When scheduling missed delayed work, defer to ScheduleWork so that we don't post another task if work is already scheduled - 1102. By Chris Coulson
-
Fix arm build regression
- 1103. By Chris Coulson
-
Enable run-time NEON detection in components that support it (eg, skia)
- 1104. By Chris Coulson
-
Add back to the task depth checking that was removed in an earlier commit when it broke due to changes to MessageLoop initialization. I think it's reasonably important to keep this check as the consequences of an application stopping the MessagePump whilst processing a task aren't good
- 1105. By Chris Coulson
-
r1101 introduced a threading bug to MessagePump:
:ScheduleWork, which can be called on any thread - 1106. By Alexandre Abreu
-
Expose user agent as part of downloadRequest
- 1107. By Alexandre Abreu
-
Remove deprecated patch
- 1108. By Alexandre Abreu
-
Guess mimetype based on suggested filename when available
- 1109. By Alexandre Abreu
-
remove EOLs at end of series file
- 1110. By Alexandre Abreu
-
Add forgotten download manager delegate file
- 1111. By Alexandre Abreu
-
Add forgotten download manager delegate file
- 1112. By Alexandre Abreu
-
Fix build issue w/ string16 not declared
- 1113. By Alexandre Abreu
-
download requested UA: add forgotten file (test related)
- 1114. By Olivier Tilloy
-
Add missing unit tests now that clipboard support has landed.
- 1115. By Chris Coulson
-
Land some refactoring of permissions, which starts to decouple it from WebView in to separate classes
- 1116. By Chris Coulson
-
Refinements to MediaAccessPerm
issionRequest:
- Remove the per-request capture device override
- Add WebContext.default{ Audio,Video} CaptureDeviceId , which will be used for all media capture.
Note, the tests for WebContext.defaultVideoCap tureDeviceId are not great - we don't have a way yet to verify that it actually causes the correct device to be used. WebContext. defaultAudioCap tureDeviceId is not yet tested at all, because we have no way to mock audio devices right now like we do with video devices - 1117. By Chris Coulson
-
Bump Chromium rev to 45.0.2421.0
- 1118. By Chris Coulson
-
base::FilePath:
:Extension( ) returns the extension with the preceding period, but net::GetMimeTyp eFromExtension assumes that there is no period, causing it to fall back to a platform lookup which returns the wrong mime-type and results in test_WebView_ downloadAnchorR equest failing - 1119. By Chris Coulson
-
Route media permissions through MediaCaptureDev
iceDispatcher - 1120. By Chris Coulson
-
Change Oxide.available
{Audio, Video}CaptureDe vices() in to a notifiable property - 1121. By Chris Coulson
-
Fix failing test
- 1122. By Chris Coulson
-
Depend on keyed_service_core to fix a link failure in component builds
- 1123. By Chris Coulson
-
Fix up some additional dependencies
- 1124. By Chris Coulson
-
Fix a startup ordering issue when creating WebContext
- 1125. By Chris Coulson
-
Persist geolocation permission request decisions for the life of WebContext
Chris Coulson (chrisccoulson) wrote : | # |
Ok, I've reviewed this again.
There's also quite a few cases missing in the tests - please take a look at the geolocation permission tests.
Also, we should figure out a way to test the actual libnotify integration (I'm not sure of the best way to do that, but it shouldn't be too difficult to mock).
- 1126. By Chris Coulson
-
Bump Chromium rev to 45.0.2427.7
- 1127. By Chris Coulson
-
Persist media device permissions for the life of WebContext
- 1128. By Chris Coulson
-
Make ContentBrowserC
lient / ContentRenderer Client memebers of ContentMainDelegate like ContentClient already is - 1129. By Chris Coulson
-
Pass the application locale to ui::ResourceBun
dle::InitShared InstanceWithLoc ale. Because we don't build with glib support, it's unable to detect the system locale and depends on a preferred one being passed - 1130. By Chris Coulson
-
Convert UserScriptMaster in to a KeyedService
- 1131. By Chris Coulson
-
Create a single TestWebContext in tst_WebView_
save_restore_ state.qml - 1132. By Chris Coulson
-
Don't allow QObjects to be passed to WebContextDeleg
ateWorker - 1133. By Maxim Ermilov
-
add Web Notifications support
Unmerged revisions
Preview Diff
1 | === modified file 'build/system.gyp' |
2 | --- build/system.gyp 2015-01-21 23:40:11 +0000 |
3 | +++ build/system.gyp 2015-06-19 15:51:41 +0000 |
4 | @@ -18,6 +18,25 @@ |
5 | 'variables': { |
6 | 'pkg_config': 'pkg-config' |
7 | }, |
8 | + 'targets': [ |
9 | + { |
10 | + 'target_name': 'libnotify', |
11 | + 'type': 'none', |
12 | + 'direct_dependent_settings': { |
13 | + 'cflags_cc': [ |
14 | + '<!@(<(pkg_config) --cflags libnotify)' |
15 | + ] |
16 | + }, |
17 | + 'link_settings': { |
18 | + 'ldflags': [ |
19 | + '<!@(<(pkg_config) --libs-only-L --libs-only-other libnotify)', |
20 | + ], |
21 | + 'libraries': [ |
22 | + '<!@(<(pkg_config) --libs-only-l libnotify)', |
23 | + ], |
24 | + }, |
25 | + }, |
26 | + ], |
27 | 'conditions': [ |
28 | ['target_arch=="arm"', { |
29 | 'targets': [ |
30 | |
31 | === modified file 'qt/core/browser/oxide_qt_browser_platform_integration.cc' |
32 | --- qt/core/browser/oxide_qt_browser_platform_integration.cc 2015-06-12 07:39:38 +0000 |
33 | +++ qt/core/browser/oxide_qt_browser_platform_integration.cc 2015-06-19 15:51:41 +0000 |
34 | @@ -161,6 +161,11 @@ |
35 | return state_; |
36 | } |
37 | |
38 | +std::string |
39 | +BrowserPlatformIntegration::GetAppName() { |
40 | + return QCoreApplication::applicationName().toStdString(); |
41 | +} |
42 | + |
43 | bool BrowserPlatformIntegration::eventFilter(QObject* watched, QEvent* event) { |
44 | if (event->type() == QEvent::ApplicationActivate || |
45 | event->type() == QEvent::ApplicationDeactivate) { |
46 | |
47 | === modified file 'qt/core/browser/oxide_qt_browser_platform_integration.h' |
48 | --- qt/core/browser/oxide_qt_browser_platform_integration.h 2015-06-12 07:39:38 +0000 |
49 | +++ qt/core/browser/oxide_qt_browser_platform_integration.h 2015-06-19 15:51:41 +0000 |
50 | @@ -57,6 +57,7 @@ |
51 | void BrowserThreadInit(content::BrowserThread::ID id) override; |
52 | content::LocationProvider* CreateLocationProvider() override; |
53 | ApplicationState GetApplicationState() override; |
54 | + std::string GetAppName() override; |
55 | ui::ClipboardOxideFactory GetClipboardOxideFactory() override; |
56 | |
57 | // QObject implementation |
58 | |
59 | === modified file 'qt/core/browser/oxide_qt_web_view.cc' |
60 | --- qt/core/browser/oxide_qt_web_view.cc 2015-06-04 17:11:01 +0000 |
61 | +++ qt/core/browser/oxide_qt_web_view.cc 2015-06-19 15:51:41 +0000 |
62 | @@ -1011,6 +1011,16 @@ |
63 | client_->RequestGeolocationPermission(req.release()); |
64 | } |
65 | |
66 | +void WebView::RequestNotificationPermission( |
67 | + scoped_ptr<oxide::SimplePermissionRequest> request) { |
68 | + scoped_ptr<OxideQSimplePermissionRequest> req( |
69 | + OxideQSimplePermissionRequestPrivate::Create( |
70 | + request.Pass())); |
71 | + |
72 | + // The embedder takes ownership of this |
73 | + client_->RequestNotificationPermission(req.release()); |
74 | +} |
75 | + |
76 | void WebView::RequestMediaAccessPermission( |
77 | scoped_ptr<oxide::MediaAccessPermissionRequest> request) { |
78 | scoped_ptr<OxideQMediaAccessPermissionRequest> req( |
79 | |
80 | === modified file 'qt/core/browser/oxide_qt_web_view.h' |
81 | --- qt/core/browser/oxide_qt_web_view.h 2015-06-04 13:21:49 +0000 |
82 | +++ qt/core/browser/oxide_qt_web_view.h 2015-06-19 15:51:41 +0000 |
83 | @@ -177,6 +177,8 @@ |
84 | // oxide::PermissionRequestDispatcherClient implementation |
85 | void RequestGeolocationPermission( |
86 | scoped_ptr<oxide::SimplePermissionRequest> request) override; |
87 | + void RequestNotificationPermission( |
88 | + scoped_ptr<oxide::SimplePermissionRequest> request) override; |
89 | void RequestMediaAccessPermission( |
90 | scoped_ptr<oxide::MediaAccessPermissionRequest> request) override; |
91 | |
92 | |
93 | === modified file 'qt/core/glue/oxide_qt_web_view_proxy_client.h' |
94 | --- qt/core/glue/oxide_qt_web_view_proxy_client.h 2015-05-27 20:56:59 +0000 |
95 | +++ qt/core/glue/oxide_qt_web_view_proxy_client.h 2015-06-19 15:51:41 +0000 |
96 | @@ -32,6 +32,7 @@ |
97 | class OxideQMediaAccessPermissionRequest; |
98 | class OxideQNavigationRequest; |
99 | class OxideQNewViewRequest; |
100 | +class OxideQSimplePermissionRequest; |
101 | |
102 | QT_BEGIN_NAMESPACE |
103 | class QCursor; |
104 | @@ -128,6 +129,8 @@ |
105 | OxideQGeolocationPermissionRequest* request) = 0; |
106 | virtual void RequestMediaAccessPermission( |
107 | OxideQMediaAccessPermissionRequest* request) = 0; |
108 | + virtual void RequestNotificationPermission( |
109 | + OxideQSimplePermissionRequest* request) = 0; |
110 | |
111 | virtual void HandleUnhandledKeyboardEvent(QKeyEvent* event) = 0; |
112 | |
113 | |
114 | === modified file 'qt/qmlplugin/oxide_qml_plugin.cc' |
115 | --- qt/qmlplugin/oxide_qml_plugin.cc 2015-06-05 18:43:21 +0000 |
116 | +++ qt/qmlplugin/oxide_qml_plugin.cc 2015-06-19 15:51:41 +0000 |
117 | @@ -134,6 +134,7 @@ |
118 | qmlRegisterUncreatableType<OxideQLoadEvent, 2>(uri, 1, 8, "LoadEvent", |
119 | "LoadEvent is delivered by WebView.loadEvent"); |
120 | qmlRegisterType<OxideQQuickWebView, 4>(uri, 1, 8, "WebView"); |
121 | + qmlRegisterType<OxideQQuickWebView, 5>(uri, 1, 8, "WebView"); |
122 | |
123 | qmlRegisterType<OxideQQuickWebContext, 3>(uri, 1, 9, "WebContext"); |
124 | } |
125 | |
126 | === modified file 'qt/quick/api/oxideqquickwebview.cc' |
127 | --- qt/quick/api/oxideqquickwebview.cc 2015-05-28 23:51:39 +0000 |
128 | +++ qt/quick/api/oxideqquickwebview.cc 2015-06-19 15:51:41 +0000 |
129 | @@ -461,6 +461,29 @@ |
130 | |
131 | } |
132 | |
133 | +void OxideQQuickWebViewPrivate::RequestNotificationPermission( |
134 | + OxideQSimplePermissionRequest* request) { |
135 | + Q_Q(OxideQQuickWebView); |
136 | + |
137 | + QQmlEngine* engine = qmlEngine(q); |
138 | + if (!engine) { |
139 | + delete request; |
140 | + return; |
141 | + } |
142 | + |
143 | + { |
144 | + QJSValue val = engine->newQObject(request); |
145 | + if (!val.isQObject()) { |
146 | + delete request; |
147 | + return; |
148 | + } |
149 | + |
150 | + emit q->notificationPermissionRequested(val); |
151 | + } |
152 | + |
153 | + engine->collectGarbage(); |
154 | +} |
155 | + |
156 | void OxideQQuickWebViewPrivate::HandleUnhandledKeyboardEvent( |
157 | QKeyEvent* event) { |
158 | Q_Q(OxideQQuickWebView); |
159 | |
160 | === modified file 'qt/quick/api/oxideqquickwebview_p.h' |
161 | --- qt/quick/api/oxideqquickwebview_p.h 2015-05-28 23:51:39 +0000 |
162 | +++ qt/quick/api/oxideqquickwebview_p.h 2015-06-19 15:51:41 +0000 |
163 | @@ -345,6 +345,7 @@ |
164 | void navigationRequested(OxideQNavigationRequest* request); |
165 | void newViewRequested(OxideQNewViewRequest* request); |
166 | void geolocationPermissionRequested(const QJSValue& request); |
167 | + Q_REVISION(5) void notificationPermissionRequested(const QJSValue& request); |
168 | Q_REVISION(4) void mediaAccessPermissionRequested(const QJSValue& request); |
169 | void javaScriptConsoleMessage(LogMessageSeverityLevel level, |
170 | const QString& message, |
171 | |
172 | === modified file 'qt/quick/api/oxideqquickwebview_p_p.h' |
173 | --- qt/quick/api/oxideqquickwebview_p_p.h 2015-05-28 23:51:39 +0000 |
174 | +++ qt/quick/api/oxideqquickwebview_p_p.h 2015-06-19 15:51:41 +0000 |
175 | @@ -128,6 +128,9 @@ |
176 | OxideQGeolocationPermissionRequest* request) override; |
177 | void RequestMediaAccessPermission( |
178 | OxideQMediaAccessPermissionRequest* request) override; |
179 | + void RequestNotificationPermission( |
180 | + OxideQSimplePermissionRequest* request) override; |
181 | + |
182 | void HandleUnhandledKeyboardEvent(QKeyEvent *event) override; |
183 | void FrameMetadataUpdated( |
184 | oxide::qt::FrameMetadataChangeFlags flags) override; |
185 | |
186 | === added file 'qt/tests/qmltests/api/tst_WebNotificationPermissionRequest.html' |
187 | --- qt/tests/qmltests/api/tst_WebNotificationPermissionRequest.html 1970-01-01 00:00:00 +0000 |
188 | +++ qt/tests/qmltests/api/tst_WebNotificationPermissionRequest.html 2015-06-19 15:51:41 +0000 |
189 | @@ -0,0 +1,21 @@ |
190 | +<html> |
191 | +<body> |
192 | +</body> |
193 | +<script> |
194 | + |
195 | +var vgaConstraints = {video: true, audio: true}; |
196 | + |
197 | +function invoke() { |
198 | + Notification.requestPermission(function(permission){ |
199 | + if(permission == 'granted'){ |
200 | + var e = new CustomEvent("result", { bubbles: true, detail: { status: 0 } }); |
201 | + document.documentElement.dispatchEvent(e); |
202 | + } else { |
203 | + var e = new CustomEvent("result", { bubbles: true, detail: { status: 1 } }); |
204 | + document.documentElement.dispatchEvent(e); |
205 | + } |
206 | + }); |
207 | +} |
208 | +setTimeout(invoke, 400); |
209 | +</script> |
210 | +</html> |
211 | |
212 | === added file 'qt/tests/qmltests/api/tst_WebNotificationPermissionRequest.js' |
213 | --- qt/tests/qmltests/api/tst_WebNotificationPermissionRequest.js 1970-01-01 00:00:00 +0000 |
214 | +++ qt/tests/qmltests/api/tst_WebNotificationPermissionRequest.js 2015-06-19 15:51:41 +0000 |
215 | @@ -0,0 +1,6 @@ |
216 | +// ==UserScript== |
217 | +// @run-at document-start |
218 | +// ==/UserScript== |
219 | +document.addEventListener("result", function(event) { |
220 | + oxide.sendMessage("TEST-RESPONSE", { status: event.detail.status }); |
221 | +}); |
222 | |
223 | === added file 'qt/tests/qmltests/api/tst_WebNotificationPermissionRequest.qml' |
224 | --- qt/tests/qmltests/api/tst_WebNotificationPermissionRequest.qml 1970-01-01 00:00:00 +0000 |
225 | +++ qt/tests/qmltests/api/tst_WebNotificationPermissionRequest.qml 2015-06-19 15:51:41 +0000 |
226 | @@ -0,0 +1,198 @@ |
227 | +import QtQuick 2.0 |
228 | +import QtTest 1.0 |
229 | +import com.canonical.Oxide 1.8 |
230 | +import com.canonical.Oxide.Testing 1.0 |
231 | + |
232 | +Item { |
233 | + width: 200 |
234 | + height: 200 |
235 | + |
236 | + SignalSpy { |
237 | + id: spy |
238 | + signalName: "notificationPermissionRequested" |
239 | + } |
240 | + |
241 | + Component { |
242 | + id: userScriptFactory |
243 | + UserScript {} |
244 | + } |
245 | + |
246 | + TestWebContext { |
247 | + id: c |
248 | + Component.onCompleted: { |
249 | + var script = userScriptFactory.createObject(null, { |
250 | + context: "oxide://testutils/", |
251 | + url: Qt.resolvedUrl("tst_WebNotificationPermissionRequest.js"), |
252 | + matchAllFrames: true |
253 | + }); |
254 | + addUserScript(script); |
255 | + } |
256 | + } |
257 | + |
258 | + Component { |
259 | + id: webViewFactory |
260 | + TestWebView { |
261 | + context: c |
262 | + |
263 | + property var lastRequest: null |
264 | + onNotificationPermissionRequested: { |
265 | + lastRequest = request; |
266 | + } |
267 | + |
268 | + QtObject { |
269 | + id: _internal |
270 | + property var lastStatus: -1 |
271 | + } |
272 | + property alias lastStatus: _internal.lastStatus |
273 | + |
274 | + messageHandlers: [ |
275 | + ScriptMessageHandler { |
276 | + msgId: "TEST-RESPONSE" |
277 | + contexts: [ "oxide://testutils/" ] |
278 | + callback: function(msg) { |
279 | + _internal.lastStatus = msg.args.status; |
280 | + } |
281 | + } |
282 | + ] |
283 | + } |
284 | + } |
285 | + |
286 | + TestCase { |
287 | + id: test |
288 | + name: "NotificationPermissionRequest_session_persist" |
289 | + when: windowShown |
290 | + |
291 | + function _test_accept(req) { |
292 | + req.allow(); |
293 | + } |
294 | + |
295 | + function _test_deny(req) { |
296 | + req.deny(); |
297 | + } |
298 | + |
299 | + function _test_destroy(req) { |
300 | + req.destroy(); |
301 | + } |
302 | + |
303 | + function init() { |
304 | + spy.target = null; |
305 | + spy.clear(); |
306 | + c.clearTemporarySavedPermissionStatuses(); |
307 | + } |
308 | + |
309 | + function test_NotificationPermissionRequest_session_persist1_data() { |
310 | + return [ |
311 | + { function: _test_accept, expected: 0, save: true }, |
312 | + { function: _test_deny, expected: 1, save: true }, |
313 | + { function: _test_destroy, expected: 1, save: false }, |
314 | + ]; |
315 | + } |
316 | + |
317 | + function test_NotificationPermissionRequest_session_persist1(data) { |
318 | + var webView = webViewFactory.createObject(null, {}); |
319 | + spy.target = webView; |
320 | + |
321 | + webView.url = "http://foo.testsuite/tst_WebNotificationPermissionRequest.html"; |
322 | + |
323 | + verify(webView.waitForLoadSucceeded()); |
324 | + |
325 | + spy.wait(); |
326 | + |
327 | + compare(webView.lastRequest.embedder, "http://foo.testsuite/"); |
328 | + |
329 | + data.function(webView.lastRequest); |
330 | + |
331 | + verify(webView.waitFor(function() { return webView.lastStatus != -1; })); |
332 | + compare(webView.lastStatus, data.expected); |
333 | + |
334 | + spy.clear(); |
335 | + webView.lastStatus = -1; |
336 | + |
337 | + webView.reload(); |
338 | + verify(webView.waitForLoadSucceeded()); |
339 | + |
340 | + if (data.save) { |
341 | + verify(webView.waitFor(function() { return webView.lastStatus != -1; })); |
342 | + compare(webView.lastStatus, data.expected); |
343 | + } else { |
344 | + spy.wait(); |
345 | + compare(webView.lastRequest.embedder, "http://foo.testsuite/"); |
346 | + } |
347 | + } |
348 | + |
349 | + function test_NotificationPermissionRequest_session_persist2_data() { |
350 | + return test_NotificationPermissionRequest_session_persist1_data(); |
351 | + } |
352 | + |
353 | + function test_NotificationPermissionRequest_session_persist2(data) { |
354 | + var webView = webViewFactory.createObject(null, {}); |
355 | + spy.target = webView; |
356 | + |
357 | + webView.url = "http://foo.testsuite/tst_WebNotificationPermissionRequest.html"; |
358 | + verify(webView.waitForLoadSucceeded()); |
359 | + |
360 | + spy.wait(); |
361 | + |
362 | + compare(webView.lastRequest.embedder, "http://foo.testsuite/"); |
363 | + |
364 | + data.function(webView.lastRequest); |
365 | + |
366 | + verify(webView.waitFor(function() { return webView.lastStatus != -1; })); |
367 | + compare(webView.lastStatus, data.expected); |
368 | + |
369 | + webView = webViewFactory.createObject(null, {}); |
370 | + spy.target = webView; |
371 | + |
372 | + spy.clear(); |
373 | + |
374 | + webView.url = "http://foo.testsuite/tst_WebNotificationPermissionRequest.html"; |
375 | + verify(webView.waitForLoadSucceeded()); |
376 | + |
377 | + if (data.save) { |
378 | + verify(webView.waitFor(function() { return webView.lastStatus != -1; })); |
379 | + compare(webView.lastStatus, data.expected); |
380 | + } else { |
381 | + spy.wait(); |
382 | + compare(webView.lastRequest.embedder, "http://foo.testsuite/"); |
383 | + } |
384 | + } |
385 | + |
386 | + function test_NotificationPermissionRequest_session_persist3_data() { |
387 | + return [ |
388 | + // Same origin / different embedder |
389 | + { url1: "http://foo.testsuite/tst_WebNotificationPermissionRequest.html", |
390 | + url2: "http://bar.testsuite/tst_WebNotificationPermissionRequest.html" }, |
391 | + // Same origin / embedder == allowed origin |
392 | + { url1: "http://foo.testsuite/tst_WebNotificationPermissionRequest.html", |
393 | + url2: "http://testsuite/tst_WebNotificationPermissionRequest.html" }, |
394 | + // Different origin / different embedder |
395 | + { url1: "http://foo.testsuite/tst_WebNotificationPermissionRequest.html", |
396 | + url2: "http://bar.testsuite/tst_WebNotificationPermissionRequest.html" }, |
397 | + ]; |
398 | + } |
399 | + |
400 | + // Verify several cases where saved permissions should not be used |
401 | + function test_NotificationPermissionRequest_session_persist3(data) { |
402 | + var webView = webViewFactory.createObject(null, {}); |
403 | + spy.target = webView; |
404 | + |
405 | + webView.url = data.url1; |
406 | + verify(webView.waitForLoadSucceeded()); |
407 | + |
408 | + spy.wait(); |
409 | + |
410 | + webView.lastRequest.allow(); |
411 | + |
412 | + verify(webView.waitFor(function() { return webView.lastStatus != -1; })); |
413 | + compare(webView.lastStatus, 0); |
414 | + |
415 | + spy.clear(); |
416 | + webView.lastStatus = -1; |
417 | + |
418 | + webView.url = data.url2; |
419 | + verify(webView.waitForLoadSucceeded()); |
420 | + |
421 | + spy.wait(); |
422 | + } |
423 | + } |
424 | +} |
425 | |
426 | === modified file 'shared/browser/oxide_browser_platform_integration.h' |
427 | --- shared/browser/oxide_browser_platform_integration.h 2015-06-12 07:39:38 +0000 |
428 | +++ shared/browser/oxide_browser_platform_integration.h 2015-06-19 15:51:41 +0000 |
429 | @@ -96,6 +96,8 @@ |
430 | // Get the current application state |
431 | virtual ApplicationState GetApplicationState(); |
432 | |
433 | + virtual std::string GetAppName() = 0; |
434 | + |
435 | protected: |
436 | BrowserPlatformIntegration(); |
437 | |
438 | |
439 | === modified file 'shared/browser/oxide_content_browser_client.cc' |
440 | --- shared/browser/oxide_content_browser_client.cc 2015-06-18 15:48:50 +0000 |
441 | +++ shared/browser/oxide_content_browser_client.cc 2015-06-19 15:51:41 +0000 |
442 | @@ -52,6 +52,7 @@ |
443 | #include "oxide_web_preferences.h" |
444 | #include "oxide_web_view.h" |
445 | #include "oxide_web_view_contents_helper.h" |
446 | +#include "oxide_platform_notification_service.h" |
447 | |
448 | #if defined(ENABLE_PLUGINS) |
449 | #include "content/public/browser/browser_ppapi_host.h" |
450 | @@ -298,7 +299,14 @@ |
451 | const std::string& application_locale, |
452 | BrowserPlatformIntegration* integration) |
453 | : application_locale_(application_locale), |
454 | - platform_integration_(integration) {} |
455 | + platform_integration_(integration) { |
456 | + PlatformNotificationService::GetInstance()->Initialize(integration->GetAppName()); |
457 | +} |
458 | + |
459 | +content::PlatformNotificationService* |
460 | +ContentBrowserClient::GetPlatformNotificationService() { |
461 | + return PlatformNotificationService::GetInstance(); |
462 | +} |
463 | |
464 | ContentBrowserClient::~ContentBrowserClient() {} |
465 | |
466 | |
467 | === modified file 'shared/browser/oxide_content_browser_client.h' |
468 | --- shared/browser/oxide_content_browser_client.h 2015-06-17 21:04:11 +0000 |
469 | +++ shared/browser/oxide_content_browser_client.h 2015-06-19 15:51:41 +0000 |
470 | @@ -49,6 +49,7 @@ |
471 | private: |
472 | // content::ContentBrowserClient implementation |
473 | std::string GetApplicationLocale() final; |
474 | + content::PlatformNotificationService* GetPlatformNotificationService() final; |
475 | content::BrowserMainParts* CreateBrowserMainParts( |
476 | const content::MainFunctionParams& parameters) final; |
477 | void RenderProcessWillLaunch(content::RenderProcessHost* host) final; |
478 | |
479 | === added file 'shared/browser/oxide_platform_notification_service.cc' |
480 | --- shared/browser/oxide_platform_notification_service.cc 1970-01-01 00:00:00 +0000 |
481 | +++ shared/browser/oxide_platform_notification_service.cc 2015-06-19 15:51:41 +0000 |
482 | @@ -0,0 +1,265 @@ |
483 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
484 | +// Copyright (C) 2014 Canonical Ltd. |
485 | + |
486 | +// This library is free software; you can redistribute it and/or |
487 | +// modify it under the terms of the GNU Lesser General Public |
488 | +// License as published by the Free Software Foundation; either |
489 | +// version 2.1 of the License, or (at your option) any later version. |
490 | + |
491 | +// This library is distributed in the hope that it will be useful, |
492 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
493 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
494 | +// Lesser General Public License for more details. |
495 | + |
496 | +// You should have received a copy of the GNU Lesser General Public |
497 | +// License along with this library; if not, write to the Free Software |
498 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
499 | + |
500 | +#include "oxide_platform_notification_service.h" |
501 | + |
502 | +#include <map> |
503 | +#include <libnotify/notify.h> |
504 | +#include "third_party/skia/include/core/SkImageEncoder.h" |
505 | +#include "third_party/skia/include/core/SkBitmap.h" |
506 | + |
507 | +#include "base/strings/utf_string_conversions.h" |
508 | +#include "content/public/common/platform_notification_data.h" |
509 | +#include "content/public/browser/desktop_notification_delegate.h" |
510 | +#include "third_party/skia/include/core/SkUnPreMultiply.h" |
511 | + |
512 | +#include "shared/browser/permissions/oxide_temporary_saved_permission_context.h" |
513 | +#include "shared/browser/oxide_browser_context.h" |
514 | + |
515 | +namespace oxide { |
516 | + |
517 | +// Copy&paste from chrome/browser/ui/libgtk2ui/skia_utils_gtk2.cc |
518 | +// to avoid dependency on full Gdk. |
519 | +GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap& bitmap) { |
520 | + if (bitmap.isNull()) { |
521 | + return nullptr; |
522 | + } |
523 | + |
524 | + SkAutoLockPixels lock_pixels(bitmap); |
525 | + |
526 | + int width = bitmap.width(); |
527 | + int height = bitmap.height(); |
528 | + |
529 | + GdkPixbuf* pixbuf = |
530 | + gdk_pixbuf_new(GDK_COLORSPACE_RGB, // The only colorspace gtk supports. |
531 | + TRUE, // There is an alpha channel. |
532 | + 8, |
533 | + width, |
534 | + height); |
535 | + |
536 | + // SkBitmaps are premultiplied, we need to unpremultiply them. |
537 | + const int kBytesPerPixel = 4; |
538 | + uint8_t* divided = gdk_pixbuf_get_pixels(pixbuf); |
539 | + |
540 | + for (int y = 0, i = 0; y < height; y++) { |
541 | + for (int x = 0; x < width; x++) { |
542 | + uint32_t pixel = bitmap.getAddr32(0, y)[x]; |
543 | + |
544 | + int alpha = SkColorGetA(pixel); |
545 | + if (alpha != 0 && alpha != 255) { |
546 | + SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel); |
547 | + divided[i + 0] = SkColorGetR(unmultiplied); |
548 | + divided[i + 1] = SkColorGetG(unmultiplied); |
549 | + divided[i + 2] = SkColorGetB(unmultiplied); |
550 | + divided[i + 3] = alpha; |
551 | + } else { |
552 | + divided[i + 0] = SkColorGetR(pixel); |
553 | + divided[i + 1] = SkColorGetG(pixel); |
554 | + divided[i + 2] = SkColorGetB(pixel); |
555 | + divided[i + 3] = alpha; |
556 | + } |
557 | + i += kBytesPerPixel; |
558 | + } |
559 | + } |
560 | + |
561 | + return pixbuf; |
562 | +} |
563 | + |
564 | + |
565 | +namespace { |
566 | + |
567 | +blink::WebNotificationPermission |
568 | +ToNotificationPermission(TemporarySavedPermissionStatus status) { |
569 | + switch (status) { |
570 | + case TEMPORARY_SAVED_PERMISSION_STATUS_ALLOWED: |
571 | + return blink::WebNotificationPermissionAllowed; |
572 | + case TEMPORARY_SAVED_PERMISSION_STATUS_DENIED: |
573 | + return blink::WebNotificationPermissionDenied; |
574 | + default: |
575 | + return blink::WebNotificationPermissionDefault; |
576 | + }; |
577 | +} |
578 | + |
579 | +class DesktopNotification: public base::RefCounted<DesktopNotification> { |
580 | +public: |
581 | + base::Closure* GetCancelCallback(); |
582 | + |
583 | + static scoped_refptr<DesktopNotification> CreateDesktopNotification( |
584 | + const GURL& origin, const std::string &tag); |
585 | + void Initialize( |
586 | + const base::string16& title, const base::string16& body, |
587 | + const SkBitmap& icon, |
588 | + scoped_ptr<content::DesktopNotificationDelegate> delegate); |
589 | +private: |
590 | + DesktopNotification(const GURL &origin, const std::string &tag); |
591 | + ~DesktopNotification(); |
592 | + |
593 | + void CancelNotification(); |
594 | + |
595 | + GURL origin_; |
596 | + std::string tag_; |
597 | + base::Closure cancel_callback_; |
598 | + NotifyNotification *notification_; |
599 | + scoped_ptr<content::DesktopNotificationDelegate> delegate_; |
600 | + |
601 | + static void OnClosed(NotifyNotification *notification, DesktopNotification *self); |
602 | + static std::map<GURL, std::map<std::string, scoped_refptr<DesktopNotification>>> table_; |
603 | + |
604 | + friend class base::RefCounted<DesktopNotification>; |
605 | +}; |
606 | + |
607 | +std::map<GURL, std::map<std::string, scoped_refptr<DesktopNotification>>> DesktopNotification::table_; |
608 | + |
609 | +DesktopNotification::DesktopNotification(const GURL &origin, const std::string &tag) |
610 | + : origin_(origin), tag_(tag), notification_(nullptr) { |
611 | +} |
612 | + |
613 | +scoped_refptr<DesktopNotification> |
614 | +DesktopNotification::CreateDesktopNotification(const GURL& origin, const std::string &tag) { |
615 | + table_[origin][tag] = new DesktopNotification(origin, tag); |
616 | + return table_[origin][tag]; |
617 | +} |
618 | + |
619 | +void |
620 | +DesktopNotification::Initialize( |
621 | + const base::string16& title, const base::string16& body, |
622 | + const SkBitmap& icon, |
623 | + scoped_ptr<content::DesktopNotificationDelegate> delegate) { |
624 | + DCHECK(!notification_); |
625 | + |
626 | + delegate_ = delegate.Pass(); |
627 | + |
628 | + std::string t = base::UTF16ToUTF8(title); |
629 | + std::string b = base::UTF16ToUTF8(body); |
630 | + |
631 | + notification_ = notify_notification_new(t.c_str(), b.c_str(), nullptr); |
632 | + |
633 | + g_signal_connect(notification_, "closed", G_CALLBACK(OnClosed), this); |
634 | + |
635 | + if (delegate_.get()) { |
636 | + delegate_->NotificationDisplayed(); |
637 | + } |
638 | + |
639 | + if (icon.width() && icon.height()) { |
640 | + GdkPixbuf *pix = GdkPixbufFromSkBitmap(icon); |
641 | + notify_notification_set_image_from_pixbuf(notification_, pix); |
642 | + g_object_unref(G_OBJECT(pix)); |
643 | + } |
644 | + notify_notification_show(notification_, nullptr); |
645 | +} |
646 | + |
647 | +base::Closure* |
648 | +DesktopNotification::GetCancelCallback() { |
649 | + cancel_callback_ = base::Bind(&DesktopNotification::CancelNotification, this); |
650 | + return &cancel_callback_; |
651 | +} |
652 | + |
653 | +DesktopNotification::~DesktopNotification() { |
654 | + g_object_unref(G_OBJECT(notification_)); |
655 | +} |
656 | + |
657 | +void |
658 | +DesktopNotification::CancelNotification() { |
659 | + table_[origin_].erase(tag_); |
660 | + this->Release(); |
661 | +} |
662 | + |
663 | +void |
664 | +DesktopNotification::OnClosed(NotifyNotification *notification, DesktopNotification *self) { |
665 | + table_[self->origin_].erase(self->tag_); |
666 | + if (self->delegate_.get()) { |
667 | + self->delegate_->NotificationClosed(); |
668 | + } |
669 | + self->Release(); |
670 | +} |
671 | + |
672 | +} |
673 | + |
674 | +void |
675 | +PlatformNotificationService::Initialize(const std::string& name) { |
676 | + notify_init(name.c_str()); |
677 | +} |
678 | + |
679 | +blink::WebNotificationPermission |
680 | +PlatformNotificationService::CheckPermissionOnIOThread( |
681 | + content::ResourceContext* resource_context, |
682 | + const GURL& origin, |
683 | + int render_process_id) { |
684 | + TemporarySavedPermissionContext* permission_context = |
685 | + BrowserContextIOData::FromResourceContext(resource_context)->GetTemporarySavedPermissionContext(); |
686 | + |
687 | + return ToNotificationPermission(permission_context->GetPermissionStatus( |
688 | + TEMPORARY_SAVED_PERMISSION_TYPE_NOTIFICATIONS, origin, origin)); |
689 | +} |
690 | + |
691 | +blink::WebNotificationPermission |
692 | +PlatformNotificationService::CheckPermissionOnUIThread( |
693 | + content::BrowserContext* browser_context, |
694 | + const GURL& origin, |
695 | + int render_process_id) { |
696 | + BrowserContext* context = static_cast<BrowserContext*>(browser_context); |
697 | + TemporarySavedPermissionContext* permission_context = context->GetTemporarySavedPermissionContext(); |
698 | + |
699 | + return ToNotificationPermission(permission_context->GetPermissionStatus( |
700 | + TEMPORARY_SAVED_PERMISSION_TYPE_NOTIFICATIONS, origin, origin)); |
701 | +} |
702 | + |
703 | +void |
704 | +PlatformNotificationService::DisplayNotification( |
705 | + content::BrowserContext* browser_context, |
706 | + const GURL& origin, |
707 | + const SkBitmap& icon, |
708 | + const content::PlatformNotificationData& notification_data, |
709 | + scoped_ptr<content::DesktopNotificationDelegate> delegate, |
710 | + base::Closure* cancel_callback) { |
711 | + |
712 | + scoped_refptr<DesktopNotification> notification = DesktopNotification::CreateDesktopNotification( |
713 | + origin, notification_data.tag); |
714 | + notification->Initialize(notification_data.title, notification_data.body, icon, delegate.Pass()); |
715 | + |
716 | + cancel_callback = notification->GetCancelCallback(); |
717 | +} |
718 | + |
719 | +void |
720 | +PlatformNotificationService::DisplayPersistentNotification( |
721 | + content::BrowserContext* browser_context, |
722 | + int64 service_worker_registration_id, |
723 | + const GURL& origin, |
724 | + const SkBitmap& icon, |
725 | + const content::PlatformNotificationData& notification_data) { |
726 | + NOTIMPLEMENTED(); |
727 | +} |
728 | + |
729 | +void |
730 | +PlatformNotificationService::ClosePersistentNotification(content::BrowserContext* browser_context, |
731 | + int64_t persistent_notification_id) { |
732 | + NOTIMPLEMENTED(); |
733 | +} |
734 | + |
735 | +bool |
736 | +PlatformNotificationService::GetDisplayedPersistentNotifications( |
737 | + content::BrowserContext* browser_context, |
738 | + std::set<std::string>* displayed_notifications) { |
739 | + return false; |
740 | +} |
741 | + |
742 | +PlatformNotificationService* |
743 | +PlatformNotificationService::GetInstance() { |
744 | + return Singleton<PlatformNotificationService>::get(); |
745 | +} |
746 | + |
747 | +} |
748 | |
749 | === added file 'shared/browser/oxide_platform_notification_service.h' |
750 | --- shared/browser/oxide_platform_notification_service.h 1970-01-01 00:00:00 +0000 |
751 | +++ shared/browser/oxide_platform_notification_service.h 2015-06-19 15:51:41 +0000 |
752 | @@ -0,0 +1,77 @@ |
753 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
754 | +// Copyright (C) 2014 Canonical Ltd. |
755 | + |
756 | +// This library is free software; you can redistribute it and/or |
757 | +// modify it under the terms of the GNU Lesser General Public |
758 | +// License as published by the Free Software Foundation; either |
759 | +// version 2.1 of the License, or (at your option) any later version. |
760 | + |
761 | +// This library is distributed in the hope that it will be useful, |
762 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
763 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
764 | +// Lesser General Public License for more details. |
765 | + |
766 | +// You should have received a copy of the GNU Lesser General Public |
767 | +// License along with this library; if not, write to the Free Software |
768 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
769 | + |
770 | +#ifndef _OXIDE_QT_CORE_PLATFORM_NOTIFICATION_H_ |
771 | +#define _OXIDE_QT_CORE_PLATFORM_NOTIFICATION_H_ |
772 | + |
773 | +#include <string> |
774 | + |
775 | +#include "base/memory/singleton.h" |
776 | +#include "base/values.h" |
777 | +#include "content/public/browser/platform_notification_service.h" |
778 | + |
779 | +namespace oxide { |
780 | + |
781 | +class PlatformNotificationService: public content::PlatformNotificationService { |
782 | +public: |
783 | + void Initialize(const std::string &name); |
784 | + |
785 | + blink::WebNotificationPermission CheckPermissionOnIOThread( |
786 | + content::ResourceContext* resource_context, |
787 | + const GURL& origin, |
788 | + int render_process_id) override; |
789 | + |
790 | + blink::WebNotificationPermission CheckPermissionOnUIThread( |
791 | + content::BrowserContext* browser_context, |
792 | + const GURL& origin, |
793 | + int render_process_id) override; |
794 | + |
795 | + void DisplayNotification( |
796 | + content::BrowserContext* browser_context, |
797 | + const GURL& origin, |
798 | + const SkBitmap& icon, |
799 | + const content::PlatformNotificationData& notification_data, |
800 | + scoped_ptr<content::DesktopNotificationDelegate> delegate, |
801 | + base::Closure* cancel_callback) override; |
802 | + |
803 | + void DisplayPersistentNotification( |
804 | + content::BrowserContext* browser_context, |
805 | + int64 service_worker_registration_id, |
806 | + const GURL& origin, |
807 | + const SkBitmap& icon, |
808 | + const content::PlatformNotificationData& notification_data) override; |
809 | + |
810 | + void ClosePersistentNotification( |
811 | + content::BrowserContext* browser_context, |
812 | + int64_t persistent_notification_id) override; |
813 | + |
814 | + bool GetDisplayedPersistentNotifications( |
815 | + content::BrowserContext* browser_context, |
816 | + std::set<std::string>* displayed_notifications) override; |
817 | + |
818 | + static PlatformNotificationService* GetInstance(); |
819 | +private: |
820 | + friend struct DefaultSingletonTraits<PlatformNotificationService>; |
821 | + PlatformNotificationService() = default; |
822 | + |
823 | + DISALLOW_COPY_AND_ASSIGN(PlatformNotificationService); |
824 | +}; |
825 | + |
826 | + |
827 | +} |
828 | + |
829 | +#endif |
830 | |
831 | === modified file 'shared/browser/oxide_web_view.cc' |
832 | --- shared/browser/oxide_web_view.cc 2015-06-18 15:48:50 +0000 |
833 | +++ shared/browser/oxide_web_view.cc 2015-06-19 15:51:41 +0000 |
834 | @@ -1271,7 +1271,7 @@ |
835 | DCHECK(root_frame_.get()); |
836 | |
837 | if (params->context && init_data_->load_params) { |
838 | - web_contents_->GetController().LoadURLWithParams(*init_data_->load_params); |
839 | + web_contents_->GetController().LoadURLWithParams(*init_data_->load_params); |
840 | } |
841 | |
842 | web_contents_->GetController().LoadIfNecessary(); |
843 | |
844 | === modified file 'shared/browser/permissions/oxide_permission_manager.cc' |
845 | --- shared/browser/permissions/oxide_permission_manager.cc 2015-06-17 21:04:11 +0000 |
846 | +++ shared/browser/permissions/oxide_permission_manager.cc 2015-06-19 15:51:41 +0000 |
847 | @@ -21,6 +21,7 @@ |
848 | #include "content/public/browser/geolocation_provider.h" |
849 | #include "content/public/browser/permission_type.h" |
850 | #include "content/public/common/permission_status.mojom.h" |
851 | +#include "shared/browser/oxide_platform_notification_service.h" |
852 | |
853 | #include "shared/browser/oxide_browser_context.h" |
854 | |
855 | @@ -57,6 +58,7 @@ |
856 | bool IsPermissionTypeSupported(content::PermissionType permission) { |
857 | switch (permission) { |
858 | case content::PermissionType::GEOLOCATION: |
859 | + case content::PermissionType::NOTIFICATIONS: |
860 | return true; |
861 | default: |
862 | return false; |
863 | @@ -68,6 +70,8 @@ |
864 | switch (permission) { |
865 | case content::PermissionType::GEOLOCATION: |
866 | return TEMPORARY_SAVED_PERMISSION_TYPE_GEOLOCATION; |
867 | + case content::PermissionType::NOTIFICATIONS: |
868 | + return TEMPORARY_SAVED_PERMISSION_TYPE_NOTIFICATIONS; |
869 | default: |
870 | NOTREACHED(); |
871 | // XXX(chrisccoulson): Perhaps we need __builtin_unreachable here? |
872 | @@ -134,6 +138,7 @@ |
873 | case content::PermissionType::GEOLOCATION: |
874 | return base::Bind(&RespondToGeolocationPermissionRequest, |
875 | wrapped_callback); |
876 | + case content::PermissionType::NOTIFICATIONS: |
877 | default: |
878 | return wrapped_callback; |
879 | } |
880 | |
881 | === modified file 'shared/browser/permissions/oxide_permission_request_dispatcher.cc' |
882 | --- shared/browser/permissions/oxide_permission_request_dispatcher.cc 2015-06-17 21:04:11 +0000 |
883 | +++ shared/browser/permissions/oxide_permission_request_dispatcher.cc 2015-06-19 15:51:41 +0000 |
884 | @@ -140,6 +140,9 @@ |
885 | case content::PermissionType::GEOLOCATION: |
886 | client_->RequestGeolocationPermission(request.Pass()); |
887 | break; |
888 | + case content::PermissionType::NOTIFICATIONS: |
889 | + client_->RequestNotificationPermission(request.Pass()); |
890 | + break; |
891 | default: |
892 | NOTIMPLEMENTED(); |
893 | break; |
894 | |
895 | === modified file 'shared/browser/permissions/oxide_permission_request_dispatcher_client.h' |
896 | --- shared/browser/permissions/oxide_permission_request_dispatcher_client.h 2015-06-04 08:35:28 +0000 |
897 | +++ shared/browser/permissions/oxide_permission_request_dispatcher_client.h 2015-06-19 15:51:41 +0000 |
898 | @@ -38,6 +38,9 @@ |
899 | |
900 | virtual void RequestMediaAccessPermission( |
901 | scoped_ptr<MediaAccessPermissionRequest> request) {} |
902 | + |
903 | + virtual void RequestNotificationPermission( |
904 | + scoped_ptr<SimplePermissionRequest> request) {} |
905 | }; |
906 | |
907 | } // namespace oxide |
908 | |
909 | === modified file 'shared/browser/permissions/oxide_temporary_saved_permission_context.h' |
910 | --- shared/browser/permissions/oxide_temporary_saved_permission_context.h 2015-06-10 13:10:39 +0000 |
911 | +++ shared/browser/permissions/oxide_temporary_saved_permission_context.h 2015-06-19 15:51:41 +0000 |
912 | @@ -41,6 +41,7 @@ |
913 | PERMISSION_TYPES_START, |
914 | |
915 | TEMPORARY_SAVED_PERMISSION_TYPE_GEOLOCATION = PERMISSION_TYPES_START, |
916 | + TEMPORARY_SAVED_PERMISSION_TYPE_NOTIFICATIONS, |
917 | TEMPORARY_SAVED_PERMISSION_TYPE_MEDIA_DEVICE_MIC, |
918 | TEMPORARY_SAVED_PERMISSION_TYPE_MEDIA_DEVICE_CAMERA, |
919 | |
920 | |
921 | === modified file 'shared/shared.gyp' |
922 | --- shared/shared.gyp 2015-06-18 15:48:50 +0000 |
923 | +++ shared/shared.gyp 2015-06-19 15:51:41 +0000 |
924 | @@ -17,6 +17,7 @@ |
925 | { |
926 | 'variables': { |
927 | 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/oxide', |
928 | + 'pkg_config': 'pkg-config' |
929 | }, |
930 | 'conditions': [ |
931 | ['enable_mediahub==1', { |
932 | @@ -264,6 +265,7 @@ |
933 | '<(DEPTH)/ui/ozone/ozone.gyp:ozone', |
934 | '<(DEPTH)/url/url.gyp:url_lib', |
935 | '<(DEPTH)/v8/tools/gyp/v8.gyp:v8', |
936 | + '../build/system.gyp:libnotify', |
937 | ], |
938 | 'include_dirs': [ |
939 | '..', |
940 | @@ -357,6 +359,8 @@ |
941 | 'browser/oxide_message_pump.h', |
942 | 'browser/oxide_network_delegate.cc', |
943 | 'browser/oxide_network_delegate.h', |
944 | + 'browser/oxide_platform_notification_service.h', |
945 | + 'browser/oxide_platform_notification_service.cc', |
946 | 'browser/oxide_power_save_blocker.cc', |
947 | 'browser/oxide_power_save_blocker.h', |
948 | 'browser/oxide_quota_permission_context.cc', |
this work is required for PushNotifications.