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

Side by Side Diff: content/shell/browser/layout_test/layout_test_notification_manager.cc

Issue 774573003: Start pulling away notification logic from ChromeContentBrowserClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 unified diff | Download patch
« no previous file with comments | « content/shell/browser/layout_test/layout_test_notification_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_notification_manager.h" 5 #include "content/shell/browser/layout_test/layout_test_notification_manager.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "content/public/browser/desktop_notification_delegate.h" 9 #include "content/public/browser/desktop_notification_delegate.h"
10 #include "content/public/common/show_desktop_notification_params.h" 10 #include "content/public/common/show_desktop_notification_params.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 LayoutTestNotificationManager::LayoutTestNotificationManager() 14 LayoutTestNotificationManager::LayoutTestNotificationManager()
15 : weak_factory_(this) {} 15 : weak_factory_(this) {}
16 16
17 LayoutTestNotificationManager::~LayoutTestNotificationManager() {} 17 LayoutTestNotificationManager::~LayoutTestNotificationManager() {}
18 18
19 blink::WebNotificationPermission 19 blink::WebNotificationPermission
20 LayoutTestNotificationManager::CheckPermission(const GURL& origin) { 20 LayoutTestNotificationManager::CheckPermission(
21 ResourceContext* resource_context,
22 const GURL& origin,
23 int render_process_id) {
21 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 24 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
22 NotificationPermissionMap::iterator iter = 25 NotificationPermissionMap::iterator iter =
23 permission_map_.find(origin); 26 permission_map_.find(origin);
24 if (iter == permission_map_.end()) 27 if (iter == permission_map_.end())
25 return blink::WebNotificationPermissionDefault; 28 return blink::WebNotificationPermissionDefault;
26 29
27 return iter->second; 30 return iter->second;
28 } 31 }
29 32
30 bool LayoutTestNotificationManager::RequestPermission(const GURL& origin) { 33 bool LayoutTestNotificationManager::RequestPermission(const GURL& origin) {
31 return CheckPermission(origin) == blink::WebNotificationPermissionAllowed; 34 return CheckPermission(nullptr, origin, 0) ==
35 blink::WebNotificationPermissionAllowed;
32 } 36 }
33 37
34 void LayoutTestNotificationManager::SetPermission( 38 void LayoutTestNotificationManager::SetPermission(
35 const GURL& origin, 39 const GURL& origin,
36 blink::WebNotificationPermission permission) { 40 blink::WebNotificationPermission permission) {
37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
38 permission_map_[origin] = permission; 42 permission_map_[origin] = permission;
39 } 43 }
40 44
41 void LayoutTestNotificationManager::ClearPermissions() { 45 void LayoutTestNotificationManager::ClearPermissions() {
42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
43 permission_map_.clear(); 47 permission_map_.clear();
44 } 48 }
45 49
46 void LayoutTestNotificationManager::Show( 50 void LayoutTestNotificationManager::DisplayNotification(
51 BrowserContext* browser_context,
47 const ShowDesktopNotificationHostMsgParams& params, 52 const ShowDesktopNotificationHostMsgParams& params,
48 scoped_ptr<DesktopNotificationDelegate> delegate, 53 scoped_ptr<DesktopNotificationDelegate> delegate,
54 int render_process_id,
49 base::Closure* cancel_callback) { 55 base::Closure* cancel_callback) {
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
51 std::string title = base::UTF16ToUTF8(params.title); 57 std::string title = base::UTF16ToUTF8(params.title);
52 58
53 DCHECK(cancel_callback); 59 DCHECK(cancel_callback);
54 *cancel_callback = base::Bind(&LayoutTestNotificationManager::Close, 60 *cancel_callback = base::Bind(&LayoutTestNotificationManager::Close,
55 weak_factory_.GetWeakPtr(), 61 weak_factory_.GetWeakPtr(),
56 title); 62 title);
57 63
58 if (params.replace_id.length()) { 64 if (params.replace_id.length()) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 void LayoutTestNotificationManager::Close(const std::string& title) { 96 void LayoutTestNotificationManager::Close(const std::string& title) {
91 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
92 auto iterator = notifications_.find(title); 98 auto iterator = notifications_.find(title);
93 if (iterator == notifications_.end()) 99 if (iterator == notifications_.end())
94 return; 100 return;
95 101
96 iterator->second->NotificationClosed(false); 102 iterator->second->NotificationClosed(false);
97 } 103 }
98 104
99 } // namespace content 105 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/layout_test/layout_test_notification_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698