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

Side by Side Diff: chrome/browser/extensions/api/alarms/alarms_api.cc

Issue 12093036: Move Extension Location and Type enums to Manifest, and move InstallWarning to its own file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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/extensions/api/alarms/alarms_api.h" 5 #include "chrome/browser/extensions/api/alarms/alarms_api.h"
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/extensions/api/alarms/alarm_manager.h" 9 #include "chrome/browser/extensions/api/alarms/alarm_manager.h"
10 #include "chrome/browser/extensions/extension_system.h" 10 #include "chrome/browser/extensions/extension_system.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 COMPILE_ASSERT(kReleaseDelayMinimum == 1, update_warning_message_below);
55 if (extension->location() == Extension::LOAD) 55 if (extension->location() == Manifest::LOAD)
56 warnings->push_back(ErrorUtils::FormatErrorMessage( 56 warnings->push_back(ErrorUtils::FormatErrorMessage(
57 "Alarm delay is less than minimum of 1 minutes." 57 "Alarm delay is less than minimum of 1 minutes."
58 " In released .crx, alarm \"*\" will fire in approximately" 58 " In released .crx, alarm \"*\" will fire in approximately"
59 " 1 minutes.", 59 " 1 minutes.",
60 alarm_name)); 60 alarm_name));
61 else 61 else
62 warnings->push_back(ErrorUtils::FormatErrorMessage( 62 warnings->push_back(ErrorUtils::FormatErrorMessage(
63 "Alarm delay is less than minimum of 1 minutes." 63 "Alarm delay is less than minimum of 1 minutes."
64 " Alarm \"*\" will fire in approximately 1 minutes.", 64 " Alarm \"*\" will fire in approximately 1 minutes.",
65 alarm_name)); 65 alarm_name));
66 } 66 }
67 } 67 }
68 if (create_info.period_in_minutes.get()) { 68 if (create_info.period_in_minutes.get()) {
69 if (*create_info.period_in_minutes < kReleaseDelayMinimum) { 69 if (*create_info.period_in_minutes < kReleaseDelayMinimum) {
70 COMPILE_ASSERT(kReleaseDelayMinimum == 1, update_warning_message_below); 70 COMPILE_ASSERT(kReleaseDelayMinimum == 1, update_warning_message_below);
71 if (extension->location() == Extension::LOAD) 71 if (extension->location() == Manifest::LOAD)
72 warnings->push_back(ErrorUtils::FormatErrorMessage( 72 warnings->push_back(ErrorUtils::FormatErrorMessage(
73 "Alarm period is less than minimum of 1 minutes." 73 "Alarm period is less than minimum of 1 minutes."
74 " In released .crx, alarm \"*\" will fire approximately" 74 " In released .crx, alarm \"*\" will fire approximately"
75 " every 1 minutes.", 75 " every 1 minutes.",
76 alarm_name)); 76 alarm_name));
77 else 77 else
78 warnings->push_back(ErrorUtils::FormatErrorMessage( 78 warnings->push_back(ErrorUtils::FormatErrorMessage(
79 "Alarm period is less than minimum of 1 minutes." 79 "Alarm period is less than minimum of 1 minutes."
80 " Alarm \"*\" will fire approximately every 1 minutes.", 80 " Alarm \"*\" will fire approximately every 1 minutes.",
81 alarm_name)); 81 alarm_name));
(...skipping 19 matching lines...) Expand all
101 if (!ValidateAlarmCreateInfo( 101 if (!ValidateAlarmCreateInfo(
102 alarm_name, params->alarm_info, GetExtension(), &error_, &warnings)) 102 alarm_name, params->alarm_info, GetExtension(), &error_, &warnings))
103 return false; 103 return false;
104 for (std::vector<std::string>::const_iterator it = warnings.begin(); 104 for (std::vector<std::string>::const_iterator it = warnings.begin();
105 it != warnings.end(); ++it) 105 it != warnings.end(); ++it)
106 WriteToConsole(content::CONSOLE_MESSAGE_LEVEL_WARNING, *it); 106 WriteToConsole(content::CONSOLE_MESSAGE_LEVEL_WARNING, *it);
107 107
108 Alarm alarm(alarm_name, 108 Alarm alarm(alarm_name,
109 params->alarm_info, 109 params->alarm_info,
110 base::TimeDelta::FromMinutes( 110 base::TimeDelta::FromMinutes(
111 GetExtension()->location() == Extension::LOAD ? 111 GetExtension()->location() == Manifest::LOAD ?
112 kDevDelayMinimum : kReleaseDelayMinimum), 112 kDevDelayMinimum : kReleaseDelayMinimum),
113 now_); 113 now_);
114 ExtensionSystem::Get(profile())->alarm_manager()->AddAlarm( 114 ExtensionSystem::Get(profile())->alarm_manager()->AddAlarm(
115 extension_id(), alarm); 115 extension_id(), alarm);
116 116
117 return true; 117 return true;
118 } 118 }
119 119
120 bool AlarmsGetFunction::RunImpl() { 120 bool AlarmsGetFunction::RunImpl() {
121 scoped_ptr<alarms::Get::Params> params(alarms::Get::Params::Create(*args_)); 121 scoped_ptr<alarms::Get::Params> params(alarms::Get::Params::Create(*args_));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 return true; 169 return true;
170 } 170 }
171 171
172 bool AlarmsClearAllFunction::RunImpl() { 172 bool AlarmsClearAllFunction::RunImpl() {
173 ExtensionSystem::Get(profile())->alarm_manager()->RemoveAllAlarms( 173 ExtensionSystem::Get(profile())->alarm_manager()->RemoveAllAlarms(
174 extension_id()); 174 extension_id());
175 return true; 175 return true;
176 } 176 }
177 177
178 } // namespace extensions 178 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/admin_policy_unittest.cc ('k') | chrome/browser/extensions/api/alarms/alarms_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698