Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: chrome/browser/dom_ui/history_ui.cc

Issue 342020: First of several patches to get rid of MessageLoop caching now that we have C... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/string_piece.h" 11 #include "base/string_piece.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/thread.h" 13 #include "base/thread.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/browser/bookmarks/bookmark_model.h" 16 #include "chrome/browser/bookmarks/bookmark_model.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/chrome_thread.h"
18 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" 18 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h"
19 #include "chrome/browser/metrics/user_metrics.h" 19 #include "chrome/browser/metrics/user_metrics.h"
20 #include "chrome/browser/history/history_types.h" 20 #include "chrome/browser/history/history_types.h"
21 #include "chrome/browser/profile.h" 21 #include "chrome/browser/profile.h"
22 #include "chrome/common/jstemplate_builder.h" 22 #include "chrome/common/jstemplate_builder.h"
23 #include "chrome/common/notification_service.h" 23 #include "chrome/common/notification_service.h"
24 #include "chrome/common/time_format.h" 24 #include "chrome/common/time_format.h"
25 #include "chrome/common/url_constants.h" 25 #include "chrome/common/url_constants.h"
26 #include "net/base/escape.h" 26 #include "net/base/escape.h"
27 27
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 103 }
104 104
105 BrowsingHistoryHandler::~BrowsingHistoryHandler() { 105 BrowsingHistoryHandler::~BrowsingHistoryHandler() {
106 cancelable_consumer_.CancelAllRequests(); 106 cancelable_consumer_.CancelAllRequests();
107 if (remover_) 107 if (remover_)
108 remover_->RemoveObserver(this); 108 remover_->RemoveObserver(this);
109 } 109 }
110 110
111 DOMMessageHandler* BrowsingHistoryHandler::Attach(DOMUI* dom_ui) { 111 DOMMessageHandler* BrowsingHistoryHandler::Attach(DOMUI* dom_ui) {
112 // Create our favicon data source. 112 // Create our favicon data source.
113 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, 113 ChromeThread::PostTask(
114 NewRunnableMethod(&chrome_url_data_manager, 114 ChromeThread::IO, FROM_HERE,
115 &ChromeURLDataManager::AddDataSource, 115 NewRunnableMethod(
116 new DOMUIFavIconSource(dom_ui->GetProfile()))); 116 &chrome_url_data_manager,
117 &ChromeURLDataManager::AddDataSource,
118 new DOMUIFavIconSource(dom_ui->GetProfile())));
117 119
118 // Get notifications when history is cleared. 120 // Get notifications when history is cleared.
119 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED, 121 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED,
120 Source<Profile>(dom_ui->GetProfile()->GetOriginalProfile())); 122 Source<Profile>(dom_ui->GetProfile()->GetOriginalProfile()));
121 return DOMMessageHandler::Attach(dom_ui); 123 return DOMMessageHandler::Attach(dom_ui);
122 } 124 }
123 125
124 void BrowsingHistoryHandler::RegisterMessages() { 126 void BrowsingHistoryHandler::RegisterMessages() {
125 dom_ui_->RegisterMessageCallback("getHistory", 127 dom_ui_->RegisterMessageCallback("getHistory",
126 NewCallback(this, &BrowsingHistoryHandler::HandleGetHistory)); 128 NewCallback(this, &BrowsingHistoryHandler::HandleGetHistory));
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 // HistoryUIContents 363 // HistoryUIContents
362 // 364 //
363 //////////////////////////////////////////////////////////////////////////////// 365 ////////////////////////////////////////////////////////////////////////////////
364 366
365 HistoryUI::HistoryUI(TabContents* contents) : DOMUI(contents) { 367 HistoryUI::HistoryUI(TabContents* contents) : DOMUI(contents) {
366 AddMessageHandler((new BrowsingHistoryHandler())->Attach(this)); 368 AddMessageHandler((new BrowsingHistoryHandler())->Attach(this));
367 369
368 HistoryUIHTMLSource* html_source = new HistoryUIHTMLSource(); 370 HistoryUIHTMLSource* html_source = new HistoryUIHTMLSource();
369 371
370 // Set up the chrome://history/ source. 372 // Set up the chrome://history/ source.
371 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, 373 ChromeThread::PostTask(
372 NewRunnableMethod(&chrome_url_data_manager, 374 ChromeThread::IO, FROM_HERE,
375 NewRunnableMethod(
376 &chrome_url_data_manager,
373 &ChromeURLDataManager::AddDataSource, 377 &ChromeURLDataManager::AddDataSource,
374 html_source)); 378 html_source));
375 } 379 }
376 380
377 // static 381 // static
378 const GURL HistoryUI::GetHistoryURLWithSearchText(const std::wstring& text) { 382 const GURL HistoryUI::GetHistoryURLWithSearchText(const std::wstring& text) {
379 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + 383 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" +
380 EscapeQueryParamValue(WideToUTF8(text))); 384 EscapeQueryParamValue(WideToUTF8(text)));
381 } 385 }
382 386
383 // static 387 // static
384 RefCountedMemory* HistoryUI::GetFaviconResourceBytes() { 388 RefCountedMemory* HistoryUI::GetFaviconResourceBytes() {
385 return ResourceBundle::GetSharedInstance(). 389 return ResourceBundle::GetSharedInstance().
386 LoadImageResourceBytes(IDR_HISTORY_FAVICON); 390 LoadImageResourceBytes(IDR_HISTORY_FAVICON);
387 } 391 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698