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

Side by Side Diff: chrome/browser/sync/sync_global_error.cc

Issue 11886079: Revert 177136 due to memory error on Mac ASAN (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_global_error.h" 5 #include "chrome/browser/sync/sync_global_error.h"
6 6
7 #include "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/api/sync/profile_sync_service_observer.h" 8 #include "chrome/browser/api/sync/profile_sync_service_observer.h"
9 #include "chrome/browser/sync/profile_sync_service.h" 9 #include "chrome/browser/sync/profile_sync_service.h"
10 #include "chrome/browser/sync/sync_ui_util.h" 10 #include "chrome/browser/sync/sync_ui_util.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_commands.h" 12 #include "chrome/browser/ui/browser_commands.h"
13 #include "chrome/browser/ui/chrome_pages.h" 13 #include "chrome/browser/ui/chrome_pages.h"
14 #include "chrome/browser/ui/global_error/global_error_service.h" 14 #include "chrome/browser/ui/global_error/global_error_service.h"
15 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 15 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
16 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 16 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
17 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 17 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
18 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
19 #include "google_apis/gaia/google_service_auth_error.h" 19 #include "google_apis/gaia/google_service_auth_error.h"
20 #include "grit/chromium_strings.h" 20 #include "grit/chromium_strings.h"
21 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
22 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
23 23
24 typedef GoogleServiceAuthError AuthError;
25
24 SyncGlobalError::SyncGlobalError(ProfileSyncService* service, 26 SyncGlobalError::SyncGlobalError(ProfileSyncService* service,
25 SigninManager* signin) 27 SigninManager* signin)
26 : service_(service), 28 : service_(service),
27 signin_(signin) { 29 signin_(signin) {
28 DCHECK(service_); 30 DCHECK(service_);
29 DCHECK(signin_); 31 DCHECK(signin_);
30 OnStateChanged(); 32 OnStateChanged();
31 } 33 }
32 34
33 SyncGlobalError::~SyncGlobalError() { 35 SyncGlobalError::~SyncGlobalError() {
34 } 36 }
35 37
36 bool SyncGlobalError::HasBadge() { 38 bool SyncGlobalError::HasBadge() {
37 return !menu_label_.empty(); 39 return !menu_label_.empty();
38 } 40 }
39 41
40 bool SyncGlobalError::HasMenuItem() { 42 bool SyncGlobalError::HasMenuItem() {
41 // When we're on Chrome OS we need to add a separate menu item to the wrench 43 // When we're on Chrome OS we need to add a separate menu item to the wrench
42 // menu to the show the error. On other platforms we can just reuse the 44 // menu to the show the error. On other platforms we can just reuse the
43 // "Sign in to Chrome..." menu item to show the error. 45 // "Sign in to Chrome..." menu item to show the error.
44 #if defined(OS_CHROMEOS) 46 #if defined(OS_CHROMEOS)
45 return !menu_label_.empty(); 47 return !menu_label_.empty();
46 #else 48 #else
47 return false; 49 return false;
48 #endif 50 #endif
49 } 51 }
50 52
51 int SyncGlobalError::MenuItemCommandID() { 53 int SyncGlobalError::MenuItemCommandID() {
52 return IDC_SHOW_SIGNIN_ERROR; 54 return IDC_SHOW_SYNC_ERROR;
53 } 55 }
54 56
55 string16 SyncGlobalError::MenuItemLabel() { 57 string16 SyncGlobalError::MenuItemLabel() {
56 return menu_label_; 58 return menu_label_;
57 } 59 }
58 60
59 void SyncGlobalError::ExecuteMenuItem(Browser* browser) { 61 void SyncGlobalError::ExecuteMenuItem(Browser* browser) {
62 #if defined(OS_CHROMEOS)
63 if (service_->GetAuthError().state() != AuthError::NONE) {
64 DLOG(INFO) << "Signing out the user to fix a sync error.";
65 // TODO(beng): seems like this could just call browser::AttemptUserExit().
66 chrome::ExecuteCommand(browser, IDC_EXIT);
67 return;
68 }
69 #endif
60 LoginUIService* login_ui = LoginUIServiceFactory::GetForProfile( 70 LoginUIService* login_ui = LoginUIServiceFactory::GetForProfile(
61 service_->profile()); 71 service_->profile());
62 if (login_ui->current_login_ui()) { 72 if (login_ui->current_login_ui()) {
63 login_ui->current_login_ui()->FocusUI(); 73 login_ui->current_login_ui()->FocusUI();
64 return; 74 return;
65 } 75 }
66 // Need to navigate to the settings page and display the UI. 76 // Need to navigate to the settings page and display the UI.
67 chrome::ShowSettingsSubPage(browser, chrome::kSyncSetupSubPage); 77 chrome::ShowSettingsSubPage(browser, chrome::kSyncSetupSubPage);
68 } 78 }
69 79
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 bubble_accept_label_ = bubble_accept_label; 128 bubble_accept_label_ = bubble_accept_label;
119 129
120 // Profile can be NULL during tests. 130 // Profile can be NULL during tests.
121 Profile* profile = service_->profile(); 131 Profile* profile = service_->profile();
122 if (profile) { 132 if (profile) {
123 GlobalErrorServiceFactory::GetForProfile( 133 GlobalErrorServiceFactory::GetForProfile(
124 profile)->NotifyErrorsChanged(this); 134 profile)->NotifyErrorsChanged(this);
125 } 135 }
126 } 136 }
127 } 137 }
138
139 bool SyncGlobalError::HasCustomizedSyncMenuItem() {
140 return !menu_label_.empty();
141 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/sync_global_error.h ('k') | chrome/browser/sync/sync_global_error_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698