Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1438)

Unified Diff: content/renderer/durable_dispatcher.cc

Issue 1164073005: Allow script to request durable storage permission (chrome side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased onto content setting patch Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698