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" |
11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/protector/base_setting_change.h" |
13 #include "chrome/browser/protector/settings_change_global_error_delegate.h" | 14 #include "chrome/browser/protector/settings_change_global_error_delegate.h" |
14 #include "chrome/browser/ui/browser_list.h" | 15 #include "chrome/browser/ui/browser_list.h" |
15 #include "chrome/browser/ui/global_error_service.h" | 16 #include "chrome/browser/ui/global_error_service.h" |
16 #include "chrome/browser/ui/global_error_service_factory.h" | 17 #include "chrome/browser/ui/global_error_service_factory.h" |
17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
18 | 19 |
19 using content::BrowserThread; | 20 using content::BrowserThread; |
20 | 21 |
21 namespace protector { | 22 namespace protector { |
22 | 23 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 97 } |
97 | 98 |
98 void SettingsChangeGlobalError::BubbleViewCancelButtonPressed() { | 99 void SettingsChangeGlobalError::BubbleViewCancelButtonPressed() { |
99 closed_by_button_ = true; | 100 closed_by_button_ = true; |
100 delegate_->OnApplyChange(); | 101 delegate_->OnApplyChange(); |
101 } | 102 } |
102 | 103 |
103 void SettingsChangeGlobalError::RemoveFromProfile() { | 104 void SettingsChangeGlobalError::RemoveFromProfile() { |
104 if (profile_) | 105 if (profile_) |
105 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(this); | 106 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(this); |
106 if (!closed_by_button_) | |
107 delegate_->OnDecisionTimeout(); | |
108 delegate_->OnRemovedFromProfile(); | 107 delegate_->OnRemovedFromProfile(); |
109 } | 108 } |
110 | 109 |
111 void SettingsChangeGlobalError::BubbleViewDidClose() { | 110 void SettingsChangeGlobalError::BubbleViewDidClose() { |
112 browser_ = NULL; | 111 browser_ = NULL; |
113 if (!closed_by_button_) { | 112 if (!closed_by_button_) { |
114 BrowserThread::PostDelayedTask( | 113 BrowserThread::PostDelayedTask( |
115 BrowserThread::UI, FROM_HERE, | 114 BrowserThread::UI, FROM_HERE, |
116 base::Bind(&SettingsChangeGlobalError::RemoveFromProfile, | 115 base::Bind(&SettingsChangeGlobalError::OnInactiveTimeout, |
117 weak_factory_.GetWeakPtr()), | 116 weak_factory_.GetWeakPtr()), |
118 kMenuItemDisplayPeriodMs); | 117 kMenuItemDisplayPeriodMs); |
119 } else { | 118 } else { |
120 RemoveFromProfile(); | 119 RemoveFromProfile(); |
121 } | 120 } |
122 } | 121 } |
123 | 122 |
124 void SettingsChangeGlobalError::ShowForProfile(Profile* profile) { | 123 void SettingsChangeGlobalError::ShowForProfile(Profile* profile) { |
125 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 124 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
126 AddToProfile(profile); | 125 AddToProfile(profile); |
(...skipping 14 matching lines...) Expand all Loading... |
141 } | 140 } |
142 | 141 |
143 void SettingsChangeGlobalError::Show() { | 142 void SettingsChangeGlobalError::Show() { |
144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
145 DCHECK(profile_); | 144 DCHECK(profile_); |
146 browser_ = BrowserList::GetLastActiveWithProfile(profile_); | 145 browser_ = BrowserList::GetLastActiveWithProfile(profile_); |
147 if (browser_) | 146 if (browser_) |
148 ShowBubbleView(browser_); | 147 ShowBubbleView(browser_); |
149 } | 148 } |
150 | 149 |
| 150 void SettingsChangeGlobalError::OnInactiveTimeout() { |
| 151 delegate_->OnDecisionTimeout(); |
| 152 RemoveFromProfile(); |
| 153 } |
| 154 |
151 } // namespace protector | 155 } // namespace protector |
OLD | NEW |