OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/protector/settings_change_global_error.h" | 5 #include "chrome/browser/protector/settings_change_global_error.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 kBubbleKeepSettingIDs[change->type()], | 146 kBubbleKeepSettingIDs[change->type()], |
147 old_setting); | 147 old_setting); |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 bool SettingsChangeGlobalError::IsAcceptButtonDefault() { | 151 bool SettingsChangeGlobalError::IsAcceptButtonDefault() { |
152 return false; | 152 return false; |
153 } | 153 } |
154 | 154 |
155 void SettingsChangeGlobalError::BubbleViewAcceptButtonPressed() { | 155 void SettingsChangeGlobalError::BubbleViewAcceptButtonPressed() { |
| 156 closed_by_button_ = true; |
156 DCHECK(delegate_); | 157 DCHECK(delegate_); |
157 VLOG(1) << "Apply changes"; | 158 VLOG(1) << "Apply changes"; |
158 delegate_->OnApplyChanges(); | 159 delegate_->OnApplyChanges(); |
159 closed_by_button_ = true; | |
160 } | 160 } |
161 | 161 |
162 void SettingsChangeGlobalError::BubbleViewCancelButtonPressed() { | 162 void SettingsChangeGlobalError::BubbleViewCancelButtonPressed() { |
| 163 closed_by_button_ = true; |
163 DCHECK(delegate_); | 164 DCHECK(delegate_); |
164 VLOG(1) << "Discard changes"; | 165 VLOG(1) << "Discard changes"; |
165 delegate_->OnDiscardChanges(); | 166 delegate_->OnDiscardChanges(); |
166 closed_by_button_ = true; | |
167 } | 167 } |
168 | 168 |
169 void SettingsChangeGlobalError::RemoveFromProfile() { | 169 void SettingsChangeGlobalError::RemoveFromProfile() { |
170 DCHECK(delegate_); | 170 DCHECK(delegate_); |
171 if (profile_) | 171 if (profile_) |
172 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(this); | 172 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(this); |
173 if (!closed_by_button_) | 173 if (!closed_by_button_) |
174 delegate_->OnDecisionTimeout(); | 174 delegate_->OnDecisionTimeout(); |
| 175 delegate_->OnRemovedFromProfile(); |
175 } | 176 } |
176 | 177 |
177 void SettingsChangeGlobalError::BubbleViewDidClose() { | 178 void SettingsChangeGlobalError::BubbleViewDidClose() { |
178 browser_ = NULL; | 179 browser_ = NULL; |
179 if (!closed_by_button_) { | 180 if (!closed_by_button_) { |
180 BrowserThread::PostDelayedTask( | 181 BrowserThread::PostDelayedTask( |
181 BrowserThread::UI, FROM_HERE, | 182 BrowserThread::UI, FROM_HERE, |
182 base::Bind(&SettingsChangeGlobalError::RemoveFromProfile, | 183 base::Bind(&SettingsChangeGlobalError::RemoveFromProfile, |
183 weak_factory_.GetWeakPtr()), | 184 weak_factory_.GetWeakPtr()), |
184 kMenuItemDisplayPeriodMs); | 185 kMenuItemDisplayPeriodMs); |
(...skipping 23 matching lines...) Expand all Loading... |
208 | 209 |
209 void SettingsChangeGlobalError::Show() { | 210 void SettingsChangeGlobalError::Show() { |
210 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
211 DCHECK(profile_); | 212 DCHECK(profile_); |
212 browser_ = BrowserList::GetLastActiveWithProfile(profile_); | 213 browser_ = BrowserList::GetLastActiveWithProfile(profile_); |
213 if (browser_) | 214 if (browser_) |
214 ShowBubbleView(browser_); | 215 ShowBubbleView(browser_); |
215 } | 216 } |
216 | 217 |
217 } // namespace protector | 218 } // namespace protector |
OLD | NEW |