| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/dom_ui/history_ui.h" | 5 #include "chrome/browser/dom_ui/history_ui.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/singleton.h" |
| 11 #include "base/string_piece.h" | 12 #include "base/string_piece.h" |
| 12 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 13 #include "base/thread.h" | 14 #include "base/thread.h" |
| 14 #include "base/time.h" | 15 #include "base/time.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "chrome/browser/bookmarks/bookmark_model.h" | 17 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 17 #include "chrome/browser/chrome_thread.h" | 18 #include "chrome/browser/chrome_thread.h" |
| 18 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" | 19 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" |
| 19 #include "chrome/browser/metrics/user_metrics.h" | 20 #include "chrome/browser/metrics/user_metrics.h" |
| 20 #include "chrome/browser/history/history_types.h" | 21 #include "chrome/browser/history/history_types.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 cancelable_consumer_.CancelAllRequests(); | 107 cancelable_consumer_.CancelAllRequests(); |
| 107 if (remover_) | 108 if (remover_) |
| 108 remover_->RemoveObserver(this); | 109 remover_->RemoveObserver(this); |
| 109 } | 110 } |
| 110 | 111 |
| 111 DOMMessageHandler* BrowsingHistoryHandler::Attach(DOMUI* dom_ui) { | 112 DOMMessageHandler* BrowsingHistoryHandler::Attach(DOMUI* dom_ui) { |
| 112 // Create our favicon data source. | 113 // Create our favicon data source. |
| 113 ChromeThread::PostTask( | 114 ChromeThread::PostTask( |
| 114 ChromeThread::IO, FROM_HERE, | 115 ChromeThread::IO, FROM_HERE, |
| 115 NewRunnableMethod( | 116 NewRunnableMethod( |
| 116 &chrome_url_data_manager, | 117 Singleton<ChromeURLDataManager>().get(), |
| 117 &ChromeURLDataManager::AddDataSource, | 118 &ChromeURLDataManager::AddDataSource, |
| 118 new DOMUIFavIconSource(dom_ui->GetProfile()))); | 119 new DOMUIFavIconSource(dom_ui->GetProfile()))); |
| 119 | 120 |
| 120 // Get notifications when history is cleared. | 121 // Get notifications when history is cleared. |
| 121 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED, | 122 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED, |
| 122 Source<Profile>(dom_ui->GetProfile()->GetOriginalProfile())); | 123 Source<Profile>(dom_ui->GetProfile()->GetOriginalProfile())); |
| 123 return DOMMessageHandler::Attach(dom_ui); | 124 return DOMMessageHandler::Attach(dom_ui); |
| 124 } | 125 } |
| 125 | 126 |
| 126 void BrowsingHistoryHandler::RegisterMessages() { | 127 void BrowsingHistoryHandler::RegisterMessages() { |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 367 |
| 367 HistoryUI::HistoryUI(TabContents* contents) : DOMUI(contents) { | 368 HistoryUI::HistoryUI(TabContents* contents) : DOMUI(contents) { |
| 368 AddMessageHandler((new BrowsingHistoryHandler())->Attach(this)); | 369 AddMessageHandler((new BrowsingHistoryHandler())->Attach(this)); |
| 369 | 370 |
| 370 HistoryUIHTMLSource* html_source = new HistoryUIHTMLSource(); | 371 HistoryUIHTMLSource* html_source = new HistoryUIHTMLSource(); |
| 371 | 372 |
| 372 // Set up the chrome://history/ source. | 373 // Set up the chrome://history/ source. |
| 373 ChromeThread::PostTask( | 374 ChromeThread::PostTask( |
| 374 ChromeThread::IO, FROM_HERE, | 375 ChromeThread::IO, FROM_HERE, |
| 375 NewRunnableMethod( | 376 NewRunnableMethod( |
| 376 &chrome_url_data_manager, | 377 Singleton<ChromeURLDataManager>().get(), |
| 377 &ChromeURLDataManager::AddDataSource, | 378 &ChromeURLDataManager::AddDataSource, |
| 378 html_source)); | 379 html_source)); |
| 379 } | 380 } |
| 380 | 381 |
| 381 // static | 382 // static |
| 382 const GURL HistoryUI::GetHistoryURLWithSearchText(const std::wstring& text) { | 383 const GURL HistoryUI::GetHistoryURLWithSearchText(const std::wstring& text) { |
| 383 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + | 384 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + |
| 384 EscapeQueryParamValue(WideToUTF8(text))); | 385 EscapeQueryParamValue(WideToUTF8(text))); |
| 385 } | 386 } |
| 386 | 387 |
| 387 // static | 388 // static |
| 388 RefCountedMemory* HistoryUI::GetFaviconResourceBytes() { | 389 RefCountedMemory* HistoryUI::GetFaviconResourceBytes() { |
| 389 return ResourceBundle::GetSharedInstance(). | 390 return ResourceBundle::GetSharedInstance(). |
| 390 LoadImageResourceBytes(IDR_HISTORY_FAVICON); | 391 LoadImageResourceBytes(IDR_HISTORY_FAVICON); |
| 391 } | 392 } |
| OLD | NEW |