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

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

Issue 794633002: Remove ShowDesktopNotificationHostMsgParams in favor of PlatformNotificationData. (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
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/platform_notification_data.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( 20 LayoutTestNotificationManager::CheckPermission(
(...skipping 21 matching lines...) Expand all
42 permission_map_[origin] = permission; 42 permission_map_[origin] = permission;
43 } 43 }
44 44
45 void LayoutTestNotificationManager::ClearPermissions() { 45 void LayoutTestNotificationManager::ClearPermissions() {
46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
47 permission_map_.clear(); 47 permission_map_.clear();
48 } 48 }
49 49
50 void LayoutTestNotificationManager::DisplayNotification( 50 void LayoutTestNotificationManager::DisplayNotification(
51 BrowserContext* browser_context, 51 BrowserContext* browser_context,
52 const ShowDesktopNotificationHostMsgParams& params, 52 const GURL& origin,
53 const SkBitmap& icon,
54 const PlatformNotificationData& notification_data,
53 scoped_ptr<DesktopNotificationDelegate> delegate, 55 scoped_ptr<DesktopNotificationDelegate> delegate,
54 int render_process_id, 56 int render_process_id,
55 base::Closure* cancel_callback) { 57 base::Closure* cancel_callback) {
56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
57 std::string title = base::UTF16ToUTF8(params.title); 59 std::string title = base::UTF16ToUTF8(notification_data.title);
58 60
59 DCHECK(cancel_callback); 61 DCHECK(cancel_callback);
60 *cancel_callback = base::Bind(&LayoutTestNotificationManager::Close, 62 *cancel_callback = base::Bind(&LayoutTestNotificationManager::Close,
61 weak_factory_.GetWeakPtr(), 63 weak_factory_.GetWeakPtr(),
62 title); 64 title);
63 65
64 if (params.replace_id.length()) { 66 if (notification_data.tag.length()) {
65 std::string replace_id = base::UTF16ToUTF8(params.replace_id); 67 std::string replace_id = base::UTF16ToUTF8(notification_data.tag);
66 auto replace_iter = replacements_.find(replace_id); 68 auto replace_iter = replacements_.find(replace_id);
67 if (replace_iter != replacements_.end()) { 69 if (replace_iter != replacements_.end()) {
68 const std::string& previous_title = replace_iter->second; 70 const std::string& previous_title = replace_iter->second;
69 auto notification_iter = notifications_.find(previous_title); 71 auto notification_iter = notifications_.find(previous_title);
70 if (notification_iter != notifications_.end()) { 72 if (notification_iter != notifications_.end()) {
71 DesktopNotificationDelegate* previous_delegate = 73 DesktopNotificationDelegate* previous_delegate =
72 notification_iter->second; 74 notification_iter->second;
73 previous_delegate->NotificationClosed(false); 75 previous_delegate->NotificationClosed(false);
74 76
75 notifications_.erase(notification_iter); 77 notifications_.erase(notification_iter);
76 delete previous_delegate; 78 delete previous_delegate;
77 } 79 }
78 } 80 }
79 81
80 replacements_[replace_id] = title; 82 replacements_[replace_id] = title;
81 } 83 }
82 84
83 notifications_[title] = delegate.release(); 85 notifications_[title] = delegate.release();
84 notifications_[title]->NotificationDisplayed(); 86 notifications_[title]->NotificationDisplayed();
85 } 87 }
86 88
87 void LayoutTestNotificationManager::DisplayPersistentNotification( 89 void LayoutTestNotificationManager::DisplayPersistentNotification(
88 BrowserContext* browser_context, 90 BrowserContext* browser_context,
89 int64 service_worker_registration_id, 91 int64 service_worker_registration_id,
90 const ShowDesktopNotificationHostMsgParams& params, 92 const GURL& origin,
93 const SkBitmap& icon,
94 const PlatformNotificationData& platform_notification_data,
91 int render_process_id) { 95 int render_process_id) {
92 // TODO(peter): Make persistent notifications layout testable. 96 // TODO(peter): Make persistent notifications layout testable.
93 NOTIMPLEMENTED(); 97 NOTIMPLEMENTED();
94 } 98 }
95 99
96 void LayoutTestNotificationManager::ClosePersistentNotification( 100 void LayoutTestNotificationManager::ClosePersistentNotification(
97 BrowserContext* browser_context, 101 BrowserContext* browser_context,
98 const std::string& persistent_notification_id) { 102 const std::string& persistent_notification_id) {
99 // TODO(peter): Make persistent notifications layout testable. 103 // TODO(peter): Make persistent notifications layout testable.
100 NOTIMPLEMENTED(); 104 NOTIMPLEMENTED();
(...skipping 11 matching lines...) Expand all
112 void LayoutTestNotificationManager::Close(const std::string& title) { 116 void LayoutTestNotificationManager::Close(const std::string& title) {
113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
114 auto iterator = notifications_.find(title); 118 auto iterator = notifications_.find(title);
115 if (iterator == notifications_.end()) 119 if (iterator == notifications_.end())
116 return; 120 return;
117 121
118 iterator->second->NotificationClosed(false); 122 iterator->second->NotificationClosed(false);
119 } 123 }
120 124
121 } // namespace content 125 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698