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

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

Issue 2168713002: Removed sync error menu item from the wrench menu (material design user menu only) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/sync/sync_ui_util.h" 8 #include "chrome/browser/sync/sync_ui_util.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_commands.h" 10 #include "chrome/browser/ui/browser_commands.h"
11 #include "chrome/browser/ui/chrome_pages.h" 11 #include "chrome/browser/ui/chrome_pages.h"
12 #include "chrome/browser/ui/global_error/global_error_service.h" 12 #include "chrome/browser/ui/global_error/global_error_service.h"
13 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 13 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
14 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
15 #include "chrome/grit/generated_resources.h" 15 #include "chrome/grit/generated_resources.h"
16 #include "components/browser_sync/browser/profile_sync_service.h" 16 #include "components/browser_sync/browser/profile_sync_service.h"
17 #include "components/signin/core/common/profile_management_switches.h"
17 #include "google_apis/gaia/google_service_auth_error.h" 18 #include "google_apis/gaia/google_service_auth_error.h"
18 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
19 20
20 SyncGlobalError::SyncGlobalError(GlobalErrorService* global_error_service, 21 SyncGlobalError::SyncGlobalError(GlobalErrorService* global_error_service,
21 LoginUIService* login_ui_service, 22 LoginUIService* login_ui_service,
22 SyncErrorController* error_controller, 23 SyncErrorController* error_controller,
23 ProfileSyncService* profile_sync_service) 24 ProfileSyncService* profile_sync_service)
24 : global_error_service_(global_error_service), 25 : global_error_service_(global_error_service),
25 login_ui_service_(login_ui_service), 26 login_ui_service_(login_ui_service),
26 error_controller_(error_controller), 27 error_controller_(error_controller),
27 sync_service_(profile_sync_service) { 28 sync_service_(profile_sync_service) {
28 DCHECK(sync_service_); 29 DCHECK(sync_service_);
29 error_controller_->AddObserver(this); 30 error_controller_->AddObserver(this);
30 global_error_service_->AddGlobalError(this); 31 if (!switches::IsMaterialDesignUserMenu())
32 global_error_service_->AddGlobalError(this);
31 } 33 }
32 34
33 SyncGlobalError::~SyncGlobalError() { 35 SyncGlobalError::~SyncGlobalError() {
34 DCHECK(!error_controller_) 36 DCHECK(!error_controller_)
35 << "SyncGlobalError::Shutdown() was not called"; 37 << "SyncGlobalError::Shutdown() was not called";
36 } 38 }
37 39
38 void SyncGlobalError::Shutdown() { 40 void SyncGlobalError::Shutdown() {
39 global_error_service_->RemoveGlobalError(this); 41 if (!switches::IsMaterialDesignUserMenu())
42 global_error_service_->RemoveGlobalError(this);
40 error_controller_->RemoveObserver(this); 43 error_controller_->RemoveObserver(this);
41 error_controller_ = NULL; 44 error_controller_ = NULL;
42 } 45 }
43 46
44 bool SyncGlobalError::HasMenuItem() { 47 bool SyncGlobalError::HasMenuItem() {
45 return !menu_label_.empty(); 48 return !menu_label_.empty();
46 } 49 }
47 50
48 int SyncGlobalError::MenuItemCommandID() { 51 int SyncGlobalError::MenuItemCommandID() {
49 return IDC_SHOW_SYNC_ERROR; 52 return IDC_SHOW_SYNC_ERROR;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 90
88 void SyncGlobalError::BubbleViewAcceptButtonPressed(Browser* browser) { 91 void SyncGlobalError::BubbleViewAcceptButtonPressed(Browser* browser) {
89 ExecuteMenuItem(browser); 92 ExecuteMenuItem(browser);
90 } 93 }
91 94
92 void SyncGlobalError::BubbleViewCancelButtonPressed(Browser* browser) { 95 void SyncGlobalError::BubbleViewCancelButtonPressed(Browser* browser) {
93 NOTREACHED(); 96 NOTREACHED();
94 } 97 }
95 98
96 void SyncGlobalError::OnErrorChanged() { 99 void SyncGlobalError::OnErrorChanged() {
100 if (switches::IsMaterialDesignUserMenu())
101 return;
102
97 base::string16 menu_label; 103 base::string16 menu_label;
98 base::string16 bubble_message; 104 base::string16 bubble_message;
99 base::string16 bubble_accept_label; 105 base::string16 bubble_accept_label;
100 sync_ui_util::GetStatusLabelsForSyncGlobalError( 106 sync_ui_util::GetStatusLabelsForSyncGlobalError(
101 sync_service_, &menu_label, &bubble_message, &bubble_accept_label); 107 sync_service_, &menu_label, &bubble_message, &bubble_accept_label);
102 108
103 // All the labels should be empty or all of them non-empty. 109 // All the labels should be empty or all of them non-empty.
104 DCHECK((menu_label.empty() && bubble_message.empty() && 110 DCHECK((menu_label.empty() && bubble_message.empty() &&
105 bubble_accept_label.empty()) || 111 bubble_accept_label.empty()) ||
106 (!menu_label.empty() && !bubble_message.empty() && 112 (!menu_label.empty() && !bubble_message.empty() &&
107 !bubble_accept_label.empty())); 113 !bubble_accept_label.empty()));
108 114
109 if (menu_label != menu_label_ || bubble_message != bubble_message_ || 115 if (menu_label != menu_label_ || bubble_message != bubble_message_ ||
110 bubble_accept_label != bubble_accept_label_) { 116 bubble_accept_label != bubble_accept_label_) {
111 menu_label_ = menu_label; 117 menu_label_ = menu_label;
112 bubble_message_ = bubble_message; 118 bubble_message_ = bubble_message;
113 bubble_accept_label_ = bubble_accept_label; 119 bubble_accept_label_ = bubble_accept_label;
114 120
115 global_error_service_->NotifyErrorsChanged(this); 121 global_error_service_->NotifyErrorsChanged(this);
116 } 122 }
117 } 123 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698