| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/child/permissions/permission_dispatcher.h" | 5 #include "content/child/permissions/permission_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "content/child/worker_task_runner.h" | 8 #include "content/child/worker_task_runner.h" |
| 9 #include "content/public/common/service_registry.h" | 9 #include "content/public/common/service_registry.h" |
| 10 #include "third_party/WebKit/public/platform/WebURL.h" | 10 #include "third_party/WebKit/public/platform/WebURL.h" |
| 11 #include "third_party/WebKit/public/platform/modules/permissions/WebPermissionOb
server.h" | 11 #include "third_party/WebKit/public/platform/modules/permissions/WebPermissionOb
server.h" |
| 12 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
| 12 | 13 |
| 13 using blink::WebPermissionObserver; | 14 using blink::WebPermissionObserver; |
| 14 | 15 |
| 15 namespace content { | 16 namespace content { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 PermissionName GetPermissionName(blink::WebPermissionType type) { | 20 PermissionName GetPermissionName(blink::WebPermissionType type) { |
| 20 switch (type) { | 21 switch (type) { |
| 21 case blink::WebPermissionTypeGeolocation: | 22 case blink::WebPermissionTypeGeolocation: |
| 22 return PERMISSION_NAME_GEOLOCATION; | 23 return PERMISSION_NAME_GEOLOCATION; |
| 23 case blink::WebPermissionTypeNotifications: | 24 case blink::WebPermissionTypeNotifications: |
| 24 return PERMISSION_NAME_NOTIFICATIONS; | 25 return PERMISSION_NAME_NOTIFICATIONS; |
| 25 case blink::WebPermissionTypePushNotifications: | 26 case blink::WebPermissionTypePushNotifications: |
| 26 return PERMISSION_NAME_PUSH_NOTIFICATIONS; | 27 return PERMISSION_NAME_PUSH_NOTIFICATIONS; |
| 27 case blink::WebPermissionTypeMidiSysEx: | 28 case blink::WebPermissionTypeMidiSysEx: |
| 28 return PERMISSION_NAME_MIDI_SYSEX; | 29 return PERMISSION_NAME_MIDI_SYSEX; |
| 30 case blink::WebPermissionTypeDurableStorage: |
| 31 return PERMISSION_NAME_DURABLE_STORAGE; |
| 29 default: | 32 default: |
| 30 // The default statement is only there to prevent compilation failures if | 33 // The default statement is only there to prevent compilation failures if |
| 31 // WebPermissionType enum gets extended. | 34 // WebPermissionType enum gets extended. |
| 32 NOTREACHED(); | 35 NOTREACHED(); |
| 33 return PERMISSION_NAME_GEOLOCATION; | 36 return PERMISSION_NAME_GEOLOCATION; |
| 34 } | 37 } |
| 35 } | 38 } |
| 36 | 39 |
| 37 PermissionStatus GetPermissionStatus(blink::WebPermissionStatus status) { | 40 PermissionStatus GetPermissionStatus(blink::WebPermissionStatus status) { |
| 38 switch (status) { | 41 switch (status) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 PermissionDispatcher::CallbackInformation::~CallbackInformation() { | 101 PermissionDispatcher::CallbackInformation::~CallbackInformation() { |
| 99 } | 102 } |
| 100 | 103 |
| 101 PermissionDispatcher::PermissionDispatcher(ServiceRegistry* service_registry) | 104 PermissionDispatcher::PermissionDispatcher(ServiceRegistry* service_registry) |
| 102 : service_registry_(service_registry) { | 105 : service_registry_(service_registry) { |
| 103 } | 106 } |
| 104 | 107 |
| 105 PermissionDispatcher::~PermissionDispatcher() { | 108 PermissionDispatcher::~PermissionDispatcher() { |
| 106 } | 109 } |
| 107 | 110 |
| 111 void PermissionDispatcher::requestDurablePermission(const blink::WebURL& origin, |
| 112 blink::WebPermissionQueryCallback* callback) { |
| 113 int request_id = pending_callbacks_.Add( |
| 114 new CallbackInformation(callback, kNoWorkerThread)); |
| 115 GetPermissionServicePtr()->RequestPermission( |
| 116 PERMISSION_NAME_DURABLE_STORAGE, origin.string().utf8(), |
| 117 blink::WebUserGestureIndicator::isProcessingUserGesture(), |
| 118 base::Bind(&PermissionDispatcher::OnQueryPermission, |
| 119 base::Unretained(this), |
| 120 request_id)); |
| 121 } |
| 122 |
| 108 void PermissionDispatcher::queryPermission( | 123 void PermissionDispatcher::queryPermission( |
| 109 blink::WebPermissionType type, | 124 blink::WebPermissionType type, |
| 110 const blink::WebURL& origin, | 125 const blink::WebURL& origin, |
| 111 blink::WebPermissionQueryCallback* callback) { | 126 blink::WebPermissionQueryCallback* callback) { |
| 112 QueryPermissionInternal( | 127 QueryPermissionInternal( |
| 113 type, origin.string().utf8(), callback, kNoWorkerThread); | 128 type, origin.string().utf8(), callback, kNoWorkerThread); |
| 114 } | 129 } |
| 115 | 130 |
| 116 void PermissionDispatcher::startListening( | 131 void PermissionDispatcher::startListening( |
| 117 blink::WebPermissionType type, | 132 blink::WebPermissionType type, |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 origin, | 292 origin, |
| 278 current_status, | 293 current_status, |
| 279 base::Bind(&PermissionDispatcher::OnPermissionChanged, | 294 base::Bind(&PermissionDispatcher::OnPermissionChanged, |
| 280 base::Unretained(this), | 295 base::Unretained(this), |
| 281 type, | 296 type, |
| 282 origin, | 297 origin, |
| 283 base::Unretained(observer))); | 298 base::Unretained(observer))); |
| 284 } | 299 } |
| 285 | 300 |
| 286 } // namespace content | 301 } // namespace content |
| OLD | NEW |