Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/shell/browser/layout_test/layout_test_content_browser_client.h " | 5 #include "content/shell/browser/layout_test/layout_test_content_browser_client.h " |
| 6 | 6 |
| 7 #include "content/public/browser/browser_thread.h" | 7 #include "content/public/browser/browser_thread.h" |
| 8 #include "content/shell/browser/layout_test/layout_test_notification_manager.h" | 8 #include "content/shell/browser/layout_test/layout_test_notification_manager.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 LayoutTestContentBrowserClient* g_layout_test_browser_client; | 13 LayoutTestContentBrowserClient* g_layout_test_browser_client; |
| 14 | 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); | |
|
Peter Beverloo
2014/10/20 17:32:16
Removing this is not OK and will break tests.
In
Miguel Garcia
2014/10/21 17:17:12
Fixed now
On 2014/10/20 17:32:16, Peter Beverloo
| |
| 23 else | |
| 24 callback.Run(blink::WebNotificationPermissionAllowed); | |
| 25 } | |
| 26 | |
| 27 } // namespace | 15 } // namespace |
| 28 | 16 |
| 29 LayoutTestContentBrowserClient::LayoutTestContentBrowserClient() { | 17 LayoutTestContentBrowserClient::LayoutTestContentBrowserClient() { |
| 30 DCHECK(!g_layout_test_browser_client); | 18 DCHECK(!g_layout_test_browser_client); |
| 31 g_layout_test_browser_client = this; | 19 g_layout_test_browser_client = this; |
| 32 } | 20 } |
| 33 | 21 |
| 34 LayoutTestContentBrowserClient::~LayoutTestContentBrowserClient() { | 22 LayoutTestContentBrowserClient::~LayoutTestContentBrowserClient() { |
| 35 g_layout_test_browser_client = nullptr; | 23 g_layout_test_browser_client = nullptr; |
| 36 } | 24 } |
| 37 | 25 |
| 38 LayoutTestContentBrowserClient* LayoutTestContentBrowserClient::Get() { | 26 LayoutTestContentBrowserClient* LayoutTestContentBrowserClient::Get() { |
| 39 return g_layout_test_browser_client; | 27 return g_layout_test_browser_client; |
| 40 } | 28 } |
| 41 | 29 |
| 42 LayoutTestNotificationManager* | 30 LayoutTestNotificationManager* |
| 43 LayoutTestContentBrowserClient::GetLayoutTestNotificationManager() { | 31 LayoutTestContentBrowserClient::GetLayoutTestNotificationManager() { |
| 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 45 if (!layout_test_notification_manager_) { | 33 if (!layout_test_notification_manager_) { |
| 46 layout_test_notification_manager_.reset( | 34 layout_test_notification_manager_.reset( |
| 47 new LayoutTestNotificationManager()); | 35 new LayoutTestNotificationManager()); |
| 48 } | 36 } |
| 49 | 37 |
| 50 return layout_test_notification_manager_.get(); | 38 return layout_test_notification_manager_.get(); |
| 51 } | 39 } |
| 52 | 40 |
| 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 | 41 blink::WebNotificationPermission |
| 67 LayoutTestContentBrowserClient::CheckDesktopNotificationPermission( | 42 LayoutTestContentBrowserClient::CheckDesktopNotificationPermission( |
| 68 const GURL& source_url, | 43 const GURL& source_url, |
| 69 ResourceContext* context, | 44 ResourceContext* context, |
| 70 int render_process_id) { | 45 int render_process_id) { |
| 71 LayoutTestNotificationManager* manager = GetLayoutTestNotificationManager(); | 46 LayoutTestNotificationManager* manager = GetLayoutTestNotificationManager(); |
| 72 if (manager) | 47 if (manager) |
| 73 return manager->CheckPermission(source_url); | 48 return manager->CheckPermission(source_url); |
| 74 | 49 |
| 75 return blink::WebNotificationPermissionAllowed; | 50 return blink::WebNotificationPermissionAllowed; |
| 76 } | 51 } |
| 77 | 52 |
| 78 } // namespace content | 53 } // namespace content |
| OLD | NEW |