OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/signin/core/browser/signin_error_controller.h" | 5 #include "components/signin/core/browser/signin_error_controller.h" |
6 | 6 |
7 namespace { | 7 namespace { |
8 | 8 |
9 typedef std::set<const SigninErrorController::AuthStatusProvider*> | 9 typedef std::set<const SigninErrorController::AuthStatusProvider*> |
10 AuthStatusProviderSet; | 10 AuthStatusProviderSet; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 it != provider_set_.end(); ++it) { | 55 it != provider_set_.end(); ++it) { |
56 GoogleServiceAuthError error = (*it)->GetAuthStatus(); | 56 GoogleServiceAuthError error = (*it)->GetAuthStatus(); |
57 | 57 |
58 // Ignore the states we don't want to elevate to the user. | 58 // Ignore the states we don't want to elevate to the user. |
59 if (error.state() == GoogleServiceAuthError::NONE || | 59 if (error.state() == GoogleServiceAuthError::NONE || |
60 error.state() == GoogleServiceAuthError::CONNECTION_FAILED) { | 60 error.state() == GoogleServiceAuthError::CONNECTION_FAILED) { |
61 continue; | 61 continue; |
62 } | 62 } |
63 | 63 |
64 std::string account_id = (*it)->GetAccountId(); | 64 std::string account_id = (*it)->GetAccountId(); |
| 65 std::string username = (*it)->GetUsername(); |
65 | 66 |
66 // Prioritize this error if it matches the previous |auth_error_|. | 67 // Prioritize this error if it matches the previous |auth_error_|. |
67 if (error.state() == prev_state && account_id == prev_account_id) { | 68 if (error.state() == prev_state && account_id == prev_account_id) { |
68 auth_error_ = error; | 69 auth_error_ = error; |
69 error_account_id_ = account_id; | 70 error_account_id_ = account_id; |
| 71 error_username_ = username; |
70 error_changed = true; | 72 error_changed = true; |
71 break; | 73 break; |
72 } | 74 } |
73 | 75 |
74 // Use this error if we haven't found one already, but keep looking for the | 76 // Use this error if we haven't found one already, but keep looking for the |
75 // previous |auth_error_| in case there's a match elsewhere in the set. | 77 // previous |auth_error_| in case there's a match elsewhere in the set. |
76 if (!error_changed) { | 78 if (!error_changed) { |
77 auth_error_ = error; | 79 auth_error_ = error; |
78 error_account_id_ = account_id; | 80 error_account_id_ = account_id; |
| 81 error_username_ = username; |
79 error_changed = true; | 82 error_changed = true; |
80 } | 83 } |
81 } | 84 } |
82 | 85 |
83 if (!error_changed && prev_state != GoogleServiceAuthError::NONE) { | 86 if (!error_changed && prev_state != GoogleServiceAuthError::NONE) { |
84 // No provider reported an error, so clear the error we have now. | 87 // No provider reported an error, so clear the error we have now. |
85 auth_error_ = GoogleServiceAuthError::AuthErrorNone(); | 88 auth_error_ = GoogleServiceAuthError::AuthErrorNone(); |
86 error_account_id_.clear(); | 89 error_account_id_.clear(); |
| 90 error_username_.clear(); |
87 error_changed = true; | 91 error_changed = true; |
88 } | 92 } |
89 | 93 |
90 if (error_changed) { | 94 if (error_changed) { |
91 FOR_EACH_OBSERVER(Observer, observer_list_, OnErrorChanged()); | 95 FOR_EACH_OBSERVER(Observer, observer_list_, OnErrorChanged()); |
92 } | 96 } |
93 } | 97 } |
94 | 98 |
95 bool SigninErrorController::HasError() const { | 99 bool SigninErrorController::HasError() const { |
96 return auth_error_.state() != GoogleServiceAuthError::NONE && | 100 return auth_error_.state() != GoogleServiceAuthError::NONE && |
97 auth_error_.state() != GoogleServiceAuthError::CONNECTION_FAILED; | 101 auth_error_.state() != GoogleServiceAuthError::CONNECTION_FAILED; |
98 } | 102 } |
99 | 103 |
100 void SigninErrorController::AddObserver(Observer* observer) { | 104 void SigninErrorController::AddObserver(Observer* observer) { |
101 observer_list_.AddObserver(observer); | 105 observer_list_.AddObserver(observer); |
102 } | 106 } |
103 | 107 |
104 void SigninErrorController::RemoveObserver(Observer* observer) { | 108 void SigninErrorController::RemoveObserver(Observer* observer) { |
105 observer_list_.RemoveObserver(observer); | 109 observer_list_.RemoveObserver(observer); |
106 } | 110 } |
OLD | NEW |