| 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/history2_ui.h" | 5 #include "chrome/browser/dom_ui/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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 : search_text_() { | 122 : search_text_() { |
| 123 } | 123 } |
| 124 | 124 |
| 125 BrowsingHistoryHandler2::~BrowsingHistoryHandler2() { | 125 BrowsingHistoryHandler2::~BrowsingHistoryHandler2() { |
| 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* BrowsingHistoryHandler2::Attach(DOMUI* dom_ui) { | 130 WebUIMessageHandler* BrowsingHistoryHandler2::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>(dom_ui->GetProfile()->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 BrowsingHistoryHandler2::RegisterMessages() { | 145 void BrowsingHistoryHandler2::RegisterMessages() { |
| 143 dom_ui_->RegisterMessageCallback("getHistory", | 146 dom_ui_->RegisterMessageCallback("getHistory", |
| 144 NewCallback(this, &BrowsingHistoryHandler2::HandleGetHistory)); | 147 NewCallback(this, &BrowsingHistoryHandler2::HandleGetHistory)); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 // HistoryUIContents | 393 // HistoryUIContents |
| 391 // | 394 // |
| 392 //////////////////////////////////////////////////////////////////////////////// | 395 //////////////////////////////////////////////////////////////////////////////// |
| 393 | 396 |
| 394 HistoryUI2::HistoryUI2(TabContents* contents) : DOMUI(contents) { | 397 HistoryUI2::HistoryUI2(TabContents* contents) : DOMUI(contents) { |
| 395 AddMessageHandler((new BrowsingHistoryHandler2())->Attach(this)); | 398 AddMessageHandler((new BrowsingHistoryHandler2())->Attach(this)); |
| 396 | 399 |
| 397 HistoryUIHTMLSource2* html_source = new HistoryUIHTMLSource2(); | 400 HistoryUIHTMLSource2* html_source = new HistoryUIHTMLSource2(); |
| 398 | 401 |
| 399 // Set up the chrome://history2/ source. | 402 // Set up the chrome://history2/ source. |
| 400 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 403 BrowserThread::PostTask( |
| 404 BrowserThread::IO, FROM_HERE, |
| 405 NewRunnableMethod( |
| 406 ChromeURLDataManager::GetInstance(), |
| 407 &ChromeURLDataManager::AddDataSource, |
| 408 make_scoped_refptr(html_source))); |
| 401 } | 409 } |
| 402 | 410 |
| 403 // static | 411 // static |
| 404 const GURL HistoryUI2::GetHistoryURLWithSearchText(const string16& text) { | 412 const GURL HistoryUI2::GetHistoryURLWithSearchText(const string16& text) { |
| 405 return GURL(std::string(chrome::kChromeUIHistory2URL) + "#q=" + | 413 return GURL(std::string(chrome::kChromeUIHistory2URL) + "#q=" + |
| 406 EscapeQueryParamValue(UTF16ToUTF8(text), true)); | 414 EscapeQueryParamValue(UTF16ToUTF8(text), true)); |
| 407 } | 415 } |
| 408 | 416 |
| 409 // static | 417 // static |
| 410 RefCountedMemory* HistoryUI2::GetFaviconResourceBytes() { | 418 RefCountedMemory* HistoryUI2::GetFaviconResourceBytes() { |
| 411 return ResourceBundle::GetSharedInstance(). | 419 return ResourceBundle::GetSharedInstance(). |
| 412 LoadDataResourceBytes(IDR_HISTORY_FAVICON); | 420 LoadDataResourceBytes(IDR_HISTORY_FAVICON); |
| 413 } | 421 } |
| OLD | NEW |