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

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

Issue 1148323007: [Extensions] Introduce a ScopedExtensionDialogAutoConfirm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 5 years, 6 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"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/extension_util.h" 13 #include "chrome/browser/extensions/extension_util.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser_navigator.h" 15 #include "chrome/browser/ui/browser_navigator.h"
16 #include "chrome/grit/generated_resources.h" 16 #include "chrome/grit/generated_resources.h"
17 #include "extensions/browser/extension_dialog_auto_confirm.h"
17 #include "extensions/browser/extension_registry.h" 18 #include "extensions/browser/extension_registry.h"
18 #include "extensions/browser/extension_system.h" 19 #include "extensions/browser/extension_system.h"
19 #include "extensions/browser/image_loader.h" 20 #include "extensions/browser/image_loader.h"
20 #include "extensions/common/constants.h" 21 #include "extensions/common/constants.h"
21 #include "extensions/common/extension.h" 22 #include "extensions/common/extension.h"
22 #include "extensions/common/extension_icon_set.h" 23 #include "extensions/common/extension_icon_set.h"
23 #include "extensions/common/extension_resource.h" 24 #include "extensions/common/extension_resource.h"
24 #include "extensions/common/extension_urls.h" 25 #include "extensions/common/extension_urls.h"
25 #include "extensions/common/manifest_handlers/icons_handler.h" 26 #include "extensions/common/manifest_handlers/icons_handler.h"
26 #include "extensions/common/manifest_url_handlers.h" 27 #include "extensions/common/manifest_url_handlers.h"
(...skipping 14 matching lines...) Expand all
41 // pixel size under maximal supported scale factor. 42 // pixel size under maximal supported scale factor.
42 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { 43 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) {
43 const gfx::ImageSkia& image = 44 const gfx::ImageSkia& image =
44 is_app ? util::GetDefaultAppIcon() : util::GetDefaultExtensionIcon(); 45 is_app ? util::GetDefaultAppIcon() : util::GetDefaultExtensionIcon();
45 return image.GetRepresentation( 46 return image.GetRepresentation(
46 gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap(); 47 gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap();
47 } 48 }
48 49
49 } // namespace 50 } // namespace
50 51
51 // static
52 ExtensionUninstallDialog::AutoConfirmForTests
53 ExtensionUninstallDialog::g_auto_confirm_for_testing =
54 ExtensionUninstallDialog::NONE;
55
56 ExtensionUninstallDialog::ScopedAutoConfirm::ScopedAutoConfirm(
57 AutoConfirmForTests new_value)
58 : original_value_(g_auto_confirm_for_testing) {
59 g_auto_confirm_for_testing = new_value;
60 }
61
62 ExtensionUninstallDialog::ScopedAutoConfirm::~ScopedAutoConfirm() {
63 g_auto_confirm_for_testing = original_value_;
64 }
65
66 ExtensionUninstallDialog::ExtensionUninstallDialog( 52 ExtensionUninstallDialog::ExtensionUninstallDialog(
67 Profile* profile, 53 Profile* profile,
68 ExtensionUninstallDialog::Delegate* delegate) 54 ExtensionUninstallDialog::Delegate* delegate)
69 : profile_(profile), 55 : profile_(profile),
70 delegate_(delegate), 56 delegate_(delegate),
71 uninstall_reason_(UNINSTALL_REASON_FOR_TESTING) { 57 uninstall_reason_(UNINSTALL_REASON_FOR_TESTING) {
72 } 58 }
73 59
74 ExtensionUninstallDialog::~ExtensionUninstallDialog() { 60 ExtensionUninstallDialog::~ExtensionUninstallDialog() {
75 } 61 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 ExtensionRegistry::Get(profile_) 116 ExtensionRegistry::Get(profile_)
131 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING); 117 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING);
132 if (!target_extension) { 118 if (!target_extension) {
133 delegate_->OnExtensionUninstallDialogClosed( 119 delegate_->OnExtensionUninstallDialogClosed(
134 false, base::ASCIIToUTF16(kExtensionRemovedError)); 120 false, base::ASCIIToUTF16(kExtensionRemovedError));
135 return; 121 return;
136 } 122 }
137 123
138 SetIcon(image); 124 SetIcon(image);
139 125
140 switch (g_auto_confirm_for_testing) { 126 switch (ScopedTestDialogAutoConfirm::GetAutoConfirmValue()) {
141 case NONE: 127 case ScopedTestDialogAutoConfirm::NONE:
142 Show(); 128 Show();
143 break; 129 break;
144 case ACCEPT: 130 case ScopedTestDialogAutoConfirm::ACCEPT:
145 OnDialogClosed(CLOSE_ACTION_UNINSTALL); 131 OnDialogClosed(CLOSE_ACTION_UNINSTALL);
146 break; 132 break;
147 case CANCEL: 133 case ScopedTestDialogAutoConfirm::CANCEL:
148 OnDialogClosed(CLOSE_ACTION_CANCELED); 134 OnDialogClosed(CLOSE_ACTION_CANCELED);
149 break; 135 break;
150 } 136 }
151 } 137 }
152 138
153 std::string ExtensionUninstallDialog::GetHeadingText() { 139 std::string ExtensionUninstallDialog::GetHeadingText() {
154 if (triggering_extension_) { 140 if (triggering_extension_) {
155 return l10n_util::GetStringFUTF8( 141 return l10n_util::GetStringFUTF8(
156 IDS_EXTENSION_PROGRAMMATIC_UNINSTALL_PROMPT_HEADING, 142 IDS_EXTENSION_PROGRAMMATIC_UNINSTALL_PROMPT_HEADING,
157 base::UTF8ToUTF16(triggering_extension_->name()), 143 base::UTF8ToUTF16(triggering_extension_->name()),
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 void ExtensionUninstallDialog::HandleReportAbuse() { 194 void ExtensionUninstallDialog::HandleReportAbuse() {
209 chrome::NavigateParams params( 195 chrome::NavigateParams params(
210 profile_, 196 profile_,
211 extension_urls::GetWebstoreReportAbuseUrl(extension_->id()), 197 extension_urls::GetWebstoreReportAbuseUrl(extension_->id()),
212 ui::PAGE_TRANSITION_LINK); 198 ui::PAGE_TRANSITION_LINK);
213 params.disposition = NEW_FOREGROUND_TAB; 199 params.disposition = NEW_FOREGROUND_TAB;
214 chrome::Navigate(&params); 200 chrome::Navigate(&params);
215 } 201 }
216 202
217 } // namespace extensions 203 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_uninstall_dialog.h ('k') | chrome/browser/extensions/unpacked_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698