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 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_ 7 8 #include "base/strings/string16.h" 9 10 class ProfileSyncService; 11 class SigninManagerBase; 12 13 // Utility functions to gather current sync status information from the sync 14 // service and constructs messages suitable for showing in UI. 15 namespace sync_ui_util { 16 17 enum MessageType { 18 PRE_SYNCED, // User has not set up sync. 19 SYNCED, // We are synced and authenticated to a gmail account. 20 SYNC_ERROR, // A sync error (such as invalid credentials) has occurred. 21 SYNC_PROMO, // A situation has occurred which should be brought to the user's 22 // attention, but not as an error. 23 }; 24 25 enum StatusLabelStyle { 26 PLAIN_TEXT, // Label will be plain-text only. 27 WITH_HTML // Label may contain an HTML-formatted link. 28 }; 29 30 // TODO(akalin): audit the use of ProfileSyncService* service below, 31 // and use const ProfileSyncService& service where possible. 32 33 // Create status and link labels for the current status labels and link text 34 // by querying |service|. 35 // |style| sets the link properties, see |StatusLabelStyle|. 36 MessageType GetStatusLabels(ProfileSyncService* service, 37 const SigninManagerBase& signin, 38 StatusLabelStyle style, 39 base::string16* status_label, 40 base::string16* link_label); 41 42 // Same as above but for use specifically on the New Tab Page. 43 // |status_label| may contain an HTML-formatted link. 44 MessageType GetStatusLabelsForNewTabPage(ProfileSyncService* service, 45 const SigninManagerBase& signin, 46 base::string16* status_label, 47 base::string16* link_label); 48 49 // Gets various labels for the sync global error based on the sync error state. 50 // |menu_item_label|, |bubble_message|, and |bubble_accept_label| must not be 51 // NULL. Note that we don't use SyncGlobalError on Chrome OS. 52 #if !defined(OS_CHROMEOS) 53 void GetStatusLabelsForSyncGlobalError(const ProfileSyncService* service, 54 base::string16* menu_item_label, 55 base::string16* bubble_message, 56 base::string16* bubble_accept_label); 57 #endif 58 59 MessageType GetStatus(ProfileSyncService* service, 60 const SigninManagerBase& signin); 61 62 } // namespace sync_ui_util 63 #endif // CHROME_BROWSER_SYNC_SYNC_UI_UTIL_H_ 64