| OLD | NEW |
| 1 // Copyright (c) 2010 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 "base/command_line.h" |
| 7 #include "base/i18n/number_formatting.h" | 8 #include "base/i18n/number_formatting.h" |
| 8 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
| 9 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/sync/profile_sync_service.h" | 13 #include "chrome/browser/sync/profile_sync_service.h" |
| 14 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/options/options_window.h" | 15 #include "chrome/browser/ui/options/options_window.h" |
| 16 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/common/net/gaia/google_service_auth_error.h" | 17 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 18 #include "chrome/common/url_constants.h" |
| 15 #include "grit/browser_resources.h" | 19 #include "grit/browser_resources.h" |
| 16 #include "grit/chromium_strings.h" | 20 #include "grit/chromium_strings.h" |
| 17 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
| 20 | 24 |
| 21 typedef GoogleServiceAuthError AuthError; | 25 typedef GoogleServiceAuthError AuthError; |
| 22 | 26 |
| 23 namespace sync_ui_util { | 27 namespace sync_ui_util { |
| 24 | 28 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 MessageType type = GetStatus(service); | 263 MessageType type = GetStatus(service); |
| 260 | 264 |
| 261 if (type == sync_ui_util::SYNCED) | 265 if (type == sync_ui_util::SYNCED) |
| 262 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNCED_LABEL); | 266 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNCED_LABEL); |
| 263 else if (type == sync_ui_util::SYNC_ERROR) | 267 else if (type == sync_ui_util::SYNC_ERROR) |
| 264 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNC_ERROR_LABEL); | 268 return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNC_ERROR_LABEL); |
| 265 else | 269 else |
| 266 return l10n_util::GetStringUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL); | 270 return l10n_util::GetStringUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL); |
| 267 } | 271 } |
| 268 | 272 |
| 269 void OpenSyncMyBookmarksDialog( | 273 void OpenSyncMyBookmarksDialog(Profile* profile, |
| 270 Profile* profile, ProfileSyncService::SyncEventCodes code) { | 274 Browser* browser, |
| 275 ProfileSyncService::SyncEventCodes code) { |
| 271 ProfileSyncService* service = | 276 ProfileSyncService* service = |
| 272 profile->GetOriginalProfile()->GetProfileSyncService(); | 277 profile->GetOriginalProfile()->GetProfileSyncService(); |
| 273 if (!service || !service->IsSyncEnabled()) { | 278 if (!service || !service->IsSyncEnabled()) { |
| 274 LOG(DFATAL) << "OpenSyncMyBookmarksDialog called with sync disabled"; | 279 LOG(DFATAL) << "OpenSyncMyBookmarksDialog called with sync disabled"; |
| 275 return; | 280 return; |
| 276 } | 281 } |
| 282 |
| 283 bool use_tabbed_options = !CommandLine::ForCurrentProcess()->HasSwitch( |
| 284 switches::kDisableTabbedOptions); |
| 285 |
| 277 if (service->HasSyncSetupCompleted()) { | 286 if (service->HasSyncSetupCompleted()) { |
| 278 ShowOptionsWindow(OPTIONS_PAGE_CONTENT, OPTIONS_GROUP_NONE, profile); | 287 if (use_tabbed_options) { |
| 288 bool create_window = browser == NULL; |
| 289 if (create_window) |
| 290 browser = Browser::Create(profile); |
| 291 browser->ShowOptionsTab(chrome::kPersonalOptionsSubPage); |
| 292 if (create_window) |
| 293 browser->window()->Show(); |
| 294 } else { |
| 295 ShowOptionsWindow(OPTIONS_PAGE_CONTENT, OPTIONS_GROUP_NONE, profile); |
| 296 } |
| 279 } else { | 297 } else { |
| 280 service->ShowLoginDialog(NULL); | 298 service->ShowLoginDialog(NULL); |
| 281 ProfileSyncService::SyncEvent(code); // UMA stats | 299 ProfileSyncService::SyncEvent(code); // UMA stats |
| 282 } | 300 } |
| 283 } | 301 } |
| 284 | 302 |
| 285 void AddBoolSyncDetail(ListValue* details, | 303 void AddBoolSyncDetail(ListValue* details, |
| 286 const std::string& stat_name, | 304 const std::string& stat_name, |
| 287 bool stat_value) { | 305 bool stat_value) { |
| 288 DictionaryValue* val = new DictionaryValue; | 306 DictionaryValue* val = new DictionaryValue; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 | 460 |
| 443 DictionaryValue* val = new DictionaryValue; | 461 DictionaryValue* val = new DictionaryValue; |
| 444 val->SetString("stat_name", "Autofill Migration Time"); | 462 val->SetString("stat_name", "Autofill Migration Time"); |
| 445 val->SetString("stat_value", ConstructTime(info.autofill_migration_time)); | 463 val->SetString("stat_value", ConstructTime(info.autofill_migration_time)); |
| 446 details->Append(val); | 464 details->Append(val); |
| 447 } | 465 } |
| 448 } | 466 } |
| 449 } | 467 } |
| 450 | 468 |
| 451 } // namespace sync_ui_util | 469 } // namespace sync_ui_util |
| OLD | NEW |