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

Unified Diff: content/shell/browser/shell_content_browser_client.cc

Issue 395883002: Support layout testing Web Notifications from Document and Worker contexts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: another rebase Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/shell/browser/shell_content_browser_client.h ('k') | content/shell/browser/shell_message_filter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/browser/shell_content_browser_client.cc
diff --git a/content/shell/browser/shell_content_browser_client.cc b/content/shell/browser/shell_content_browser_client.cc
index a178ee0969984a26a570cd9366479426664cd414..8a2f3fe7a58cada596978c12f7dff66eaeaae6b0 100644
--- a/content/shell/browser/shell_content_browser_client.cc
+++ b/content/shell/browser/shell_content_browser_client.cc
@@ -22,6 +22,7 @@
#include "content/shell/browser/shell_devtools_delegate.h"
#include "content/shell/browser/shell_message_filter.h"
#include "content/shell/browser/shell_net_log.h"
+#include "content/shell/browser/shell_notification_manager.h"
#include "content/shell/browser/shell_quota_permission_context.h"
#include "content/shell/browser/shell_resource_dispatcher_host_delegate.h"
#include "content/shell/browser/shell_web_contents_view_delegate_creator.h"
@@ -114,6 +115,18 @@ int GetCrashSignalFD(const CommandLine& command_line) {
}
#endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
+void RequestDesktopNotificationPermissionOnIO(
+ const GURL& source_origin,
+ RenderFrameHost* render_frame_host,
+ const base::Callback<void(blink::WebNotificationPermission)>& callback) {
+ ShellNotificationManager* manager =
+ ShellContentBrowserClient::Get()->GetShellNotificationManager();
+ if (manager)
+ manager->RequestPermission(source_origin, callback);
+ else
+ callback.Run(blink::WebNotificationPermissionAllowed);
+}
+
} // namespace
ShellContentBrowserClient* ShellContentBrowserClient::Get() {
@@ -137,6 +150,18 @@ ShellContentBrowserClient::~ShellContentBrowserClient() {
g_browser_client = NULL;
}
+ShellNotificationManager*
+ShellContentBrowserClient::GetShellNotificationManager() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
+ return NULL;
+
+ if (!shell_notification_manager_)
+ shell_notification_manager_.reset(new ShellNotificationManager());
+
+ return shell_notification_manager_.get();
+}
+
BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts(
const MainFunctionParams& parameters) {
shell_browser_main_parts_ = new ShellBrowserMainParts(parameters);
@@ -277,6 +302,31 @@ ShellContentBrowserClient::CreateQuotaPermissionContext() {
return new ShellQuotaPermissionContext();
}
+void ShellContentBrowserClient::RequestDesktopNotificationPermission(
+ const GURL& source_origin,
+ RenderFrameHost* render_frame_host,
+ const base::Callback<void(blink::WebNotificationPermission)>& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ BrowserThread::PostTask(BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&RequestDesktopNotificationPermissionOnIO,
+ source_origin,
+ render_frame_host,
+ callback));
+}
+
+blink::WebNotificationPermission
+ShellContentBrowserClient::CheckDesktopNotificationPermission(
+ const GURL& source_url,
+ ResourceContext* context,
+ int render_process_id) {
+ ShellNotificationManager* manager = GetShellNotificationManager();
+ if (manager)
+ return manager->CheckPermission(source_url);
+
+ return blink::WebNotificationPermissionAllowed;
+}
+
SpeechRecognitionManagerDelegate*
ShellContentBrowserClient::GetSpeechRecognitionManagerDelegate() {
return new ShellSpeechRecognitionManagerDelegate();
« no previous file with comments | « content/shell/browser/shell_content_browser_client.h ('k') | content/shell/browser/shell_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698