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" |
(...skipping 17 matching lines...) Expand all Loading... |
28 if (manager) | 28 if (manager) |
29 manager->RequestPermission(source_origin, callback); | 29 manager->RequestPermission(source_origin, callback); |
30 else | 30 else |
31 callback.Run(blink::WebNotificationPermissionAllowed); | 31 callback.Run(blink::WebNotificationPermissionAllowed); |
32 } | 32 } |
33 | 33 |
34 } // namespace | 34 } // namespace |
35 | 35 |
36 LayoutTestContentBrowserClient::LayoutTestContentBrowserClient() { | 36 LayoutTestContentBrowserClient::LayoutTestContentBrowserClient() { |
37 DCHECK(!g_layout_test_browser_client); | 37 DCHECK(!g_layout_test_browser_client); |
| 38 |
| 39 layout_test_notification_manager_.reset( |
| 40 new LayoutTestNotificationManager()); |
| 41 |
38 g_layout_test_browser_client = this; | 42 g_layout_test_browser_client = this; |
39 } | 43 } |
40 | 44 |
41 LayoutTestContentBrowserClient::~LayoutTestContentBrowserClient() { | 45 LayoutTestContentBrowserClient::~LayoutTestContentBrowserClient() { |
42 g_layout_test_browser_client = nullptr; | 46 g_layout_test_browser_client = nullptr; |
43 } | 47 } |
44 | 48 |
45 LayoutTestContentBrowserClient* LayoutTestContentBrowserClient::Get() { | 49 LayoutTestContentBrowserClient* LayoutTestContentBrowserClient::Get() { |
46 return g_layout_test_browser_client; | 50 return g_layout_test_browser_client; |
47 } | 51 } |
48 | 52 |
49 LayoutTestNotificationManager* | 53 LayoutTestNotificationManager* |
50 LayoutTestContentBrowserClient::GetLayoutTestNotificationManager() { | 54 LayoutTestContentBrowserClient::GetLayoutTestNotificationManager() { |
51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
52 if (!layout_test_notification_manager_) { | |
53 layout_test_notification_manager_.reset( | |
54 new LayoutTestNotificationManager()); | |
55 } | |
56 | |
57 return layout_test_notification_manager_.get(); | 55 return layout_test_notification_manager_.get(); |
58 } | 56 } |
59 | 57 |
60 void LayoutTestContentBrowserClient::RenderProcessWillLaunch( | 58 void LayoutTestContentBrowserClient::RenderProcessWillLaunch( |
61 RenderProcessHost* host) { | 59 RenderProcessHost* host) { |
62 ShellContentBrowserClient::RenderProcessWillLaunch(host); | 60 ShellContentBrowserClient::RenderProcessWillLaunch(host); |
63 | 61 |
64 StoragePartition* partition = | 62 StoragePartition* partition = |
65 BrowserContext::GetDefaultStoragePartition(browser_context()); | 63 BrowserContext::GetDefaultStoragePartition(browser_context()); |
66 host->AddFilter(new LayoutTestMessageFilter( | 64 host->AddFilter(new LayoutTestMessageFilter( |
(...skipping 23 matching lines...) Expand all Loading... |
90 const GURL& source_url, | 88 const GURL& source_url, |
91 ResourceContext* context, | 89 ResourceContext* context, |
92 int render_process_id) { | 90 int render_process_id) { |
93 LayoutTestNotificationManager* manager = GetLayoutTestNotificationManager(); | 91 LayoutTestNotificationManager* manager = GetLayoutTestNotificationManager(); |
94 if (manager) | 92 if (manager) |
95 return manager->CheckPermission(source_url); | 93 return manager->CheckPermission(source_url); |
96 | 94 |
97 return blink::WebNotificationPermissionAllowed; | 95 return blink::WebNotificationPermissionAllowed; |
98 } | 96 } |
99 | 97 |
| 98 void LayoutTestContentBrowserClient::ShowDesktopNotification( |
| 99 const ShowDesktopNotificationHostMsgParams& params, |
| 100 RenderFrameHost* render_frame_host, |
| 101 scoped_ptr<DesktopNotificationDelegate> delegate, |
| 102 base::Closure* cancel_callback) { |
| 103 if (auto* manager = GetLayoutTestNotificationManager()) |
| 104 manager->Show(params, delegate.Pass(), cancel_callback); |
| 105 } |
| 106 |
100 } // namespace content | 107 } // namespace content |
OLD | NEW |