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_context.h" | |
| 7 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "content/public/browser/render_process_host.h" | |
| 10 #include "content/public/browser/storage_partition.h" | |
| 11 #include "content/shell/browser/layout_test/layout_test_message_filter.h" | |
| 8 #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" | |
| 14 #include "content/shell/common/shell_messages.h" | |
| 15 #include "content/shell/common/webkit_test_helpers.h" | |
| 9 | 16 |
| 10 namespace content { | 17 namespace content { |
| 11 namespace { | 18 namespace { |
| 12 | 19 |
| 13 LayoutTestContentBrowserClient* g_layout_test_browser_client; | 20 LayoutTestContentBrowserClient* g_layout_test_browser_client; |
| 14 | 21 |
| 15 void RequestDesktopNotificationPermissionOnIO( | 22 void RequestDesktopNotificationPermissionOnIO( |
| 16 const GURL& source_origin, | 23 const GURL& source_origin, |
| 17 RenderFrameHost* render_frame_host, | 24 RenderFrameHost* render_frame_host, |
| 18 const base::Callback<void(blink::WebNotificationPermission)>& callback) { | 25 const base::Callback<void(blink::WebNotificationPermission)>& callback) { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 43 LayoutTestContentBrowserClient::GetLayoutTestNotificationManager() { | 50 LayoutTestContentBrowserClient::GetLayoutTestNotificationManager() { |
| 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 45 if (!layout_test_notification_manager_) { | 52 if (!layout_test_notification_manager_) { |
| 46 layout_test_notification_manager_.reset( | 53 layout_test_notification_manager_.reset( |
| 47 new LayoutTestNotificationManager()); | 54 new LayoutTestNotificationManager()); |
| 48 } | 55 } |
| 49 | 56 |
| 50 return layout_test_notification_manager_.get(); | 57 return layout_test_notification_manager_.get(); |
| 51 } | 58 } |
| 52 | 59 |
| 60 void LayoutTestContentBrowserClient::RenderProcessWillLaunch( | |
| 61 RenderProcessHost* host) { | |
| 62 ShellContentBrowserClient::RenderProcessWillLaunch(host); | |
| 63 | |
| 64 StoragePartition* partition = | |
| 65 BrowserContext::GetDefaultStoragePartition(browser_context()); | |
| 66 host->AddFilter(new LayoutTestMessageFilter( | |
| 67 host->GetID(), | |
| 68 partition->GetDatabaseTracker(), | |
| 69 partition->GetQuotaManager(), | |
| 70 partition->GetURLRequestContext())); | |
| 71 | |
| 72 host->Send(new ShellViewMsg_SetWebKitSourceDir(GetWebKitRootDirFilePath())); | |
|
Mike West
2014/10/16 19:42:32
Nit: We should totally rename these to Blink at so
Peter Beverloo
2014/10/17 11:07:43
Agreed, but I'd prefer to avoid changing logic/nam
| |
| 73 } | |
| 74 | |
| 53 void LayoutTestContentBrowserClient::RequestDesktopNotificationPermission( | 75 void LayoutTestContentBrowserClient::RequestDesktopNotificationPermission( |
| 54 const GURL& source_origin, | 76 const GURL& source_origin, |
| 55 RenderFrameHost* render_frame_host, | 77 RenderFrameHost* render_frame_host, |
| 56 const base::Callback<void(blink::WebNotificationPermission)>& callback) { | 78 const base::Callback<void(blink::WebNotificationPermission)>& callback) { |
| 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 79 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 58 BrowserThread::PostTask(BrowserThread::IO, | 80 BrowserThread::PostTask(BrowserThread::IO, |
| 59 FROM_HERE, | 81 FROM_HERE, |
| 60 base::Bind(&RequestDesktopNotificationPermissionOnIO, | 82 base::Bind(&RequestDesktopNotificationPermissionOnIO, |
| 61 source_origin, | 83 source_origin, |
| 62 render_frame_host, | 84 render_frame_host, |
| 63 callback)); | 85 callback)); |
| 64 } | 86 } |
| 65 | 87 |
| 66 blink::WebNotificationPermission | 88 blink::WebNotificationPermission |
| 67 LayoutTestContentBrowserClient::CheckDesktopNotificationPermission( | 89 LayoutTestContentBrowserClient::CheckDesktopNotificationPermission( |
| 68 const GURL& source_url, | 90 const GURL& source_url, |
| 69 ResourceContext* context, | 91 ResourceContext* context, |
| 70 int render_process_id) { | 92 int render_process_id) { |
| 71 LayoutTestNotificationManager* manager = GetLayoutTestNotificationManager(); | 93 LayoutTestNotificationManager* manager = GetLayoutTestNotificationManager(); |
| 72 if (manager) | 94 if (manager) |
| 73 return manager->CheckPermission(source_url); | 95 return manager->CheckPermission(source_url); |
| 74 | 96 |
| 75 return blink::WebNotificationPermissionAllowed; | 97 return blink::WebNotificationPermissionAllowed; |
| 76 } | 98 } |
| 77 | 99 |
| 78 } // namespace content | 100 } // namespace content |
| OLD | NEW |