Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: chrome/browser/extensions/extension_uninstall_dialog.cc

Issue 2860663003: Make CWS Report Abuse page the active tab after report abuse and uninstall (Closed)
Patch Set: Addressing last nits Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 false, base::ASCIIToUTF16(kExtensionRemovedError)); 119 false, base::ASCIIToUTF16(kExtensionRemovedError));
120 return; 120 return;
121 } 121 }
122 122
123 SetIcon(image); 123 SetIcon(image);
124 124
125 switch (ScopedTestDialogAutoConfirm::GetAutoConfirmValue()) { 125 switch (ScopedTestDialogAutoConfirm::GetAutoConfirmValue()) {
126 case ScopedTestDialogAutoConfirm::NONE: 126 case ScopedTestDialogAutoConfirm::NONE:
127 Show(); 127 Show();
128 break; 128 break;
129 case ScopedTestDialogAutoConfirm::ACCEPT_AND_OPTION:
130 OnDialogClosed(CLOSE_ACTION_UNINSTALL_AND_REPORT_ABUSE);
131 break;
129 case ScopedTestDialogAutoConfirm::ACCEPT: 132 case ScopedTestDialogAutoConfirm::ACCEPT:
130 OnDialogClosed(CLOSE_ACTION_UNINSTALL); 133 OnDialogClosed(CLOSE_ACTION_UNINSTALL);
131 break; 134 break;
132 case ScopedTestDialogAutoConfirm::CANCEL: 135 case ScopedTestDialogAutoConfirm::CANCEL:
133 OnDialogClosed(CLOSE_ACTION_CANCELED); 136 OnDialogClosed(CLOSE_ACTION_CANCELED);
134 break; 137 break;
135 } 138 }
136 } 139 }
137 140
138 std::string ExtensionUninstallDialog::GetHeadingText() { 141 std::string ExtensionUninstallDialog::GetHeadingText() {
(...skipping 17 matching lines...) Expand all
156 if (ShouldShowReportAbuseCheckbox()) { 159 if (ShouldShowReportAbuseCheckbox()) {
157 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallDialogAction", 160 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallDialogAction",
158 action, 161 action,
159 CLOSE_ACTION_LAST); 162 CLOSE_ACTION_LAST);
160 } 163 }
161 164
162 bool success = false; 165 bool success = false;
163 base::string16 error; 166 base::string16 error;
164 switch (action) { 167 switch (action) {
165 case CLOSE_ACTION_UNINSTALL_AND_REPORT_ABUSE: 168 case CLOSE_ACTION_UNINSTALL_AND_REPORT_ABUSE:
169 // If the extension specifies a custom uninstall page via
170 // chrome.runtime.setUninstallURL, then at uninstallation its uninstall
171 // page opens. To ensure that the CWS Report Abuse page is the active tab
172 // at uninstallation, HandleReportAbuse() is called after Uninstall().
173 success = Uninstall(&error);
166 HandleReportAbuse(); 174 HandleReportAbuse();
167 // Fall through. 175 break;
168 case CLOSE_ACTION_UNINSTALL: { 176 case CLOSE_ACTION_UNINSTALL: {
169 const Extension* current_extension = 177 success = Uninstall(&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; 178 break;
182 } 179 }
183 case CLOSE_ACTION_CANCELED: 180 case CLOSE_ACTION_CANCELED:
184 error = base::ASCIIToUTF16("User canceled uninstall dialog"); 181 error = base::ASCIIToUTF16("User canceled uninstall dialog");
185 break; 182 break;
186 case CLOSE_ACTION_LAST: 183 case CLOSE_ACTION_LAST:
187 NOTREACHED(); 184 NOTREACHED();
188 } 185 }
186 delegate_->OnExtensionUninstallDialogClosed(success, error);
187 }
189 188
190 delegate_->OnExtensionUninstallDialogClosed(success, error); 189 bool ExtensionUninstallDialog::Uninstall(base::string16* error) {
190 const Extension* current_extension =
191 ExtensionRegistry::Get(profile_)->GetExtensionById(
192 extension_->id(), ExtensionRegistry::EVERYTHING);
193 if (current_extension) {
194 return ExtensionSystem::Get(profile_)
195 ->extension_service()
196 ->UninstallExtension(extension_->id(), uninstall_reason_,
197 base::Bind(&base::DoNothing), error);
198 }
199 *error = base::ASCIIToUTF16(kExtensionRemovedError);
200 return false;
191 } 201 }
192 202
193 void ExtensionUninstallDialog::HandleReportAbuse() { 203 void ExtensionUninstallDialog::HandleReportAbuse() {
194 chrome::NavigateParams params( 204 chrome::NavigateParams params(
195 profile_, 205 profile_,
196 extension_urls::GetWebstoreReportAbuseUrl(extension_->id(), kReferrerId), 206 extension_urls::GetWebstoreReportAbuseUrl(extension_->id(), kReferrerId),
197 ui::PAGE_TRANSITION_LINK); 207 ui::PAGE_TRANSITION_LINK);
198 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; 208 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
199 chrome::Navigate(&params); 209 chrome::Navigate(&params);
200 } 210 }
201 211
202 } // namespace extensions 212 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698