Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/renderer/durable_dispatcher.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "content/public/common/service_registry.h" | |
| 9 #include "content/public/renderer/render_frame.h" | |
| 10 #include "third_party/WebKit/public/platform/WebString.h" | |
| 11 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | |
| 12 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 DurableStorageDispatcher::DurableStorageDispatcher(RenderFrame* render_frame) | |
| 17 : RenderFrameObserver(render_frame) { | |
| 18 } | |
| 19 | |
| 20 DurableStorageDispatcher::~DurableStorageDispatcher() { | |
| 21 } | |
| 22 | |
| 23 void DurableStorageDispatcher::requestPermission( | |
| 24 const WebURL& url, | |
| 25 blink::WebDurableStoragePermissionCallbacks* callbacks) { | |
| 26 callbacks_.reset(callbacks); | |
| 27 LOG(ERROR) | |
| 28 << "About to call RequestPermission through the permission service"; | |
| 29 if (!permission_service_.get()) { | |
| 30 render_frame()->GetServiceRegistry()->ConnectToRemoteService( | |
| 31 mojo::GetProxy(&permission_service_)); | |
| 32 } | |
| 33 DCHECK(permission_service_); | |
| 34 | |
| 35 permission_service_->RequestPermission( | |
| 36 PERMISSION_NAME_DURABLE_STORAGE, url.string().utf8(), | |
| 37 blink::WebUserGestureIndicator::isProcessingUserGesture(), | |
| 38 base::Bind(&DurableStorageDispatcher::OnPermissionSet, | |
| 39 base::Unretained(this))); | |
| 40 } | |
| 41 | |
| 42 void DurableStorageDispatcher::OnPermissionSet(PermissionStatus status) { | |
| 43 LOG(ERROR) << "Top of OnPermissionSet, status = " << status; | |
| 44 blink::WebDurableStoragePermission result; | |
| 45 switch (status) { | |
| 46 case PERMISSION_STATUS_GRANTED: | |
| 47 result = blink::WebDurableStoragePermission::Granted; | |
| 48 break; | |
| 49 case PERMISSION_STATUS_DENIED: | |
| 50 result = blink::WebDurableStoragePermission::Denied; | |
| 51 break; | |
| 52 case PERMISSION_STATUS_ASK: | |
| 53 result = blink::WebDurableStoragePermission::Default; | |
|
mlamouri (slow - plz ping)
2015/07/02 09:53:01
Why do you use Default and not ASK?
dgrogan
2015/07/07 04:15:11
Default matches the storage spec.
| |
| 54 break; | |
| 55 default: | |
| 56 NOTREACHED() << "Got " << status; | |
| 57 } | |
| 58 callbacks_->didGetPermission(result); | |
| 59 } | |
| 60 | |
| 61 } // namespace content | |
| OLD | NEW |