[email protected] | 40f04797 | 2009-11-25 03:54:40 | [diff] [blame] | 1 | // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_SYNC_SYNC_UI_UTIL_H_ |
| 6 | #define CHROME_BROWSER_SYNC_SYNC_UI_UTIL_H_ |
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 7 | #pragma once |
[email protected] | 40f04797 | 2009-11-25 03:54:40 | [diff] [blame] | 8 | |
[email protected] | f1e6e021 | 2010-10-15 20:54:24 | [diff] [blame] | 9 | #include <string> |
| 10 | |
[email protected] | 40f04797 | 2009-11-25 03:54:40 | [diff] [blame] | 11 | #include "base/string16.h" |
[email protected] | f1e6e021 | 2010-10-15 20:54:24 | [diff] [blame] | 12 | #include "base/values.h" |
[email protected] | 40f04797 | 2009-11-25 03:54:40 | [diff] [blame] | 13 | #include "chrome/browser/sync/profile_sync_service.h" |
| 14 | |
| 15 | class Profile; |
[email protected] | f1e6e021 | 2010-10-15 20:54:24 | [diff] [blame] | 16 | class ListValue; |
| 17 | class DictionaryValue; |
[email protected] | 40f04797 | 2009-11-25 03:54:40 | [diff] [blame] | 18 | |
| 19 | // Utility functions to gather current sync status information from the sync |
| 20 | // service and constructs messages suitable for showing in UI. |
| 21 | namespace sync_ui_util { |
| 22 | |
| 23 | enum MessageType { |
| 24 | PRE_SYNCED, // User has not set up sync. |
| 25 | SYNCED, // We are synced and authenticated to a gmail account. |
| 26 | SYNC_ERROR, // A sync error (such as invalid credentials) has occurred. |
| 27 | }; |
| 28 | |
[email protected] | 06eee70c | 2010-01-06 22:27:39 | [diff] [blame] | 29 | // TODO(akalin): audit the use of ProfileSyncService* service below, |
| 30 | // and use const ProfileSyncService& service where possible. |
| 31 | |
[email protected] | 40f04797 | 2009-11-25 03:54:40 | [diff] [blame] | 32 | // Create status and link labels for the current status labels and link text |
| 33 | // by querying |service|. |
| 34 | MessageType GetStatusLabels(ProfileSyncService* service, |
| 35 | string16* status_label, |
| 36 | string16* link_label); |
| 37 | |
[email protected] | 5c086d7 | 2009-12-14 20:49:04 | [diff] [blame] | 38 | MessageType GetStatus(ProfileSyncService* service); |
| 39 | |
[email protected] | 06eee70c | 2010-01-06 22:27:39 | [diff] [blame] | 40 | // Determines whether or not the sync error button should be visible. |
| 41 | bool ShouldShowSyncErrorButton(ProfileSyncService* service); |
| 42 | |
| 43 | // Returns a string with the synchronization status. |
| 44 | string16 GetSyncMenuLabel(ProfileSyncService* service); |
| 45 | |
[email protected] | 40f04797 | 2009-11-25 03:54:40 | [diff] [blame] | 46 | // Open the appropriate sync dialog for the given profile (which can be |
| 47 | // incognito). |code| should be one of the START_FROM_* codes. |
| 48 | void OpenSyncMyBookmarksDialog( |
| 49 | Profile* profile, ProfileSyncService::SyncEventCodes code); |
[email protected] | 40f04797 | 2009-11-25 03:54:40 | [diff] [blame] | 50 | |
[email protected] | f1e6e021 | 2010-10-15 20:54:24 | [diff] [blame] | 51 | void AddBoolSyncDetail(ListValue* details, |
| 52 | const std::string& stat_name, |
| 53 | bool stat_value); |
| 54 | |
| 55 | void ConstructAboutInformation(ProfileSyncService* service, |
| 56 | DictionaryValue* strings); |
| 57 | |
| 58 | void AddIntSyncDetail(ListValue* details, |
| 59 | const std::string& stat_name, |
| 60 | int64 stat_value); |
| 61 | } // namespace sync_ui_util |
[email protected] | 40f04797 | 2009-11-25 03:54:40 | [diff] [blame] | 62 | #endif // CHROME_BROWSER_SYNC_SYNC_UI_UTIL_H_ |
| 63 | |