diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-17 00:16:02 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-17 00:16:02 +0000 |
commit | 3a91eff218570a1d5c322262c96fbb0a41e3b580 (patch) | |
tree | a3c651c9db024510d0d800b8a0d185d41dc0cce2 | |
parent | dabaa73dceb1772448ed1ff6935471946da53143 (diff) | |
download | chromium_src-3a91eff218570a1d5c322262c96fbb0a41e3b580.zip chromium_src-3a91eff218570a1d5c322262c96fbb0a41e3b580.tar.gz chromium_src-3a91eff218570a1d5c322262c96fbb0a41e3b580.tar.bz2 |
Spruced up the warning dialog for when you enable an extension in incognito.
I hijacked the extension install/uninstall dialog, and added another type that
it can transmogrify into.
BUG=32365
Review URL: http://codereview.chromium.org/1041002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41787 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/generated_resources.grd | 15 | ||||
-rw-r--r-- | chrome/browser/cocoa/extension_install_prompt.mm | 8 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_install_ui.cc | 60 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_install_ui.h | 33 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_ui.cc | 48 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_ui.h | 8 | ||||
-rw-r--r-- | chrome/browser/gtk/extension_install_prompt_gtk.cc | 15 | ||||
-rw-r--r-- | chrome/browser/resources/extensions_ui.html | 15 | ||||
-rw-r--r-- | chrome/browser/views/extensions/extension_install_prompt.cc | 26 |
9 files changed, 140 insertions, 88 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 2bb2658..f6bc019 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -3221,9 +3221,15 @@ each locale. --> <message name="IDS_EXTENSION_UNINSTALL_PROMPT_TITLE" desc="Titlebar of the extension uninstallation prompt window"> Confirm Uninstallation </message> + <message name="IDS_EXTENSION_ENABLE_INCOGNITO_PROMPT_TITLE" desc="Titlebar of the extension run-in-incognito prompt window"> + Confirm Run in Incognito + </message> <message name="IDS_EXTENSION_INSTALL_PROMPT_HEADING" desc="First bold line in the content area of the extension installation prompt. Asks the user if they want to install a particular extension."> Install <ph name="EXTENSION_NAME">$1<ex>Gmail Checker</ex></ph>? </message> + <message name="IDS_EXTENSION_ENABLE_INCOGNITO_PROMPT_HEADING" desc="First bold line in the content area of the run-in-incognito prompt. Asks the user if they want to enable a particular extension in incognito."> + Allow <ph name="EXTENSION_NAME">$1<ex>Gmail Checker</ex></ph> to run in incognito? + </message> <message name="IDS_EXTENSION_PROMPT_CREATE_SHORTCUT" desc="Label for checkbox that asks the user if they want to create a desktop shortcut for an app install."> Create desktop shortcut </message> @@ -3233,6 +3239,9 @@ each locale. --> <message name="IDS_EXTENSION_UNINSTALL_CONFIRMATION" desc="The warning you get when you are about to uninstall an extension."> Are you sure you want to uninstall this extension? </message> + <message name="IDS_EXTENSION_PROMPT_WARNING_INCOGNITO" desc="The warning you get when you are about to enable an extension in incognito."> + Because <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> does not control how extensions handle your personal data, this extension could leave traces on your machine even after you close the incognito window. Allow anyway? + </message> <message name="IDS_EXTENSION_PROMPT_WARNING_NEW_BROWSER" desc="Warning displayed in body of extension dialog when the extension requires access to browser APIs."> This extension will have access to your browsing history. </message> @@ -3364,9 +3373,6 @@ each locale. --> <message name="IDS_EXTENSIONS_ENABLE_INCOGNITO" desc="The checkbox for enabling extensions in incognito."> Allow this extension to run in incognito </message> - <message name="IDS_EXTENSIONS_ENABLE_INCOGNITO_WARNING" desc="A warning message displayed when the user attempts to enable a non-incognito-safe extension in incognito."> - Because <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> does not control how extensions handle your personal data, this extension could leave traces on your machine even after you close the incognito window. Enable anyway? - </message> <message name="IDS_EXTENSIONS_RELOAD" desc="The link for reloading extensions."> Reload </message> @@ -3444,6 +3450,9 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON" desc="Text for the uninstall button on the extension uninstall prompt"> Uninstall </message> + <message name="IDS_EXTENSION_PROMPT_ENABLE_INCOGNITO_BUTTON" desc="Text for the allow button on the extension run-in-incognito prompt"> + Allow + </message> <!-- Session Crashed Info Bar--> <message name="IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON" desc="Title of the restore button in the session crashed view."> diff --git a/chrome/browser/cocoa/extension_install_prompt.mm b/chrome/browser/cocoa/extension_install_prompt.mm index 8f01720..b73ebc2 100644 --- a/chrome/browser/cocoa/extension_install_prompt.mm +++ b/chrome/browser/cocoa/extension_install_prompt.mm @@ -21,12 +21,11 @@ class Profile; void ExtensionInstallUI::ShowExtensionInstallUIPromptImpl( Profile* profile, Delegate* delegate, Extension* extension, SkBitmap* icon, - const string16& warning_text, bool is_uninstall) { + const string16& warning_text, ExtensionInstallUI::PromptType type) { NSAlert* alert = [[[NSAlert alloc] init] autorelease]; NSButton* continueButton = [alert addButtonWithTitle:l10n_util::GetNSString( - is_uninstall ? IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON : - IDS_EXTENSION_PROMPT_INSTALL_BUTTON)]; + ExtensionInstallUI::kButtonIds[type])]; // Clear the key equivalent (currently 'Return') because cancel is the default // button. [continueButton setKeyEquivalent:@""]; @@ -36,8 +35,7 @@ void ExtensionInstallUI::ShowExtensionInstallUIPromptImpl( [cancelButton setKeyEquivalent:@"\r"]; [alert setMessageText:l10n_util::GetNSStringF( - is_uninstall ? IDS_EXTENSION_UNINSTALL_PROMPT_HEADING : - IDS_EXTENSION_INSTALL_PROMPT_HEADING, + ExtensionInstallUI::kHeadingIds[type], UTF8ToUTF16(extension->name()))]; [alert setInformativeText:base::SysUTF16ToNSString(warning_text)]; [alert setAlertStyle:NSWarningAlertStyle]; diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc index ef410d1..e7a8406 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -39,6 +39,25 @@ #include "chrome/browser/cocoa/extension_installed_bubble_bridge.h" #endif +// static +const int ExtensionInstallUI::kTitleIds[NUM_PROMPT_TYPES] = { + IDS_EXTENSION_INSTALL_PROMPT_TITLE, + IDS_EXTENSION_UNINSTALL_PROMPT_TITLE, + IDS_EXTENSION_ENABLE_INCOGNITO_PROMPT_TITLE +}; +// static +const int ExtensionInstallUI::kHeadingIds[NUM_PROMPT_TYPES] = { + IDS_EXTENSION_INSTALL_PROMPT_HEADING, + IDS_EXTENSION_UNINSTALL_PROMPT_HEADING, + IDS_EXTENSION_ENABLE_INCOGNITO_PROMPT_HEADING +}; +// static +const int ExtensionInstallUI::kButtonIds[NUM_PROMPT_TYPES] = { + IDS_EXTENSION_PROMPT_INSTALL_BUTTON, + IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON, + IDS_EXTENSION_PROMPT_ENABLE_INCOGNITO_BUTTON +}; + namespace { static std::wstring GetInstallWarning(Extension* extension) { @@ -114,22 +133,6 @@ ExtensionInstallUI::ExtensionInstallUI(Profile* profile) #endif {} -// static -void ExtensionInstallUI::ShowExtensionInstallPrompt( - Profile* profile, Delegate* delegate, Extension* extension, SkBitmap* icon, - const string16& warning_text) { - ShowExtensionInstallUIPromptImpl(profile, delegate, extension, icon, - warning_text, false); // uninstall == false. -} - -// static -void ExtensionInstallUI::ShowExtensionUninstallPrompt( - Profile* profile, Delegate* delegate, Extension* extension, SkBitmap* icon, - const string16& warning_text) { - ShowExtensionInstallUIPromptImpl(profile, delegate, extension, icon, - warning_text, true); // uninstall == true. -} - void ExtensionInstallUI::ConfirmInstall(Delegate* delegate, Extension* extension, SkBitmap* install_icon) { @@ -166,8 +169,9 @@ void ExtensionInstallUI::ConfirmInstall(Delegate* delegate, Source<ExtensionInstallUI>(this), NotificationService::NoDetails()); - ShowExtensionInstallPrompt(profile_, delegate, extension, &icon_, - WideToUTF16Hack(GetInstallWarning(extension))); + ShowExtensionInstallUIPromptImpl( + profile_, delegate, extension, &icon_, + WideToUTF16Hack(GetInstallWarning(extension)), INSTALL_PROMPT); } void ExtensionInstallUI::ConfirmUninstall(Delegate* delegate, @@ -182,7 +186,25 @@ void ExtensionInstallUI::ConfirmUninstall(Delegate* delegate, string16 message = l10n_util::GetStringUTF16(IDS_EXTENSION_UNINSTALL_CONFIRMATION); - ShowExtensionUninstallPrompt(profile_, delegate, extension, icon, message); + ShowExtensionInstallUIPromptImpl(profile_, delegate, extension, icon, + message, UNINSTALL_PROMPT); +} + +void ExtensionInstallUI::ConfirmEnableIncognito(Delegate* delegate, + Extension* extension, + SkBitmap* icon) { + DCHECK(ui_loop_ == MessageLoop::current()); + + if (!icon) { + icon = ResourceBundle::GetSharedInstance().GetBitmapNamed( + IDR_EXTENSION_DEFAULT_ICON); + } + + string16 message = + l10n_util::GetStringFUTF16(IDS_EXTENSION_PROMPT_WARNING_INCOGNITO, + l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); + ShowExtensionInstallUIPromptImpl(profile_, delegate, extension, icon, + message, ENABLE_INCOGNITO_PROMPT); } void ExtensionInstallUI::OnInstallSuccess(Extension* extension) { diff --git a/chrome/browser/extensions/extension_install_ui.h b/chrome/browser/extensions/extension_install_ui.h index 3e51659..fc3bdbb 100644 --- a/chrome/browser/extensions/extension_install_ui.h +++ b/chrome/browser/extensions/extension_install_ui.h @@ -24,6 +24,18 @@ class TabContents; // Displays all the UI around extension installation and uninstallation. class ExtensionInstallUI { public: + enum PromptType { + INSTALL_PROMPT = 0, + UNINSTALL_PROMPT, + ENABLE_INCOGNITO_PROMPT, + NUM_PROMPT_TYPES + }; + + // A mapping from PromptType to message ID for various dialog content. + static const int kTitleIds[NUM_PROMPT_TYPES]; + static const int kHeadingIds[NUM_PROMPT_TYPES]; + static const int kButtonIds[NUM_PROMPT_TYPES]; + class Delegate { public: // We call this method after ConfirmInstall()/ConfirmUninstall() to signal @@ -35,17 +47,6 @@ class ExtensionInstallUI { virtual void InstallUIAbort() = 0; }; - static void ShowExtensionInstallPrompt(Profile* profile, - Delegate* delegate, - Extension* extension, - SkBitmap* install_icon, - const string16& warning_text); - static void ShowExtensionUninstallPrompt(Profile* profile, - Delegate* delegate, - Extension* extension, - SkBitmap* install_icon, - const string16& warning_text); - explicit ExtensionInstallUI(Profile* profile); virtual ~ExtensionInstallUI() {} @@ -66,6 +67,14 @@ class ExtensionInstallUI { virtual void ConfirmUninstall(Delegate* delegate, Extension* extension, SkBitmap* icon); + // This is called by the extensions management page to verify whether the + // uninstallation should proceed. This is declared virtual for testing. + // + // We *MUST* eventually call either Proceed() or Abort() + // on |delegate|. + virtual void ConfirmEnableIncognito(Delegate* delegate, Extension* extension, + SkBitmap* icon); + // Installation was successful. This is declared virtual for testing. virtual void OnInstallSuccess(Extension* extension); @@ -96,7 +105,7 @@ class ExtensionInstallUI { // NOTE: The implementations of this function is platform-specific. static void ShowExtensionInstallUIPromptImpl( Profile* profile, Delegate* delegate, Extension* extension, - SkBitmap* icon, const string16& warning_text, bool is_uninstall); + SkBitmap* icon, const string16& warning_text, PromptType type); Profile* profile_; MessageLoop* ui_loop_; diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc index 00b658e..65d19be 100644 --- a/chrome/browser/extensions/extensions_ui.cc +++ b/chrome/browser/extensions/extensions_ui.cc @@ -123,9 +123,6 @@ void ExtensionsUIHTMLSource::StartDataRequest(const std::string& path, l10n_util::GetString(IDS_EXTENSIONS_ENABLE)); localized_strings.SetString(L"enableIncognito", l10n_util::GetString(IDS_EXTENSIONS_ENABLE_INCOGNITO)); - localized_strings.SetString(L"enableIncognitoWarning", - l10n_util::GetStringF(IDS_EXTENSIONS_ENABLE_INCOGNITO_WARNING, - l10n_util::GetString(IDS_PRODUCT_NAME))); localized_strings.SetString(L"reload", l10n_util::GetString(IDS_EXTENSIONS_RELOAD)); localized_strings.SetString(L"uninstall", @@ -449,7 +446,19 @@ void ExtensionsDOMHandler::HandleEnableIncognitoMessage(const Value* value) { Extension* extension = extensions_service_->GetExtensionById(extension_id, true); DCHECK(extension); - extensions_service_->SetIsIncognitoEnabled(extension, (enable_str == "true")); + + if (enable_str == "true") { + // Prompt the user first. + scoped_ptr<SkBitmap> icon; + Extension::DecodeIcon(extension, Extension::EXTENSION_ICON_LARGE, &icon); + + ui_prompt_type_ = ExtensionInstallUI::ENABLE_INCOGNITO_PROMPT; + extension_id_prompting_ = extension_id; + ExtensionInstallUI client(dom_ui_->GetProfile()); + client.ConfirmEnableIncognito(this, extension, icon.get()); + } else { + extensions_service_->SetIsIncognitoEnabled(extension, false); + } } void ExtensionsDOMHandler::HandleUninstallMessage(const Value* value) { @@ -468,7 +477,8 @@ void ExtensionsDOMHandler::HandleUninstallMessage(const Value* value) { Extension::DecodeIcon(extension, Extension::EXTENSION_ICON_LARGE, &uninstall_icon); - extension_id_uninstalling_ = extension_id; + ui_prompt_type_ = ExtensionInstallUI::UNINSTALL_PROMPT; + extension_id_prompting_ = extension_id; ExtensionInstallUI client(dom_ui_->GetProfile()); client.ConfirmUninstall(this, extension, uninstall_icon.get()); } @@ -478,17 +488,31 @@ void ExtensionsDOMHandler::InstallUIProceed(bool create_app_shortcut) { // result in it telling us to create a shortcut. DCHECK(!create_app_shortcut); - // The extension can be uninstalled in another window while the uninstall UI - // was showing. Do nothing in that case. - if (extensions_service_->GetExtensionById(extension_id_uninstalling_, true)) { - extensions_service_->UninstallExtension(extension_id_uninstalling_, - false /* external_uninstall */); + // The extension can be uninstalled in another window while the UI was + // showing. Do nothing in that case. + Extension* extension = + extensions_service_->GetExtensionById(extension_id_prompting_, true); + if (!extension) + return; + + switch (ui_prompt_type_) { + case ExtensionInstallUI::UNINSTALL_PROMPT: + extensions_service_->UninstallExtension(extension_id_prompting_, + false /* external_uninstall */); + break; + case ExtensionInstallUI::ENABLE_INCOGNITO_PROMPT: + extensions_service_->SetIsIncognitoEnabled(extension, true); + break; + default: + NOTREACHED(); + break; } - extension_id_uninstalling_ = ""; + + extension_id_prompting_ = ""; } void ExtensionsDOMHandler::InstallUIAbort() { - extension_id_uninstalling_ = ""; + extension_id_prompting_ = ""; } void ExtensionsDOMHandler::HandleOptionsMessage(const Value* value) { diff --git a/chrome/browser/extensions/extensions_ui.h b/chrome/browser/extensions/extensions_ui.h index decdc64..daf5c2b 100644 --- a/chrome/browser/extensions/extensions_ui.h +++ b/chrome/browser/extensions/extensions_ui.h @@ -217,8 +217,12 @@ class ExtensionsDOMHandler // necessary. NotificationRegistrar registrar_; - // The id of the extension we are about to un-install. - std::string extension_id_uninstalling_; + // The id of the extension we are prompting the user about. + std::string extension_id_prompting_; + + // The type of prompt that is open. Only ever uninstall or enable-incognito. + // Invalid if no prompt is open. + ExtensionInstallUI::PromptType ui_prompt_type_; DISALLOW_COPY_AND_ASSIGN(ExtensionsDOMHandler); }; diff --git a/chrome/browser/gtk/extension_install_prompt_gtk.cc b/chrome/browser/gtk/extension_install_prompt_gtk.cc index ef93811..ff5dc1a 100644 --- a/chrome/browser/gtk/extension_install_prompt_gtk.cc +++ b/chrome/browser/gtk/extension_install_prompt_gtk.cc @@ -52,12 +52,10 @@ void ShowInstallPromptDialog(GtkWindow* parent, SkBitmap* skia_icon, Extension *extension, ExtensionInstallUI::Delegate *delegate, const string16& warning_text, - bool is_uninstall) { + ExtensionInstallUI::PromptType type) { // Build the dialog. - int title_id = is_uninstall ? IDS_EXTENSION_UNINSTALL_PROMPT_TITLE : - IDS_EXTENSION_INSTALL_PROMPT_TITLE; - int button_id = is_uninstall ? IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON : - IDS_EXTENSION_PROMPT_INSTALL_BUTTON; + int title_id = ExtensionInstallUI::kTitleIds[type]; + int button_id = ExtensionInstallUI::kButtonIds[type]; GtkWidget* dialog = gtk_dialog_new_with_buttons( l10n_util::GetStringUTF8(title_id).c_str(), parent, @@ -85,8 +83,7 @@ void ShowInstallPromptDialog(GtkWindow* parent, SkBitmap* skia_icon, GtkWidget* right_column_area = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(icon_hbox), right_column_area, TRUE, TRUE, 0); - int heading_id = is_uninstall ? IDS_EXTENSION_UNINSTALL_PROMPT_HEADING : - IDS_EXTENSION_INSTALL_PROMPT_HEADING; + int heading_id = ExtensionInstallUI::kHeadingIds[type]; std::string heading_text = WideToUTF8(l10n_util::GetStringF( heading_id, UTF8ToWide(extension->name()))); GtkWidget* heading_label = MakeMarkupLabel("<span weight=\"bold\">%s</span>", @@ -111,7 +108,7 @@ void ShowInstallPromptDialog(GtkWindow* parent, SkBitmap* skia_icon, void ExtensionInstallUI::ShowExtensionInstallUIPromptImpl( Profile* profile, Delegate* delegate, Extension* extension, SkBitmap* icon, - const string16& warning_text, bool is_uninstall) { + const string16& warning_text, ExtensionInstallUI::PromptType type) { Browser* browser = BrowserList::GetLastActiveWithProfile(profile); if (!browser) { delegate->InstallUIAbort(); @@ -126,5 +123,5 @@ void ExtensionInstallUI::ShowExtensionInstallUIPromptImpl( } ShowInstallPromptDialog(browser_window->window(), icon, extension, - delegate, warning_text, is_uninstall); + delegate, warning_text, type); } diff --git a/chrome/browser/resources/extensions_ui.html b/chrome/browser/resources/extensions_ui.html index 399f919..657c342 100644 --- a/chrome/browser/resources/extensions_ui.html +++ b/chrome/browser/resources/extensions_ui.html @@ -547,16 +547,13 @@ function handleEnableExtension(node, enable) { * Handles the 'enableIncognito' checkbox getting changed. */ function handleToggleExtensionIncognito(node, toggleCheckbox) { - if (toggleCheckbox) - node.checked = !node.checked; + var enable = toggleCheckbox ? !node.checked : node.checked; - if (node.checked) { - if (!confirm(templateData["enableIncognitoWarning"])) { - node.checked = false; - return; - } - } - chrome.send('enableIncognito', [node.extensionId, String(node.checked)]); + // This is kinda cheesy, but if we're enabling, we have to wait for the + // prompt, so don't show as enabled until the user says OK. + node.checked = false; + + chrome.send('enableIncognito', [node.extensionId, String(enable)]); requestExtensionsData(); } diff --git a/chrome/browser/views/extensions/extension_install_prompt.cc b/chrome/browser/views/extensions/extension_install_prompt.cc index 7bbfa91..482cb3c 100644 --- a/chrome/browser/views/extensions/extension_install_prompt.cc +++ b/chrome/browser/views/extensions/extension_install_prompt.cc @@ -41,9 +41,9 @@ class InstallDialogContent : public views::View, public views::DialogDelegate { public: InstallDialogContent(ExtensionInstallUI::Delegate* delegate, Extension* extension, SkBitmap* icon, const std::wstring& warning_text, - bool is_uninstall) + ExtensionInstallUI::PromptType type) : delegate_(delegate), icon_(NULL), warning_(NULL), - create_shortcut_(NULL), is_uninstall_(is_uninstall) { + create_shortcut_(NULL), type_(type) { if (extension->IsApp()) { icon_size_ = kIconSizeApp; right_column_width_ = kRightColumnWidthApp; @@ -62,16 +62,14 @@ class InstallDialogContent : public views::View, public views::DialogDelegate { AddChildView(icon_); heading_ = new views::Label( - l10n_util::GetStringF(is_uninstall ? - IDS_EXTENSION_UNINSTALL_PROMPT_HEADING : - IDS_EXTENSION_INSTALL_PROMPT_HEADING, + l10n_util::GetStringF(ExtensionInstallUI::kHeadingIds[type_], UTF8ToWide(extension->name()))); heading_->SetFont(heading_->GetFont().DeriveFont(1, gfx::Font::BOLD)); heading_->SetMultiLine(true); heading_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); AddChildView(heading_); - if (!is_uninstall && extension->IsApp()) { + if (type_ == ExtensionInstallUI::INSTALL_PROMPT && extension->IsApp()) { create_shortcut_ = new views::Checkbox( l10n_util::GetString(IDS_EXTENSION_PROMPT_CREATE_SHORTCUT)); create_shortcut_->SetChecked(true); @@ -91,10 +89,7 @@ class InstallDialogContent : public views::View, public views::DialogDelegate { MessageBoxFlags::DialogButton button) const { switch (button) { case MessageBoxFlags::DIALOGBUTTON_OK: - if (is_uninstall_) - return l10n_util::GetString(IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON); - else - return l10n_util::GetString(IDS_EXTENSION_PROMPT_INSTALL_BUTTON); + return l10n_util::GetString(ExtensionInstallUI::kButtonIds[type_]); case MessageBoxFlags::DIALOGBUTTON_CANCEL: return l10n_util::GetString(IDS_CANCEL); default: @@ -122,10 +117,7 @@ class InstallDialogContent : public views::View, public views::DialogDelegate { // WindowDelegate virtual bool IsModal() const { return true; } virtual std::wstring GetWindowTitle() const { - if (is_uninstall_) - return l10n_util::GetString(IDS_EXTENSION_UNINSTALL_PROMPT_TITLE); - else - return l10n_util::GetString(IDS_EXTENSION_INSTALL_PROMPT_TITLE); + return l10n_util::GetString(ExtensionInstallUI::kTitleIds[type_]); } virtual views::View* GetContentsView() { return this; } @@ -191,7 +183,7 @@ class InstallDialogContent : public views::View, public views::DialogDelegate { views::Label* heading_; views::Label* warning_; views::Checkbox* create_shortcut_; - bool is_uninstall_; + ExtensionInstallUI::PromptType type_; int right_column_width_; int icon_size_; @@ -203,7 +195,7 @@ class InstallDialogContent : public views::View, public views::DialogDelegate { // static void ExtensionInstallUI::ShowExtensionInstallUIPromptImpl( Profile* profile, Delegate* delegate, Extension* extension, SkBitmap* icon, - const string16& warning_text, bool is_uninstall) { + const string16& warning_text, PromptType type) { Browser* browser = BrowserList::GetLastActiveWithProfile(profile); if (!browser) { delegate->InstallUIAbort(); @@ -219,5 +211,5 @@ void ExtensionInstallUI::ShowExtensionInstallUIPromptImpl( views::Window::CreateChromeWindow(window->GetNativeHandle(), gfx::Rect(), new InstallDialogContent(delegate, extension, icon, UTF16ToWideHack(warning_text), - is_uninstall))->Show(); + type))->Show(); } |