OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/history2_ui.h" | 5 #include "chrome/browser/dom_ui/history2_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/callback.h" | 9 #include "base/callback.h" |
10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/singleton.h" | 12 #include "base/singleton.h" |
13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
14 #include "base/string_piece.h" | 14 #include "base/string_piece.h" |
15 #include "base/thread.h" | 15 #include "base/thread.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/bookmarks/bookmark_model.h" | 18 #include "chrome/browser/bookmarks/bookmark_model.h" |
19 #include "chrome/browser/browser.h" | 19 #include "chrome/browser/browser.h" |
| 20 #include "chrome/browser/browser_list.h" |
20 #include "chrome/browser/chrome_thread.h" | 21 #include "chrome/browser/chrome_thread.h" |
21 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" | 22 #include "chrome/browser/dom_ui/dom_ui_favicon_source.h" |
22 #include "chrome/browser/metrics/user_metrics.h" | 23 #include "chrome/browser/metrics/user_metrics.h" |
23 #include "chrome/browser/history/history_types.h" | 24 #include "chrome/browser/history/history_types.h" |
24 #include "chrome/browser/profile.h" | 25 #include "chrome/browser/profile.h" |
25 #include "chrome/browser/tab_contents/tab_contents.h" | 26 #include "chrome/browser/tab_contents/tab_contents.h" |
26 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 27 #include "chrome/browser/tab_contents/tab_contents_delegate.h" |
27 #include "chrome/common/jstemplate_builder.h" | 28 #include "chrome/common/jstemplate_builder.h" |
28 #include "chrome/common/notification_service.h" | 29 #include "chrome/common/notification_service.h" |
29 #include "chrome/common/time_format.h" | 30 #include "chrome/common/time_format.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 } | 229 } |
229 | 230 |
230 HistoryService* hs = | 231 HistoryService* hs = |
231 dom_ui_->GetProfile()->GetHistoryService(Profile::EXPLICIT_ACCESS); | 232 dom_ui_->GetProfile()->GetHistoryService(Profile::EXPLICIT_ACCESS); |
232 hs->ExpireHistoryBetween( | 233 hs->ExpireHistoryBetween( |
233 urls, begin_time, end_time, &cancelable_delete_consumer_, | 234 urls, begin_time, end_time, &cancelable_delete_consumer_, |
234 NewCallback(this, &BrowsingHistoryHandler2::RemoveComplete)); | 235 NewCallback(this, &BrowsingHistoryHandler2::RemoveComplete)); |
235 } | 236 } |
236 | 237 |
237 void BrowsingHistoryHandler2::HandleClearBrowsingData(const Value* value) { | 238 void BrowsingHistoryHandler2::HandleClearBrowsingData(const Value* value) { |
238 dom_ui_->tab_contents()->delegate()->GetBrowser()-> | 239 // TODO(beng): This is an improper direct dependency on Browser. Route this |
239 OpenClearBrowsingDataDialog(); | 240 // through some sort of delegate. |
| 241 Browser* browser = BrowserList::FindBrowserWithProfile(dom_ui_->GetProfile()); |
| 242 if (browser) |
| 243 browser->OpenClearBrowsingDataDialog(); |
240 } | 244 } |
241 | 245 |
242 void BrowsingHistoryHandler2::QueryComplete( | 246 void BrowsingHistoryHandler2::QueryComplete( |
243 HistoryService::Handle request_handle, | 247 HistoryService::Handle request_handle, |
244 history::QueryResults* results) { | 248 history::QueryResults* results) { |
245 | 249 |
246 ListValue results_value; | 250 ListValue results_value; |
247 base::Time midnight_today = base::Time::Now().LocalMidnight(); | 251 base::Time midnight_today = base::Time::Now().LocalMidnight(); |
248 | 252 |
249 for (size_t i = 0; i < results->size(); ++i) { | 253 for (size_t i = 0; i < results->size(); ++i) { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 const GURL HistoryUI2::GetHistoryURLWithSearchText(const string16& text) { | 409 const GURL HistoryUI2::GetHistoryURLWithSearchText(const string16& text) { |
406 return GURL(std::string(chrome::kChromeUIHistory2URL) + "#q=" + | 410 return GURL(std::string(chrome::kChromeUIHistory2URL) + "#q=" + |
407 EscapeQueryParamValue(UTF16ToUTF8(text), true)); | 411 EscapeQueryParamValue(UTF16ToUTF8(text), true)); |
408 } | 412 } |
409 | 413 |
410 // static | 414 // static |
411 RefCountedMemory* HistoryUI2::GetFaviconResourceBytes() { | 415 RefCountedMemory* HistoryUI2::GetFaviconResourceBytes() { |
412 return ResourceBundle::GetSharedInstance(). | 416 return ResourceBundle::GetSharedInstance(). |
413 LoadDataResourceBytes(IDR_HISTORY_FAVICON); | 417 LoadDataResourceBytes(IDR_HISTORY_FAVICON); |
414 } | 418 } |
OLD | NEW |