OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ios/chrome/browser/ui/webui/history/browsing_history_handler.h" | 5 #include "ios/chrome/browser/ui/webui/history/browsing_history_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 94 } |
95 | 95 |
96 // Returns true if |entry| represents a local visit that had no corresponding | 96 // Returns true if |entry| represents a local visit that had no corresponding |
97 // visit on the server. | 97 // visit on the server. |
98 bool IsLocalOnlyResult(const BrowsingHistoryHandler::HistoryEntry& entry) { | 98 bool IsLocalOnlyResult(const BrowsingHistoryHandler::HistoryEntry& entry) { |
99 return entry.entry_type == BrowsingHistoryHandler::HistoryEntry::LOCAL_ENTRY; | 99 return entry.entry_type == BrowsingHistoryHandler::HistoryEntry::LOCAL_ENTRY; |
100 } | 100 } |
101 | 101 |
102 // Gets the name and type of a device for the given sync client ID. | 102 // Gets the name and type of a device for the given sync client ID. |
103 // |name| and |type| are out parameters. | 103 // |name| and |type| are out parameters. |
104 void GetDeviceNameAndType(const ProfileSyncService* sync_service, | 104 void GetDeviceNameAndType(const browser_sync::ProfileSyncService* sync_service, |
105 const std::string& client_id, | 105 const std::string& client_id, |
106 std::string* name, | 106 std::string* name, |
107 std::string* type) { | 107 std::string* type) { |
108 // DeviceInfoTracker must be syncing in order for remote history entries to | 108 // DeviceInfoTracker must be syncing in order for remote history entries to |
109 // be available. | 109 // be available. |
110 DCHECK(sync_service); | 110 DCHECK(sync_service); |
111 DCHECK(sync_service->GetDeviceInfoTracker()); | 111 DCHECK(sync_service->GetDeviceInfoTracker()); |
112 DCHECK(sync_service->GetDeviceInfoTracker()->IsSyncing()); | 112 DCHECK(sync_service->GetDeviceInfoTracker()->IsSyncing()); |
113 | 113 |
114 std::unique_ptr<sync_driver::DeviceInfo> device_info = | 114 std::unique_ptr<sync_driver::DeviceInfo> device_info = |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 else | 188 else |
189 base::i18n::AdjustStringForLocaleDirection(&title_to_set); | 189 base::i18n::AdjustStringForLocaleDirection(&title_to_set); |
190 } | 190 } |
191 result->SetString("title", title_to_set); | 191 result->SetString("title", title_to_set); |
192 } | 192 } |
193 | 193 |
194 std::unique_ptr<base::DictionaryValue> | 194 std::unique_ptr<base::DictionaryValue> |
195 BrowsingHistoryHandler::HistoryEntry::ToValue( | 195 BrowsingHistoryHandler::HistoryEntry::ToValue( |
196 BookmarkModel* bookmark_model, | 196 BookmarkModel* bookmark_model, |
197 SupervisedUserService* supervised_user_service, | 197 SupervisedUserService* supervised_user_service, |
198 const ProfileSyncService* sync_service) const { | 198 const browser_sync::ProfileSyncService* sync_service) const { |
199 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 199 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
200 SetUrlAndTitle(result.get()); | 200 SetUrlAndTitle(result.get()); |
201 | 201 |
202 base::string16 domain = url_formatter::IDNToUnicode(url.host()); | 202 base::string16 domain = url_formatter::IDNToUnicode(url.host()); |
203 // When the domain is empty, use the scheme instead. This allows for a | 203 // When the domain is empty, use the scheme instead. This allows for a |
204 // sensible treatment of e.g. file: URLs when group by domain is on. | 204 // sensible treatment of e.g. file: URLs when group by domain is on. |
205 if (domain.empty()) | 205 if (domain.empty()) |
206 domain = base::UTF8ToUTF16(url.scheme() + ":"); | 206 domain = base::UTF8ToUTF16(url.scheme() + ":"); |
207 | 207 |
208 // The items which are to be written into result are also described in | 208 // The items which are to be written into result are also described in |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 web_history_request_ = web_history->QueryHistory( | 363 web_history_request_ = web_history->QueryHistory( |
364 search_text, options, | 364 search_text, options, |
365 base::Bind(&BrowsingHistoryHandler::WebHistoryQueryComplete, | 365 base::Bind(&BrowsingHistoryHandler::WebHistoryQueryComplete, |
366 base::Unretained(this), search_text, options, | 366 base::Unretained(this), search_text, options, |
367 base::TimeTicks::Now())); | 367 base::TimeTicks::Now())); |
368 // Start a timer so we know when to give up. | 368 // Start a timer so we know when to give up. |
369 web_history_timer_.Start( | 369 web_history_timer_.Start( |
370 FROM_HERE, base::TimeDelta::FromSeconds(kWebHistoryTimeoutSeconds), | 370 FROM_HERE, base::TimeDelta::FromSeconds(kWebHistoryTimeoutSeconds), |
371 this, &BrowsingHistoryHandler::WebHistoryTimeout); | 371 this, &BrowsingHistoryHandler::WebHistoryTimeout); |
372 | 372 |
373 ProfileSyncService* sync_service = | 373 browser_sync::ProfileSyncService* sync_service = |
374 IOSChromeProfileSyncServiceFactory::GetInstance()->GetForBrowserState( | 374 IOSChromeProfileSyncServiceFactory::GetInstance()->GetForBrowserState( |
375 browser_state); | 375 browser_state); |
376 // Test the existence of other forms of browsing history. | 376 // Test the existence of other forms of browsing history. |
377 browsing_data::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( | 377 browsing_data::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( |
378 sync_service, web_history, | 378 sync_service, web_history, |
379 base::Bind( | 379 base::Bind( |
380 &BrowsingHistoryHandler::OtherFormsOfBrowsingHistoryQueryComplete, | 380 &BrowsingHistoryHandler::OtherFormsOfBrowsingHistoryQueryComplete, |
381 weak_factory_.GetWeakPtr())); | 381 weak_factory_.GetWeakPtr())); |
382 | 382 |
383 // Set this to false until the results actually arrive. | 383 // Set this to false until the results actually arrive. |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 } | 584 } |
585 } | 585 } |
586 results->swap(new_results); | 586 results->swap(new_results); |
587 } | 587 } |
588 | 588 |
589 void BrowsingHistoryHandler::ReturnResultsToFrontEnd() { | 589 void BrowsingHistoryHandler::ReturnResultsToFrontEnd() { |
590 ios::ChromeBrowserState* browser_state = | 590 ios::ChromeBrowserState* browser_state = |
591 ios::ChromeBrowserState::FromWebUIIOS(web_ui()); | 591 ios::ChromeBrowserState::FromWebUIIOS(web_ui()); |
592 BookmarkModel* bookmark_model = | 592 BookmarkModel* bookmark_model = |
593 ios::BookmarkModelFactory::GetForBrowserState(browser_state); | 593 ios::BookmarkModelFactory::GetForBrowserState(browser_state); |
594 ProfileSyncService* sync_service = | 594 browser_sync::ProfileSyncService* sync_service = |
595 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state); | 595 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state); |
596 | 596 |
597 // Combine the local and remote results into |query_results_|, and remove | 597 // Combine the local and remote results into |query_results_|, and remove |
598 // any duplicates. | 598 // any duplicates. |
599 if (!web_history_query_results_.empty()) { | 599 if (!web_history_query_results_.empty()) { |
600 int local_result_count = query_results_.size(); | 600 int local_result_count = query_results_.size(); |
601 query_results_.insert(query_results_.end(), | 601 query_results_.insert(query_results_.end(), |
602 web_history_query_results_.begin(), | 602 web_history_query_results_.begin(), |
603 web_history_query_results_.end()); | 603 web_history_query_results_.end()); |
604 MergeDuplicateResults(&query_results_); | 604 MergeDuplicateResults(&query_results_); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 | 851 |
852 void BrowsingHistoryHandler::OnURLsDeleted( | 852 void BrowsingHistoryHandler::OnURLsDeleted( |
853 history::HistoryService* history_service, | 853 history::HistoryService* history_service, |
854 bool all_history, | 854 bool all_history, |
855 bool expired, | 855 bool expired, |
856 const history::URLRows& deleted_rows, | 856 const history::URLRows& deleted_rows, |
857 const std::set<GURL>& favicon_urls) { | 857 const std::set<GURL>& favicon_urls) { |
858 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) | 858 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) |
859 web_ui()->CallJavascriptFunction("historyDeleted"); | 859 web_ui()->CallJavascriptFunction("historyDeleted"); |
860 } | 860 } |
OLD | NEW |