Index: content/renderer/durable_dispatcher.cc |
diff --git a/content/renderer/durable_dispatcher.cc b/content/renderer/durable_dispatcher.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..413a5e1f95833ed38ce53caa6779d049d3256427 |
--- /dev/null |
+++ b/content/renderer/durable_dispatcher.cc |
@@ -0,0 +1,61 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/renderer/durable_dispatcher.h" |
+ |
+#include "base/bind.h" |
+#include "content/public/common/service_registry.h" |
+#include "content/public/renderer/render_frame.h" |
+#include "third_party/WebKit/public/platform/WebString.h" |
+#include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
+#include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
+ |
+namespace content { |
+ |
+DurableStorageDispatcher::DurableStorageDispatcher(RenderFrame* render_frame) |
+ : RenderFrameObserver(render_frame) { |
+} |
+ |
+DurableStorageDispatcher::~DurableStorageDispatcher() { |
+} |
+ |
+void DurableStorageDispatcher::requestPermission( |
+ const WebURL& url, |
+ blink::WebDurableStoragePermissionCallbacks* callbacks) { |
+ callbacks_.reset(callbacks); |
+ LOG(ERROR) |
+ << "About to call RequestPermission through the permission service"; |
+ if (!permission_service_.get()) { |
+ render_frame()->GetServiceRegistry()->ConnectToRemoteService( |
+ mojo::GetProxy(&permission_service_)); |
+ } |
+ DCHECK(permission_service_); |
+ |
+ permission_service_->RequestPermission( |
+ PERMISSION_NAME_DURABLE_STORAGE, url.string().utf8(), |
+ blink::WebUserGestureIndicator::isProcessingUserGesture(), |
+ base::Bind(&DurableStorageDispatcher::OnPermissionSet, |
+ base::Unretained(this))); |
+} |
+ |
+void DurableStorageDispatcher::OnPermissionSet(PermissionStatus status) { |
+ LOG(ERROR) << "Top of OnPermissionSet, status = " << status; |
+ blink::WebDurableStoragePermission result; |
+ switch (status) { |
+ case PERMISSION_STATUS_GRANTED: |
+ result = blink::WebDurableStoragePermission::Granted; |
+ break; |
+ case PERMISSION_STATUS_DENIED: |
+ result = blink::WebDurableStoragePermission::Denied; |
+ break; |
+ case PERMISSION_STATUS_ASK: |
+ 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.
|
+ break; |
+ default: |
+ NOTREACHED() << "Got " << status; |
+ } |
+ callbacks_->didGetPermission(result); |
+} |
+ |
+} // namespace content |