OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 service->BackgroundContentsOpened(&details, profile_); | 83 service->BackgroundContentsOpened(&details, profile_); |
84 } | 84 } |
85 | 85 |
86 virtual void Navigate(GURL url) { | 86 virtual void Navigate(GURL url) { |
87 url_ = url; | 87 url_ = url; |
88 content::NotificationService::current()->Notify( | 88 content::NotificationService::current()->Notify( |
89 chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, | 89 chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, |
90 content::Source<Profile>(profile_), | 90 content::Source<Profile>(profile_), |
91 content::Details<BackgroundContents>(this)); | 91 content::Details<BackgroundContents>(this)); |
92 } | 92 } |
93 virtual const GURL& GetURL() const OVERRIDE { return url_; } | 93 virtual const GURL& GetURL() const override { return url_; } |
94 | 94 |
95 void MockClose(Profile* profile) { | 95 void MockClose(Profile* profile) { |
96 content::NotificationService::current()->Notify( | 96 content::NotificationService::current()->Notify( |
97 chrome::NOTIFICATION_BACKGROUND_CONTENTS_CLOSED, | 97 chrome::NOTIFICATION_BACKGROUND_CONTENTS_CLOSED, |
98 content::Source<Profile>(profile), | 98 content::Source<Profile>(profile), |
99 content::Details<BackgroundContents>(this)); | 99 content::Details<BackgroundContents>(this)); |
100 delete this; | 100 delete this; |
101 } | 101 } |
102 | 102 |
103 virtual ~MockBackgroundContents() { | 103 virtual ~MockBackgroundContents() { |
(...skipping 29 matching lines...) Expand all Loading... |
133 message_center::MessageCenter::Get(); | 133 message_center::MessageCenter::Get(); |
134 | 134 |
135 message_center->AddObserver(this); | 135 message_center->AddObserver(this); |
136 run_loop_.Run(); | 136 run_loop_.Run(); |
137 message_center->RemoveObserver(this); | 137 message_center->RemoveObserver(this); |
138 } | 138 } |
139 | 139 |
140 private: | 140 private: |
141 // message_center::MessageCenterObserver overrides: | 141 // message_center::MessageCenterObserver overrides: |
142 virtual void OnNotificationAdded( | 142 virtual void OnNotificationAdded( |
143 const std::string& notification_id) OVERRIDE { | 143 const std::string& notification_id) override { |
144 if (notification_id == FindNotificationIdFromDelegateId(target_id_)) | 144 if (notification_id == FindNotificationIdFromDelegateId(target_id_)) |
145 run_loop_.Quit(); | 145 run_loop_.Quit(); |
146 } | 146 } |
147 | 147 |
148 virtual void OnNotificationUpdated( | 148 virtual void OnNotificationUpdated( |
149 const std::string& notification_id) OVERRIDE { | 149 const std::string& notification_id) override { |
150 if (notification_id == FindNotificationIdFromDelegateId(target_id_)) | 150 if (notification_id == FindNotificationIdFromDelegateId(target_id_)) |
151 run_loop_.Quit(); | 151 run_loop_.Quit(); |
152 } | 152 } |
153 | 153 |
154 std::string FindNotificationIdFromDelegateId(const std::string& delegate_id) { | 154 std::string FindNotificationIdFromDelegateId(const std::string& delegate_id) { |
155 MessageCenterNotificationManager* manager = | 155 MessageCenterNotificationManager* manager = |
156 static_cast<MessageCenterNotificationManager*>( | 156 static_cast<MessageCenterNotificationManager*>( |
157 g_browser_process->notification_ui_manager()); | 157 g_browser_process->notification_ui_manager()); |
158 DCHECK(manager); | 158 DCHECK(manager); |
159 return manager->FindById(delegate_id, profile_)->id(); | 159 return manager->FindById(delegate_id, profile_)->id(); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 CreateCrashNotification(extension); | 387 CreateCrashNotification(extension); |
388 CreateCrashNotification(extension); | 388 CreateCrashNotification(extension); |
389 | 389 |
390 message_center::MessageCenter* message_center = | 390 message_center::MessageCenter* message_center = |
391 message_center::MessageCenter::Get(); | 391 message_center::MessageCenter::Get(); |
392 message_center::NotificationList::Notifications notifications = | 392 message_center::NotificationList::Notifications notifications = |
393 message_center->GetVisibleNotifications(); | 393 message_center->GetVisibleNotifications(); |
394 ASSERT_EQ(1u, notifications.size()); | 394 ASSERT_EQ(1u, notifications.size()); |
395 } | 395 } |
396 #endif | 396 #endif |
OLD | NEW |