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

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

Issue 7086030: Refresh the history page if history entries get deleted, except for when currently editing entries (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 6 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
« no previous file with comments | « chrome/browser/ui/webui/history2_ui.h ('k') | chrome/browser/ui/webui/history_ui.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/history2_ui.h" 5 #include "chrome/browser/ui/webui/history2_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_list.h" 25 #include "chrome/browser/ui/browser_list.h"
26 #include "chrome/browser/ui/webui/favicon_source.h" 26 #include "chrome/browser/ui/webui/favicon_source.h"
27 #include "chrome/common/jstemplate_builder.h" 27 #include "chrome/common/jstemplate_builder.h"
28 #include "chrome/common/time_format.h" 28 #include "chrome/common/time_format.h"
29 #include "chrome/common/url_constants.h" 29 #include "chrome/common/url_constants.h"
30 #include "content/browser/browser_thread.h" 30 #include "content/browser/browser_thread.h"
31 #include "content/browser/tab_contents/tab_contents.h" 31 #include "content/browser/tab_contents/tab_contents.h"
32 #include "content/browser/tab_contents/tab_contents_delegate.h" 32 #include "content/browser/tab_contents/tab_contents_delegate.h"
33 #include "content/browser/user_metrics.h" 33 #include "content/browser/user_metrics.h"
34 #include "content/common/notification_source.h"
34 #include "grit/browser_resources.h" 35 #include "grit/browser_resources.h"
35 #include "grit/chromium_strings.h" 36 #include "grit/chromium_strings.h"
36 #include "grit/generated_resources.h" 37 #include "grit/generated_resources.h"
37 #include "grit/locale_settings.h" 38 #include "grit/locale_settings.h"
38 #include "grit/theme_resources.h" 39 #include "grit/theme_resources.h"
39 #include "net/base/escape.h" 40 #include "net/base/escape.h"
40 #include "ui/base/l10n/l10n_util.h" 41 #include "ui/base/l10n/l10n_util.h"
41 #include "ui/base/resource/resource_bundle.h" 42 #include "ui/base/resource/resource_bundle.h"
42 43
43 // Maximum number of search results to return in a given search. We should 44 // Maximum number of search results to return in a given search. We should
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 cancelable_search_consumer_.CancelAllRequests(); 126 cancelable_search_consumer_.CancelAllRequests();
126 cancelable_delete_consumer_.CancelAllRequests(); 127 cancelable_delete_consumer_.CancelAllRequests();
127 } 128 }
128 129
129 WebUIMessageHandler* BrowsingHistoryHandler2::Attach(WebUI* web_ui) { 130 WebUIMessageHandler* BrowsingHistoryHandler2::Attach(WebUI* web_ui) {
130 // Create our favicon data source. 131 // Create our favicon data source.
131 Profile* profile = web_ui->GetProfile(); 132 Profile* profile = web_ui->GetProfile();
132 profile->GetChromeURLDataManager()->AddDataSource( 133 profile->GetChromeURLDataManager()->AddDataSource(
133 new FaviconSource(profile, FaviconSource::FAVICON)); 134 new FaviconSource(profile, FaviconSource::FAVICON));
134 135
136 // Get notifications when history is cleared.
137 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED,
138 Source<Profile>(web_ui->GetProfile()->GetOriginalProfile()));
135 return WebUIMessageHandler::Attach(web_ui); 139 return WebUIMessageHandler::Attach(web_ui);
136 } 140 }
137 141
138 void BrowsingHistoryHandler2::RegisterMessages() { 142 void BrowsingHistoryHandler2::RegisterMessages() {
139 web_ui_->RegisterMessageCallback("getHistory", 143 web_ui_->RegisterMessageCallback("getHistory",
140 NewCallback(this, &BrowsingHistoryHandler2::HandleGetHistory)); 144 NewCallback(this, &BrowsingHistoryHandler2::HandleGetHistory));
141 web_ui_->RegisterMessageCallback("searchHistory", 145 web_ui_->RegisterMessageCallback("searchHistory",
142 NewCallback(this, &BrowsingHistoryHandler2::HandleSearchHistory)); 146 NewCallback(this, &BrowsingHistoryHandler2::HandleSearchHistory));
143 web_ui_->RegisterMessageCallback("removeURLsOnOneDay", 147 web_ui_->RegisterMessageCallback("removeURLsOnOneDay",
144 NewCallback(this, &BrowsingHistoryHandler2::HandleRemoveURLsOnOneDay)); 148 NewCallback(this, &BrowsingHistoryHandler2::HandleRemoveURLsOnOneDay));
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 } else { 366 } else {
363 exploded.month = 12; 367 exploded.month = 12;
364 exploded.year--; 368 exploded.year--;
365 } 369 }
366 options.begin_time = base::Time::FromLocalExploded(exploded); 370 options.begin_time = base::Time::FromLocalExploded(exploded);
367 } 371 }
368 372
369 return options; 373 return options;
370 } 374 }
371 375
376 void BrowsingHistoryHandler2::Observe(NotificationType type,
377 const NotificationSource& source,
378 const NotificationDetails& details) {
379 if (type != NotificationType::HISTORY_URLS_DELETED) {
380 NOTREACHED();
381 return;
382 }
383
384 // Some URLs were deleted from history. Reload the list.
385 web_ui_->CallJavascriptFunction("historyDeleted");
386 }
387
372 //////////////////////////////////////////////////////////////////////////////// 388 ////////////////////////////////////////////////////////////////////////////////
373 // 389 //
374 // HistoryUIContents 390 // HistoryUIContents
375 // 391 //
376 //////////////////////////////////////////////////////////////////////////////// 392 ////////////////////////////////////////////////////////////////////////////////
377 393
378 HistoryUI2::HistoryUI2(TabContents* contents) : ChromeWebUI(contents) { 394 HistoryUI2::HistoryUI2(TabContents* contents) : ChromeWebUI(contents) {
379 AddMessageHandler((new BrowsingHistoryHandler2())->Attach(this)); 395 AddMessageHandler((new BrowsingHistoryHandler2())->Attach(this));
380 396
381 HistoryUIHTMLSource2* html_source = new HistoryUIHTMLSource2(); 397 HistoryUIHTMLSource2* html_source = new HistoryUIHTMLSource2();
382 398
383 // Set up the chrome://history2/ source. 399 // Set up the chrome://history2/ source.
384 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); 400 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source);
385 } 401 }
386 402
387 // static 403 // static
388 const GURL HistoryUI2::GetHistoryURLWithSearchText(const string16& text) { 404 const GURL HistoryUI2::GetHistoryURLWithSearchText(const string16& text) {
389 return GURL(std::string(chrome::kChromeUIHistory2URL) + "#q=" + 405 return GURL(std::string(chrome::kChromeUIHistory2URL) + "#q=" +
390 EscapeQueryParamValue(UTF16ToUTF8(text), true)); 406 EscapeQueryParamValue(UTF16ToUTF8(text), true));
391 } 407 }
392 408
393 // static 409 // static
394 RefCountedMemory* HistoryUI2::GetFaviconResourceBytes() { 410 RefCountedMemory* HistoryUI2::GetFaviconResourceBytes() {
395 return ResourceBundle::GetSharedInstance(). 411 return ResourceBundle::GetSharedInstance().
396 LoadDataResourceBytes(IDR_HISTORY_FAVICON); 412 LoadDataResourceBytes(IDR_HISTORY_FAVICON);
397 } 413 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/history2_ui.h ('k') | chrome/browser/ui/webui/history_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698