| OLD | NEW |
| 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/protector/settings_change_global_error.h" | 5 #include "chrome/browser/protector/settings_change_global_error.h" |
| 6 | 6 |
| 7 #include <bitset> | 7 #include <bitset> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 delegate_->OnDiscardChange(this, browser); | 197 delegate_->OnDiscardChange(this, browser); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void SettingsChangeGlobalError::BubbleViewCancelButtonPressed( | 200 void SettingsChangeGlobalError::BubbleViewCancelButtonPressed( |
| 201 Browser* browser) { | 201 Browser* browser) { |
| 202 closed_by_button_ = true; | 202 closed_by_button_ = true; |
| 203 delegate_->OnApplyChange(this, browser); | 203 delegate_->OnApplyChange(this, browser); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void SettingsChangeGlobalError::OnBrowserSetLastActive( | 206 void SettingsChangeGlobalError::OnBrowserSetLastActive( |
| 207 const Browser* browser) { | 207 Browser* browser) { |
| 208 if (show_on_browser_activation_ && browser && browser->is_type_tabbed()) { | 208 if (show_on_browser_activation_ && browser && browser->is_type_tabbed()) { |
| 209 // A tabbed browser window got activated, show the error bubble again. | 209 // A tabbed browser window got activated, show the error bubble again. |
| 210 // Calling ShowBubble() immediately from here does not always work because | 210 // Calling ShowBubble() immediately from here does not always work because |
| 211 // the old browser window may still have focus. | 211 // the old browser window may still have focus. |
| 212 // Multiple posted ShowBubble() calls are fine since the first successful | 212 // Multiple posted ShowBubble() calls are fine since the first successful |
| 213 // one will invalidate all the weak pointers. | 213 // one will invalidate all the weak pointers. |
| 214 // Note that ShowBubble() will display the bubble in the last active browser | 214 // Note that ShowBubble() will display the bubble in the last active browser |
| 215 // (which may not be |browser| at the moment ShowBubble() is executed). | 215 // (which may not be |browser| at the moment ShowBubble() is executed). |
| 216 BrowserThread::PostTask( | 216 BrowserThread::PostTask( |
| 217 BrowserThread::UI, FROM_HERE, | 217 BrowserThread::UI, FROM_HERE, |
| 218 base::Bind(&SettingsChangeGlobalError::ShowBubble, | 218 base::Bind(&SettingsChangeGlobalError::ShowBubble, |
| 219 weak_factory_.GetWeakPtr())); | 219 weak_factory_.GetWeakPtr())); |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 | 222 |
| 223 void SettingsChangeGlobalError::ShowBubbleInBrowser(Browser* browser) { | 223 void SettingsChangeGlobalError::ShowBubbleInBrowser(Browser* browser) { |
| 224 show_on_browser_activation_ = false; | 224 show_on_browser_activation_ = false; |
| 225 // Cancel any previously posted tasks so that the global error | 225 // Cancel any previously posted tasks so that the global error |
| 226 // does not get removed on timeout while still showing the bubble. | 226 // does not get removed on timeout while still showing the bubble. |
| 227 weak_factory_.InvalidateWeakPtrs(); | 227 weak_factory_.InvalidateWeakPtrs(); |
| 228 ShowBubbleView(browser); | 228 ShowBubbleView(browser); |
| 229 } | 229 } |
| 230 | 230 |
| 231 void SettingsChangeGlobalError::OnInactiveTimeout() { | 231 void SettingsChangeGlobalError::OnInactiveTimeout() { |
| 232 delegate_->OnDecisionTimeout(this); | 232 delegate_->OnDecisionTimeout(this); |
| 233 RemoveFromProfile(); | 233 RemoveFromProfile(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace protector | 236 } // namespace protector |
| OLD | NEW |