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