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/downloads_dom_handler.h" | 5 #include "chrome/browser/ui/webui/downloads_dom_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // Returns a JSON dictionary containing some of the attributes of |download|. | 111 // Returns a JSON dictionary containing some of the attributes of |download|. |
112 // The JSON dictionary will also have a field "id" set to |id|, and a field | 112 // The JSON dictionary will also have a field "id" set to |id|, and a field |
113 // "otr" set to |incognito|. | 113 // "otr" set to |incognito|. |
114 base::DictionaryValue* CreateDownloadItemValue( | 114 base::DictionaryValue* CreateDownloadItemValue( |
115 content::DownloadItem* download_item, | 115 content::DownloadItem* download_item, |
116 bool incognito) { | 116 bool incognito) { |
117 // TODO(asanka): Move towards using download_model here for getting status and | 117 // TODO(asanka): Move towards using download_model here for getting status and |
118 // progress. The difference currently only matters to Drive downloads and | 118 // progress. The difference currently only matters to Drive downloads and |
119 // those don't show up on the downloads page, but should. | 119 // those don't show up on the downloads page, but should. |
120 DownloadItemModel download_model(download_item); | 120 DownloadItemModel download_model(download_item); |
| 121 |
| 122 // The items which are to be written into file_value are also described in |
| 123 // chrome/browser/resources/downloads/downloads.js in @typedef for |
| 124 // BackendDownloadObject. Please update it whenever you add or remove |
| 125 // any keys in file_value. |
121 base::DictionaryValue* file_value = new base::DictionaryValue(); | 126 base::DictionaryValue* file_value = new base::DictionaryValue(); |
122 | 127 |
123 file_value->SetInteger( | 128 file_value->SetInteger( |
124 "started", static_cast<int>(download_item->GetStartTime().ToTimeT())); | 129 "started", static_cast<int>(download_item->GetStartTime().ToTimeT())); |
125 file_value->SetString( | 130 file_value->SetString( |
126 "since_string", ui::TimeFormat::RelativeDate( | 131 "since_string", ui::TimeFormat::RelativeDate( |
127 download_item->GetStartTime(), NULL)); | 132 download_item->GetStartTime(), NULL)); |
128 file_value->SetString( | 133 file_value->SetString( |
129 "date_string", base::TimeFormatShortDate(download_item->GetStartTime())); | 134 "date_string", base::TimeFormatShortDate(download_item->GetStartTime())); |
130 file_value->SetInteger("id", download_item->GetId()); | 135 file_value->SetInteger("id", download_item->GetId()); |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 } | 580 } |
576 | 581 |
577 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { | 582 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { |
578 web_ui()->CallJavascriptFunction("downloadsList", downloads); | 583 web_ui()->CallJavascriptFunction("downloadsList", downloads); |
579 } | 584 } |
580 | 585 |
581 void DownloadsDOMHandler::CallDownloadUpdated( | 586 void DownloadsDOMHandler::CallDownloadUpdated( |
582 const base::ListValue& download_item) { | 587 const base::ListValue& download_item) { |
583 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); | 588 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); |
584 } | 589 } |
OLD | NEW |