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 "components/sync_driver/about_sync_util.h" | 5 #include "components/sync_driver/about_sync_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/location.h" | 10 #include "base/location.h" |
10 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "components/signin/core/browser/signin_manager_base.h" | 14 #include "components/signin/core/browser/signin_manager_base.h" |
14 #include "components/sync_driver/sync_service.h" | 15 #include "components/sync_driver/sync_service.h" |
15 #include "components/version_info/version_info.h" | 16 #include "components/version_info/version_info.h" |
16 #include "sync/api/time.h" | 17 #include "sync/api/time.h" |
17 #include "sync/internal_api/public/engine/sync_status.h" | 18 #include "sync/internal_api/public/engine/sync_status.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 const char kTypes[] = "types"; | 64 const char kTypes[] = "types"; |
64 const char kUpdate[] = "update"; | 65 const char kUpdate[] = "update"; |
65 | 66 |
66 namespace { | 67 namespace { |
67 | 68 |
68 // Creates a 'section' for display on about:sync, consisting of a title and a | 69 // Creates a 'section' for display on about:sync, consisting of a title and a |
69 // list of fields. Returns a pointer to the new section. Note that | 70 // list of fields. Returns a pointer to the new section. Note that |
70 // |parent_list|, not the caller, owns the newly added section. | 71 // |parent_list|, not the caller, owns the newly added section. |
71 base::ListValue* AddSection(base::ListValue* parent_list, | 72 base::ListValue* AddSection(base::ListValue* parent_list, |
72 const std::string& title) { | 73 const std::string& title) { |
73 base::DictionaryValue* section = new base::DictionaryValue(); | 74 std::unique_ptr<base::DictionaryValue> section(new base::DictionaryValue()); |
74 base::ListValue* section_contents = new base::ListValue(); | 75 base::ListValue* section_contents = new base::ListValue(); |
75 section->SetString("title", title); | 76 section->SetString("title", title); |
76 section->Set("data", section_contents); | 77 section->Set("data", section_contents); |
77 section->SetBoolean("is_sensitive", false); | 78 section->SetBoolean("is_sensitive", false); |
78 parent_list->Append(section); | 79 parent_list->Append(std::move(section)); |
79 return section_contents; | 80 return section_contents; |
80 } | 81 } |
81 | 82 |
82 // Same as AddSection, but for data that should be elided when dumped into text | 83 // Same as AddSection, but for data that should be elided when dumped into text |
83 // form and posted in a public forum (e.g. unique identifiers). | 84 // form and posted in a public forum (e.g. unique identifiers). |
84 base::ListValue* AddSensitiveSection(base::ListValue* parent_list, | 85 base::ListValue* AddSensitiveSection(base::ListValue* parent_list, |
85 const std::string& title) { | 86 const std::string& title) { |
86 base::DictionaryValue* section = new base::DictionaryValue(); | 87 std::unique_ptr<base::DictionaryValue> section(new base::DictionaryValue()); |
87 base::ListValue* section_contents = new base::ListValue(); | 88 base::ListValue* section_contents = new base::ListValue(); |
88 section->SetString("title", title); | 89 section->SetString("title", title); |
89 section->Set("data", section_contents); | 90 section->Set("data", section_contents); |
90 section->SetBoolean("is_sensitive", true); | 91 section->SetBoolean("is_sensitive", true); |
91 parent_list->Append(section); | 92 parent_list->Append(std::move(section)); |
92 return section_contents; | 93 return section_contents; |
93 } | 94 } |
94 | 95 |
95 // The following helper classes help manage the about:sync fields which will be | 96 // The following helper classes help manage the about:sync fields which will be |
96 // populated in method in ConstructAboutInformation. | 97 // populated in method in ConstructAboutInformation. |
97 // | 98 // |
98 // Each instance of one of thse classes indicates a field in about:sync. Each | 99 // Each instance of one of thse classes indicates a field in about:sync. Each |
99 // field will be serialized to a DictionaryValue with entries for 'stat_name', | 100 // field will be serialized to a DictionaryValue with entries for 'stat_name', |
100 // 'stat_value' and 'is_valid'. | 101 // 'stat_value' and 'is_valid'. |
101 | 102 |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 } | 526 } |
526 | 527 |
527 about_info->Set("type_status", service->GetTypeStatusMap()); | 528 about_info->Set("type_status", service->GetTypeStatusMap()); |
528 | 529 |
529 return about_info; | 530 return about_info; |
530 } | 531 } |
531 | 532 |
532 } // namespace sync_ui_util | 533 } // namespace sync_ui_util |
533 | 534 |
534 } // namespace sync_driver | 535 } // namespace sync_driver |
OLD | NEW |