OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/history_ui.h" | 5 #include "chrome/browser/ui/webui/history_ui.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 const ProfileSyncService* sync_service) const { | 320 const ProfileSyncService* sync_service) const { |
321 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 321 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
322 SetUrlAndTitle(result.get()); | 322 SetUrlAndTitle(result.get()); |
323 | 323 |
324 base::string16 domain = net::IDNToUnicode(url.host(), accept_languages); | 324 base::string16 domain = net::IDNToUnicode(url.host(), accept_languages); |
325 // When the domain is empty, use the scheme instead. This allows for a | 325 // When the domain is empty, use the scheme instead. This allows for a |
326 // sensible treatment of e.g. file: URLs when group by domain is on. | 326 // sensible treatment of e.g. file: URLs when group by domain is on. |
327 if (domain.empty()) | 327 if (domain.empty()) |
328 domain = base::UTF8ToUTF16(url.scheme() + ":"); | 328 domain = base::UTF8ToUTF16(url.scheme() + ":"); |
329 | 329 |
| 330 // The items which are to be written into result are also described in |
| 331 // chrome/browser/resources/history/history.js in @typedef for |
| 332 // BackendHistoryResultObject. Please update it whenever you add or remove |
| 333 // any keys in result. |
330 result->SetString("domain", domain); | 334 result->SetString("domain", domain); |
331 result->SetDouble("time", time.ToJsTime()); | 335 result->SetDouble("time", time.ToJsTime()); |
332 | 336 |
333 // Pass the timestamps in a list. | 337 // Pass the timestamps in a list. |
334 scoped_ptr<base::ListValue> timestamps(new base::ListValue); | 338 scoped_ptr<base::ListValue> timestamps(new base::ListValue); |
335 for (std::set<int64>::const_iterator it = all_timestamps.begin(); | 339 for (std::set<int64>::const_iterator it = all_timestamps.begin(); |
336 it != all_timestamps.end(); ++it) { | 340 it != all_timestamps.end(); ++it) { |
337 timestamps->AppendDouble(base::Time::FromInternalValue(*it).ToJsTime()); | 341 timestamps->AppendDouble(base::Time::FromInternalValue(*it).ToJsTime()); |
338 } | 342 } |
339 result->Set("allTimestamps", timestamps.release()); | 343 result->Set("allTimestamps", timestamps.release()); |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 page.url(), | 780 page.url(), |
777 page.title(), | 781 page.title(), |
778 page.visit_time(), | 782 page.visit_time(), |
779 std::string(), | 783 std::string(), |
780 !search_text.empty(), | 784 !search_text.empty(), |
781 page.snippet().text(), | 785 page.snippet().text(), |
782 page.blocked_visit(), | 786 page.blocked_visit(), |
783 accept_languages)); | 787 accept_languages)); |
784 } | 788 } |
785 | 789 |
| 790 // The items which are to be written into results_info_value_ are also |
| 791 // described in chrome/browser/resources/history/history.js in @typedef for |
| 792 // BackendHistoryResultsInfoObject. Please update it whenever you add or |
| 793 // remove any keys in results_info_value_. |
786 results_info_value_.SetString("term", search_text); | 794 results_info_value_.SetString("term", search_text); |
787 results_info_value_.SetBoolean("finished", results->reached_beginning()); | 795 results_info_value_.SetBoolean("finished", results->reached_beginning()); |
788 | 796 |
789 // Add the specific dates that were searched to display them. | 797 // Add the specific dates that were searched to display them. |
790 // TODO(sergiu): Put today if the start is in the future. | 798 // TODO(sergiu): Put today if the start is in the future. |
791 results_info_value_.SetString("queryStartTime", | 799 results_info_value_.SetString("queryStartTime", |
792 getRelativeDateLocalized(options.begin_time)); | 800 getRelativeDateLocalized(options.begin_time)); |
793 if (!options.end_time.is_null()) { | 801 if (!options.end_time.is_null()) { |
794 results_info_value_.SetString("queryEndTime", | 802 results_info_value_.SetString("queryEndTime", |
795 getRelativeDateLocalized(options.end_time - | 803 getRelativeDateLocalized(options.end_time - |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 Profile* profile = Profile::FromWebUI(web_ui); | 1015 Profile* profile = Profile::FromWebUI(web_ui); |
1008 content::WebUIDataSource::Add(profile, CreateHistoryUIHTMLSource(profile)); | 1016 content::WebUIDataSource::Add(profile, CreateHistoryUIHTMLSource(profile)); |
1009 } | 1017 } |
1010 | 1018 |
1011 // static | 1019 // static |
1012 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( | 1020 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( |
1013 ui::ScaleFactor scale_factor) { | 1021 ui::ScaleFactor scale_factor) { |
1014 return ResourceBundle::GetSharedInstance(). | 1022 return ResourceBundle::GetSharedInstance(). |
1015 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); | 1023 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); |
1016 } | 1024 } |
OLD | NEW |