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 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "components/signin/core/browser/signin_manager_base.h" | 13 #include "components/signin/core/browser/signin_manager_base.h" |
14 #include "components/sync_driver/sync_service.h" | 14 #include "components/sync_driver/sync_service.h" |
15 #include "components/version_info/version_info.h" | 15 #include "components/version_info/version_info.h" |
16 #include "sync/api/time.h" | 16 #include "sync/api/time.h" |
17 #include "sync/internal_api/public/engine/sync_status.h" | 17 #include "sync/internal_api/public/engine/sync_status.h" |
18 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" | 18 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
19 #include "sync/internal_api/public/util/sync_string_conversions.h" | 19 #include "sync/internal_api/public/util/sync_string_conversions.h" |
20 #include "sync/protocol/proto_enum_conversions.h" | 20 #include "sync/protocol/proto_enum_conversions.h" |
21 | 21 |
22 using base::DictionaryValue; | 22 using base::DictionaryValue; |
23 using base::ListValue; | 23 using base::ListValue; |
24 | 24 |
| 25 namespace sync_driver { |
| 26 |
25 const char kIdentityTitle[] = "Identity"; | 27 const char kIdentityTitle[] = "Identity"; |
26 const char kDetailsKey[] = "details"; | 28 const char kDetailsKey[] = "details"; |
27 | 29 |
| 30 // Resource paths. |
| 31 const char kAboutJS[] = "about.js"; |
| 32 const char kChromeSyncJS[] = "chrome_sync.js"; |
| 33 const char kDataJS[] = "data.js"; |
| 34 const char kEventsJS[] = "events.js"; |
| 35 const char kSearchJS[] = "search.js"; |
| 36 const char kSyncIndexJS[] = "sync_index.js"; |
| 37 const char kSyncLogJS[] = "sync_log.js"; |
| 38 const char kSyncNodeBrowserJS[] = "sync_node_browser.js"; |
| 39 const char kSyncSearchJS[] = "sync_search.js"; |
| 40 const char kTypesJS[] = "types.js"; |
| 41 |
| 42 // Message handlers. |
| 43 const char kDispatchEvent[] = "chrome.sync.dispatchEvent"; |
| 44 const char kGetAllNodes[] = "getAllNodes"; |
| 45 const char kGetAllNodesCallback[] = "chrome.sync.getAllNodesCallback"; |
| 46 const char kRegisterForEvents[] = "registerForEvents"; |
| 47 const char kRegisterForPerTypeCounters[] = "registerForPerTypeCounters"; |
| 48 const char kRequestListOfTypes[] = "requestListOfTypes"; |
| 49 const char kRequestUpdatedAboutInfo[] = "requestUpdatedAboutInfo"; |
| 50 |
| 51 // Other strings. |
| 52 const char kCommit[] = "commit"; |
| 53 const char kCounters[] = "counters"; |
| 54 const char kCounterType[] = "counterType"; |
| 55 const char kModelType[] = "modelType"; |
| 56 const char kOnAboutInfoUpdated[] = "onAboutInfoUpdated"; |
| 57 const char kOnCountersUpdated[] = "onCountersUpdated"; |
| 58 const char kOnProtocolEvent[] = "onProtocolEvent"; |
| 59 const char kOnReceivedListOfTypes[] = "onReceivedListOfTypes"; |
| 60 const char kStatus[] = "status"; |
| 61 const char kTypes[] = "types"; |
| 62 const char kUpdate[] = "update"; |
| 63 |
28 namespace { | 64 namespace { |
29 | 65 |
30 // Creates a 'section' for display on about:sync, consisting of a title and a | 66 // Creates a 'section' for display on about:sync, consisting of a title and a |
31 // list of fields. Returns a pointer to the new section. Note that | 67 // list of fields. Returns a pointer to the new section. Note that |
32 // |parent_list|, not the caller, owns the newly added section. | 68 // |parent_list|, not the caller, owns the newly added section. |
33 base::ListValue* AddSection(base::ListValue* parent_list, | 69 base::ListValue* AddSection(base::ListValue* parent_list, |
34 const std::string& title) { | 70 const std::string& title) { |
35 base::DictionaryValue* section = new base::DictionaryValue(); | 71 base::DictionaryValue* section = new base::DictionaryValue(); |
36 base::ListValue* section_contents = new base::ListValue(); | 72 base::ListValue* section_contents = new base::ListValue(); |
37 section->SetString("title", title); | 73 section->SetString("title", title); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 GetTimeStr(status.connection_status_update_time, "n/a").c_str()); | 229 GetTimeStr(status.connection_status_update_time, "n/a").c_str()); |
194 break; | 230 break; |
195 default: | 231 default: |
196 NOTREACHED(); | 232 NOTREACHED(); |
197 } | 233 } |
198 return message; | 234 return message; |
199 } | 235 } |
200 | 236 |
201 } // namespace | 237 } // namespace |
202 | 238 |
203 namespace sync_ui_util { | |
204 | |
205 // This function both defines the structure of the message to be returned and | 239 // This function both defines the structure of the message to be returned and |
206 // its contents. Most of the message consists of simple fields in about:sync | 240 // its contents. Most of the message consists of simple fields in about:sync |
207 // which are grouped into sections and populated with the help of the SyncStat | 241 // which are grouped into sections and populated with the help of the SyncStat |
208 // classes defined above. | 242 // classes defined above. |
209 scoped_ptr<base::DictionaryValue> ConstructAboutInformation( | 243 scoped_ptr<base::DictionaryValue> ConstructAboutInformation( |
210 sync_driver::SyncService* service, | 244 sync_driver::SyncService* service, |
211 SigninManagerBase* signin, | 245 SigninManagerBase* signin, |
212 version_info::Channel channel) { | 246 version_info::Channel channel) { |
213 scoped_ptr<base::DictionaryValue> about_info(new base::DictionaryValue()); | 247 scoped_ptr<base::DictionaryValue> about_info(new base::DictionaryValue()); |
214 | 248 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 ": " + service->unrecoverable_error_message(); | 519 ": " + service->unrecoverable_error_message(); |
486 about_info->SetString("unrecoverable_error_message", | 520 about_info->SetString("unrecoverable_error_message", |
487 unrecoverable_error_message); | 521 unrecoverable_error_message); |
488 } | 522 } |
489 | 523 |
490 about_info->Set("type_status", service->GetTypeStatusMap()); | 524 about_info->Set("type_status", service->GetTypeStatusMap()); |
491 | 525 |
492 return about_info.Pass(); | 526 return about_info.Pass(); |
493 } | 527 } |
494 | 528 |
495 } // namespace sync_ui_util | 529 } // namespace sync_driver |
OLD | NEW |