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

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

Issue 131094: Add GetMessageHandlers to HtmlDialogUIDelegate to allow... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months 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
« no previous file with comments | « chrome/browser/dom_ui/history_ui.h ('k') | chrome/browser/dom_ui/html_dialog_ui.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); 89 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin());
90 90
91 SendResponse(request_id, html_bytes); 91 SendResponse(request_id, html_bytes);
92 } 92 }
93 93
94 //////////////////////////////////////////////////////////////////////////////// 94 ////////////////////////////////////////////////////////////////////////////////
95 // 95 //
96 // HistoryHandler 96 // HistoryHandler
97 // 97 //
98 //////////////////////////////////////////////////////////////////////////////// 98 ////////////////////////////////////////////////////////////////////////////////
99 BrowsingHistoryHandler::BrowsingHistoryHandler(DOMUI* dom_ui) 99 BrowsingHistoryHandler::BrowsingHistoryHandler()
100 : DOMMessageHandler(dom_ui), 100 : search_text_(),
101 search_text_(),
102 remover_(NULL) { 101 remover_(NULL) {
103 dom_ui_->RegisterMessageCallback("getHistory",
104 NewCallback(this, &BrowsingHistoryHandler::HandleGetHistory));
105 dom_ui_->RegisterMessageCallback("searchHistory",
106 NewCallback(this, &BrowsingHistoryHandler::HandleSearchHistory));
107 dom_ui_->RegisterMessageCallback("deleteDay",
108 NewCallback(this, &BrowsingHistoryHandler::HandleDeleteDay));
109
110 // Create our favicon data source. 102 // Create our favicon data source.
111 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, 103 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
112 NewRunnableMethod(&chrome_url_data_manager, 104 NewRunnableMethod(&chrome_url_data_manager,
113 &ChromeURLDataManager::AddDataSource, 105 &ChromeURLDataManager::AddDataSource,
114 new DOMUIFavIconSource(dom_ui_->GetProfile()))); 106 new DOMUIFavIconSource(dom_ui_->GetProfile())));
115 107
116 // Get notifications when history is cleared. 108 // Get notifications when history is cleared.
117 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED, 109 registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED,
118 Source<Profile>(dom_ui_->GetProfile()->GetOriginalProfile())); 110 Source<Profile>(dom_ui_->GetProfile()->GetOriginalProfile()));
119 } 111 }
120 112
121 BrowsingHistoryHandler::~BrowsingHistoryHandler() { 113 BrowsingHistoryHandler::~BrowsingHistoryHandler() {
122 cancelable_consumer_.CancelAllRequests(); 114 cancelable_consumer_.CancelAllRequests();
123 if (remover_.get()) 115 if (remover_.get())
124 remover_->RemoveObserver(this); 116 remover_->RemoveObserver(this);
125 } 117 }
126 118
119 void BrowsingHistoryHandler::RegisterMessages() {
120 dom_ui_->RegisterMessageCallback("getHistory",
121 NewCallback(this, &BrowsingHistoryHandler::HandleGetHistory));
122 dom_ui_->RegisterMessageCallback("searchHistory",
123 NewCallback(this, &BrowsingHistoryHandler::HandleSearchHistory));
124 dom_ui_->RegisterMessageCallback("deleteDay",
125 NewCallback(this, &BrowsingHistoryHandler::HandleDeleteDay));
126 }
127
127 void BrowsingHistoryHandler::HandleGetHistory(const Value* value) { 128 void BrowsingHistoryHandler::HandleGetHistory(const Value* value) {
128 // Anything in-flight is invalid. 129 // Anything in-flight is invalid.
129 cancelable_consumer_.CancelAllRequests(); 130 cancelable_consumer_.CancelAllRequests();
130 131
131 // Get arguments (if any). 132 // Get arguments (if any).
132 int day = 0; 133 int day = 0;
133 ExtractIntegerValue(value, &day); 134 ExtractIntegerValue(value, &day);
134 135
135 // Set our query options. 136 // Set our query options.
136 history::QueryOptions options; 137 history::QueryOptions options;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 dom_ui_->CallJavascriptFunction(L"historyDeleted"); 350 dom_ui_->CallJavascriptFunction(L"historyDeleted");
350 } 351 }
351 352
352 //////////////////////////////////////////////////////////////////////////////// 353 ////////////////////////////////////////////////////////////////////////////////
353 // 354 //
354 // HistoryUIContents 355 // HistoryUIContents
355 // 356 //
356 //////////////////////////////////////////////////////////////////////////////// 357 ////////////////////////////////////////////////////////////////////////////////
357 358
358 HistoryUI::HistoryUI(TabContents* contents) : DOMUI(contents) { 359 HistoryUI::HistoryUI(TabContents* contents) : DOMUI(contents) {
359 AddMessageHandler(new BrowsingHistoryHandler(this)); 360 AddMessageHandler((new BrowsingHistoryHandler())->Attach(this));
360 361
361 HistoryUIHTMLSource* html_source = new HistoryUIHTMLSource(); 362 HistoryUIHTMLSource* html_source = new HistoryUIHTMLSource();
362 363
363 // Set up the chrome://history/ source. 364 // Set up the chrome://history/ source.
364 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, 365 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
365 NewRunnableMethod(&chrome_url_data_manager, 366 NewRunnableMethod(&chrome_url_data_manager,
366 &ChromeURLDataManager::AddDataSource, 367 &ChromeURLDataManager::AddDataSource,
367 html_source)); 368 html_source));
368 } 369 }
369 370
370 // static 371 // static
371 const GURL HistoryUI::GetHistoryURLWithSearchText(const std::wstring& text) { 372 const GURL HistoryUI::GetHistoryURLWithSearchText(const std::wstring& text) {
372 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + 373 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" +
373 EscapeQueryParamValue(WideToUTF8(text))); 374 EscapeQueryParamValue(WideToUTF8(text)));
374 } 375 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/history_ui.h ('k') | chrome/browser/dom_ui/html_dialog_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698