| 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/api/alarms/alarms_api.h" | 5 #include "chrome/browser/extensions/api/alarms/alarms_api.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/time/clock.h" | 8 #include "base/time/clock.h" |
| 9 #include "base/time/default_clock.h" | 9 #include "base/time/default_clock.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 } | 44 } |
| 45 | 45 |
| 46 // Users can always use an absolute timeout to request an arbitrarily-short or | 46 // Users can always use an absolute timeout to request an arbitrarily-short or |
| 47 // negative delay. We won't honor the short timeout, but we can't check it | 47 // negative delay. We won't honor the short timeout, but we can't check it |
| 48 // and warn the user because it would introduce race conditions (say they | 48 // and warn the user because it would introduce race conditions (say they |
| 49 // compute a long-enough timeout, but then the call into the alarms interface | 49 // compute a long-enough timeout, but then the call into the alarms interface |
| 50 // gets delayed past the boundary). However, it's still worth warning about | 50 // gets delayed past the boundary). However, it's still worth warning about |
| 51 // relative delays that are shorter than we'll honor. | 51 // relative delays that are shorter than we'll honor. |
| 52 if (create_info.delay_in_minutes.get()) { | 52 if (create_info.delay_in_minutes.get()) { |
| 53 if (*create_info.delay_in_minutes < kReleaseDelayMinimum) { | 53 if (*create_info.delay_in_minutes < kReleaseDelayMinimum) { |
| 54 COMPILE_ASSERT(kReleaseDelayMinimum == 1, update_warning_message_below); | 54 static_assert(kReleaseDelayMinimum == 1, |
| 55 "warning message must be updated"); |
| 55 if (Manifest::IsUnpackedLocation(extension->location())) | 56 if (Manifest::IsUnpackedLocation(extension->location())) |
| 56 warnings->push_back(ErrorUtils::FormatErrorMessage( | 57 warnings->push_back(ErrorUtils::FormatErrorMessage( |
| 57 "Alarm delay is less than minimum of 1 minutes." | 58 "Alarm delay is less than minimum of 1 minutes." |
| 58 " In released .crx, alarm \"*\" will fire in approximately" | 59 " In released .crx, alarm \"*\" will fire in approximately" |
| 59 " 1 minutes.", | 60 " 1 minutes.", |
| 60 alarm_name)); | 61 alarm_name)); |
| 61 else | 62 else |
| 62 warnings->push_back(ErrorUtils::FormatErrorMessage( | 63 warnings->push_back(ErrorUtils::FormatErrorMessage( |
| 63 "Alarm delay is less than minimum of 1 minutes." | 64 "Alarm delay is less than minimum of 1 minutes." |
| 64 " Alarm \"*\" will fire in approximately 1 minutes.", | 65 " Alarm \"*\" will fire in approximately 1 minutes.", |
| 65 alarm_name)); | 66 alarm_name)); |
| 66 } | 67 } |
| 67 } | 68 } |
| 68 if (create_info.period_in_minutes.get()) { | 69 if (create_info.period_in_minutes.get()) { |
| 69 if (*create_info.period_in_minutes < kReleaseDelayMinimum) { | 70 if (*create_info.period_in_minutes < kReleaseDelayMinimum) { |
| 70 COMPILE_ASSERT(kReleaseDelayMinimum == 1, update_warning_message_below); | 71 static_assert(kReleaseDelayMinimum == 1, |
| 72 "warning message must be updated"); |
| 71 if (Manifest::IsUnpackedLocation(extension->location())) | 73 if (Manifest::IsUnpackedLocation(extension->location())) |
| 72 warnings->push_back(ErrorUtils::FormatErrorMessage( | 74 warnings->push_back(ErrorUtils::FormatErrorMessage( |
| 73 "Alarm period is less than minimum of 1 minutes." | 75 "Alarm period is less than minimum of 1 minutes." |
| 74 " In released .crx, alarm \"*\" will fire approximately" | 76 " In released .crx, alarm \"*\" will fire approximately" |
| 75 " every 1 minutes.", | 77 " every 1 minutes.", |
| 76 alarm_name)); | 78 alarm_name)); |
| 77 else | 79 else |
| 78 warnings->push_back(ErrorUtils::FormatErrorMessage( | 80 warnings->push_back(ErrorUtils::FormatErrorMessage( |
| 79 "Alarm period is less than minimum of 1 minutes." | 81 "Alarm period is less than minimum of 1 minutes." |
| 80 " Alarm \"*\" will fire approximately every 1 minutes.", | 82 " Alarm \"*\" will fire approximately every 1 minutes.", |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 extension_id(), base::Bind(&AlarmsClearAllFunction::Callback, this)); | 197 extension_id(), base::Bind(&AlarmsClearAllFunction::Callback, this)); |
| 196 return true; | 198 return true; |
| 197 } | 199 } |
| 198 | 200 |
| 199 void AlarmsClearAllFunction::Callback() { | 201 void AlarmsClearAllFunction::Callback() { |
| 200 SetResult(new base::FundamentalValue(true)); | 202 SetResult(new base::FundamentalValue(true)); |
| 201 SendResponse(true); | 203 SendResponse(true); |
| 202 } | 204 } |
| 203 | 205 |
| 204 } // namespace extensions | 206 } // namespace extensions |
| OLD | NEW |