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

Unified Diff: content/shell/browser/layout_test/layout_test_permission_manager.cc

Issue 1011953003: Refactor Permissions related method out of ContentBrowserClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission_type_enum_class
Patch Set: fix cros Created 5 years, 9 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/shell/browser/layout_test/layout_test_permission_manager.cc
diff --git a/content/shell/browser/layout_test/layout_test_permission_manager.cc b/content/shell/browser/layout_test/layout_test_permission_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ed4e7c66546d9130cd2729a3cdf7f18e54889f42
--- /dev/null
+++ b/content/shell/browser/layout_test/layout_test_permission_manager.cc
@@ -0,0 +1,72 @@
+// Copyright 2015 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/shell/browser/layout_test/layout_test_permission_manager.h"
+
+#include "base/bind.h"
+#include "base/callback.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/permission_type.h"
+#include "content/shell/browser/layout_test/layout_test_content_browser_client.h"
+#include "content/shell/browser/layout_test/layout_test_notification_manager.h"
+#include "url/gurl.h"
+
+namespace content {
+
+namespace {
+
+void RequestDesktopNotificationPermissionOnIO(
+ const GURL& origin,
+ const base::Callback<void(PermissionStatus)>& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ LayoutTestNotificationManager* manager =
+ LayoutTestContentBrowserClient::Get()->GetLayoutTestNotificationManager();
+ PermissionStatus result = manager ? manager->RequestPermission(origin)
+ : PERMISSION_STATUS_GRANTED;
+
+ // The callback came from the UI thread, we need to run it from there again.
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(callback, result));
+}
+
+} // anonymous namespace
+
+LayoutTestPermissionManager::LayoutTestPermissionManager()
+ : ShellPermissionManager() {
+}
+
+LayoutTestPermissionManager::~LayoutTestPermissionManager() {
+}
+
+void LayoutTestPermissionManager::RequestPermission(
+ PermissionType permission,
+ WebContents* web_contents,
+ int request_id,
+ const GURL& requesting_origin,
+ bool user_gesture,
+ const base::Callback<void(PermissionStatus)>& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ if (permission == PermissionType::NOTIFICATIONS) {
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&RequestDesktopNotificationPermissionOnIO,
+ requesting_origin,
+ callback));
+ return;
+ }
+
+ ShellPermissionManager::RequestPermission(permission,
+ web_contents,
+ request_id,
+ requesting_origin,
+ user_gesture,
+ callback);
+}
+
+} // namespace content
« no previous file with comments | « content/shell/browser/layout_test/layout_test_permission_manager.h ('k') | content/shell/browser/shell_browser_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698