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 "chromeos/dbus/power_policy_controller.h" | 5 #include "chromeos/dbus/power_policy_controller.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 battery_idle_action(ACTION_SUSPEND), | 81 battery_idle_action(ACTION_SUSPEND), |
82 lid_closed_action(ACTION_SUSPEND), | 82 lid_closed_action(ACTION_SUSPEND), |
83 use_audio_activity(true), | 83 use_audio_activity(true), |
84 use_video_activity(true), | 84 use_video_activity(true), |
85 ac_brightness_percent(-1.0), | 85 ac_brightness_percent(-1.0), |
86 battery_brightness_percent(-1.0), | 86 battery_brightness_percent(-1.0), |
87 allow_screen_wake_locks(true), | 87 allow_screen_wake_locks(true), |
88 enable_auto_screen_lock(false), | 88 enable_auto_screen_lock(false), |
89 presentation_screen_dim_delay_factor(1.0), | 89 presentation_screen_dim_delay_factor(1.0), |
90 user_activity_screen_dim_delay_factor(1.0), | 90 user_activity_screen_dim_delay_factor(1.0), |
91 wait_for_initial_user_activity(false) {} | 91 wait_for_initial_user_activity(false), |
| 92 force_nonzero_brightness_for_user_activity(true) {} |
92 | 93 |
93 // static | 94 // static |
94 std::string PowerPolicyController::GetPolicyDebugString( | 95 std::string PowerPolicyController::GetPolicyDebugString( |
95 const power_manager::PowerManagementPolicy& policy) { | 96 const power_manager::PowerManagementPolicy& policy) { |
96 std::string str; | 97 std::string str; |
97 if (policy.has_ac_delays()) | 98 if (policy.has_ac_delays()) |
98 APPEND_DELAYS(str, policy.ac_delays(), "ac"); | 99 APPEND_DELAYS(str, policy.ac_delays(), "ac"); |
99 if (policy.has_battery_delays()) | 100 if (policy.has_battery_delays()) |
100 APPEND_DELAYS(str, policy.battery_delays(), "battery"); | 101 APPEND_DELAYS(str, policy.battery_delays(), "battery"); |
101 if (policy.has_ac_idle_action()) | 102 if (policy.has_ac_idle_action()) |
(...skipping 19 matching lines...) Expand all Loading... |
121 policy.presentation_screen_dim_delay_factor()); | 122 policy.presentation_screen_dim_delay_factor()); |
122 } | 123 } |
123 if (policy.has_user_activity_screen_dim_delay_factor()) { | 124 if (policy.has_user_activity_screen_dim_delay_factor()) { |
124 str += base::StringPrintf("user_activity_screen_dim_delay_factor=%f ", | 125 str += base::StringPrintf("user_activity_screen_dim_delay_factor=%f ", |
125 policy.user_activity_screen_dim_delay_factor()); | 126 policy.user_activity_screen_dim_delay_factor()); |
126 } | 127 } |
127 if (policy.has_wait_for_initial_user_activity()) { | 128 if (policy.has_wait_for_initial_user_activity()) { |
128 str += base::StringPrintf("wait_for_initial_user_activity=%d ", | 129 str += base::StringPrintf("wait_for_initial_user_activity=%d ", |
129 policy.wait_for_initial_user_activity()); | 130 policy.wait_for_initial_user_activity()); |
130 } | 131 } |
| 132 if (policy.has_force_nonzero_brightness_for_user_activity()) { |
| 133 str += base::StringPrintf("force_nonzero_brightness_for_user_activity=%d ", |
| 134 policy.force_nonzero_brightness_for_user_activity()); |
| 135 } |
131 if (policy.has_reason()) | 136 if (policy.has_reason()) |
132 str += base::StringPrintf("reason=\"%s\" ", policy.reason().c_str()); | 137 str += base::StringPrintf("reason=\"%s\" ", policy.reason().c_str()); |
133 base::TrimWhitespace(str, base::TRIM_TRAILING, &str); | 138 base::TrimWhitespace(str, base::TRIM_TRAILING, &str); |
134 return str; | 139 return str; |
135 } | 140 } |
136 | 141 |
137 // static | 142 // static |
138 void PowerPolicyController::Initialize(PowerManagerClient* client) { | 143 void PowerPolicyController::Initialize(PowerManagerClient* client) { |
139 DCHECK(!IsInitialized()); | 144 DCHECK(!IsInitialized()); |
140 g_power_policy_controller = new PowerPolicyController(client); | 145 g_power_policy_controller = new PowerPolicyController(client); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 if (values.battery_brightness_percent >= 0.0) { | 208 if (values.battery_brightness_percent >= 0.0) { |
204 prefs_policy_.set_battery_brightness_percent( | 209 prefs_policy_.set_battery_brightness_percent( |
205 values.battery_brightness_percent); | 210 values.battery_brightness_percent); |
206 } | 211 } |
207 prefs_policy_.set_presentation_screen_dim_delay_factor( | 212 prefs_policy_.set_presentation_screen_dim_delay_factor( |
208 values.presentation_screen_dim_delay_factor); | 213 values.presentation_screen_dim_delay_factor); |
209 prefs_policy_.set_user_activity_screen_dim_delay_factor( | 214 prefs_policy_.set_user_activity_screen_dim_delay_factor( |
210 values.user_activity_screen_dim_delay_factor); | 215 values.user_activity_screen_dim_delay_factor); |
211 prefs_policy_.set_wait_for_initial_user_activity( | 216 prefs_policy_.set_wait_for_initial_user_activity( |
212 values.wait_for_initial_user_activity); | 217 values.wait_for_initial_user_activity); |
| 218 prefs_policy_.set_force_nonzero_brightness_for_user_activity( |
| 219 values.force_nonzero_brightness_for_user_activity); |
213 | 220 |
214 honor_screen_wake_locks_ = values.allow_screen_wake_locks; | 221 honor_screen_wake_locks_ = values.allow_screen_wake_locks; |
215 | 222 |
216 prefs_were_set_ = true; | 223 prefs_were_set_ = true; |
217 SendCurrentPolicy(); | 224 SendCurrentPolicy(); |
218 } | 225 } |
219 | 226 |
220 int PowerPolicyController::AddScreenWakeLock(const std::string& reason) { | 227 int PowerPolicyController::AddScreenWakeLock(const std::string& reason) { |
221 int id = next_wake_lock_id_++; | 228 int id = next_wake_lock_id_++; |
222 screen_wake_locks_[id] = reason; | 229 screen_wake_locks_[id] = reason; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 it != system_wake_locks_.end(); ++it) { | 299 it != system_wake_locks_.end(); ++it) { |
293 reason += (reason.empty() ? "" : ", ") + it->second; | 300 reason += (reason.empty() ? "" : ", ") + it->second; |
294 } | 301 } |
295 | 302 |
296 if (!reason.empty()) | 303 if (!reason.empty()) |
297 policy.set_reason(reason); | 304 policy.set_reason(reason); |
298 client_->SetPolicy(policy); | 305 client_->SetPolicy(policy); |
299 } | 306 } |
300 | 307 |
301 } // namespace chromeos | 308 } // namespace chromeos |
OLD | NEW |