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

Side by Side Diff: chrome/browser/background/background_contents_service_unittest.cc

Issue 648653003: Standardize usage of virtual/override/final in chrome/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
OLDNEW
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
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 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 ~MockBackgroundContents() override {
104 content::NotificationService::current()->Notify( 104 content::NotificationService::current()->Notify(
105 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, 105 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED,
106 content::Source<Profile>(profile_), 106 content::Source<Profile>(profile_),
107 content::Details<BackgroundContents>(this)); 107 content::Details<BackgroundContents>(this));
108 } 108 }
109 109
110 const base::string16& appid() { return appid_; } 110 const base::string16& appid() { return appid_; }
111 111
112 private: 112 private:
113 GURL url_; 113 GURL url_;
114 114
115 // The ID of our parent application 115 // The ID of our parent application
116 base::string16 appid_; 116 base::string16 appid_;
117 117
118 // Parent profile 118 // Parent profile
119 Profile* profile_; 119 Profile* profile_;
120 }; 120 };
121 121
122 #if defined(ENABLE_NOTIFICATIONS) 122 #if defined(ENABLE_NOTIFICATIONS)
123 // Wait for the notification created. 123 // Wait for the notification created.
124 class NotificationWaiter : public message_center::MessageCenterObserver { 124 class NotificationWaiter : public message_center::MessageCenterObserver {
125 public: 125 public:
126 explicit NotificationWaiter(const std::string& target_id, Profile* profile) 126 explicit NotificationWaiter(const std::string& target_id, Profile* profile)
127 : target_id_(target_id), profile_(profile) {} 127 : target_id_(target_id), profile_(profile) {}
128 virtual ~NotificationWaiter() {} 128 ~NotificationWaiter() override {}
129 129
130 void WaitForNotificationAdded() { 130 void WaitForNotificationAdded() {
131 DCHECK(!run_loop_.running()); 131 DCHECK(!run_loop_.running());
132 message_center::MessageCenter* message_center = 132 message_center::MessageCenter* message_center =
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 void OnNotificationAdded(const std::string& notification_id) override {
143 const std::string& notification_id) override {
144 if (notification_id == FindNotificationIdFromDelegateId(target_id_)) 143 if (notification_id == FindNotificationIdFromDelegateId(target_id_))
145 run_loop_.Quit(); 144 run_loop_.Quit();
146 } 145 }
147 146
148 virtual void OnNotificationUpdated( 147 void OnNotificationUpdated(const std::string& notification_id) override {
149 const std::string& notification_id) override {
150 if (notification_id == FindNotificationIdFromDelegateId(target_id_)) 148 if (notification_id == FindNotificationIdFromDelegateId(target_id_))
151 run_loop_.Quit(); 149 run_loop_.Quit();
152 } 150 }
153 151
154 std::string FindNotificationIdFromDelegateId(const std::string& delegate_id) { 152 std::string FindNotificationIdFromDelegateId(const std::string& delegate_id) {
155 MessageCenterNotificationManager* manager = 153 MessageCenterNotificationManager* manager =
156 static_cast<MessageCenterNotificationManager*>( 154 static_cast<MessageCenterNotificationManager*>(
157 g_browser_process->notification_ui_manager()); 155 g_browser_process->notification_ui_manager());
158 DCHECK(manager); 156 DCHECK(manager);
159 return manager->FindById(delegate_id, profile_)->id(); 157 return manager->FindById(delegate_id, profile_)->id();
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 CreateCrashNotification(extension); 385 CreateCrashNotification(extension);
388 CreateCrashNotification(extension); 386 CreateCrashNotification(extension);
389 387
390 message_center::MessageCenter* message_center = 388 message_center::MessageCenter* message_center =
391 message_center::MessageCenter::Get(); 389 message_center::MessageCenter::Get();
392 message_center::NotificationList::Notifications notifications = 390 message_center::NotificationList::Notifications notifications =
393 message_center->GetVisibleNotifications(); 391 message_center->GetVisibleNotifications();
394 ASSERT_EQ(1u, notifications.size()); 392 ASSERT_EQ(1u, notifications.size());
395 } 393 }
396 #endif 394 #endif
OLDNEW
« no previous file with comments | « chrome/browser/background/background_contents_service_factory.h ('k') | chrome/browser/background/background_mode_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698