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_context.h" | 7 #include "content/public/browser/browser_context.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "content/public/browser/render_process_host.h" | 9 #include "content/public/browser/render_process_host.h" |
10 #include "content/public/browser/storage_partition.h" | 10 #include "content/public/browser/storage_partition.h" |
11 #include "content/shell/browser/layout_test/layout_test_message_filter.h" | 11 #include "content/shell/browser/layout_test/layout_test_message_filter.h" |
12 #include "content/shell/browser/layout_test/layout_test_notification_manager.h" | 12 #include "content/shell/browser/layout_test/layout_test_notification_manager.h" |
13 #include "content/shell/browser/shell_browser_context.h" | 13 #include "content/shell/browser/shell_browser_context.h" |
14 #include "content/shell/common/shell_messages.h" | 14 #include "content/shell/common/shell_messages.h" |
15 #include "content/shell/common/webkit_test_helpers.h" | 15 #include "content/shell/common/webkit_test_helpers.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 namespace { | 18 namespace { |
19 | 19 |
20 LayoutTestContentBrowserClient* g_layout_test_browser_client; | 20 LayoutTestContentBrowserClient* g_layout_test_browser_client; |
21 | 21 |
22 void RequestDesktopNotificationPermissionOnIO( | 22 void RequestDesktopNotificationPermissionOnIO( |
23 const GURL& source_origin, | 23 const GURL& source_origin, |
24 const base::Callback<void(bool)>& callback) { | 24 const base::Callback<void(bool)>& callback) { |
25 LayoutTestNotificationManager* manager = | 25 LayoutTestNotificationManager* manager = |
26 LayoutTestContentBrowserClient::Get()->GetLayoutTestNotificationManager(); | 26 LayoutTestContentBrowserClient::Get()->GetLayoutTestNotificationManager(); |
27 if (manager) | 27 bool allowed = manager ? manager->RequestPermission(source_origin) |
28 manager->RequestPermission(source_origin, callback); | 28 : true; |
29 else | 29 |
30 callback.Run(true); | 30 // The callback came from the UI thread, we need to run it from there again. |
| 31 BrowserThread::PostTask( |
| 32 BrowserThread::UI, |
| 33 FROM_HERE, |
| 34 base::Bind(callback, allowed)); |
31 } | 35 } |
32 | 36 |
33 } // namespace | 37 } // namespace |
34 | 38 |
35 LayoutTestContentBrowserClient::LayoutTestContentBrowserClient() { | 39 LayoutTestContentBrowserClient::LayoutTestContentBrowserClient() { |
36 DCHECK(!g_layout_test_browser_client); | 40 DCHECK(!g_layout_test_browser_client); |
37 | 41 |
38 layout_test_notification_manager_.reset( | 42 layout_test_notification_manager_.reset( |
39 new LayoutTestNotificationManager()); | 43 new LayoutTestNotificationManager()); |
40 | 44 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 const ShowDesktopNotificationHostMsgParams& params, | 114 const ShowDesktopNotificationHostMsgParams& params, |
111 BrowserContext* browser_context, | 115 BrowserContext* browser_context, |
112 int render_process_id, | 116 int render_process_id, |
113 scoped_ptr<DesktopNotificationDelegate> delegate, | 117 scoped_ptr<DesktopNotificationDelegate> delegate, |
114 base::Closure* cancel_callback) { | 118 base::Closure* cancel_callback) { |
115 if (auto* manager = GetLayoutTestNotificationManager()) | 119 if (auto* manager = GetLayoutTestNotificationManager()) |
116 manager->Show(params, delegate.Pass(), cancel_callback); | 120 manager->Show(params, delegate.Pass(), cancel_callback); |
117 } | 121 } |
118 | 122 |
119 } // namespace content | 123 } // namespace content |
OLD | NEW |