Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(712)

Side by Side Diff: chrome/browser/ui/webui/browsing_history_handler.cc

Issue 2354053003: History: Fix flicker of sync notices when loading new data (Closed)
Patch Set: Timeout also resets value Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 history::WebHistoryService* web_history = 411 history::WebHistoryService* web_history =
412 WebHistoryServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())); 412 WebHistoryServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()));
413 if (web_history) { 413 if (web_history) {
414 DCHECK(!web_history_service_observer_.IsObserving(web_history)); 414 DCHECK(!web_history_service_observer_.IsObserving(web_history));
415 web_history_service_observer_.Add(web_history); 415 web_history_service_observer_.Add(web_history);
416 sync_service_observer_.RemoveAll(); 416 sync_service_observer_.RemoveAll();
417 } 417 }
418 } 418 }
419 419
420 void BrowsingHistoryHandler::WebHistoryTimeout() { 420 void BrowsingHistoryHandler::WebHistoryTimeout() {
421 has_synced_results_ = false;
421 // TODO(dubroy): Communicate the failure to the front end. 422 // TODO(dubroy): Communicate the failure to the front end.
422 if (!query_task_tracker_.HasTrackedTasks()) 423 if (!query_task_tracker_.HasTrackedTasks())
423 ReturnResultsToFrontEnd(); 424 ReturnResultsToFrontEnd();
424 425
425 UMA_HISTOGRAM_ENUMERATION( 426 UMA_HISTOGRAM_ENUMERATION(
426 "WebHistory.QueryCompletion", 427 "WebHistory.QueryCompletion",
427 WEB_HISTORY_QUERY_TIMED_OUT, NUM_WEB_HISTORY_QUERY_BUCKETS); 428 WEB_HISTORY_QUERY_TIMED_OUT, NUM_WEB_HISTORY_QUERY_BUCKETS);
428 } 429 }
429 430
430 void BrowsingHistoryHandler::QueryHistory( 431 void BrowsingHistoryHandler::QueryHistory(
431 const base::string16& search_text, 432 const base::string16& search_text,
432 const history::QueryOptions& options) { 433 const history::QueryOptions& options) {
433 Profile* profile = Profile::FromWebUI(web_ui()); 434 Profile* profile = Profile::FromWebUI(web_ui());
434 435
435 // Anything in-flight is invalid. 436 // Anything in-flight is invalid.
436 query_task_tracker_.TryCancelAll(); 437 query_task_tracker_.TryCancelAll();
437 web_history_request_.reset(); 438 web_history_request_.reset();
438 439
439 query_results_.clear(); 440 query_results_.clear();
440 results_info_value_.Clear(); 441 results_info_value_.Clear();
441 has_synced_results_ = false;
442 has_other_forms_of_browsing_history_ = false;
443 442
444 history::HistoryService* hs = HistoryServiceFactory::GetForProfile( 443 history::HistoryService* hs = HistoryServiceFactory::GetForProfile(
445 profile, ServiceAccessType::EXPLICIT_ACCESS); 444 profile, ServiceAccessType::EXPLICIT_ACCESS);
446 hs->QueryHistory(search_text, 445 hs->QueryHistory(search_text,
447 options, 446 options,
448 base::Bind(&BrowsingHistoryHandler::QueryComplete, 447 base::Bind(&BrowsingHistoryHandler::QueryComplete,
449 base::Unretained(this), 448 base::Unretained(this),
450 search_text, 449 search_text,
451 options), 450 options),
452 &query_task_tracker_); 451 &query_task_tracker_);
(...skipping 21 matching lines...) Expand all
474 // Test the existence of other forms of browsing history. 473 // Test the existence of other forms of browsing history.
475 browsing_data::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory( 474 browsing_data::ShouldShowNoticeAboutOtherFormsOfBrowsingHistory(
476 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile), 475 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile),
477 web_history, 476 web_history,
478 base::Bind( 477 base::Bind(
479 &BrowsingHistoryHandler::OtherFormsOfBrowsingHistoryQueryComplete, 478 &BrowsingHistoryHandler::OtherFormsOfBrowsingHistoryQueryComplete,
480 weak_factory_.GetWeakPtr())); 479 weak_factory_.GetWeakPtr()));
481 } else { 480 } else {
482 // The notice could not have been shown, because there is no web history. 481 // The notice could not have been shown, because there is no web history.
483 RecordMetricsForNoticeAboutOtherFormsOfBrowsingHistory(false); 482 RecordMetricsForNoticeAboutOtherFormsOfBrowsingHistory(false);
483 has_synced_results_ = false;
484 has_other_forms_of_browsing_history_ = false;
484 } 485 }
485 } 486 }
486 487
487 void BrowsingHistoryHandler::HandleQueryHistory(const base::ListValue* args) { 488 void BrowsingHistoryHandler::HandleQueryHistory(const base::ListValue* args) {
488 history::QueryOptions options; 489 history::QueryOptions options;
489 490
490 // Parse the arguments from JavaScript. There are five required arguments: 491 // Parse the arguments from JavaScript. There are five required arguments:
491 // - the text to search for (may be empty) 492 // - the text to search for (may be empty)
492 // - the offset from which the search should start (in multiples of week or 493 // - the offset from which the search should start (in multiples of week or
493 // month, set by the next argument). 494 // month, set by the next argument).
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 bool expired, 1005 bool expired,
1005 const history::URLRows& deleted_rows, 1006 const history::URLRows& deleted_rows,
1006 const std::set<GURL>& favicon_urls) { 1007 const std::set<GURL>& favicon_urls) {
1007 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) 1008 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_))
1008 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); 1009 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted");
1009 } 1010 }
1010 1011
1011 void BrowsingHistoryHandler::OnWebHistoryDeleted() { 1012 void BrowsingHistoryHandler::OnWebHistoryDeleted() {
1012 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted"); 1013 web_ui()->CallJavascriptFunctionUnsafe("historyDeleted");
1013 } 1014 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698