OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/extensions/api/power/power_api.h" | 5 #include "chrome/browser/extensions/api/power/power_api.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 function->set_extension(extension); | 159 function->set_extension(extension); |
160 return utils::RunFunction(function.get(), args, browser(), utils::NONE); | 160 return utils::RunFunction(function.get(), args, browser(), utils::NONE); |
161 } | 161 } |
162 | 162 |
163 // Send a notification to PowerApiManager saying that |extension| has | 163 // Send a notification to PowerApiManager saying that |extension| has |
164 // been unloaded. | 164 // been unloaded. |
165 void UnloadExtension(extensions::Extension* extension) { | 165 void UnloadExtension(extensions::Extension* extension) { |
166 UnloadedExtensionInfo details( | 166 UnloadedExtensionInfo details( |
167 extension, UnloadedExtensionInfo::REASON_UNINSTALL); | 167 extension, UnloadedExtensionInfo::REASON_UNINSTALL); |
168 PowerApiManager::GetInstance()->Observe( | 168 PowerApiManager::GetInstance()->Observe( |
169 chrome::NOTIFICATION_EXTENSION_UNLOADED, | 169 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
170 content::Source<Profile>(browser()->profile()), | 170 content::Source<Profile>(browser()->profile()), |
171 content::Details<UnloadedExtensionInfo>(&details)); | 171 content::Details<UnloadedExtensionInfo>(&details)); |
172 } | 172 } |
173 | 173 |
174 scoped_ptr<PowerSaveBlockerStubManager> manager_; | 174 scoped_ptr<PowerSaveBlockerStubManager> manager_; |
175 scoped_refptr<extensions::Extension> extension_; | 175 scoped_refptr<extensions::Extension> extension_; |
176 }; | 176 }; |
177 | 177 |
178 TEST_F(PowerApiTest, RequestAndRelease) { | 178 TEST_F(PowerApiTest, RequestAndRelease) { |
179 // Simulate an extension making and releasing a "display" request and a | 179 // Simulate an extension making and releasing a "display" request and a |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 EXPECT_EQ(NONE, manager_->PopFirstRequest()); | 276 EXPECT_EQ(NONE, manager_->PopFirstRequest()); |
277 | 277 |
278 // Make the first extension block display-sleep again. | 278 // Make the first extension block display-sleep again. |
279 ASSERT_TRUE(CallFunction(REQUEST, kDisplayArgs, extension_.get())); | 279 ASSERT_TRUE(CallFunction(REQUEST, kDisplayArgs, extension_.get())); |
280 EXPECT_EQ(BLOCK_DISPLAY_SLEEP, manager_->PopFirstRequest()); | 280 EXPECT_EQ(BLOCK_DISPLAY_SLEEP, manager_->PopFirstRequest()); |
281 EXPECT_EQ(UNBLOCK_APP_SUSPENSION, manager_->PopFirstRequest()); | 281 EXPECT_EQ(UNBLOCK_APP_SUSPENSION, manager_->PopFirstRequest()); |
282 EXPECT_EQ(NONE, manager_->PopFirstRequest()); | 282 EXPECT_EQ(NONE, manager_->PopFirstRequest()); |
283 } | 283 } |
284 | 284 |
285 } // namespace extensions | 285 } // namespace extensions |
OLD | NEW |