| 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/extensions/extension_install_ui.h" | 5 #include "chrome/browser/extensions/extension_install_ui.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/browser_list.h" | 15 #include "chrome/browser/browser_list.h" |
| 16 #include "chrome/browser/browser_window.h" | 16 #include "chrome/browser/browser_window.h" |
| 17 #include "chrome/browser/extensions/extension_install_dialog.h" | |
| 18 #include "chrome/browser/extensions/extension_install_dialog2.h" | 17 #include "chrome/browser/extensions/extension_install_dialog2.h" |
| 19 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" | 18 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" |
| 20 #include "chrome/browser/platform_util.h" | 19 #include "chrome/browser/platform_util.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/tabs/tab_strip_model.h" | 21 #include "chrome/browser/tabs/tab_strip_model.h" |
| 23 #include "chrome/browser/themes/theme_service_factory.h" | 22 #include "chrome/browser/themes/theme_service_factory.h" |
| 24 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 25 #include "chrome/browser/ui/browser_dialogs.h" | 24 #include "chrome/browser/ui/browser_dialogs.h" |
| 26 #include "chrome/common/extensions/extension.h" | 25 #include "chrome/common/extensions/extension.h" |
| 27 #include "chrome/common/extensions/extension_icon_set.h" | 26 #include "chrome/common/extensions/extension_icon_set.h" |
| 28 #include "chrome/common/extensions/extension_resource.h" | 27 #include "chrome/common/extensions/extension_resource.h" |
| 29 #include "chrome/common/extensions/url_pattern.h" | 28 #include "chrome/common/extensions/url_pattern.h" |
| 30 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
| 31 #include "content/browser/tab_contents/tab_contents.h" | 30 #include "content/browser/tab_contents/tab_contents.h" |
| 32 #include "content/common/notification_service.h" | 31 #include "content/common/notification_service.h" |
| 33 #include "grit/chromium_strings.h" | 32 #include "grit/chromium_strings.h" |
| 34 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
| 35 #include "grit/theme_resources.h" | 34 #include "grit/theme_resources.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 37 #include "ui/base/resource/resource_bundle.h" | 36 #include "ui/base/resource/resource_bundle.h" |
| 38 | 37 |
| 39 #if defined(TOOLKIT_GTK) | 38 #if defined(TOOLKIT_GTK) |
| 40 #include "chrome/browser/extensions/gtk_theme_installed_infobar_delegate.h" | 39 #include "chrome/browser/extensions/gtk_theme_installed_infobar_delegate.h" |
| 41 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 40 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 42 #endif | 41 #endif |
| 43 | 42 |
| 44 // static | 43 // static |
| 45 const int ExtensionInstallUI::kTitleIds[NUM_PROMPT_TYPES] = { | 44 const int ExtensionInstallUI::kTitleIds[NUM_PROMPT_TYPES] = { |
| 46 IDS_EXTENSION_INSTALL_PROMPT_TITLE, | 45 IDS_EXTENSION_INSTALL_PROMPT_TITLE, |
| 47 IDS_EXTENSION_UNINSTALL_PROMPT_TITLE, | |
| 48 IDS_EXTENSION_RE_ENABLE_PROMPT_TITLE | 46 IDS_EXTENSION_RE_ENABLE_PROMPT_TITLE |
| 49 }; | 47 }; |
| 50 // static | 48 // static |
| 51 const int ExtensionInstallUI::kHeadingIds[NUM_PROMPT_TYPES] = { | 49 const int ExtensionInstallUI::kHeadingIds[NUM_PROMPT_TYPES] = { |
| 52 IDS_EXTENSION_INSTALL_PROMPT_HEADING, | 50 IDS_EXTENSION_INSTALL_PROMPT_HEADING, |
| 53 IDS_EXTENSION_UNINSTALL_PROMPT_HEADING, | |
| 54 IDS_EXTENSION_RE_ENABLE_PROMPT_HEADING | 51 IDS_EXTENSION_RE_ENABLE_PROMPT_HEADING |
| 55 }; | 52 }; |
| 56 // static | 53 // static |
| 57 const int ExtensionInstallUI::kButtonIds[NUM_PROMPT_TYPES] = { | 54 const int ExtensionInstallUI::kButtonIds[NUM_PROMPT_TYPES] = { |
| 58 IDS_EXTENSION_PROMPT_INSTALL_BUTTON, | 55 IDS_EXTENSION_PROMPT_INSTALL_BUTTON, |
| 59 IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON, | |
| 60 IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON | 56 IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON |
| 61 }; | 57 }; |
| 62 // static | 58 // static |
| 63 const int ExtensionInstallUI::kWarningIds[NUM_PROMPT_TYPES] = { | 59 const int ExtensionInstallUI::kWarningIds[NUM_PROMPT_TYPES] = { |
| 64 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, | 60 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, |
| 65 0, // No warning label when uninstalling. | |
| 66 IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO | 61 IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO |
| 67 }; | 62 }; |
| 68 | 63 |
| 69 namespace { | 64 namespace { |
| 70 | 65 |
| 71 // Size of extension icon in top left of dialog. | 66 // Size of extension icon in top left of dialog. |
| 72 const int kIconSize = 69; | 67 const int kIconSize = 69; |
| 73 | 68 |
| 74 // Shows the application install animation on the new tab page for the app | 69 // Shows the application install animation on the new tab page for the app |
| 75 // with |app_id|. If a NTP already exists on the active |browser|, this will | 70 // with |app_id|. If a NTP already exists on the active |browser|, this will |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // immediately installed, and then we show an infobar (see OnInstallSuccess) | 128 // immediately installed, and then we show an infobar (see OnInstallSuccess) |
| 134 // to allow the user to revert if they don't like it. | 129 // to allow the user to revert if they don't like it. |
| 135 if (extension->is_theme()) { | 130 if (extension->is_theme()) { |
| 136 delegate->InstallUIProceed(); | 131 delegate->InstallUIProceed(); |
| 137 return; | 132 return; |
| 138 } | 133 } |
| 139 | 134 |
| 140 ShowConfirmation(INSTALL_PROMPT); | 135 ShowConfirmation(INSTALL_PROMPT); |
| 141 } | 136 } |
| 142 | 137 |
| 143 void ExtensionInstallUI::ConfirmUninstall(Delegate* delegate, | |
| 144 const Extension* extension) { | |
| 145 DCHECK(ui_loop_ == MessageLoop::current()); | |
| 146 extension_ = extension; | |
| 147 delegate_ = delegate; | |
| 148 | |
| 149 ShowConfirmation(UNINSTALL_PROMPT); | |
| 150 } | |
| 151 | |
| 152 void ExtensionInstallUI::ConfirmReEnable(Delegate* delegate, | 138 void ExtensionInstallUI::ConfirmReEnable(Delegate* delegate, |
| 153 const Extension* extension) { | 139 const Extension* extension) { |
| 154 DCHECK(ui_loop_ == MessageLoop::current()); | 140 DCHECK(ui_loop_ == MessageLoop::current()); |
| 155 extension_ = extension; | 141 extension_ = extension; |
| 156 delegate_ = delegate; | 142 delegate_ = delegate; |
| 157 | 143 |
| 158 ShowConfirmation(RE_ENABLE_PROMPT); | 144 ShowConfirmation(RE_ENABLE_PROMPT); |
| 159 } | 145 } |
| 160 | 146 |
| 161 void ExtensionInstallUI::OnInstallSuccess(const Extension* extension, | 147 void ExtensionInstallUI::OnInstallSuccess(const Extension* extension, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 NotificationService* service = NotificationService::current(); | 209 NotificationService* service = NotificationService::current(); |
| 224 service->Notify(NotificationType::EXTENSION_WILL_SHOW_CONFIRM_DIALOG, | 210 service->Notify(NotificationType::EXTENSION_WILL_SHOW_CONFIRM_DIALOG, |
| 225 Source<ExtensionInstallUI>(this), | 211 Source<ExtensionInstallUI>(this), |
| 226 NotificationService::NoDetails()); | 212 NotificationService::NoDetails()); |
| 227 | 213 |
| 228 std::vector<string16> warnings = extension_->GetPermissionMessages(); | 214 std::vector<string16> warnings = extension_->GetPermissionMessages(); |
| 229 ShowExtensionInstallDialog2( | 215 ShowExtensionInstallDialog2( |
| 230 profile_, delegate_, extension_, &icon_, warnings, prompt_type_); | 216 profile_, delegate_, extension_, &icon_, warnings, prompt_type_); |
| 231 break; | 217 break; |
| 232 } | 218 } |
| 233 case UNINSTALL_PROMPT: { | |
| 234 ShowExtensionInstallDialog( | |
| 235 profile_, delegate_, extension_, &icon_, UNINSTALL_PROMPT); | |
| 236 break; | |
| 237 } | |
| 238 default: | 219 default: |
| 239 NOTREACHED() << "Unknown message"; | 220 NOTREACHED() << "Unknown message"; |
| 240 break; | 221 break; |
| 241 } | 222 } |
| 242 } | 223 } |
| 243 | 224 |
| 244 void ExtensionInstallUI::ShowThemeInfoBar(const std::string& previous_theme_id, | 225 void ExtensionInstallUI::ShowThemeInfoBar(const std::string& previous_theme_id, |
| 245 bool previous_use_system_theme, | 226 bool previous_use_system_theme, |
| 246 const Extension* new_theme, | 227 const Extension* new_theme, |
| 247 Profile* profile) { | 228 Profile* profile) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 const std::string& previous_theme_id, | 284 const std::string& previous_theme_id, |
| 304 bool previous_use_system_theme) { | 285 bool previous_use_system_theme) { |
| 305 #if defined(TOOLKIT_GTK) | 286 #if defined(TOOLKIT_GTK) |
| 306 return new GtkThemeInstalledInfoBarDelegate(tab_contents, new_theme, | 287 return new GtkThemeInstalledInfoBarDelegate(tab_contents, new_theme, |
| 307 previous_theme_id, previous_use_system_theme); | 288 previous_theme_id, previous_use_system_theme); |
| 308 #else | 289 #else |
| 309 return new ThemeInstalledInfoBarDelegate(tab_contents, new_theme, | 290 return new ThemeInstalledInfoBarDelegate(tab_contents, new_theme, |
| 310 previous_theme_id); | 291 previous_theme_id); |
| 311 #endif | 292 #endif |
| 312 } | 293 } |
| OLD | NEW |