Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ui/webui/browsing_history_handler.h" | 5 #include "chrome/browser/ui/webui/browsing_history_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
| 15 #include "base/i18n/time_formatting.h" | 15 #include "base/i18n/time_formatting.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
| 18 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
| 19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/time/default_clock.h" | |
| 21 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 22 #include "base/values.h" | 23 #include "base/values.h" |
| 23 #include "chrome/browser/banners/app_banner_settings_helper.h" | 24 #include "chrome/browser/banners/app_banner_settings_helper.h" |
| 24 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 25 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 25 #include "chrome/browser/engagement/site_engagement_service.h" | 26 #include "chrome/browser/engagement/site_engagement_service.h" |
| 26 #include "chrome/browser/favicon/fallback_icon_service_factory.h" | 27 #include "chrome/browser/favicon/fallback_icon_service_factory.h" |
| 27 #include "chrome/browser/favicon/large_icon_service_factory.h" | 28 #include "chrome/browser/favicon/large_icon_service_factory.h" |
| 28 #include "chrome/browser/history/history_service_factory.h" | 29 #include "chrome/browser/history/history_service_factory.h" |
| 29 #include "chrome/browser/history/history_utils.h" | 30 #include "chrome/browser/history/history_utils.h" |
| 30 #include "chrome/browser/history/web_history_service_factory.h" | 31 #include "chrome/browser/history/web_history_service_factory.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 NUM_WEB_HISTORY_QUERY_BUCKETS | 99 NUM_WEB_HISTORY_QUERY_BUCKETS |
| 99 }; | 100 }; |
| 100 | 101 |
| 101 // Identifiers for the type of device from which a history entry originated. | 102 // Identifiers for the type of device from which a history entry originated. |
| 102 static const char kDeviceTypeLaptop[] = "laptop"; | 103 static const char kDeviceTypeLaptop[] = "laptop"; |
| 103 static const char kDeviceTypePhone[] = "phone"; | 104 static const char kDeviceTypePhone[] = "phone"; |
| 104 static const char kDeviceTypeTablet[] = "tablet"; | 105 static const char kDeviceTypeTablet[] = "tablet"; |
| 105 | 106 |
| 106 // Returns a localized version of |visit_time| including a relative | 107 // Returns a localized version of |visit_time| including a relative |
| 107 // indicator (e.g. today, yesterday). | 108 // indicator (e.g. today, yesterday). |
| 108 base::string16 GetRelativeDateLocalized(const base::Time& visit_time) { | 109 base::string16 GetRelativeDateLocalized(base::Clock* clock, |
| 109 base::Time midnight = base::Time::Now().LocalMidnight(); | 110 const base::Time& visit_time) { |
| 111 base::Time midnight = clock->Now().LocalMidnight(); | |
| 110 base::string16 date_str = ui::TimeFormat::RelativeDate(visit_time, &midnight); | 112 base::string16 date_str = ui::TimeFormat::RelativeDate(visit_time, &midnight); |
| 111 if (date_str.empty()) { | 113 if (date_str.empty()) { |
| 112 date_str = base::TimeFormatFriendlyDate(visit_time); | 114 date_str = base::TimeFormatFriendlyDate(visit_time); |
| 113 } else { | 115 } else { |
| 114 date_str = l10n_util::GetStringFUTF16( | 116 date_str = l10n_util::GetStringFUTF16( |
| 115 IDS_HISTORY_DATE_WITH_RELATIVE_TIME, | 117 IDS_HISTORY_DATE_WITH_RELATIVE_TIME, |
| 116 date_str, | 118 date_str, |
| 117 base::TimeFormatFriendlyDate(visit_time)); | 119 base::TimeFormatFriendlyDate(visit_time)); |
| 118 } | 120 } |
| 119 return date_str; | 121 return date_str; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 void RecordMetricsForNoticeAboutOtherFormsOfBrowsingHistory(bool shown) { | 172 void RecordMetricsForNoticeAboutOtherFormsOfBrowsingHistory(bool shown) { |
| 171 UMA_HISTOGRAM_BOOLEAN( | 173 UMA_HISTOGRAM_BOOLEAN( |
| 172 "History.ShownHeaderAboutOtherFormsOfBrowsingHistory", | 174 "History.ShownHeaderAboutOtherFormsOfBrowsingHistory", |
| 173 shown); | 175 shown); |
| 174 } | 176 } |
| 175 | 177 |
| 176 } // namespace | 178 } // namespace |
| 177 | 179 |
| 178 BrowsingHistoryHandler::HistoryEntry::HistoryEntry( | 180 BrowsingHistoryHandler::HistoryEntry::HistoryEntry( |
| 179 BrowsingHistoryHandler::HistoryEntry::EntryType entry_type, | 181 BrowsingHistoryHandler::HistoryEntry::EntryType entry_type, |
| 180 const GURL& url, const base::string16& title, base::Time time, | 182 const GURL& url, |
| 181 const std::string& client_id, bool is_search_result, | 183 const base::string16& title, |
| 182 const base::string16& snippet, bool blocked_visit) { | 184 base::Time time, |
| 185 const std::string& client_id, | |
| 186 bool is_search_result, | |
| 187 const base::string16& snippet, | |
| 188 bool blocked_visit, | |
| 189 base::Clock* clock) { | |
| 183 this->entry_type = entry_type; | 190 this->entry_type = entry_type; |
| 184 this->url = url; | 191 this->url = url; |
| 185 this->title = title; | 192 this->title = title; |
| 186 this->time = time; | 193 this->time = time; |
| 187 this->client_id = client_id; | 194 this->client_id = client_id; |
| 188 all_timestamps.insert(time.ToInternalValue()); | 195 all_timestamps.insert(time.ToInternalValue()); |
| 189 this->is_search_result = is_search_result; | 196 this->is_search_result = is_search_result; |
| 190 this->snippet = snippet; | 197 this->snippet = snippet; |
| 191 this->blocked_visit = blocked_visit; | 198 this->blocked_visit = blocked_visit; |
| 199 this->clock = clock; | |
| 192 } | 200 } |
| 193 | 201 |
| 194 BrowsingHistoryHandler::HistoryEntry::HistoryEntry() | 202 BrowsingHistoryHandler::HistoryEntry::HistoryEntry() |
| 195 : entry_type(EMPTY_ENTRY), is_search_result(false), blocked_visit(false) { | 203 : entry_type(EMPTY_ENTRY), is_search_result(false), blocked_visit(false) { |
| 196 } | 204 } |
| 197 | 205 |
| 198 BrowsingHistoryHandler::HistoryEntry::HistoryEntry(const HistoryEntry& other) = | 206 BrowsingHistoryHandler::HistoryEntry::HistoryEntry(const HistoryEntry& other) = |
| 199 default; | 207 default; |
| 200 | 208 |
| 201 BrowsingHistoryHandler::HistoryEntry::~HistoryEntry() { | 209 BrowsingHistoryHandler::HistoryEntry::~HistoryEntry() { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 base::string16 date_time_of_day; | 280 base::string16 date_time_of_day; |
| 273 bool is_blocked_visit = false; | 281 bool is_blocked_visit = false; |
| 274 int host_filtering_behavior = -1; | 282 int host_filtering_behavior = -1; |
| 275 | 283 |
| 276 // Only pass in the strings we need (search results need a shortdate | 284 // Only pass in the strings we need (search results need a shortdate |
| 277 // and snippet, browse results need day and time information). Makes sure that | 285 // and snippet, browse results need day and time information). Makes sure that |
| 278 // values of result are never undefined | 286 // values of result are never undefined |
| 279 if (is_search_result) { | 287 if (is_search_result) { |
| 280 snippet_string = snippet; | 288 snippet_string = snippet; |
| 281 } else { | 289 } else { |
| 282 base::Time midnight = base::Time::Now().LocalMidnight(); | 290 base::Time midnight = clock->Now().LocalMidnight(); |
| 283 base::string16 date_str = ui::TimeFormat::RelativeDate(time, &midnight); | 291 base::string16 date_str = ui::TimeFormat::RelativeDate(time, &midnight); |
| 284 if (date_str.empty()) { | 292 if (date_str.empty()) { |
| 285 date_str = base::TimeFormatFriendlyDate(time); | 293 date_str = base::TimeFormatFriendlyDate(time); |
| 286 } else { | 294 } else { |
| 287 date_str = l10n_util::GetStringFUTF16( | 295 date_str = l10n_util::GetStringFUTF16( |
| 288 IDS_HISTORY_DATE_WITH_RELATIVE_TIME, | 296 IDS_HISTORY_DATE_WITH_RELATIVE_TIME, |
| 289 date_str, | 297 date_str, |
| 290 base::TimeFormatFriendlyDate(time)); | 298 base::TimeFormatFriendlyDate(time)); |
| 291 } | 299 } |
| 292 date_relative_day = date_str; | 300 date_relative_day = date_str; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 return entry1.time > entry2.time; | 335 return entry1.time > entry2.time; |
| 328 } | 336 } |
| 329 | 337 |
| 330 BrowsingHistoryHandler::BrowsingHistoryHandler() | 338 BrowsingHistoryHandler::BrowsingHistoryHandler() |
| 331 : has_pending_delete_request_(false), | 339 : has_pending_delete_request_(false), |
| 332 history_service_observer_(this), | 340 history_service_observer_(this), |
| 333 web_history_service_observer_(this), | 341 web_history_service_observer_(this), |
| 334 sync_service_observer_(this), | 342 sync_service_observer_(this), |
| 335 has_synced_results_(false), | 343 has_synced_results_(false), |
| 336 has_other_forms_of_browsing_history_(false), | 344 has_other_forms_of_browsing_history_(false), |
| 345 clock_(new base::DefaultClock()), | |
| 337 weak_factory_(this) {} | 346 weak_factory_(this) {} |
| 338 | 347 |
| 339 BrowsingHistoryHandler::~BrowsingHistoryHandler() { | 348 BrowsingHistoryHandler::~BrowsingHistoryHandler() { |
| 340 query_task_tracker_.TryCancelAll(); | 349 query_task_tracker_.TryCancelAll(); |
| 341 web_history_request_.reset(); | 350 web_history_request_.reset(); |
| 342 } | 351 } |
| 343 | 352 |
| 344 void BrowsingHistoryHandler::RegisterMessages() { | 353 void BrowsingHistoryHandler::RegisterMessages() { |
| 345 // Create our favicon data source. | 354 // Create our favicon data source. |
| 346 Profile* profile = Profile::FromWebUI(web_ui()); | 355 Profile* profile = Profile::FromWebUI(web_ui()); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 web_ui()->CallJavascriptFunctionUnsafe("deleteFailed"); | 551 web_ui()->CallJavascriptFunctionUnsafe("deleteFailed"); |
| 543 return; | 552 return; |
| 544 } | 553 } |
| 545 | 554 |
| 546 history::HistoryService* history_service = | 555 history::HistoryService* history_service = |
| 547 HistoryServiceFactory::GetForProfile(profile, | 556 HistoryServiceFactory::GetForProfile(profile, |
| 548 ServiceAccessType::EXPLICIT_ACCESS); | 557 ServiceAccessType::EXPLICIT_ACCESS); |
| 549 history::WebHistoryService* web_history = | 558 history::WebHistoryService* web_history = |
| 550 WebHistoryServiceFactory::GetForProfile(profile); | 559 WebHistoryServiceFactory::GetForProfile(profile); |
| 551 | 560 |
| 552 base::Time now = base::Time::Now(); | 561 base::Time now = clock_->Now(); |
| 553 std::vector<history::ExpireHistoryArgs> expire_list; | 562 std::vector<history::ExpireHistoryArgs> expire_list; |
| 554 expire_list.reserve(args->GetSize()); | 563 expire_list.reserve(args->GetSize()); |
| 555 | 564 |
| 556 DCHECK(urls_to_be_deleted_.empty()); | 565 DCHECK(urls_to_be_deleted_.empty()); |
| 557 for (base::ListValue::const_iterator it = args->begin(); | 566 for (base::ListValue::const_iterator it = args->begin(); |
| 558 it != args->end(); ++it) { | 567 it != args->end(); ++it) { |
| 559 base::DictionaryValue* deletion = NULL; | 568 base::DictionaryValue* deletion = NULL; |
| 560 base::string16 url; | 569 base::string16 url; |
| 561 base::ListValue* timestamps = NULL; | 570 base::ListValue* timestamps = NULL; |
| 562 | 571 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 715 void BrowsingHistoryHandler::QueryComplete( | 724 void BrowsingHistoryHandler::QueryComplete( |
| 716 const base::string16& search_text, | 725 const base::string16& search_text, |
| 717 const history::QueryOptions& options, | 726 const history::QueryOptions& options, |
| 718 history::QueryResults* results) { | 727 history::QueryResults* results) { |
| 719 DCHECK_EQ(0U, query_results_.size()); | 728 DCHECK_EQ(0U, query_results_.size()); |
| 720 query_results_.reserve(results->size()); | 729 query_results_.reserve(results->size()); |
| 721 | 730 |
| 722 for (size_t i = 0; i < results->size(); ++i) { | 731 for (size_t i = 0; i < results->size(); ++i) { |
| 723 history::URLResult const &page = (*results)[i]; | 732 history::URLResult const &page = (*results)[i]; |
| 724 // TODO(dubroy): Use sane time (crbug.com/146090) here when it's ready. | 733 // TODO(dubroy): Use sane time (crbug.com/146090) here when it's ready. |
| 725 query_results_.push_back( | 734 query_results_.push_back(HistoryEntry( |
| 726 HistoryEntry( | 735 HistoryEntry::LOCAL_ENTRY, page.url(), page.title(), page.visit_time(), |
| 727 HistoryEntry::LOCAL_ENTRY, | 736 std::string(), !search_text.empty(), page.snippet().text(), |
| 728 page.url(), | 737 page.blocked_visit(), clock_.get())); |
| 729 page.title(), | |
| 730 page.visit_time(), | |
| 731 std::string(), | |
| 732 !search_text.empty(), | |
| 733 page.snippet().text(), | |
| 734 page.blocked_visit())); | |
| 735 } | 738 } |
| 736 | 739 |
| 737 // The items which are to be written into results_info_value_ are also | 740 // The items which are to be written into results_info_value_ are also |
| 738 // described in chrome/browser/resources/history/history.js in @typedef for | 741 // described in chrome/browser/resources/history/history.js in @typedef for |
| 739 // HistoryQuery. Please update it whenever you add or remove any keys in | 742 // HistoryQuery. Please update it whenever you add or remove any keys in |
| 740 // results_info_value_. | 743 // results_info_value_. |
| 741 results_info_value_.SetString("term", search_text); | 744 results_info_value_.SetString("term", search_text); |
| 742 results_info_value_.SetBoolean("finished", results->reached_beginning()); | 745 results_info_value_.SetBoolean("finished", results->reached_beginning()); |
| 743 | 746 |
| 744 // Add the specific dates that were searched to display them. | 747 // Add the specific dates that were searched to display them. |
| 745 // TODO(sergiu): Put today if the start is in the future. | 748 // TODO(sergiu): Put today if the start is in the future. |
| 746 results_info_value_.SetString("queryStartTime", | 749 results_info_value_.SetString( |
| 747 GetRelativeDateLocalized(options.begin_time)); | 750 "queryStartTime", |
| 751 GetRelativeDateLocalized(clock_.get(), options.begin_time)); | |
| 748 if (!options.end_time.is_null()) { | 752 if (!options.end_time.is_null()) { |
| 749 results_info_value_.SetString("queryEndTime", | 753 results_info_value_.SetString( |
| 750 GetRelativeDateLocalized(options.end_time - | 754 "queryEndTime", |
| 751 base::TimeDelta::FromDays(1))); | 755 GetRelativeDateLocalized( |
| 756 clock_.get(), options.end_time - base::TimeDelta::FromDays(1))); | |
| 752 } else { | 757 } else { |
| 753 results_info_value_.SetString("queryEndTime", | 758 results_info_value_.SetString( |
| 754 GetRelativeDateLocalized(base::Time::Now())); | 759 "queryEndTime", GetRelativeDateLocalized(clock_.get(), clock_->Now())); |
| 755 } | 760 } |
| 756 if (!web_history_timer_.IsRunning()) | 761 if (!web_history_timer_.IsRunning()) |
| 757 ReturnResultsToFrontEnd(); | 762 ReturnResultsToFrontEnd(); |
| 758 } | 763 } |
| 759 | 764 |
| 760 void BrowsingHistoryHandler::ReturnResultsToFrontEnd() { | 765 void BrowsingHistoryHandler::ReturnResultsToFrontEnd() { |
| 761 Profile* profile = Profile::FromWebUI(web_ui()); | 766 Profile* profile = Profile::FromWebUI(web_ui()); |
| 762 BookmarkModel* bookmark_model = | 767 BookmarkModel* bookmark_model = |
| 763 BookmarkModelFactory::GetForBrowserContext(profile); | 768 BookmarkModelFactory::GetForBrowserContext(profile); |
| 764 SupervisedUserService* supervised_user_service = NULL; | 769 SupervisedUserService* supervised_user_service = NULL; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 879 } | 884 } |
| 880 // The timestamp on the server is a Unix time. | 885 // The timestamp on the server is a Unix time. |
| 881 base::Time time = base::Time::UnixEpoch() + | 886 base::Time time = base::Time::UnixEpoch() + |
| 882 base::TimeDelta::FromMicroseconds(timestamp_usec); | 887 base::TimeDelta::FromMicroseconds(timestamp_usec); |
| 883 | 888 |
| 884 // Get the ID of the client that this visit came from. | 889 // Get the ID of the client that this visit came from. |
| 885 std::string client_id; | 890 std::string client_id; |
| 886 id->GetString("client_id", &client_id); | 891 id->GetString("client_id", &client_id); |
| 887 | 892 |
| 888 web_history_query_results_.push_back( | 893 web_history_query_results_.push_back( |
| 889 HistoryEntry( | 894 HistoryEntry(HistoryEntry::REMOTE_ENTRY, gurl, title, time, |
| 890 HistoryEntry::REMOTE_ENTRY, | 895 client_id, !search_text.empty(), base::string16(), |
| 891 gurl, | 896 /* blocked_visit */ false, clock_.get())); |
| 892 title, | |
| 893 time, | |
| 894 client_id, | |
| 895 !search_text.empty(), | |
| 896 base::string16(), | |
| 897 /* blocked_visit */ false)); | |
| 898 } | 897 } |
| 899 } | 898 } |
| 900 } | 899 } |
| 901 has_synced_results_ = results_value != nullptr; | 900 has_synced_results_ = results_value != nullptr; |
| 902 results_info_value_.SetBoolean("hasSyncedResults", has_synced_results_); | 901 results_info_value_.SetBoolean("hasSyncedResults", has_synced_results_); |
| 903 if (!query_task_tracker_.HasTrackedTasks()) | 902 if (!query_task_tracker_.HasTrackedTasks()) |
| 904 ReturnResultsToFrontEnd(); | 903 ReturnResultsToFrontEnd(); |
| 905 } | 904 } |
| 906 | 905 |
| 907 void BrowsingHistoryHandler::OtherFormsOfBrowsingHistoryQueryComplete( | 906 void BrowsingHistoryHandler::OtherFormsOfBrowsingHistoryQueryComplete( |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 930 // TODO(dubroy): Should we handle failure somehow? Delete directives will | 929 // TODO(dubroy): Should we handle failure somehow? Delete directives will |
| 931 // ensure that the visits are eventually deleted, so maybe it's not necessary. | 930 // ensure that the visits are eventually deleted, so maybe it's not necessary. |
| 932 if (!delete_task_tracker_.HasTrackedTasks()) | 931 if (!delete_task_tracker_.HasTrackedTasks()) |
| 933 RemoveComplete(); | 932 RemoveComplete(); |
| 934 } | 933 } |
| 935 | 934 |
| 936 void BrowsingHistoryHandler::SetQueryTimeInWeeks( | 935 void BrowsingHistoryHandler::SetQueryTimeInWeeks( |
| 937 int offset, history::QueryOptions* options) { | 936 int offset, history::QueryOptions* options) { |
| 938 // LocalMidnight returns the beginning of the current day so get the | 937 // LocalMidnight returns the beginning of the current day so get the |
| 939 // beginning of the next one. | 938 // beginning of the next one. |
| 940 base::Time midnight = base::Time::Now().LocalMidnight() + | 939 base::Time midnight = |
| 941 base::TimeDelta::FromDays(1); | 940 clock_->Now().LocalMidnight() + base::TimeDelta::FromDays(1); |
| 942 options->end_time = midnight - | 941 options->end_time = midnight - |
| 943 base::TimeDelta::FromDays(7 * offset); | 942 base::TimeDelta::FromDays(7 * offset); |
| 944 options->begin_time = midnight - | 943 options->begin_time = midnight - |
| 945 base::TimeDelta::FromDays(7 * (offset + 1)); | 944 base::TimeDelta::FromDays(7 * (offset + 1)); |
| 946 } | 945 } |
| 947 | 946 |
| 948 void BrowsingHistoryHandler::SetQueryTimeInMonths( | 947 void BrowsingHistoryHandler::SetQueryTimeInMonths( |
| 949 int offset, history::QueryOptions* options) { | 948 int offset, history::QueryOptions* options) { |
| 950 // Configure the begin point of the search to the start of the | 949 // Configure the begin point of the search to the start of the |
| 951 // current month. | 950 // current month. |
| 952 base::Time::Exploded exploded; | 951 base::Time::Exploded exploded; |
| 953 base::Time::Now().LocalMidnight().LocalExplode(&exploded); | 952 clock_->Now().LocalMidnight().LocalExplode(&exploded); |
| 954 exploded.day_of_month = 1; | 953 exploded.day_of_month = 1; |
| 955 | 954 |
| 956 if (offset == 0) { | 955 if (offset == 0) { |
| 957 if (!base::Time::FromLocalExploded(exploded, &options->begin_time)) { | 956 if (!base::Time::FromLocalExploded(exploded, &options->begin_time)) { |
| 958 // TODO(maksims): implement errors handling here. | 957 // TODO(maksims): implement errors handling here. |
| 959 NOTIMPLEMENTED(); | 958 NOTIMPLEMENTED(); |
| 960 } | 959 } |
| 961 | 960 |
| 962 // Set the end time of this first search to null (which will | 961 // Set the end time of this first search to null (which will |
| 963 // show results from the future, should the user's clock have | 962 // show results from the future, should the user's clock have |
| 964 // been set incorrectly). | 963 // been set incorrectly). |
| 965 options->end_time = base::Time(); | 964 options->end_time = base::Time(); |
| 966 } else { | 965 } else { |
| 967 // Go back |offset| months in the past. The end time is not inclusive, so | 966 // Go back |offset| months in the past. The end time is not inclusive, so |
| 968 // use the first day of the |offset| - 1 and |offset| months (e.g. for | 967 // use the first day of the |offset| - 1 and |offset| months (e.g. for |
| 969 // the last month, |offset| = 1, use the first days of the last month and | 968 // the last month, |offset| = 1, use the first days of the last month and |
| 970 // the current month. | 969 // the current month. |
| 971 exploded.month -= offset - 1; | 970 exploded.month -= offset - 1; |
| 972 // Set the correct year. | 971 // Set the correct year. |
| 973 NormalizeMonths(&exploded); | 972 NormalizeMonths(&exploded); |
| 974 if (!base::Time::FromLocalExploded(exploded, &options->begin_time)) { | 973 if (!base::Time::FromLocalExploded(exploded, &options->end_time)) { |
|
Dan Beam
2016/11/10 03:31:34
this is the functional fix, right?
calamity
2016/11/10 07:16:27
Yep, nestled deep amongst all the clock nonsense.
| |
| 975 // TODO(maksims): implement errors handling here. | 974 // TODO(maksims): implement errors handling here. |
| 976 NOTIMPLEMENTED(); | 975 NOTIMPLEMENTED(); |
| 977 } | 976 } |
| 978 | 977 |
| 979 exploded.month -= 1; | 978 exploded.month -= 1; |
| 980 // Set the correct year | 979 // Set the correct year |
| 981 NormalizeMonths(&exploded); | 980 NormalizeMonths(&exploded); |
| 982 if (!base::Time::FromLocalExploded(exploded, &options->begin_time)) { | 981 if (!base::Time::FromLocalExploded(exploded, &options->begin_time)) { |
| 983 // TODO(maksims): implement errors handling here. | 982 // TODO(maksims): implement errors handling here. |
| 984 NOTIMPLEMENTED(); | 983 NOTIMPLEMENTED(); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1005 bool expired, | 1004 bool expired, |
| 1006 const history::URLRows& deleted_rows, | 1005 const history::URLRows& deleted_rows, |
| 1007 const std::set<GURL>& favicon_urls) { | 1006 const std::set<GURL>& favicon_urls) { |
| 1008 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) | 1007 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) |
| 1009 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); | 1008 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); |
| 1010 } | 1009 } |
| 1011 | 1010 |
| 1012 void BrowsingHistoryHandler::OnWebHistoryDeleted() { | 1011 void BrowsingHistoryHandler::OnWebHistoryDeleted() { |
| 1013 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); | 1012 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); |
| 1014 } | 1013 } |
| OLD | NEW |