Chromium Code Reviews| 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/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 DOMMessageHandler* BrowsingHistoryHandler::Attach(DOMUI* dom_ui) { | 110 DOMMessageHandler* BrowsingHistoryHandler::Attach(DOMUI* dom_ui) { |
| 111 // Create our favicon data source. | 111 // Create our favicon data source. |
| 112 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, | 112 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, |
| 113 NewRunnableMethod(&chrome_url_data_manager, | 113 NewRunnableMethod(&chrome_url_data_manager, |
| 114 &ChromeURLDataManager::AddDataSource, | 114 &ChromeURLDataManager::AddDataSource, |
| 115 new DOMUIFavIconSource(dom_ui->GetProfile()))); | 115 new DOMUIFavIconSource(dom_ui->GetProfile()))); |
| 116 | 116 |
| 117 // Get notifications when history is cleared. | 117 // Get notifications when history is cleared. |
| 118 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED, | 118 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED, |
| 119 Source<Profile>(dom_ui->GetProfile()->GetOriginalProfile())); | 119 Source<Profile>(dom_ui->GetProfile()->GetOriginalProfile())); |
| 120 registrar_.Add(this, NotificationType::URLS_STARRED, | |
| 121 Source<Profile>(dom_ui->GetProfile()->GetOriginalProfile())); | |
| 120 return DOMMessageHandler::Attach(dom_ui); | 122 return DOMMessageHandler::Attach(dom_ui); |
| 121 } | 123 } |
| 122 | 124 |
| 123 void BrowsingHistoryHandler::RegisterMessages() { | 125 void BrowsingHistoryHandler::RegisterMessages() { |
| 124 dom_ui_->RegisterMessageCallback("getHistory", | 126 dom_ui_->RegisterMessageCallback("getHistory", |
| 125 NewCallback(this, &BrowsingHistoryHandler::HandleGetHistory)); | 127 NewCallback(this, &BrowsingHistoryHandler::HandleGetHistory)); |
| 126 dom_ui_->RegisterMessageCallback("searchHistory", | 128 dom_ui_->RegisterMessageCallback("searchHistory", |
| 127 NewCallback(this, &BrowsingHistoryHandler::HandleSearchHistory)); | 129 NewCallback(this, &BrowsingHistoryHandler::HandleSearchHistory)); |
| 128 dom_ui_->RegisterMessageCallback("deleteDay", | 130 dom_ui_->RegisterMessageCallback("deleteDay", |
| 129 NewCallback(this, &BrowsingHistoryHandler::HandleDeleteDay)); | 131 NewCallback(this, &BrowsingHistoryHandler::HandleDeleteDay)); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 } | 340 } |
| 339 options.begin_time = base::Time::FromLocalExploded(exploded); | 341 options.begin_time = base::Time::FromLocalExploded(exploded); |
| 340 } | 342 } |
| 341 | 343 |
| 342 return options; | 344 return options; |
| 343 } | 345 } |
| 344 | 346 |
| 345 void BrowsingHistoryHandler::Observe(NotificationType type, | 347 void BrowsingHistoryHandler::Observe(NotificationType type, |
| 346 const NotificationSource& source, | 348 const NotificationSource& source, |
| 347 const NotificationDetails& details) { | 349 const NotificationDetails& details) { |
| 348 if (type != NotificationType::HISTORY_URLS_DELETED) { | 350 if (type == NotificationType::HISTORY_URLS_DELETED) { |
| 349 NOTREACHED(); | 351 // Some URLs were deleted from history. Reload the list. |
| 350 return; | 352 dom_ui_->CallJavascriptFunction(L"historyDeleted"); |
| 353 } else if (type == NotificationType::URLS_STARRED) { | |
| 354 // Maybe some bookmarks were added, removed, moved or favicon changed. | |
| 355 dom_ui_->CallJavascriptFunction(L"reloadList"); | |
|
Glen Murphy
2009/07/30 17:18:28
I don't think you want to make it reload the page
| |
| 351 } | 356 } |
| 352 | |
| 353 // Some URLs were deleted from history. Reload the list. | |
| 354 dom_ui_->CallJavascriptFunction(L"historyDeleted"); | |
| 355 } | 357 } |
| 356 | 358 |
| 357 //////////////////////////////////////////////////////////////////////////////// | 359 //////////////////////////////////////////////////////////////////////////////// |
| 358 // | 360 // |
| 359 // HistoryUIContents | 361 // HistoryUIContents |
| 360 // | 362 // |
| 361 //////////////////////////////////////////////////////////////////////////////// | 363 //////////////////////////////////////////////////////////////////////////////// |
| 362 | 364 |
| 363 HistoryUI::HistoryUI(TabContents* contents) : DOMUI(contents) { | 365 HistoryUI::HistoryUI(TabContents* contents) : DOMUI(contents) { |
| 364 AddMessageHandler((new BrowsingHistoryHandler())->Attach(this)); | 366 AddMessageHandler((new BrowsingHistoryHandler())->Attach(this)); |
| 365 | 367 |
| 366 HistoryUIHTMLSource* html_source = new HistoryUIHTMLSource(); | 368 HistoryUIHTMLSource* html_source = new HistoryUIHTMLSource(); |
| 367 | 369 |
| 368 // Set up the chrome://history/ source. | 370 // Set up the chrome://history/ source. |
| 369 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, | 371 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, |
| 370 NewRunnableMethod(&chrome_url_data_manager, | 372 NewRunnableMethod(&chrome_url_data_manager, |
| 371 &ChromeURLDataManager::AddDataSource, | 373 &ChromeURLDataManager::AddDataSource, |
| 372 html_source)); | 374 html_source)); |
| 373 } | 375 } |
| 374 | 376 |
| 375 // static | 377 // static |
| 376 const GURL HistoryUI::GetHistoryURLWithSearchText(const std::wstring& text) { | 378 const GURL HistoryUI::GetHistoryURLWithSearchText(const std::wstring& text) { |
| 377 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + | 379 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + |
| 378 EscapeQueryParamValue(WideToUTF8(text))); | 380 EscapeQueryParamValue(WideToUTF8(text))); |
| 379 } | 381 } |
| 382 | |
| OLD | NEW |