Home | History | Annotate | Download | only in sync
      1 // Copyright (c) 2011 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 #pragma once
      8 
      9 #include <string>
     10 
     11 #include "base/string16.h"
     12 #include "base/values.h"
     13 #include "chrome/browser/sync/profile_sync_service.h"
     14 
     15 class Browser;
     16 class Profile;
     17 class ListValue;
     18 class DictionaryValue;
     19 
     20 // Utility functions to gather current sync status information from the sync
     21 // service and constructs messages suitable for showing in UI.
     22 namespace sync_ui_util {
     23 
     24 enum MessageType {
     25   PRE_SYNCED,  // User has not set up sync.
     26   SYNCED,      // We are synced and authenticated to a gmail account.
     27   SYNC_ERROR,  // A sync error (such as invalid credentials) has occurred.
     28   SYNC_PROMO,  // A situation has occurred which should be brought to the user's
     29                // attention, but not as an error.
     30 };
     31 
     32 // TODO(akalin): audit the use of ProfileSyncService* service below,
     33 // and use const ProfileSyncService& service where possible.
     34 
     35 // Create status and link labels for the current status labels and link text
     36 // by querying |service|.
     37 MessageType GetStatusLabels(ProfileSyncService* service,
     38                             string16* status_label,
     39                             string16* link_label);
     40 
     41 // Same as above but for use specifically on the New Tab Page.
     42 MessageType GetStatusLabelsForNewTabPage(ProfileSyncService* service,
     43                                          string16* status_label,
     44                                          string16* link_label);
     45 
     46 MessageType GetStatus(ProfileSyncService* service);
     47 
     48 // Determines whether or not the sync error button should be visible.
     49 bool ShouldShowSyncErrorButton(ProfileSyncService* service);
     50 
     51 // Returns a string with the synchronization status.
     52 string16 GetSyncMenuLabel(ProfileSyncService* service);
     53 
     54 // Open the appropriate sync dialog for the given profile (which can be
     55 // incognito). |browser| is the browser window that should be used if the UI
     56 // is in-window (i.e., WebUI). |code| should be one of the START_FROM_* codes.
     57 void OpenSyncMyBookmarksDialog(Profile* profile,
     58                                Browser* browser,
     59                                ProfileSyncService::SyncEventCodes code);
     60 
     61 void AddBoolSyncDetail(ListValue* details,
     62                        const std::string& stat_name,
     63                        bool stat_value);
     64 
     65 // |service| can be NULL.
     66 void ConstructAboutInformation(ProfileSyncService* service,
     67                                DictionaryValue* strings);
     68 
     69 void AddIntSyncDetail(ListValue* details,
     70                       const std::string& stat_name,
     71                       int64 stat_value);
     72 }  // namespace sync_ui_util
     73 #endif  // CHROME_BROWSER_SYNC_SYNC_UI_UTIL_H_
     74