| OLD | NEW |
| 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/dom_ui/history_ui.h" | 5 #include "chrome/browser/dom_ui/history_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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 : search_text_() { | 122 : search_text_() { |
| 123 } | 123 } |
| 124 | 124 |
| 125 BrowsingHistoryHandler::~BrowsingHistoryHandler() { | 125 BrowsingHistoryHandler::~BrowsingHistoryHandler() { |
| 126 cancelable_search_consumer_.CancelAllRequests(); | 126 cancelable_search_consumer_.CancelAllRequests(); |
| 127 cancelable_delete_consumer_.CancelAllRequests(); | 127 cancelable_delete_consumer_.CancelAllRequests(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 WebUIMessageHandler* BrowsingHistoryHandler::Attach(DOMUI* dom_ui) { | 130 WebUIMessageHandler* BrowsingHistoryHandler::Attach(DOMUI* dom_ui) { |
| 131 // Create our favicon data source. | 131 // Create our favicon data source. |
| 132 Profile* profile = dom_ui->GetProfile(); | 132 BrowserThread::PostTask( |
| 133 profile->GetChromeURLDataManager()->AddDataSource( | 133 BrowserThread::IO, FROM_HERE, |
| 134 new WebUIFavIconSource(profile)); | 134 NewRunnableMethod( |
| 135 ChromeURLDataManager::GetInstance(), |
| 136 &ChromeURLDataManager::AddDataSource, |
| 137 make_scoped_refptr(new WebUIFavIconSource(dom_ui->GetProfile())))); |
| 135 | 138 |
| 136 // Get notifications when history is cleared. | 139 // Get notifications when history is cleared. |
| 137 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED, | 140 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED, |
| 138 Source<Profile>(profile->GetOriginalProfile())); | 141 Source<Profile>(dom_ui->GetProfile()->GetOriginalProfile())); |
| 139 return WebUIMessageHandler::Attach(dom_ui); | 142 return WebUIMessageHandler::Attach(dom_ui); |
| 140 } | 143 } |
| 141 | 144 |
| 142 void BrowsingHistoryHandler::RegisterMessages() { | 145 void BrowsingHistoryHandler::RegisterMessages() { |
| 143 dom_ui_->RegisterMessageCallback("getHistory", | 146 dom_ui_->RegisterMessageCallback("getHistory", |
| 144 NewCallback(this, &BrowsingHistoryHandler::HandleGetHistory)); | 147 NewCallback(this, &BrowsingHistoryHandler::HandleGetHistory)); |
| 145 dom_ui_->RegisterMessageCallback("searchHistory", | 148 dom_ui_->RegisterMessageCallback("searchHistory", |
| 146 NewCallback(this, &BrowsingHistoryHandler::HandleSearchHistory)); | 149 NewCallback(this, &BrowsingHistoryHandler::HandleSearchHistory)); |
| 147 dom_ui_->RegisterMessageCallback("removeURLsOnOneDay", | 150 dom_ui_->RegisterMessageCallback("removeURLsOnOneDay", |
| 148 NewCallback(this, &BrowsingHistoryHandler::HandleRemoveURLsOnOneDay)); | 151 NewCallback(this, &BrowsingHistoryHandler::HandleRemoveURLsOnOneDay)); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 // HistoryUIContents | 381 // HistoryUIContents |
| 379 // | 382 // |
| 380 //////////////////////////////////////////////////////////////////////////////// | 383 //////////////////////////////////////////////////////////////////////////////// |
| 381 | 384 |
| 382 HistoryUI::HistoryUI(TabContents* contents) : DOMUI(contents) { | 385 HistoryUI::HistoryUI(TabContents* contents) : DOMUI(contents) { |
| 383 AddMessageHandler((new BrowsingHistoryHandler())->Attach(this)); | 386 AddMessageHandler((new BrowsingHistoryHandler())->Attach(this)); |
| 384 | 387 |
| 385 HistoryUIHTMLSource* html_source = new HistoryUIHTMLSource(); | 388 HistoryUIHTMLSource* html_source = new HistoryUIHTMLSource(); |
| 386 | 389 |
| 387 // Set up the chrome://history/ source. | 390 // Set up the chrome://history/ source. |
| 388 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 391 BrowserThread::PostTask( |
| 392 BrowserThread::IO, FROM_HERE, |
| 393 NewRunnableMethod( |
| 394 ChromeURLDataManager::GetInstance(), |
| 395 &ChromeURLDataManager::AddDataSource, |
| 396 make_scoped_refptr(html_source))); |
| 389 } | 397 } |
| 390 | 398 |
| 391 // static | 399 // static |
| 392 const GURL HistoryUI::GetHistoryURLWithSearchText(const string16& text) { | 400 const GURL HistoryUI::GetHistoryURLWithSearchText(const string16& text) { |
| 393 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + | 401 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + |
| 394 EscapeQueryParamValue(UTF16ToUTF8(text), true)); | 402 EscapeQueryParamValue(UTF16ToUTF8(text), true)); |
| 395 } | 403 } |
| 396 | 404 |
| 397 // static | 405 // static |
| 398 RefCountedMemory* HistoryUI::GetFaviconResourceBytes() { | 406 RefCountedMemory* HistoryUI::GetFaviconResourceBytes() { |
| 399 return ResourceBundle::GetSharedInstance(). | 407 return ResourceBundle::GetSharedInstance(). |
| 400 LoadDataResourceBytes(IDR_HISTORY_FAVICON); | 408 LoadDataResourceBytes(IDR_HISTORY_FAVICON); |
| 401 } | 409 } |
| OLD | NEW |