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

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

Issue 10086021: Revert 132268 - Single URL Expires Were Not Being Deleted. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
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 "chrome/browser/ui/webui/history_ui.h" 5 #include "chrome/browser/ui/webui/history_ui.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 } else { 422 } else {
423 exploded.month = 12; 423 exploded.month = 12;
424 exploded.year--; 424 exploded.year--;
425 } 425 }
426 options.begin_time = base::Time::FromLocalExploded(exploded); 426 options.begin_time = base::Time::FromLocalExploded(exploded);
427 } 427 }
428 428
429 return options; 429 return options;
430 } 430 }
431 431
432 // Helper function for Observe that determines if there are any differences
433 // between the URLs noticed for deletion and the ones we are expecting.
434 static bool DeletionsDiffer(const history::URLRows& deleted_rows,
435 const std::set<GURL>& urls_to_be_deleted) {
436 if (deleted_rows.size() != urls_to_be_deleted.size())
437 return true;
438 for (history::URLRows::const_iterator i = deleted_rows.begin();
439 i != deleted_rows.end(); ++i) {
440 if (urls_to_be_deleted.find(i->url()) == urls_to_be_deleted.end())
441 return true;
442 }
443 return false;
444 }
445
446 void BrowsingHistoryHandler::Observe( 432 void BrowsingHistoryHandler::Observe(
447 int type, 433 int type,
448 const content::NotificationSource& source, 434 const content::NotificationSource& source,
449 const content::NotificationDetails& details) { 435 const content::NotificationDetails& details) {
450 if (type != chrome::NOTIFICATION_HISTORY_URLS_DELETED) { 436 if (type != chrome::NOTIFICATION_HISTORY_URLS_DELETED) {
451 NOTREACHED(); 437 NOTREACHED();
452 return; 438 return;
453 } 439 }
454 history::URLsDeletedDetails* deletedDetails = 440 history::URLsDeletedDetails* deletedDetails =
455 content::Details<history::URLsDeletedDetails>(details).ptr(); 441 content::Details<history::URLsDeletedDetails>(details).ptr();
456 if (deletedDetails->all_history || 442 if (deletedDetails->urls != urls_to_be_deleted_ ||
457 DeletionsDiffer(deletedDetails->rows, urls_to_be_deleted_)) 443 deletedDetails->all_history) {
444 // Notify the page that someone else deleted from the history.
458 web_ui()->CallJavascriptFunction("historyDeleted"); 445 web_ui()->CallJavascriptFunction("historyDeleted");
446 }
459 } 447 }
460 448
461 //////////////////////////////////////////////////////////////////////////////// 449 ////////////////////////////////////////////////////////////////////////////////
462 // 450 //
463 // HistoryUI 451 // HistoryUI
464 // 452 //
465 //////////////////////////////////////////////////////////////////////////////// 453 ////////////////////////////////////////////////////////////////////////////////
466 454
467 HistoryUI::HistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) { 455 HistoryUI::HistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) {
468 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); 456 web_ui->AddMessageHandler(new BrowsingHistoryHandler());
469 457
470 HistoryUIHTMLSource* html_source = new HistoryUIHTMLSource(); 458 HistoryUIHTMLSource* html_source = new HistoryUIHTMLSource();
471 459
472 // Set up the chrome://history-frame/ source. 460 // Set up the chrome://history-frame/ source.
473 Profile* profile = Profile::FromWebUI(web_ui); 461 Profile* profile = Profile::FromWebUI(web_ui);
474 profile->GetChromeURLDataManager()->AddDataSource(html_source); 462 profile->GetChromeURLDataManager()->AddDataSource(html_source);
475 } 463 }
476 464
477 // static 465 // static
478 const GURL HistoryUI::GetHistoryURLWithSearchText(const string16& text) { 466 const GURL HistoryUI::GetHistoryURLWithSearchText(const string16& text) {
479 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + 467 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" +
480 net::EscapeQueryParamValue(UTF16ToUTF8(text), true)); 468 net::EscapeQueryParamValue(UTF16ToUTF8(text), true));
481 } 469 }
482 470
483 // static 471 // static
484 RefCountedMemory* HistoryUI::GetFaviconResourceBytes() { 472 RefCountedMemory* HistoryUI::GetFaviconResourceBytes() {
485 return ResourceBundle::GetSharedInstance(). 473 return ResourceBundle::GetSharedInstance().
486 LoadDataResourceBytes(IDR_HISTORY_FAVICON); 474 LoadDataResourceBytes(IDR_HISTORY_FAVICON);
487 } 475 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_typed_url_unittest.cc ('k') | chrome/browser/visitedlink/visitedlink_master.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698