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_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" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 const std::string& localized_user_count, | 116 const std::string& localized_user_count, |
117 double average_rating, | 117 double average_rating, |
118 int rating_count) { | 118 int rating_count) { |
119 CHECK_EQ(INLINE_INSTALL_PROMPT, type_); | 119 CHECK_EQ(INLINE_INSTALL_PROMPT, type_); |
120 localized_user_count_ = localized_user_count; | 120 localized_user_count_ = localized_user_count; |
121 average_rating_ = average_rating; | 121 average_rating_ = average_rating; |
122 rating_count_ = rating_count; | 122 rating_count_ = rating_count; |
123 } | 123 } |
124 | 124 |
125 string16 ExtensionInstallUI::Prompt::GetDialogTitle() const { | 125 string16 ExtensionInstallUI::Prompt::GetDialogTitle() const { |
| 126 int resource_id = kTitleIds[type_]; |
| 127 |
126 if (type_ == INSTALL_PROMPT) { | 128 if (type_ == INSTALL_PROMPT) { |
127 return l10n_util::GetStringUTF16(extension_->is_app() ? | 129 if (extension_->is_app()) |
128 IDS_EXTENSION_INSTALL_APP_PROMPT_TITLE : | 130 resource_id = IDS_EXTENSION_INSTALL_APP_PROMPT_TITLE; |
129 IDS_EXTENSION_INSTALL_EXTENSION_PROMPT_TITLE); | 131 else if (extension_->is_theme()) |
130 } else { | 132 resource_id = IDS_EXTENSION_INSTALL_THEME_PROMPT_TITLE; |
131 return l10n_util::GetStringUTF16(kTitleIds[type_]); | 133 else |
| 134 resource_id = IDS_EXTENSION_INSTALL_EXTENSION_PROMPT_TITLE; |
132 } | 135 } |
| 136 |
| 137 return l10n_util::GetStringUTF16(resource_id); |
133 } | 138 } |
134 | 139 |
135 string16 ExtensionInstallUI::Prompt::GetHeading() const { | 140 string16 ExtensionInstallUI::Prompt::GetHeading() const { |
136 if (type_ == INLINE_INSTALL_PROMPT) { | 141 if (type_ == INLINE_INSTALL_PROMPT) { |
137 return UTF8ToUTF16(extension_->name()); | 142 return UTF8ToUTF16(extension_->name()); |
138 } else if (type_ == BUNDLE_INSTALL_PROMPT) { | 143 } else if (type_ == BUNDLE_INSTALL_PROMPT) { |
139 return bundle_->GetHeadingTextFor(BundleInstaller::Item::STATE_PENDING); | 144 return bundle_->GetHeadingTextFor(BundleInstaller::Item::STATE_PENDING); |
140 } else { | 145 } else { |
141 return l10n_util::GetStringFUTF16( | 146 return l10n_util::GetStringFUTF16( |
142 kHeadingIds[type_], UTF8ToUTF16(extension_->name())); | 147 kHeadingIds[type_], UTF8ToUTF16(extension_->name())); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 } | 311 } |
307 | 312 |
308 void ExtensionInstallUI::ConfirmInstall(Delegate* delegate, | 313 void ExtensionInstallUI::ConfirmInstall(Delegate* delegate, |
309 const Extension* extension) { | 314 const Extension* extension) { |
310 DCHECK(ui_loop_ == MessageLoop::current()); | 315 DCHECK(ui_loop_ == MessageLoop::current()); |
311 extension_ = extension; | 316 extension_ = extension; |
312 permissions_ = extension->GetActivePermissions(); | 317 permissions_ = extension->GetActivePermissions(); |
313 delegate_ = delegate; | 318 delegate_ = delegate; |
314 prompt_type_ = INSTALL_PROMPT; | 319 prompt_type_ = INSTALL_PROMPT; |
315 | 320 |
316 // We special-case themes to not show any confirm UI. Instead they are | 321 // In the Web Store, we special-case themes to not show any confirm UI. |
317 // immediately installed, and then we show an infobar (see OnInstallSuccess) | 322 // Instead they are immediately installed, and then we show an infobar (see |
318 // to allow the user to revert if they don't like it. | 323 // OnInstallSuccess) to allow the user to revert if they don't like it. |
319 if (extension->is_theme()) { | 324 // |
| 325 // We don't do this off-store because we don't want websites to be able to |
| 326 // clickjack people into installing themes. Even though it's not dangerous, it |
| 327 // would be annoying. |
| 328 if (extension->from_webstore() && extension->is_theme()) { |
320 delegate->InstallUIProceed(); | 329 delegate->InstallUIProceed(); |
321 return; | 330 return; |
322 } | 331 } |
323 | 332 |
324 LoadImageIfNeeded(); | 333 LoadImageIfNeeded(); |
325 } | 334 } |
326 | 335 |
327 void ExtensionInstallUI::ConfirmReEnable(Delegate* delegate, | 336 void ExtensionInstallUI::ConfirmReEnable(Delegate* delegate, |
328 const Extension* extension) { | 337 const Extension* extension) { |
329 DCHECK(ui_loop_ == MessageLoop::current()); | 338 DCHECK(ui_loop_ == MessageLoop::current()); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 bool previous_using_native_theme) { | 551 bool previous_using_native_theme) { |
543 Profile* profile = tab_contents->profile(); | 552 Profile* profile = tab_contents->profile(); |
544 return new ThemeInstalledInfoBarDelegate( | 553 return new ThemeInstalledInfoBarDelegate( |
545 tab_contents->infobar_tab_helper(), | 554 tab_contents->infobar_tab_helper(), |
546 profile->GetExtensionService(), | 555 profile->GetExtensionService(), |
547 ThemeServiceFactory::GetForProfile(profile), | 556 ThemeServiceFactory::GetForProfile(profile), |
548 new_theme, | 557 new_theme, |
549 previous_theme_id, | 558 previous_theme_id, |
550 previous_using_native_theme); | 559 previous_using_native_theme); |
551 } | 560 } |
OLD | NEW |