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 "chrome/browser/extensions/system/system_api.h" | 5 #include "chrome/browser/extensions/system/system_api.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/extension_event_router.h" | 9 #include "chrome/browser/extensions/extension_event_router.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } // namespace | 66 } // namespace |
67 | 67 |
68 namespace extensions { | 68 namespace extensions { |
69 | 69 |
70 bool GetIncognitoModeAvailabilityFunction::RunImpl() { | 70 bool GetIncognitoModeAvailabilityFunction::RunImpl() { |
71 PrefService* prefs = profile_->GetPrefs(); | 71 PrefService* prefs = profile_->GetPrefs(); |
72 int value = prefs->GetInteger(prefs::kIncognitoModeAvailability); | 72 int value = prefs->GetInteger(prefs::kIncognitoModeAvailability); |
73 EXTENSION_FUNCTION_VALIDATE( | 73 EXTENSION_FUNCTION_VALIDATE( |
74 value >= 0 && | 74 value >= 0 && |
75 value < static_cast<int>(arraysize(kIncognitoModeAvailabilityStrings))); | 75 value < static_cast<int>(arraysize(kIncognitoModeAvailabilityStrings))); |
76 result_.reset( | 76 SetResult(Value::CreateStringValue(kIncognitoModeAvailabilityStrings[value])); |
77 Value::CreateStringValue(kIncognitoModeAvailabilityStrings[value])); | |
78 return true; | 77 return true; |
79 } | 78 } |
80 | 79 |
81 bool GetUpdateStatusFunction::RunImpl() { | 80 bool GetUpdateStatusFunction::RunImpl() { |
82 std::string state; | 81 std::string state; |
83 double download_progress = 0; | 82 double download_progress = 0; |
84 #if defined(OS_CHROMEOS) | 83 #if defined(OS_CHROMEOS) |
85 // With UpdateEngineClient, we can provide more detailed information about | 84 // With UpdateEngineClient, we can provide more detailed information about |
86 // system updates on ChromeOS. | 85 // system updates on ChromeOS. |
87 const chromeos::UpdateEngineClient::Status status = | 86 const chromeos::UpdateEngineClient::Status status = |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 if (UpgradeDetector::GetInstance()->notify_upgrade()) { | 126 if (UpgradeDetector::GetInstance()->notify_upgrade()) { |
128 state = kNeedRestartState; | 127 state = kNeedRestartState; |
129 download_progress = 1; | 128 download_progress = 1; |
130 } else { | 129 } else { |
131 state = kNotAvailableState; | 130 state = kNotAvailableState; |
132 } | 131 } |
133 #endif | 132 #endif |
134 DictionaryValue* dict = new DictionaryValue(); | 133 DictionaryValue* dict = new DictionaryValue(); |
135 dict->SetString(kStateKey, state); | 134 dict->SetString(kStateKey, state); |
136 dict->SetDouble(kDownloadProgressKey, download_progress); | 135 dict->SetDouble(kDownloadProgressKey, download_progress); |
137 result_.reset(dict); | 136 SetResult(dict); |
138 | 137 |
139 return true; | 138 return true; |
140 } | 139 } |
141 | 140 |
142 void DispatchVolumeChangedEvent(double volume, bool is_volume_muted) { | 141 void DispatchVolumeChangedEvent(double volume, bool is_volume_muted) { |
143 ListValue args; | 142 ListValue args; |
144 DictionaryValue* dict = new DictionaryValue(); | 143 DictionaryValue* dict = new DictionaryValue(); |
145 dict->SetDouble(kVolumeKey, volume); | 144 dict->SetDouble(kVolumeKey, volume); |
146 dict->SetBoolean(kIsVolumeMutedKey, is_volume_muted); | 145 dict->SetBoolean(kIsVolumeMutedKey, is_volume_muted); |
147 args.Append(dict); | 146 args.Append(dict); |
(...skipping 13 matching lines...) Expand all Loading... |
161 ListValue args; | 160 ListValue args; |
162 DispatchEvent(kOnScreenUnlocked, args); | 161 DispatchEvent(kOnScreenUnlocked, args); |
163 } | 162 } |
164 | 163 |
165 void DispatchWokeUpEvent() { | 164 void DispatchWokeUpEvent() { |
166 ListValue args; | 165 ListValue args; |
167 DispatchEvent(kOnWokeUp, args); | 166 DispatchEvent(kOnWokeUp, args); |
168 } | 167 } |
169 | 168 |
170 } // namespace extensions | 169 } // namespace extensions |
OLD | NEW |