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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
10 #include "chrome/browser/extensions/extension_host.h" | 10 #include "chrome/browser/extensions/extension_host.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 NotificationListener() : started_(false), finished_(false) { | 173 NotificationListener() : started_(false), finished_(false) { |
174 int types[] = { | 174 int types[] = { |
175 chrome::NOTIFICATION_EXTENSION_UPDATING_STARTED, | 175 chrome::NOTIFICATION_EXTENSION_UPDATING_STARTED, |
176 chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND | 176 chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND |
177 }; | 177 }; |
178 for (size_t i = 0; i < arraysize(types); i++) { | 178 for (size_t i = 0; i < arraysize(types); i++) { |
179 registrar_.Add( | 179 registrar_.Add( |
180 this, types[i], content::NotificationService::AllSources()); | 180 this, types[i], content::NotificationService::AllSources()); |
181 } | 181 } |
182 } | 182 } |
183 ~NotificationListener() {} | 183 virtual ~NotificationListener() {} |
184 | 184 |
185 bool started() { return started_; } | 185 bool started() { return started_; } |
186 | 186 |
187 bool finished() { return finished_; } | 187 bool finished() { return finished_; } |
188 | 188 |
189 const std::set<std::string>& updates() { return updates_; } | 189 const std::set<std::string>& updates() { return updates_; } |
190 | 190 |
191 void Reset() { | 191 void Reset() { |
192 started_ = false; | 192 started_ = false; |
193 finished_ = false; | 193 finished_ = false; |
194 updates_.clear(); | 194 updates_.clear(); |
195 } | 195 } |
196 | 196 |
197 // Implements content::NotificationObserver interface. | 197 // Implements content::NotificationObserver interface. |
198 virtual void Observe(int type, | 198 virtual void Observe(int type, |
199 const content::NotificationSource& source, | 199 const content::NotificationSource& source, |
200 const content::NotificationDetails& details) { | 200 const content::NotificationDetails& details) OVERRIDE { |
201 switch (type) { | 201 switch (type) { |
202 case chrome::NOTIFICATION_EXTENSION_UPDATING_STARTED: { | 202 case chrome::NOTIFICATION_EXTENSION_UPDATING_STARTED: { |
203 EXPECT_FALSE(started_); | 203 EXPECT_FALSE(started_); |
204 started_ = true; | 204 started_ = true; |
205 break; | 205 break; |
206 } | 206 } |
207 case chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND: { | 207 case chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND: { |
208 const std::string& id = | 208 const std::string& id = |
209 content::Details<extensions::UpdateDetails>(details)->id; | 209 content::Details<extensions::UpdateDetails>(details)->id; |
210 updates_.insert(id); | 210 updates_.insert(id); |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 forcelist, kExtensionId, "http://localhost/autoupdate/manifest"); | 643 forcelist, kExtensionId, "http://localhost/autoupdate/manifest"); |
644 } | 644 } |
645 ASSERT_TRUE(WaitForExtensionInstall()); | 645 ASSERT_TRUE(WaitForExtensionInstall()); |
646 ASSERT_EQ(size_before + 1, service->extensions()->size()); | 646 ASSERT_EQ(size_before + 1, service->extensions()->size()); |
647 extension = service->GetExtensionById(kExtensionId, false); | 647 extension = service->GetExtensionById(kExtensionId, false); |
648 ASSERT_TRUE(extension); | 648 ASSERT_TRUE(extension); |
649 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); | 649 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); |
650 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); | 650 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); |
651 EXPECT_TRUE(service->disabled_extensions()->is_empty()); | 651 EXPECT_TRUE(service->disabled_extensions()->is_empty()); |
652 } | 652 } |
OLD | NEW |