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