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

Side by Side Diff: content/shell/browser/layout_test/layout_test_content_browser_client.cc

Issue 639293005: Content Shell: Introduce LayoutTestContentBrowserClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 6 years, 2 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 2014 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_content_browser_client.h "
6
7 #include "content/public/browser/browser_thread.h"
8 #include "content/shell/browser/layout_test/layout_test_notification_manager.h"
9
10 namespace content {
11 namespace {
12
13 LayoutTestContentBrowserClient* g_layout_test_browser_client;
14
15 void RequestDesktopNotificationPermissionOnIO(
16 const GURL& source_origin,
17 RenderFrameHost* render_frame_host,
18 const base::Callback<void(blink::WebNotificationPermission)>& callback) {
19 LayoutTestNotificationManager* manager =
20 LayoutTestContentBrowserClient::Get()->GetLayoutTestNotificationManager();
21 if (manager)
22 manager->RequestPermission(source_origin, callback);
23 else
24 callback.Run(blink::WebNotificationPermissionAllowed);
25 }
26
27 } // namespace
28
29 LayoutTestContentBrowserClient::LayoutTestContentBrowserClient() {
30 DCHECK(!g_layout_test_browser_client);
31 g_layout_test_browser_client = this;
32 }
33
34 LayoutTestContentBrowserClient::~LayoutTestContentBrowserClient() {
35 g_layout_test_browser_client = nullptr;
36 }
37
38 LayoutTestContentBrowserClient* LayoutTestContentBrowserClient::Get() {
39 return g_layout_test_browser_client;
40 }
41
42 LayoutTestNotificationManager*
43 LayoutTestContentBrowserClient::GetLayoutTestNotificationManager() {
44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
45 if (!layout_test_notification_manager_) {
46 layout_test_notification_manager_.reset(
47 new LayoutTestNotificationManager());
48 }
49
50 return layout_test_notification_manager_.get();
51 }
52
53 void LayoutTestContentBrowserClient::RequestDesktopNotificationPermission(
54 const GURL& source_origin,
55 RenderFrameHost* render_frame_host,
56 const base::Callback<void(blink::WebNotificationPermission)>& callback) {
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
58 BrowserThread::PostTask(BrowserThread::IO,
59 FROM_HERE,
60 base::Bind(&RequestDesktopNotificationPermissionOnIO,
61 source_origin,
62 render_frame_host,
63 callback));
64 }
65
66 blink::WebNotificationPermission
67 LayoutTestContentBrowserClient::CheckDesktopNotificationPermission(
68 const GURL& source_url,
69 ResourceContext* context,
70 int render_process_id) {
71 LayoutTestNotificationManager* manager = GetLayoutTestNotificationManager();
72 if (manager)
73 return manager->CheckPermission(source_url);
74
75 return blink::WebNotificationPermissionAllowed;
76 }
77
78 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698