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

Unified Diff: chrome/browser/extensions/extension_install_ui.cc

Issue 10010038: Do not show the install prompt for themes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_install_ui.cc
diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc
index 5a3f9f8ee0f2b40eac1676096ba18cd505e02162..74da2cbde965202de4ba15017f95684e6d9a1e85 100644
--- a/chrome/browser/extensions/extension_install_ui.cc
+++ b/chrome/browser/extensions/extension_install_ui.cc
@@ -33,6 +33,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_icon_set.h"
+#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/extension_resource.h"
#include "chrome/common/extensions/url_pattern.h"
#include "chrome/common/url_constants.h"
@@ -211,12 +212,42 @@ string16 ExtensionInstallUI::Prompt::GetPermission(size_t index) const {
IDS_EXTENSION_PERMISSION_LINE, permissions_[index]);
}
+// static
+scoped_refptr<Extension> ExtensionInstallUI::LocalizeExtensionForDisplay(
+ const DictionaryValue* manifest,
+ const std::string& id,
+ const std::string& localized_name,
+ const std::string& localized_description,
+ std::string* error) {
+ scoped_ptr<DictionaryValue> localized_manifest;
+ if (!localized_name.empty() || !localized_description.empty()) {
+ localized_manifest.reset(manifest->DeepCopy());
+ if (!localized_name.empty()) {
+ localized_manifest->SetString(extension_manifest_keys::kName,
+ localized_name);
+ }
+ if (!localized_description.empty()) {
+ localized_manifest->SetString(extension_manifest_keys::kDescription,
+ localized_description);
+ }
+ }
+
+ return Extension::Create(
+ FilePath(),
+ Extension::INTERNAL,
+ localized_manifest.get() ? *localized_manifest.get() : *manifest,
+ Extension::NO_FLAGS,
+ id,
+ error);
+}
+
ExtensionInstallUI::ExtensionInstallUI(Profile* profile)
: profile_(profile),
ui_loop_(MessageLoop::current()),
previous_using_native_theme_(false),
extension_(NULL),
delegate_(NULL),
+ prompt_(UNSET_PROMPT_TYPE),
Yoyo Zhou 2012/04/20 15:38:14 Does this really work with the constructor explici
jstritar 2012/04/20 16:18:27 Seems to... I'll make sure none of the try bots co
prompt_type_(NUM_PROMPT_TYPES),
ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)),
use_app_installed_bubble_(false),
@@ -235,6 +266,42 @@ ExtensionInstallUI::ExtensionInstallUI(Profile* profile)
ExtensionInstallUI::~ExtensionInstallUI() {
}
+void ExtensionInstallUI::ConfirmBundleInstall(
+ extensions::BundleInstaller* bundle,
+ const ExtensionPermissionSet* permissions) {
+ DCHECK(ui_loop_ == MessageLoop::current());
+ bundle_ = bundle;
+ permissions_ = permissions;
+ delegate_ = static_cast<Delegate*>(bundle);
Yoyo Zhou 2012/04/20 15:38:14 Is the static_cast needed?
jstritar 2012/04/20 16:18:27 Removed.
+
+ ShowConfirmation(BUNDLE_INSTALL_PROMPT);
+}
+
+void ExtensionInstallUI::ConfirmInlineInstall(
+ Delegate* delegate,
+ const Extension* extension,
+ SkBitmap* icon,
+ ExtensionInstallUI::Prompt prompt) {
+ DCHECK(ui_loop_ == MessageLoop::current());
+ extension_ = extension;
+ permissions_ = extension->GetActivePermissions();
+ delegate_ = delegate;
+ prompt_ = prompt;
+
+ SetIcon(icon);
+ ShowConfirmation(INLINE_INSTALL_PROMPT);
+}
+
+void ExtensionInstallUI::ConfirmWebstoreInstall(Delegate* delegate,
+ const Extension* extension,
+ const SkBitmap* icon) {
+ // SetIcon requires |extension_| to be set. ConfirmInstall will setup the
+ // remaining fields.
+ extension_ = extension;
+ SetIcon(icon);
+ ConfirmInstall(delegate, extension);
+}
+
void ExtensionInstallUI::ConfirmInstall(Delegate* delegate,
const Extension* extension) {
DCHECK(ui_loop_ == MessageLoop::current());
@@ -344,28 +411,7 @@ void ExtensionInstallUI::OnImageLoaded(const gfx::Image& image,
const std::string& extension_id,
int index) {
SetIcon(image.IsEmpty() ? NULL : image.ToSkBitmap());
-
- switch (prompt_type_) {
- case PERMISSIONS_PROMPT:
- case RE_ENABLE_PROMPT:
- case INSTALL_PROMPT: {
- content::NotificationService* service =
- content::NotificationService::current();
- service->Notify(chrome::NOTIFICATION_EXTENSION_WILL_SHOW_CONFIRM_DIALOG,
Yoyo Zhou 2012/04/20 15:38:14 What happened to this? Nobody cared to observe it?
jstritar 2012/04/20 16:18:27 Yeah, no observers.
- content::Source<ExtensionInstallUI>(this),
- content::NotificationService::NoDetails());
-
- Prompt prompt(prompt_type_);
- prompt.SetPermissions(permissions_->GetWarningMessages());
- prompt.set_extension(extension_);
- prompt.set_icon(gfx::Image(new SkBitmap(icon_)));
- ShowExtensionInstallDialog(profile_, delegate_, prompt);
- break;
- }
- default:
- NOTREACHED() << "Unknown message";
- break;
- }
+ ShowDialog();
}
// static
@@ -445,8 +491,15 @@ void ExtensionInstallUI::ShowThemeInfoBar(const std::string& previous_theme_id,
}
void ExtensionInstallUI::ShowConfirmation(PromptType prompt_type) {
- // Load the image asynchronously. For the response, check OnImageLoaded.
prompt_type_ = prompt_type;
+
+ // Bundle install prompts do not have an icon.
+ if (!icon_.empty() || prompt_type == BUNDLE_INSTALL_PROMPT) {
+ ShowDialog();
+ return;
+ }
+
+ // Load the image asynchronously. For the response, check OnImageLoaded.
ExtensionResource image =
extension_->GetIconResource(ExtensionIconSet::EXTENSION_ICON_LARGE,
ExtensionIconSet::MATCH_BIGGER);
@@ -455,6 +508,35 @@ void ExtensionInstallUI::ShowConfirmation(PromptType prompt_type) {
ImageLoadingTracker::DONT_CACHE);
}
+void ExtensionInstallUI::ShowDialog() {
+ // Use the pre-filled prompt if provided.
+ Prompt prompt = prompt_;
+ if (prompt.type() == UNSET_PROMPT_TYPE)
+ prompt = Prompt(prompt_type_);
+
+ switch (prompt_type_) {
+ case PERMISSIONS_PROMPT:
+ case RE_ENABLE_PROMPT:
+ case INLINE_INSTALL_PROMPT:
+ case INSTALL_PROMPT: {
+ prompt.SetPermissions(permissions_->GetWarningMessages());
+ prompt.set_extension(extension_);
+ prompt.set_icon(gfx::Image(new SkBitmap(icon_)));
+ ShowExtensionInstallDialog(profile_, delegate_, prompt);
+ break;
+ }
+ case BUNDLE_INSTALL_PROMPT: {
+ prompt.SetPermissions(permissions_->GetWarningMessages());
+ prompt.set_bundle(bundle_);
+ ShowExtensionInstallDialog(profile_, delegate_, prompt);
+ break;
+ }
+ default:
+ NOTREACHED() << "Unknown message";
+ break;
+ }
+}
+
InfoBarDelegate* ExtensionInstallUI::GetNewThemeInstalledInfoBarDelegate(
TabContentsWrapper* tab_contents,
const Extension* new_theme,

Powered by Google App Engine
This is Rietveld 408576698