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

Side by Side Diff: chrome/browser/chromeos/extensions/power/power_api_manager.cc

Issue 10968064: Move the NOTIFICATION_APP_TERMINATING notification from content to chrome, since it's fired by chro… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: cros compile Created 8 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 | Annotate | Revision Log
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 "chrome/browser/chromeos/extensions/power/power_api_manager.h" 5 #include "chrome/browser/chromeos/extensions/power/power_api_manager.h"
6 6
7 #include "chrome/common/chrome_notification_types.h" 7 #include "chrome/common/chrome_notification_types.h"
8 #include "chrome/common/extensions/extension.h" 8 #include "chrome/common/extensions/extension.h"
9 #include "chromeos/power/power_state_override.h" 9 #include "chromeos/power/power_state_override.h"
10 #include "content/public/browser/notification_service.h" 10 #include "content/public/browser/notification_service.h"
(...skipping 17 matching lines...) Expand all
28 } 28 }
29 29
30 void PowerApiManager::Observe(int type, 30 void PowerApiManager::Observe(int type,
31 const content::NotificationSource& source, 31 const content::NotificationSource& source,
32 const content::NotificationDetails& details) { 32 const content::NotificationDetails& details) {
33 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { 33 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) {
34 RemoveExtensionLock( 34 RemoveExtensionLock(
35 content::Details<extensions::UnloadedExtensionInfo>(details)-> 35 content::Details<extensions::UnloadedExtensionInfo>(details)->
36 extension->id()); 36 extension->id());
37 UpdatePowerSettings(); 37 UpdatePowerSettings();
38 } else if (type == content::NOTIFICATION_APP_TERMINATING) { 38 } else if (type == chrome::NOTIFICATION_APP_TERMINATING) {
39 // If the Chrome app is terminating, ensure we release our power overrides. 39 // If the Chrome app is terminating, ensure we release our power overrides.
40 power_state_override_.reset(NULL); 40 power_state_override_.reset(NULL);
41 } else { 41 } else {
42 NOTREACHED() << "Unexpected notification " << type; 42 NOTREACHED() << "Unexpected notification " << type;
43 } 43 }
44 } 44 }
45 45
46 PowerApiManager::PowerApiManager() 46 PowerApiManager::PowerApiManager()
47 : power_state_override_(NULL) { 47 : power_state_override_(NULL) {
48 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 48 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
49 content::NotificationService::AllSources()); 49 content::NotificationService::AllSources());
50 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, 50 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING,
51 content::NotificationService::AllSources()); 51 content::NotificationService::AllSources());
52 UpdatePowerSettings(); 52 UpdatePowerSettings();
53 } 53 }
54 54
55 PowerApiManager::~PowerApiManager() {} 55 PowerApiManager::~PowerApiManager() {}
56 56
57 void PowerApiManager::UpdatePowerSettings() { 57 void PowerApiManager::UpdatePowerSettings() {
58 // If we have a wake lock and don't have the power state overriden. 58 // If we have a wake lock and don't have the power state overriden.
59 if (extension_ids_set_.size() && !power_state_override_.get()) { 59 if (extension_ids_set_.size() && !power_state_override_.get()) {
60 power_state_override_.reset(new chromeos::PowerStateOverride( 60 power_state_override_.reset(new chromeos::PowerStateOverride(
61 chromeos::PowerStateOverride::BLOCK_DISPLAY_SLEEP)); 61 chromeos::PowerStateOverride::BLOCK_DISPLAY_SLEEP));
62 // else, if we don't have any wake locks and do have a power override. 62 // else, if we don't have any wake locks and do have a power override.
63 } else if (extension_ids_set_.empty() && power_state_override_.get()) { 63 } else if (extension_ids_set_.empty() && power_state_override_.get()) {
64 power_state_override_.reset(NULL); 64 power_state_override_.reset(NULL);
65 } 65 }
66 } 66 }
67 67
68 } // namespace power 68 } // namespace power
69 } // namespace extensions 69 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/background/background_mode_manager.cc ('k') | chrome/browser/chromeos/input_method/browser_state_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698