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/extensions/extension_uninstall_dialog.h" | 5 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 if (ShouldShowReportAbuseCheckbox()) { | 156 if (ShouldShowReportAbuseCheckbox()) { |
157 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallDialogAction", | 157 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallDialogAction", |
158 action, | 158 action, |
159 CLOSE_ACTION_LAST); | 159 CLOSE_ACTION_LAST); |
160 } | 160 } |
161 | 161 |
162 bool success = false; | 162 bool success = false; |
163 base::string16 error; | 163 base::string16 error; |
164 switch (action) { | 164 switch (action) { |
165 case CLOSE_ACTION_UNINSTALL_AND_REPORT_ABUSE: | 165 case CLOSE_ACTION_UNINSTALL_AND_REPORT_ABUSE: |
166 Uninstall(success, error); | |
Devlin
2017/05/05 20:46:38
We should add a comment indicating why this order
catmullings
2017/05/15 22:27:55
Done.
| |
166 HandleReportAbuse(); | 167 HandleReportAbuse(); |
167 // Fall through. | 168 break; |
168 case CLOSE_ACTION_UNINSTALL: { | 169 case CLOSE_ACTION_UNINSTALL: { |
169 const Extension* current_extension = | 170 Uninstall(success, error); |
170 ExtensionRegistry::Get(profile_)->GetExtensionById( | |
171 extension_->id(), ExtensionRegistry::EVERYTHING); | |
172 if (current_extension) { | |
173 success = | |
174 ExtensionSystem::Get(profile_) | |
175 ->extension_service() | |
176 ->UninstallExtension(extension_->id(), uninstall_reason_, | |
177 base::Bind(&base::DoNothing), &error); | |
178 } else { | |
179 error = base::ASCIIToUTF16(kExtensionRemovedError); | |
180 } | |
181 break; | 171 break; |
182 } | 172 } |
183 case CLOSE_ACTION_CANCELED: | 173 case CLOSE_ACTION_CANCELED: |
184 error = base::ASCIIToUTF16("User canceled uninstall dialog"); | 174 error = base::ASCIIToUTF16("User canceled uninstall dialog"); |
185 break; | 175 break; |
186 case CLOSE_ACTION_LAST: | 176 case CLOSE_ACTION_LAST: |
187 NOTREACHED(); | 177 NOTREACHED(); |
188 } | 178 } |
189 | 179 |
190 delegate_->OnExtensionUninstallDialogClosed(success, error); | 180 delegate_->OnExtensionUninstallDialogClosed(success, error); |
191 } | 181 } |
192 | 182 |
183 void ExtensionUninstallDialog::Uninstall(bool& success, base::string16& error) { | |
184 const Extension* current_extension = | |
185 ExtensionRegistry::Get(profile_)->GetExtensionById( | |
186 extension_->id(), ExtensionRegistry::EVERYTHING); | |
187 if (current_extension) { | |
188 success = | |
189 ExtensionSystem::Get(profile_)->extension_service()->UninstallExtension( | |
190 extension_->id(), uninstall_reason_, base::Bind(&base::DoNothing), | |
191 &error); | |
192 } else { | |
193 error = base::ASCIIToUTF16(kExtensionRemovedError); | |
194 } | |
195 } | |
196 | |
193 void ExtensionUninstallDialog::HandleReportAbuse() { | 197 void ExtensionUninstallDialog::HandleReportAbuse() { |
194 chrome::NavigateParams params( | 198 chrome::NavigateParams params( |
195 profile_, | 199 profile_, |
196 extension_urls::GetWebstoreReportAbuseUrl(extension_->id(), kReferrerId), | 200 extension_urls::GetWebstoreReportAbuseUrl(extension_->id(), kReferrerId), |
197 ui::PAGE_TRANSITION_LINK); | 201 ui::PAGE_TRANSITION_LINK); |
198 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; | 202 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
199 chrome::Navigate(¶ms); | 203 chrome::Navigate(¶ms); |
200 } | 204 } |
201 | 205 |
202 } // namespace extensions | 206 } // namespace extensions |
OLD | NEW |