Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6982)

Unified Diff: chrome/browser/sync/sync_global_error.cc

Issue 7906013: Show bubble and wrench menu item for sync error (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/sync_global_error.h ('k') | chrome/browser/ui/toolbar/wrench_menu_model.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/sync_global_error.cc
diff --git a/chrome/browser/sync/sync_global_error.cc b/chrome/browser/sync/sync_global_error.cc
new file mode 100644
index 0000000000000000000000000000000000000000..170e43508183241fc3af9c1bc5cb29be553a473b
--- /dev/null
+++ b/chrome/browser/sync/sync_global_error.cc
@@ -0,0 +1,162 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sync/sync_global_error.h"
+
+#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/profile_sync_service_observer.h"
+#include "chrome/common/net/gaia/google_service_auth_error.h"
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+
+typedef GoogleServiceAuthError AuthError;
+
+SyncGlobalError::SyncGlobalError(ProfileSyncService* service)
+ : error_type_(ERROR_TYPE_NONE),
+ service_(service) {
+ OnStateChanged();
+}
+
+SyncGlobalError::~SyncGlobalError() {
+}
+
+bool SyncGlobalError::HasBadge() {
+#if defined(OS_CHROMEOS)
+ // TODO(sail): Due to http://crbug.com/96608 we don't have a wrench menu
+ // item on ChromeOS thus we don't badge the wrench menu either.
+ return false;
+#else
+ return error_type_ != ERROR_TYPE_NONE;
+#endif
+}
+
+bool SyncGlobalError::HasMenuItem() {
+ // TODO(sail): Once http://crbug.com/96608 is fixed this should return
+ // true for ChromeOS.
+ return false;
+}
+
+int SyncGlobalError::MenuItemCommandID() {
+ NOTREACHED();
+ return 0;
+}
+
+string16 SyncGlobalError::MenuItemLabel() {
+ switch (error_type_) {
+ case ERROR_TYPE_PASSPHRASE:
+ return l10n_util::GetStringUTF16(
+ IDS_SYNC_PASSPHRASE_ERROR_WRENCH_MENU_ITEM);
+ default:
+ return l10n_util::GetStringUTF16(
+ IDS_SYNC_SIGN_IN_ERROR_WRENCH_MENU_ITEM);
+ }
+}
+
+void SyncGlobalError::ExecuteMenuItem(Browser* browser) {
+ service_->ShowErrorUI();
+}
+
+bool SyncGlobalError::HasBubbleView() {
+ return error_type_ != ERROR_TYPE_NONE;
+}
+
+string16 SyncGlobalError::GetBubbleViewTitle() {
+ return l10n_util::GetStringUTF16(IDS_SYNC_ERROR_BUBBLE_VIEW_TITLE);
+}
+
+string16 SyncGlobalError::GetBubbleViewMessage() {
+ string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
+ switch (error_type_) {
+ case ERROR_TYPE_PASSPHRASE:
+ return l10n_util::GetStringFUTF16(
+ IDS_SYNC_PASSPHRASE_ERROR_BUBBLE_VIEW_MESSAGE, product_name);
+ case ERROR_TYPE_SIGN_IN:
+ return l10n_util::GetStringFUTF16(
+ IDS_SYNC_SIGN_IN_ERROR_BUBBLE_VIEW_MESSAGE, product_name);
+ case ERROR_TYPE_UNAVAILABLE:
+ return l10n_util::GetStringFUTF16(
+ IDS_SYNC_UNAVAILABLE_ERROR_BUBBLE_VIEW_MESSAGE, product_name);
+ case ERROR_TYPE_OTHER:
+ return l10n_util::GetStringFUTF16(
+ IDS_SYNC_OTHER_SIGN_IN_ERROR_BUBBLE_VIEW_MESSAGE, product_name);
+ default:
+ NOTREACHED();
+ return string16();
+ }
+}
+
+string16 SyncGlobalError::GetBubbleViewAcceptButtonLabel() {
+ switch (error_type_) {
+ case ERROR_TYPE_PASSPHRASE:
+ return l10n_util::GetStringUTF16(
+ IDS_SYNC_PASSPHRASE_ERROR_BUBBLE_VIEW_ACCEPT);
+ case ERROR_TYPE_SIGN_IN:
+ case ERROR_TYPE_OTHER:
+ return l10n_util::GetStringUTF16(
+ IDS_SYNC_SIGN_IN_ERROR_BUBBLE_VIEW_ACCEPT);
+ case ERROR_TYPE_UNAVAILABLE:
+ return l10n_util::GetStringUTF16(
+ IDS_SYNC_UNAVAILABLE_ERROR_BUBBLE_VIEW_ACCEPT);
+ default:
+ NOTREACHED();
+ return string16();
+ }
+}
+
+string16 SyncGlobalError::GetBubbleViewCancelButtonLabel() {
+ return string16();
+}
+
+void SyncGlobalError::BubbleViewDidClose() {
+}
+
+void SyncGlobalError::BubbleViewAcceptButtonPressed() {
+ service_->ShowErrorUI();
+}
+
+void SyncGlobalError::BubbleViewCancelButtonPressed() {
+ NOTREACHED();
+}
+
+void SyncGlobalError::OnStateChanged() {
+ error_type_ = GetUpdatedErrorType();
+}
+
+bool SyncGlobalError::HasCustomizedSyncMenuItem() {
+ return error_type_ != ERROR_TYPE_NONE;
+}
+
+
+SyncGlobalError::ErrorType SyncGlobalError::GetUpdatedErrorType() {
+ // If the user hasn't completed sync setup then we don't worry about errors.
+ if (!service_->HasSyncSetupCompleted())
+ return ERROR_TYPE_NONE;
+
+ const AuthError& auth_error = service_->GetAuthError();
+ switch (auth_error.state()) {
tim (not reviewing) 2011/09/16 22:14:24 We have a pile of code in sync_ui_util that does e
sail 2011/09/16 22:25:07 Once this gets checked in I'll be able to delete a
sail 2011/09/16 22:26:16 Hm.. actually the Sync Settings overlay still uses
sail 2011/09/17 01:15:30 Done.
+ case AuthError::NONE:
+ case AuthError::CONNECTION_FAILED:
+ break;
+ case AuthError::INVALID_GAIA_CREDENTIALS:
+ case AuthError::ACCOUNT_DELETED:
+ case AuthError::ACCOUNT_DISABLED:
+ // If no user name is entered then the error should be handled in the
+ // setup UI.
+ if (service_->GetAuthenticatedUsername().empty())
+ break;
+ else
+ return ERROR_TYPE_SIGN_IN;
+ case AuthError::SERVICE_UNAVAILABLE:
+ return ERROR_TYPE_UNAVAILABLE;
+ default:
+ return ERROR_TYPE_OTHER;
+ }
+
+ if (service_->IsPassphraseRequired() &&
+ service_->IsPassphraseRequiredForDecryption())
+ return ERROR_TYPE_PASSPHRASE;
+
+ return ERROR_TYPE_NONE;
+}
« no previous file with comments | « chrome/browser/sync/sync_global_error.h ('k') | chrome/browser/ui/toolbar/wrench_menu_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698