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

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

Issue 218001: BrowsingDataRemover* should not be scoped. (Closed)
Patch Set: Make BrowsingDataRemover destructor private Created 11 years, 2 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
« no previous file with comments | « chrome/browser/dom_ui/history_ui.h ('k') | no next file » | 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // HistoryHandler 97 // HistoryHandler
98 // 98 //
99 //////////////////////////////////////////////////////////////////////////////// 99 ////////////////////////////////////////////////////////////////////////////////
100 BrowsingHistoryHandler::BrowsingHistoryHandler() 100 BrowsingHistoryHandler::BrowsingHistoryHandler()
101 : search_text_(), 101 : search_text_(),
102 remover_(NULL) { 102 remover_(NULL) {
103 } 103 }
104 104
105 BrowsingHistoryHandler::~BrowsingHistoryHandler() { 105 BrowsingHistoryHandler::~BrowsingHistoryHandler() {
106 cancelable_consumer_.CancelAllRequests(); 106 cancelable_consumer_.CancelAllRequests();
107 if (remover_.get()) 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 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
114 NewRunnableMethod(&chrome_url_data_manager, 114 NewRunnableMethod(&chrome_url_data_manager,
115 &ChromeURLDataManager::AddDataSource, 115 &ChromeURLDataManager::AddDataSource,
116 new DOMUIFavIconSource(dom_ui->GetProfile()))); 116 new DOMUIFavIconSource(dom_ui->GetProfile())));
117 117
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 // Get time. 198 // Get time.
199 base::Time time; 199 base::Time time;
200 bool success = base::Time::FromString(ExtractStringValue(value).c_str(), 200 bool success = base::Time::FromString(ExtractStringValue(value).c_str(),
201 &time); 201 &time);
202 DCHECK(success); 202 DCHECK(success);
203 203
204 base::Time begin_time = time.LocalMidnight(); 204 base::Time begin_time = time.LocalMidnight();
205 base::Time end_time = begin_time + base::TimeDelta::FromDays(1); 205 base::Time end_time = begin_time + base::TimeDelta::FromDays(1);
206 206
207 remover_.reset(new BrowsingDataRemover(dom_ui_->GetProfile(), 207 remover_ = new BrowsingDataRemover(dom_ui_->GetProfile(),
208 begin_time, 208 begin_time,
209 end_time)); 209 end_time);
210 remover_->AddObserver(this); 210 remover_->AddObserver(this);
211 remover_->Remove(BrowsingDataRemover::REMOVE_HISTORY | 211 remover_->Remove(BrowsingDataRemover::REMOVE_HISTORY |
212 BrowsingDataRemover::REMOVE_COOKIES | 212 BrowsingDataRemover::REMOVE_COOKIES |
213 BrowsingDataRemover::REMOVE_CACHE); 213 BrowsingDataRemover::REMOVE_CACHE);
214 } 214 }
215 215
216 void BrowsingHistoryHandler::OnBrowsingDataRemoverDone() { 216 void BrowsingHistoryHandler::OnBrowsingDataRemoverDone() {
217 dom_ui_->CallJavascriptFunction(L"deleteComplete"); 217 dom_ui_->CallJavascriptFunction(L"deleteComplete");
218 remover_->RemoveObserver(this); 218 // No need to remove ourselves as an observer as BrowsingDataRemover deletes
219 remover_.release(); 219 // itself after we return.
220 remover_ = NULL;
220 } 221 }
221 222
222 void BrowsingHistoryHandler::QueryComplete( 223 void BrowsingHistoryHandler::QueryComplete(
223 HistoryService::Handle request_handle, 224 HistoryService::Handle request_handle,
224 history::QueryResults* results) { 225 history::QueryResults* results) {
225 226
226 ListValue results_value; 227 ListValue results_value;
227 base::Time midnight_today = base::Time::Now().LocalMidnight(); 228 base::Time midnight_today = base::Time::Now().LocalMidnight();
228 229
229 for (size_t i = 0; i < results->size(); ++i) { 230 for (size_t i = 0; i < results->size(); ++i) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 const GURL HistoryUI::GetHistoryURLWithSearchText(const std::wstring& text) { 378 const GURL HistoryUI::GetHistoryURLWithSearchText(const std::wstring& text) {
378 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + 379 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" +
379 EscapeQueryParamValue(WideToUTF8(text))); 380 EscapeQueryParamValue(WideToUTF8(text)));
380 } 381 }
381 382
382 // static 383 // static
383 bool HistoryUI::GetFaviconResourceBytes(std::vector<unsigned char>* bytes) { 384 bool HistoryUI::GetFaviconResourceBytes(std::vector<unsigned char>* bytes) {
384 return ResourceBundle::GetSharedInstance(). 385 return ResourceBundle::GetSharedInstance().
385 LoadImageResourceBytes(IDR_HISTORY_FAVICON, bytes); 386 LoadImageResourceBytes(IDR_HISTORY_FAVICON, bytes);
386 } 387 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/history_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698