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 "components/history/core/browser/history_backend.h" | 5 #include "components/history/core/browser/history_backend.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 if (!url_id) { | 763 if (!url_id) { |
764 NOTREACHED() << "Adding URL failed."; | 764 NOTREACHED() << "Adding URL failed."; |
765 return std::make_pair(0, 0); | 765 return std::make_pair(0, 0); |
766 } | 766 } |
767 url_info.id_ = url_id; | 767 url_info.id_ = url_id; |
768 } | 768 } |
769 | 769 |
770 // Add the visit with the time to the database. | 770 // Add the visit with the time to the database. |
771 VisitRow visit_info(url_id, time, referring_visit, transition, 0); | 771 VisitRow visit_info(url_id, time, referring_visit, transition, 0); |
772 VisitID visit_id = db_->AddVisit(&visit_info, visit_source); | 772 VisitID visit_id = db_->AddVisit(&visit_info, visit_source); |
773 NotifyVisitObservers(visit_info); | |
774 | 773 |
775 if (visit_info.visit_time < first_recorded_time_) | 774 if (visit_info.visit_time < first_recorded_time_) |
776 first_recorded_time_ = visit_info.visit_time; | 775 first_recorded_time_ = visit_info.visit_time; |
777 | 776 |
778 // Broadcast a notification of the visit. | 777 // Broadcast a notification of the visit. |
779 if (visit_id) { | 778 if (visit_id) { |
780 RedirectList redirects; | 779 RedirectList redirects; |
781 // TODO(meelapshah) Disabled due to potential PageCycler regression. | 780 // TODO(meelapshah) Disabled due to potential PageCycler regression. |
782 // Re-enable this. | 781 // Re-enable this. |
783 // QueryRedirectsTo(url, &redirects); | 782 // QueryRedirectsTo(url, &redirects); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 VisitRow visit_info( | 822 VisitRow visit_info( |
824 url_id, i->last_visit(), 0, | 823 url_id, i->last_visit(), 0, |
825 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_LINK | | 824 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_LINK | |
826 ui::PAGE_TRANSITION_CHAIN_START | | 825 ui::PAGE_TRANSITION_CHAIN_START | |
827 ui::PAGE_TRANSITION_CHAIN_END), | 826 ui::PAGE_TRANSITION_CHAIN_END), |
828 0); | 827 0); |
829 if (!db_->AddVisit(&visit_info, visit_source)) { | 828 if (!db_->AddVisit(&visit_info, visit_source)) { |
830 NOTREACHED() << "Adding visit failed."; | 829 NOTREACHED() << "Adding visit failed."; |
831 return; | 830 return; |
832 } | 831 } |
833 NotifyVisitObservers(visit_info); | |
834 | 832 |
835 if (visit_info.visit_time < first_recorded_time_) | 833 if (visit_info.visit_time < first_recorded_time_) |
836 first_recorded_time_ = visit_info.visit_time; | 834 first_recorded_time_ = visit_info.visit_time; |
837 } | 835 } |
838 } | 836 } |
839 | 837 |
840 // Broadcast a notification for typed URLs that have been modified. This | 838 // Broadcast a notification for typed URLs that have been modified. This |
841 // will be picked up by the in-memory URL database on the main thread. | 839 // will be picked up by the in-memory URL database on the main thread. |
842 // | 840 // |
843 // TODO(brettw) bug 1140015: Add an "add page" notification so the history | 841 // TODO(brettw) bug 1140015: Add an "add page" notification so the history |
(...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2636 | 2634 |
2637 return true; | 2635 return true; |
2638 } | 2636 } |
2639 | 2637 |
2640 HistoryClient* HistoryBackend::GetHistoryClient() { | 2638 HistoryClient* HistoryBackend::GetHistoryClient() { |
2641 if (history_client_) | 2639 if (history_client_) |
2642 history_client_->BlockUntilBookmarksLoaded(); | 2640 history_client_->BlockUntilBookmarksLoaded(); |
2643 return history_client_; | 2641 return history_client_; |
2644 } | 2642 } |
2645 | 2643 |
2646 void HistoryBackend::NotifyVisitObservers(const VisitRow& visit) { | |
2647 BriefVisitInfo info; | |
2648 info.url_id = visit.url_id; | |
2649 info.time = visit.visit_time; | |
2650 info.transition = visit.transition; | |
2651 // If we don't have a delegate yet during setup or shutdown, we will drop | |
2652 // these notifications. | |
2653 if (delegate_) | |
2654 delegate_->NotifyAddVisit(info); | |
2655 } | |
2656 | |
2657 } // namespace history | 2644 } // namespace history |
OLD | NEW |