OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_history_api.h" | 5 #include "chrome/browser/extensions/extension_history_api.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 if (!temp_url.is_valid()) { | 169 if (!temp_url.is_valid()) { |
170 error_ = keys::kInvalidUrlError; | 170 error_ = keys::kInvalidUrlError; |
171 return false; | 171 return false; |
172 } | 172 } |
173 url->Swap(&temp_url); | 173 url->Swap(&temp_url); |
174 return true; | 174 return true; |
175 } | 175 } |
176 | 176 |
177 bool HistoryFunction::GetTimeFromValue(Value* value, base::Time* time) { | 177 bool HistoryFunction::GetTimeFromValue(Value* value, base::Time* time) { |
178 double ms_from_epoch = 0.0; | 178 double ms_from_epoch = 0.0; |
179 if (!value->GetAsDouble(&ms_from_epoch)) { | 179 if (!value->GetAsDouble(&ms_from_epoch)) |
180 int ms_from_epoch_as_int = 0; | 180 return false; |
181 if (!value->GetAsInteger(&ms_from_epoch_as_int)) | |
182 return false; | |
183 ms_from_epoch = static_cast<double>(ms_from_epoch_as_int); | |
184 } | |
185 // The history service has seconds resolution, while javascript Date() has | 181 // The history service has seconds resolution, while javascript Date() has |
186 // milliseconds resolution. | 182 // milliseconds resolution. |
187 double seconds_from_epoch = ms_from_epoch / 1000.0; | 183 double seconds_from_epoch = ms_from_epoch / 1000.0; |
188 // Time::FromDoubleT converts double time 0 to empty Time object. So we need | 184 // Time::FromDoubleT converts double time 0 to empty Time object. So we need |
189 // to do special handling here. | 185 // to do special handling here. |
190 *time = (seconds_from_epoch == 0) ? | 186 *time = (seconds_from_epoch == 0) ? |
191 base::Time::UnixEpoch() : base::Time::FromDoubleT(seconds_from_epoch); | 187 base::Time::UnixEpoch() : base::Time::FromDoubleT(seconds_from_epoch); |
192 return true; | 188 return true; |
193 } | 189 } |
194 | 190 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 base::Time::Now(), // To the current time. | 376 base::Time::Now(), // To the current time. |
381 &cancelable_consumer_, | 377 &cancelable_consumer_, |
382 NewCallback(this, &DeleteAllHistoryFunction::DeleteComplete)); | 378 NewCallback(this, &DeleteAllHistoryFunction::DeleteComplete)); |
383 | 379 |
384 return true; | 380 return true; |
385 } | 381 } |
386 | 382 |
387 void DeleteAllHistoryFunction::DeleteComplete() { | 383 void DeleteAllHistoryFunction::DeleteComplete() { |
388 SendAsyncResponse(); | 384 SendAsyncResponse(); |
389 } | 385 } |
OLD | NEW |