| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/sync/sync_ui_util.h" | 5 #include "chrome/browser/sync/sync_ui_util.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/google_service_auth_error.h" | 9 #include "chrome/browser/google_service_auth_error.h" |
| 10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| 11 #include "chrome/browser/sync/profile_sync_service.h" | 11 #include "chrome/browser/sync/profile_sync_service.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 DCHECK(status_label); | 156 DCHECK(status_label); |
| 157 DCHECK(link_label); | 157 DCHECK(link_label); |
| 158 return sync_ui_util::GetStatusInfo(service, status_label, link_label); | 158 return sync_ui_util::GetStatusInfo(service, status_label, link_label); |
| 159 } | 159 } |
| 160 | 160 |
| 161 MessageType GetStatus(ProfileSyncService* service) { | 161 MessageType GetStatus(ProfileSyncService* service) { |
| 162 return sync_ui_util::GetStatusInfo(service, NULL, NULL); | 162 return sync_ui_util::GetStatusInfo(service, NULL, NULL); |
| 163 } | 163 } |
| 164 | 164 |
| 165 bool ShouldShowSyncErrorButton(ProfileSyncService* service) { | 165 bool ShouldShowSyncErrorButton(ProfileSyncService* service) { |
| 166 return service && service->HasSyncSetupCompleted() && | 166 return service && !service->IsManaged() && service->HasSyncSetupCompleted() && |
| 167 (GetStatus(service) == sync_ui_util::SYNC_ERROR); | 167 (GetStatus(service) == sync_ui_util::SYNC_ERROR); |
| 168 } | 168 } |
| 169 | 169 |
| 170 string16 GetSyncMenuLabel(ProfileSyncService* service) { | 170 string16 GetSyncMenuLabel(ProfileSyncService* service) { |
| 171 MessageType type = GetStatus(service); | 171 MessageType type = GetStatus(service); |
| 172 | 172 |
| 173 if (type == sync_ui_util::SYNCED) | 173 if (type == sync_ui_util::SYNCED) |
| 174 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNCED_LABEL); | 174 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNCED_LABEL); |
| 175 else if (type == sync_ui_util::SYNC_ERROR) | 175 else if (type == sync_ui_util::SYNC_ERROR) |
| 176 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNC_ERROR_LABEL); | 176 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNC_ERROR_LABEL); |
| 177 else | 177 else |
| 178 return l10n_util::GetStringUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL); | 178 return l10n_util::GetStringUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void OpenSyncMyBookmarksDialog( | 181 void OpenSyncMyBookmarksDialog( |
| 182 Profile* profile, ProfileSyncService::SyncEventCodes code) { | 182 Profile* profile, ProfileSyncService::SyncEventCodes code) { |
| 183 ProfileSyncService* service = | 183 ProfileSyncService* service = |
| 184 profile->GetOriginalProfile()->GetProfileSyncService(); | 184 profile->GetOriginalProfile()->GetProfileSyncService(); |
| 185 if (!service) { | 185 if (!service || !service->IsSyncEnabled()) { |
| 186 LOG(DFATAL) << "OpenSyncMyBookmarksDialog called with sync disabled"; | 186 LOG(DFATAL) << "OpenSyncMyBookmarksDialog called with sync disabled"; |
| 187 return; | 187 return; |
| 188 } | 188 } |
| 189 if (service->HasSyncSetupCompleted()) { | 189 if (service->HasSyncSetupCompleted()) { |
| 190 ShowOptionsWindow(OPTIONS_PAGE_CONTENT, OPTIONS_GROUP_NONE, profile); | 190 ShowOptionsWindow(OPTIONS_PAGE_CONTENT, OPTIONS_GROUP_NONE, profile); |
| 191 } else { | 191 } else { |
| 192 service->EnableForUser(); | 192 service->EnableForUser(); |
| 193 ProfileSyncService::SyncEvent(code); | 193 ProfileSyncService::SyncEvent(code); |
| 194 } | 194 } |
| 195 } | 195 } |
| 196 | 196 |
| 197 } // namespace sync_ui_util | 197 } // namespace sync_ui_util |
| OLD | NEW |