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

Side by Side 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, 8 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/shell/browser/layout_test/layout_test_permission_manager.h"
6
7 #include "base/bind.h"
8 #include "base/callback.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/permission_type.h"
11 #include "content/shell/browser/layout_test/layout_test_content_browser_client.h "
12 #include "content/shell/browser/layout_test/layout_test_notification_manager.h"
13 #include "url/gurl.h"
14
15 namespace content {
16
17 namespace {
18
19 void RequestDesktopNotificationPermissionOnIO(
20 const GURL& origin,
21 const base::Callback<void(PermissionStatus)>& callback) {
22 DCHECK_CURRENTLY_ON(BrowserThread::IO);
23
24 LayoutTestNotificationManager* manager =
25 LayoutTestContentBrowserClient::Get()->GetLayoutTestNotificationManager();
26 PermissionStatus result = manager ? manager->RequestPermission(origin)
27 : PERMISSION_STATUS_GRANTED;
28
29 // The callback came from the UI thread, we need to run it from there again.
30 BrowserThread::PostTask(
31 BrowserThread::UI,
32 FROM_HERE,
33 base::Bind(callback, result));
34 }
35
36 } // anonymous namespace
37
38 LayoutTestPermissionManager::LayoutTestPermissionManager()
39 : ShellPermissionManager() {
40 }
41
42 LayoutTestPermissionManager::~LayoutTestPermissionManager() {
43 }
44
45 void LayoutTestPermissionManager::RequestPermission(
46 PermissionType permission,
47 WebContents* web_contents,
48 int request_id,
49 const GURL& requesting_origin,
50 bool user_gesture,
51 const base::Callback<void(PermissionStatus)>& callback) {
52 DCHECK_CURRENTLY_ON(BrowserThread::UI);
53
54 if (permission == PermissionType::NOTIFICATIONS) {
55 BrowserThread::PostTask(
56 BrowserThread::IO,
57 FROM_HERE,
58 base::Bind(&RequestDesktopNotificationPermissionOnIO,
59 requesting_origin,
60 callback));
61 return;
62 }
63
64 ShellPermissionManager::RequestPermission(permission,
65 web_contents,
66 request_id,
67 requesting_origin,
68 user_gesture,
69 callback);
70 }
71
72 } // namespace content
OLDNEW
« 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