1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
// 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/browser/sync/sync_ui_util.h"
#include "chrome/browser/ui/global_error_service.h"
#include "chrome/browser/ui/global_error_service_factory.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;
using namespace sync_ui_util;
SyncGlobalError::SyncGlobalError(ProfileSyncService* service)
: has_error_(false),
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 GetStatusLabelsForSyncGlobalError(service_, NULL, NULL, NULL) ==
SYNC_ERROR;
#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() {
string16 label;
GetStatusLabelsForSyncGlobalError(service_, &label, NULL, NULL);
return label;
}
void SyncGlobalError::ExecuteMenuItem(Browser* browser) {
service_->ShowErrorUI();
}
bool SyncGlobalError::HasBubbleView() {
return GetStatusLabelsForSyncGlobalError(service_, NULL, NULL, NULL) ==
SYNC_ERROR;
}
string16 SyncGlobalError::GetBubbleViewTitle() {
return l10n_util::GetStringUTF16(IDS_SYNC_ERROR_BUBBLE_VIEW_TITLE);
}
string16 SyncGlobalError::GetBubbleViewMessage() {
string16 label;
GetStatusLabelsForSyncGlobalError(service_, NULL, &label, NULL);
return label;
}
string16 SyncGlobalError::GetBubbleViewAcceptButtonLabel() {
string16 label;
GetStatusLabelsForSyncGlobalError(service_, NULL, NULL, &label);
return label;
}
string16 SyncGlobalError::GetBubbleViewCancelButtonLabel() {
return string16();
}
void SyncGlobalError::BubbleViewDidClose() {
}
void SyncGlobalError::BubbleViewAcceptButtonPressed() {
service_->ShowErrorUI();
}
void SyncGlobalError::BubbleViewCancelButtonPressed() {
NOTREACHED();
}
void SyncGlobalError::OnStateChanged() {
bool new_has_error = GetStatusLabelsForSyncGlobalError(
service_, NULL, NULL, NULL) == SYNC_ERROR;
if (new_has_error != has_error_) {
has_error_ = new_has_error;
GlobalErrorServiceFactory::GetForProfile(
service_->profile())->NotifyErrorsChanged(this);
}
}
bool SyncGlobalError::HasCustomizedSyncMenuItem() {
return GetStatusLabelsForSyncGlobalError(service_, NULL, NULL, NULL) ==
SYNC_ERROR;
}
|