| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/crash/core/browser/crashes_ui_util.h" | 5 #include "components/crash/core/browser/crashes_ui_util.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/i18n/time_formatting.h" | 11 #include "base/i18n/time_formatting.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "components/upload_list/upload_list.h" | 14 #include "components/upload_list/upload_list.h" |
| 15 #include "grit/components_chromium_strings.h" | 15 #include "grit/components_chromium_strings.h" |
| 16 #include "grit/components_strings.h" | 16 #include "grit/components_strings.h" |
| 17 | 17 |
| 18 namespace crash { | 18 namespace crash { |
| 19 | 19 |
| 20 const CrashesUILocalizedString kCrashesUILocalizedStrings[] = { | 20 const CrashesUILocalizedString kCrashesUILocalizedStrings[] = { |
| 21 {"bugLinkText", IDS_CRASH_BUG_LINK_LABEL}, | 21 {"bugLinkText", IDS_CRASH_BUG_LINK_LABEL}, |
| 22 {"crashCountFormat", IDS_CRASH_CRASH_COUNT_BANNER_FORMAT}, | 22 {"crashCountFormat", IDS_CRASH_CRASH_COUNT_BANNER_FORMAT}, |
| 23 {"crashHeaderFormat", IDS_CRASH_CRASH_HEADER_FORMAT}, | 23 {"crashHeaderFormat", IDS_CRASH_CRASH_HEADER_FORMAT}, |
| 24 {"crashHeaderFormatLocalOnly", IDS_CRASH_CRASH_HEADER_FORMAT_LOCAL_ONLY}, | 24 {"crashHeaderFormatLocalOnly", IDS_CRASH_CRASH_HEADER_FORMAT_LOCAL_ONLY}, |
| 25 {"crashTimeFormat", IDS_CRASH_CRASH_TIME_FORMAT}, | 25 {"crashTimeFormat", IDS_CRASH_CRASH_TIME_FORMAT}, |
| 26 {"crashAndUploadTimeFormat", IDS_CRASH_CRASH_AND_UPLOAD_TIME_FORMAT}, |
| 26 {"crashNotUploaded", IDS_CRASH_CRASH_NOT_UPLOADED}, | 27 {"crashNotUploaded", IDS_CRASH_CRASH_NOT_UPLOADED}, |
| 27 {"crashUserRequested", IDS_CRASH_CRASH_USER_REQUESTED}, | 28 {"crashUserRequested", IDS_CRASH_CRASH_USER_REQUESTED}, |
| 28 {"crashPending", IDS_CRASH_CRASH_PENDING}, | 29 {"crashPending", IDS_CRASH_CRASH_PENDING}, |
| 29 {"crashesTitle", IDS_CRASH_TITLE}, | 30 {"crashesTitle", IDS_CRASH_TITLE}, |
| 30 {"disabledHeader", IDS_CRASH_DISABLED_HEADER}, | 31 {"disabledHeader", IDS_CRASH_DISABLED_HEADER}, |
| 31 {"disabledMessage", IDS_CRASH_DISABLED_MESSAGE}, | 32 {"disabledMessage", IDS_CRASH_DISABLED_MESSAGE}, |
| 32 {"noCrashesMessage", IDS_CRASH_NO_CRASHES_MESSAGE}, | 33 {"noCrashesMessage", IDS_CRASH_NO_CRASHES_MESSAGE}, |
| 33 {"uploadCrashesLinkText", IDS_CRASH_UPLOAD_MESSAGE}, | 34 {"uploadCrashesLinkText", IDS_CRASH_UPLOAD_MESSAGE}, |
| 34 {"uploadNowLinkText", IDS_CRASH_UPLOAD_NOW_LINK_TEXT}, | 35 {"uploadNowLinkText", IDS_CRASH_UPLOAD_NOW_LINK_TEXT}, |
| 35 {"crashSizeMessage", IDS_CRASH_SIZE_MESSAGE}, | 36 {"crashSizeMessage", IDS_CRASH_SIZE_MESSAGE}, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 65 std::vector<UploadList::UploadInfo> crashes; | 66 std::vector<UploadList::UploadInfo> crashes; |
| 66 upload_list->GetUploads(50, &crashes); | 67 upload_list->GetUploads(50, &crashes); |
| 67 | 68 |
| 68 for (const auto& info : crashes) { | 69 for (const auto& info : crashes) { |
| 69 std::unique_ptr<base::DictionaryValue> crash(new base::DictionaryValue()); | 70 std::unique_ptr<base::DictionaryValue> crash(new base::DictionaryValue()); |
| 70 crash->SetString("id", info.upload_id); | 71 crash->SetString("id", info.upload_id); |
| 71 if (info.state == UploadList::UploadInfo::State::Uploaded) { | 72 if (info.state == UploadList::UploadInfo::State::Uploaded) { |
| 72 crash->SetString("upload_time", | 73 crash->SetString("upload_time", |
| 73 base::TimeFormatFriendlyDateAndTime(info.upload_time)); | 74 base::TimeFormatFriendlyDateAndTime(info.upload_time)); |
| 74 } | 75 } |
| 75 crash->SetString("time", | 76 if (!info.capture_time.is_null()) { |
| 76 base::TimeFormatFriendlyDateAndTime(info.capture_time)); | 77 crash->SetString("time", |
| 78 base::TimeFormatFriendlyDateAndTime(info.capture_time)); |
| 79 } |
| 77 crash->SetString("local_id", info.local_id); | 80 crash->SetString("local_id", info.local_id); |
| 78 crash->SetString("state", UploadInfoStateAsString(info.state)); | 81 crash->SetString("state", UploadInfoStateAsString(info.state)); |
| 79 crash->SetString("file_size", info.file_size); | 82 crash->SetString("file_size", info.file_size); |
| 80 out_value->Append(std::move(crash)); | 83 out_value->Append(std::move(crash)); |
| 81 } | 84 } |
| 82 } | 85 } |
| 83 | 86 |
| 84 } // namespace crash | 87 } // namespace crash |
| OLD | NEW |