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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 bool CallFunction(FunctionType type, | 150 bool CallFunction(FunctionType type, |
151 const std::string& args, | 151 const std::string& args, |
152 extensions::Extension* extension) { | 152 extensions::Extension* extension) { |
153 scoped_refptr<UIThreadExtensionFunction> function( | 153 scoped_refptr<UIThreadExtensionFunction> function( |
154 type == REQUEST ? | 154 type == REQUEST ? |
155 static_cast<UIThreadExtensionFunction*>( | 155 static_cast<UIThreadExtensionFunction*>( |
156 new PowerRequestKeepAwakeFunction) : | 156 new PowerRequestKeepAwakeFunction) : |
157 static_cast<UIThreadExtensionFunction*>( | 157 static_cast<UIThreadExtensionFunction*>( |
158 new PowerReleaseKeepAwakeFunction)); | 158 new PowerReleaseKeepAwakeFunction)); |
159 function->set_extension(extension); | 159 function->set_extension(extension); |
160 return utils::RunFunction(function, 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, extension_misc::UNLOAD_REASON_UNINSTALL); | 167 extension, extension_misc::UNLOAD_REASON_UNINSTALL); |
168 PowerApiManager::GetInstance()->Observe( | 168 PowerApiManager::GetInstance()->Observe( |
169 chrome::NOTIFICATION_EXTENSION_UNLOADED, | 169 chrome::NOTIFICATION_EXTENSION_UNLOADED, |
170 content::Source<Profile>(browser()->profile()), | 170 content::Source<Profile>(browser()->profile()), |
(...skipping 105 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 |