summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-24 23:34:36 +0000
committerjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-24 23:34:36 +0000
commit4c5b6feabadb0162c4ebf421e4c01d80cd96c3e3 (patch)
treeac0a8597ef816af6b82f1e63af9f0cebd562921b
parent11c117aa57a721a04daa3f3843c6688302723cb2 (diff)
downloadchromium_src-4c5b6feabadb0162c4ebf421e4c01d80cd96c3e3.zip
chromium_src-4c5b6feabadb0162c4ebf421e4c01d80cd96c3e3.tar.gz
chromium_src-4c5b6feabadb0162c4ebf421e4c01d80cd96c3e3.tar.bz2
Revert 123574 - Add GTK interface for installing bundles of extensions.
BUG=112096 TEST=*InstallBundle* Review URL: http://codereview.chromium.org/9456019 TBR=jstritar@chromium.org Review URL: https://chromiumcodereview.appspot.com/9460030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123583 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd28
-rw-r--r--chrome/browser/extensions/bundle_installer.cc80
-rw-r--r--chrome/browser/extensions/bundle_installer.h10
-rw-r--r--chrome/browser/extensions/crx_installer.cc11
-rw-r--r--chrome/browser/extensions/extension_install_dialog.cc16
-rw-r--r--chrome/browser/extensions/extension_install_dialog.h4
-rw-r--r--chrome/browser/extensions/extension_install_ui.cc39
-rw-r--r--chrome/browser/extensions/extension_install_ui.h40
-rw-r--r--chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.h6
-rw-r--r--chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.mm22
-rw-r--r--chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller_unittest.mm32
-rw-r--r--chrome/browser/ui/gtk/extensions/bundle_installed_bubble_gtk.cc157
-rw-r--r--chrome/browser/ui/gtk/extensions/bundle_installed_bubble_gtk.h58
-rw-r--r--chrome/browser/ui/gtk/extensions/extension_install_dialog_gtk.cc82
-rw-r--r--chrome/browser/ui/views/extensions/extension_install_dialog_view.cc26
-rw-r--r--chrome/chrome_browser.gypi2
16 files changed, 129 insertions, 484 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index cd1ad98..51f8243 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -3893,9 +3893,6 @@ Public Exponent (<ph name="PUBLIC_EXPONENT_NUM_BITS">$3<ex>24</ex></ph> bits):
</message>
<!-- Extension/App install prompt -->
- <message name="IDS_EXTENSION_INSTALL_PROMPT_TITLE" desc="Titlebar of the extension or app installation prompt window">
- Confirm Installation
- </message>
<message name="IDS_EXTENSION_INSTALL_APP_PROMPT_TITLE" desc="Titlebar of the extension or app installation prompt window">
Confirm New App
</message>
@@ -3914,15 +3911,6 @@ Public Exponent (<ph name="PUBLIC_EXPONENT_NUM_BITS">$3<ex>24</ex></ph> bits):
<message name="IDS_EXTENSION_INSTALL_PROMPT_HEADING" desc="First bold line in the content area of the extension or app installation prompt. Asks the user if they want to install a particular extension or app.">
Add "<ph name="EXTENSION_NAME">$1<ex>Gmail Checker</ex></ph>"?
</message>
- <message name="IDS_EXTENSION_BUNDLE_INSTALL_PROMPT_HEADING_EXTENSIONS" desc="First bold line in the content area of the extension bundle installation prompt. Asks the user if they want to install the set of extensions.">
- Install these extensions?
- </message>
- <message name="IDS_EXTENSION_BUNDLE_INSTALL_PROMPT_HEADING_APPS" desc="First bold line in the content area of the app bundle installation prompt. Asks the user if they want to install the set of apps.">
- Install these apps?
- </message>
- <message name="IDS_EXTENSION_BUNDLE_INSTALL_PROMPT_HEADING_EXTENSION_APPS" desc="First bold line in the content area of the extension and app bundle installation prompt. Asks the user if they want to install the set of apps and extensions.">
- Install these apps and extensions?
- </message>
<message name="IDS_EXTENSION_UNINSTALL_PROMPT_HEADING" desc="First bold line in the content area of the extension or app uninstallation prompt. Asks the user if they want to uninstall a particular extension or app.">
Remove "<ph name="EXTENSION_NAME">$1<ex>Gmail Checker</ex></ph>"?
</message>
@@ -3959,9 +3947,6 @@ Update checks have repeatedly failed for the extension "<ph name="EXTENSION_NAME
<message name="IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO" desc="Second line in the content area of the extension or app re-enable prompt. Note that the exact wording is important. This should mean that the extension _can now_ access the listed privileges, but not necessarily that it will or needs to. This message appeared because the user must approve new permissions of the extension or app.">
It can now access:
</message>
- <message name="IDS_EXTENSION_PROMPT_THESE_WILL_HAVE_ACCESS_TO" desc="Header for the permissions area of the bundled extension or app installation prompt. Note that the exact wording is important. This means that the extensions or apps _can_ access the listed privileges, but not necessarily that it will or needs to.">
- They can access:
- </message>
<message name="IDS_EXTENSION_PROMPT_WANTS_ACCESS_TO" desc="Second line in the content area of the extension or app permissions prompt. Note that the exact wording is important. This should mean that the extension _wants to_ access the listed privileges, but not necessarily that it will or needs to. This message appeared because the user must approve new permissions of the extension or app.">
It could access:
</message>
@@ -4167,21 +4152,10 @@ Update checks have repeatedly failed for the extension "<ph name="EXTENSION_NAME
</message>
<!-- Extension installed bubble -->
- <message name="IDS_EXTENSION_BUNDLE_INSTALLED_HEADING_EXTENSIONS" desc="First line in the content area of the extension bundle installed bubble. Instructs which extensions were installed.">
- The following extensions are now installed:
- </message>
- <message name="IDS_EXTENSION_BUNDLE_INSTALLED_HEADING_APPS" desc="First line in the content area of the extension bundle installed bubble. Instructs which apps were installed.">
- The following apps are now installed:
- </message>
- <message name="IDS_EXTENSION_BUNDLE_INSTALLED_HEADING_EXTENSION_APPS" desc="First line in the content area of the extension bundle installed bubble. Instructs which apps and extensions were installed.">
- The following apps and extensions were added:
- </message>
- <message name="IDS_EXTENSION_BUNDLE_ERROR_HEADING" desc="Text displayed in the extension bundle installed bubble when some extensions or apps failed to install. Instructs which extensions did not install.">
- We were unable to install:
- </message>
<message name="IDS_EXTENSION_INSTALLED_APP_INFO" desc="Text displayed inside a link when an app is installed. Clicking this link opens up the New Tab Page to show the app's icon.">
Show me
</message>
+
<message name="IDS_EXTENSION_INSTALLED_PAGE_ACTION_INFO" desc="Text displayed in the InfoBubble which explains that the UI of this extension is a Page Action icon which may appear for some pages.">
This icon will be visible when the extension can act on the current page.
</message>
diff --git a/chrome/browser/extensions/bundle_installer.cc b/chrome/browser/extensions/bundle_installer.cc
index cc47bbe..8772b0b 100644
--- a/chrome/browser/extensions/bundle_installer.cc
+++ b/chrome/browser/extensions/bundle_installer.cc
@@ -4,23 +4,18 @@
#include "chrome/browser/extensions/bundle_installer.h"
-#include <algorithm>
#include <string>
#include <vector>
#include "base/command_line.h"
#include "base/values.h"
#include "chrome/browser/extensions/crx_installer.h"
-#include "chrome/browser/extensions/extension_install_dialog.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/extensions/extension.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/web_contents.h"
-#include "grit/generated_resources.h"
-#include "ui/base/l10n/l10n_util.h"
using content::NavigationController;
@@ -55,35 +50,6 @@ scoped_refptr<Extension> CreateDummyExtension(BundleInstaller::Item item,
&error);
}
-bool IsAppPredicate(scoped_refptr<const Extension> extension) {
- return extension->is_app();
-}
-
-struct MatchIdFunctor {
- explicit MatchIdFunctor(const std::string& id) : id(id) {}
- bool operator()(scoped_refptr<const Extension> extension) {
- return extension->id() == id;
- }
- std::string id;
-};
-
-// Holds the message IDs for BundleInstaller::GetHeadingTextFor.
-const int kHeadingIds[3][4] = {
- {
- 0,
- IDS_EXTENSION_BUNDLE_INSTALL_PROMPT_HEADING_EXTENSIONS,
- IDS_EXTENSION_BUNDLE_INSTALL_PROMPT_HEADING_APPS,
- IDS_EXTENSION_BUNDLE_INSTALL_PROMPT_HEADING_EXTENSION_APPS
- },
- {
- 0,
- IDS_EXTENSION_BUNDLE_INSTALLED_HEADING_EXTENSIONS,
- IDS_EXTENSION_BUNDLE_INSTALLED_HEADING_APPS,
- IDS_EXTENSION_BUNDLE_INSTALLED_HEADING_EXTENSION_APPS
- },
- { IDS_EXTENSION_BUNDLE_ERROR_HEADING, 0, 0, 0 }
-};
-
} // namespace
// static
@@ -161,39 +127,11 @@ void BundleInstaller::CompleteInstall(NavigationController* controller,
}
}
-string16 BundleInstaller::GetHeadingTextFor(Item::State state) const {
- size_t total = 0;
- size_t apps = 0;
-
- // For STATE_FAILED, we can't tell if the items were apps or extensions
- // so we always show the same message.
- if (state == Item::STATE_INSTALLED || state == Item::STATE_PENDING) {
- total = GetItemsWithState(state).size();
- apps = std::count_if(
- dummy_extensions_.begin(), dummy_extensions_.end(), &IsAppPredicate);
- }
-
- bool has_apps = apps > 0;
- bool has_extensions = apps < total;
- size_t index = (has_extensions << 0) + (has_apps << 1);
-
- CHECK_LT(static_cast<size_t>(state), arraysize(kHeadingIds));
- CHECK_LT(index, arraysize(kHeadingIds[state]));
-
- int msg_id = kHeadingIds[state][index];
- if (!msg_id)
- return string16();
-
- return l10n_util::GetStringUTF16(msg_id);
-}
-
-#if !defined(TOOLKIT_USES_GTK)
// static
void BundleInstaller::ShowInstalledBubble(
const BundleInstaller* bundle, Browser* browser) {
// TODO(jstritar): provide platform specific implementations.
}
-#endif
void BundleInstaller::ParseManifests() {
if (items_.empty()) {
@@ -251,18 +189,13 @@ void BundleInstaller::ShowPrompt() {
permissions, dummy_extensions_[i]->required_permission_set());
}
- if (g_auto_approve_for_test == PROCEED) {
+ // TODO(jstritar): show the actual prompt.
+ if (g_auto_approve_for_test == PROCEED)
InstallUIProceed();
- } else if (g_auto_approve_for_test == ABORT) {
+ else if (g_auto_approve_for_test == ABORT)
InstallUIAbort(true);
- } else {
- ExtensionInstallUI::Prompt prompt(
- ExtensionInstallUI::BUNDLE_INSTALL_PROMPT);
- prompt.SetPermissions(permissions->GetWarningMessages());
- prompt.set_bundle(this);
-
- ShowExtensionInstallDialog(profile_, this, prompt);
- }
+ else
+ InstallUIAbort(false);
}
void BundleInstaller::ShowInstalledBubbleIfDone() {
@@ -329,9 +262,6 @@ void BundleInstaller::OnExtensionInstallFailure(const std::string& id,
const std::string& error) {
items_[id].state = Item::STATE_FAILED;
- std::remove_if(dummy_extensions_.begin(), dummy_extensions_.end(),
- MatchIdFunctor(id));
-
ShowInstalledBubbleIfDone();
}
diff --git a/chrome/browser/extensions/bundle_installer.h b/chrome/browser/extensions/bundle_installer.h
index 1818041..dec681d 100644
--- a/chrome/browser/extensions/bundle_installer.h
+++ b/chrome/browser/extensions/bundle_installer.h
@@ -10,7 +10,6 @@
#include <vector>
#include "base/memory/linked_ptr.h"
-#include "base/string16.h"
#include "chrome/browser/extensions/extension_install_ui.h"
#include "chrome/browser/extensions/webstore_installer.h"
#include "chrome/browser/extensions/webstore_install_helper.h"
@@ -97,15 +96,6 @@ class BundleInstaller : public WebstoreInstallHelper::Delegate,
Browser* browser,
Delegate* delegate);
- // We change the headings in the install prompt and installed bubble depending
- // on whether the bundle contains apps, extensions or both. This method gets
- // the correct heading for the items in the specified |state|, or an empty
- // string if no items are in the |state|.
- // STATE_PENDING - install prompt
- // STATE_INSTALLED - installed bubble successful installs list
- // STATE_FAILED - installed bubble failed installs list
- string16 GetHeadingTextFor(Item::State state) const;
-
private:
friend class base::RefCountedThreadSafe<BundleInstaller>;
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc
index 2f42cce..a3edce8 100644
--- a/chrome/browser/extensions/crx_installer.cc
+++ b/chrome/browser/extensions/crx_installer.cc
@@ -417,17 +417,16 @@ void CrxInstaller::ConfirmInstall() {
scoped_ptr<CrxInstaller::WhitelistEntry> entry(
RemoveWhitelistEntry(extension_->id()));
if (is_gallery_install() && entry.get() && original_manifest_.get()) {
- whitelisted = true;
- if (entry->use_app_installed_bubble)
- client_->set_use_app_installed_bubble(true);
- if (entry->skip_post_install_ui)
- client_->set_skip_post_install_ui(true);
-
if (!(original_manifest_->Equals(entry->parsed_manifest.get()))) {
ReportFailureFromUIThread(
l10n_util::GetStringUTF16(IDS_EXTENSION_MANIFEST_INVALID));
return;
}
+ whitelisted = true;
+ if (entry->use_app_installed_bubble)
+ client_->set_use_app_installed_bubble(true);
+ if (entry->skip_post_install_ui)
+ client_->set_skip_post_install_ui(true);
}
if (client_ &&
diff --git a/chrome/browser/extensions/extension_install_dialog.cc b/chrome/browser/extensions/extension_install_dialog.cc
index d580bfe..293adfa 100644
--- a/chrome/browser/extensions/extension_install_dialog.cc
+++ b/chrome/browser/extensions/extension_install_dialog.cc
@@ -12,8 +12,6 @@
#include "base/values.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/gfx/image/image.h"
namespace {
@@ -61,17 +59,19 @@ AutoConfirmForTest CheckAutoConfirmCommandLineSwitch() {
void ShowExtensionInstallDialog(Profile* profile,
ExtensionInstallUI::Delegate* delegate,
+ const Extension* extension,
+ SkBitmap* icon,
const ExtensionInstallUI::Prompt& prompt) {
AutoConfirmForTest auto_confirm = CheckAutoConfirmCommandLineSwitch();
if (auto_confirm != DO_NOT_SKIP) {
DoAutoConfirm(auto_confirm, delegate);
return;
}
- ShowExtensionInstallDialogImpl(profile, delegate, prompt);
+ ShowExtensionInstallDialogImpl(profile, delegate, extension, icon, prompt);
}
bool ShowExtensionInstallDialogForManifest(
- Profile* profile,
+ Profile *profile,
ExtensionInstallUI::Delegate* delegate,
const DictionaryValue* manifest,
const std::string& id,
@@ -120,9 +120,11 @@ bool ShowExtensionInstallDialogForManifest(
ExtensionInstallUI::Prompt filled_out_prompt = prompt;
filled_out_prompt.SetPermissions(
(*dummy_extension)->GetPermissionMessageStrings());
- filled_out_prompt.set_extension(*dummy_extension);
- filled_out_prompt.set_icon(gfx::Image(new SkBitmap(*icon)));
- ShowExtensionInstallDialog(profile, delegate, filled_out_prompt);
+ ShowExtensionInstallDialog(profile,
+ delegate,
+ dummy_extension->get(),
+ icon,
+ filled_out_prompt);
return true;
}
diff --git a/chrome/browser/extensions/extension_install_dialog.h b/chrome/browser/extensions/extension_install_dialog.h
index 0728042..e4575c9 100644
--- a/chrome/browser/extensions/extension_install_dialog.h
+++ b/chrome/browser/extensions/extension_install_dialog.h
@@ -22,11 +22,15 @@ class DictionaryValue;
void ShowExtensionInstallDialog(Profile* profile,
ExtensionInstallUI::Delegate* delegate,
+ const Extension* extension,
+ SkBitmap* icon,
const ExtensionInstallUI::Prompt& prompt);
// The implementations of this function are platform-specific.
void ShowExtensionInstallDialogImpl(Profile* profile,
ExtensionInstallUI::Delegate* delegate,
+ const Extension* extension,
+ SkBitmap* icon,
const ExtensionInstallUI::Prompt& prompt);
// Wrapper around ShowExtensionInstallDialog that shows the install dialog for
diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc
index 4587422..268a239 100644
--- a/chrome/browser/extensions/extension_install_ui.cc
+++ b/chrome/browser/extensions/extension_install_ui.cc
@@ -13,7 +13,6 @@
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/extensions/bundle_installer.h"
#include "chrome/browser/extensions/extension_install_dialog.h"
#include "chrome/browser/extensions/theme_installed_infobar_delegate.h"
#include "chrome/browser/infobars/infobar_tab_helper.h"
@@ -43,31 +42,26 @@
#include "ui/base/resource/resource_bundle.h"
using content::WebContents;
-using extensions::BundleInstaller;
static const int kTitleIds[ExtensionInstallUI::NUM_PROMPT_TYPES] = {
- 0, // The regular install prompt depends on what's being installed.
+ 0,
IDS_EXTENSION_INLINE_INSTALL_PROMPT_TITLE,
- IDS_EXTENSION_INSTALL_PROMPT_TITLE,
IDS_EXTENSION_RE_ENABLE_PROMPT_TITLE,
IDS_EXTENSION_PERMISSIONS_PROMPT_TITLE
};
static const int kHeadingIds[ExtensionInstallUI::NUM_PROMPT_TYPES] = {
IDS_EXTENSION_INSTALL_PROMPT_HEADING,
- 0, // Inline installs use the extension name.
- 0, // Heading for bundle installs depends on the bundle contents.
+ IDS_EXTENSION_INSTALL_PROMPT_HEADING,
IDS_EXTENSION_RE_ENABLE_PROMPT_HEADING,
IDS_EXTENSION_PERMISSIONS_PROMPT_HEADING
};
static const int kAcceptButtonIds[ExtensionInstallUI::NUM_PROMPT_TYPES] = {
IDS_EXTENSION_PROMPT_INSTALL_BUTTON,
IDS_EXTENSION_PROMPT_INSTALL_BUTTON,
- IDS_EXTENSION_PROMPT_INSTALL_BUTTON,
IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON,
IDS_EXTENSION_PROMPT_PERMISSIONS_BUTTON
};
static const int kAbortButtonIds[ExtensionInstallUI::NUM_PROMPT_TYPES] = {
- 0, // These all use the platform's default cancel label.
0,
0,
0,
@@ -76,7 +70,6 @@ static const int kAbortButtonIds[ExtensionInstallUI::NUM_PROMPT_TYPES] = {
static const int kPermissionsHeaderIds[ExtensionInstallUI::NUM_PROMPT_TYPES] = {
IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO,
IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO,
- IDS_EXTENSION_PROMPT_THESE_WILL_HAVE_ACCESS_TO,
IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO,
IDS_EXTENSION_PROMPT_WANTS_ACCESS_TO,
};
@@ -112,9 +105,10 @@ void ExtensionInstallUI::Prompt::SetInlineInstallWebstoreData(
rating_count_ = rating_count;
}
-string16 ExtensionInstallUI::Prompt::GetDialogTitle() const {
+string16 ExtensionInstallUI::Prompt::GetDialogTitle(
+ const Extension* extension) const {
if (type_ == INSTALL_PROMPT) {
- return l10n_util::GetStringUTF16(extension_->is_app() ?
+ return l10n_util::GetStringUTF16(extension->is_app() ?
IDS_EXTENSION_INSTALL_APP_PROMPT_TITLE :
IDS_EXTENSION_INSTALL_EXTENSION_PROMPT_TITLE);
} else {
@@ -122,14 +116,13 @@ string16 ExtensionInstallUI::Prompt::GetDialogTitle() const {
}
}
-string16 ExtensionInstallUI::Prompt::GetHeading() const {
+string16 ExtensionInstallUI::Prompt::GetHeading(
+ const std::string& extension_name) const {
if (type_ == INLINE_INSTALL_PROMPT) {
- return UTF8ToUTF16(extension_->name());
- } else if (type_ == BUNDLE_INSTALL_PROMPT) {
- return bundle_->GetHeadingTextFor(BundleInstaller::Item::STATE_PENDING);
+ return UTF8ToUTF16(extension_name);
} else {
return l10n_util::GetStringFUTF16(
- kHeadingIds[type_], UTF8ToUTF16(extension_->name()));
+ kHeadingIds[type_], UTF8ToUTF16(extension_name));
}
}
@@ -146,7 +139,7 @@ string16 ExtensionInstallUI::Prompt::GetAbortButtonLabel() const {
return l10n_util::GetStringUTF16(kAbortButtonIds[type_]);
}
-string16 ExtensionInstallUI::Prompt::GetPermissionsHeading() const {
+string16 ExtensionInstallUI::Prompt::GetPermissionsHeader() const {
return l10n_util::GetStringUTF16(kPermissionsHeaderIds[type_]);
}
@@ -197,8 +190,7 @@ size_t ExtensionInstallUI::Prompt::GetPermissionCount() const {
return permissions_.size();
}
-string16 ExtensionInstallUI::Prompt::GetPermission(size_t index) const {
- CHECK_LT(index, permissions_.size());
+string16 ExtensionInstallUI::Prompt::GetPermission(int index) const {
return l10n_util::GetStringFUTF16(
IDS_EXTENSION_PERMISSION_LINE, permissions_[index]);
}
@@ -313,10 +305,10 @@ bool disable_failure_ui_for_tests = false;
void ExtensionInstallUI::OnInstallFailure(const string16& error) {
DCHECK(ui_loop_ == MessageLoop::current());
- if (disable_failure_ui_for_tests || skip_post_install_ui_)
- return;
Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
+ if (disable_failure_ui_for_tests)
+ return;
browser::ShowErrorBox(
browser ? browser->window()->GetNativeHandle() : NULL,
l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALL_FAILURE_TITLE),
@@ -348,9 +340,8 @@ void ExtensionInstallUI::OnImageLoaded(
Prompt prompt(prompt_type_);
prompt.SetPermissions(permissions_->GetWarningMessages());
- prompt.set_extension(extension_);
- prompt.set_icon(gfx::Image(new SkBitmap(icon_)));
- ShowExtensionInstallDialog(profile_, delegate_, prompt);
+ ShowExtensionInstallDialog(
+ profile_, delegate_, extension_, &icon_, prompt);
break;
}
default:
diff --git a/chrome/browser/extensions/extension_install_ui.h b/chrome/browser/extensions/extension_install_ui.h
index bb3ad1d..a2a4881 100644
--- a/chrome/browser/extensions/extension_install_ui.h
+++ b/chrome/browser/extensions/extension_install_ui.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,7 +14,6 @@
#include "chrome/browser/extensions/image_loading_tracker.h"
#include "chrome/common/extensions/url_pattern.h"
#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/gfx/image/image.h"
#include "ui/gfx/native_widget_types.h"
class Browser;
@@ -25,10 +24,6 @@ class Profile;
class InfoBarDelegate;
class TabContentsWrapper;
-namespace extensions {
-class BundleInstaller;
-} // namespace extensions
-
// Displays all the UI around extension installation.
class ExtensionInstallUI : public ImageLoadingTracker::Observer {
public:
@@ -36,7 +31,6 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer {
UNSET_PROMPT_TYPE = -1,
INSTALL_PROMPT = 0,
INLINE_INSTALL_PROMPT,
- BUNDLE_INSTALL_PROMPT,
RE_ENABLE_PROMPT,
PERMISSIONS_PROMPT,
NUM_PROMPT_TYPES
@@ -59,12 +53,12 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer {
PromptType type() const { return type_; }
// Getters for UI element labels.
- string16 GetDialogTitle() const;
- string16 GetHeading() const;
+ string16 GetDialogTitle(const Extension* extension) const;
+ string16 GetHeading(const std::string& extension_name) const;
string16 GetAcceptButtonLabel() const;
bool HasAbortButtonLabel() const;
string16 GetAbortButtonLabel() const;
- string16 GetPermissionsHeading() const;
+ string16 GetPermissionsHeader() const;
// Getters for webstore metadata. Only populated when the type is
// INLINE_INSTALL_PROMPT.
@@ -78,20 +72,7 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer {
string16 GetRatingCount() const;
string16 GetUserCount() const;
size_t GetPermissionCount() const;
- string16 GetPermission(size_t index) const;
-
- // Populated for BUNDLE_INSTALL_PROMPT.
- const extensions::BundleInstaller* bundle() const { return bundle_; }
- void set_bundle(const extensions::BundleInstaller* bundle) {
- bundle_ = bundle;
- }
-
- // Populated for all other types.
- const Extension* extension() const { return extension_; }
- void set_extension(const Extension* extension) { extension_ = extension; }
-
- const gfx::Image& icon() const { return icon_; }
- void set_icon(const gfx::Image& icon) { icon_ = icon; }
+ string16 GetPermission(int index) const;
private:
PromptType type_;
@@ -99,13 +80,6 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer {
// permissions if only additional ones are being requested)
std::vector<string16> permissions_;
- // The extension or bundle being installed.
- const Extension* extension_;
- const extensions::BundleInstaller* bundle_;
-
- // The icon to be displayed.
- gfx::Image icon_;
-
// These fields are populated only when the prompt type is
// INLINE_INSTALL_PROMPT
// Already formatted to be locale-specific.
@@ -143,8 +117,8 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer {
}
// Whether or not to show the default UI after completing the installation.
- void set_skip_post_install_ui(bool skip_ui) {
- skip_post_install_ui_ = skip_ui;
+ void set_skip_post_install_ui(bool is_bundle) {
+ skip_post_install_ui_ = is_bundle;
}
// This is called by the installer to verify whether the installation should
diff --git a/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.h b/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.h
index e0a2ef3..4c0a9ba 100644
--- a/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.h
+++ b/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -40,7 +40,9 @@ class Profile;
NSWindow* parentWindow_; // weak
Profile* profile_; // weak
ExtensionInstallUI::Delegate* delegate_; // weak
+ const Extension* extension_; // weak
scoped_ptr<ExtensionInstallUI::Prompt> prompt_;
+ SkBitmap icon_;
}
// For unit test use only
@@ -57,7 +59,9 @@ class Profile;
- (id)initWithParentWindow:(NSWindow*)window
profile:(Profile*)profile
+ extension:(const Extension*)extension
delegate:(ExtensionInstallUI::Delegate*)delegate
+ icon:(SkBitmap*)bitmap
prompt:(const ExtensionInstallUI::Prompt&)prompt;
- (void)runAsModalSheet;
- (IBAction)storeLinkClicked:(id)sender; // Callback for "View details" link.
diff --git a/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.mm b/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.mm
index b9b3046..445fc60 100644
--- a/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.mm
+++ b/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -83,7 +83,9 @@ void AppendRatingStarsShim(const SkBitmap* skiaImage, void* data) {
- (id)initWithParentWindow:(NSWindow*)window
profile:(Profile*)profile
+ extension:(const Extension*)extension
delegate:(ExtensionInstallUI::Delegate*)delegate
+ icon:(SkBitmap*)icon
prompt:(const ExtensionInstallUI::Prompt&)prompt {
NSString* nibpath = nil;
@@ -107,7 +109,9 @@ void AppendRatingStarsShim(const SkBitmap* skiaImage, void* data) {
if ((self = [super initWithWindowNibPath:nibpath owner:self])) {
parentWindow_ = window;
profile_ = profile;
+ icon_ = *icon;
delegate_ = delegate;
+ extension_ = extension;
prompt_.reset(new ExtensionInstallUI::Prompt(prompt));
}
return self;
@@ -122,8 +126,8 @@ void AppendRatingStarsShim(const SkBitmap* skiaImage, void* data) {
}
- (IBAction)storeLinkClicked:(id)sender {
- GURL store_url(extension_urls::GetWebstoreItemDetailURLPrefix() +
- prompt_->extension()->id());
+ GURL store_url(
+ extension_urls::GetWebstoreItemDetailURLPrefix() + extension_->id());
BrowserList::GetLastActiveWithProfile(profile_)->OpenURL(OpenURLParams(
store_url, Referrer(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK,
false));
@@ -148,7 +152,8 @@ void AppendRatingStarsShim(const SkBitmap* skiaImage, void* data) {
[[self window] delegate]));
// Set control labels.
- [titleField_ setStringValue:base::SysUTF16ToNSString(prompt_->GetHeading())];
+ [titleField_ setStringValue:base::SysUTF16ToNSString(
+ prompt_->GetHeading(extension_->name()))];
[okButton_ setTitle:base::SysUTF16ToNSString(
prompt_->GetAcceptButtonLabel())];
[cancelButton_ setTitle:prompt_->HasAbortButtonLabel() ?
@@ -162,7 +167,8 @@ void AppendRatingStarsShim(const SkBitmap* skiaImage, void* data) {
prompt_->GetUserCount())];
}
- [iconView_ setImage:prompt_->icon().ToNSImage()];
+ NSImage* image = gfx::SkBitmapToNSImage(icon_);
+ [iconView_ setImage:image];
// Resize |titleField_| to fit the title.
CGFloat originalTitleWidth = [titleField_ frame].size.width;
@@ -192,7 +198,7 @@ void AppendRatingStarsShim(const SkBitmap* skiaImage, void* data) {
// If there are any warnings, then we have to do some special layout.
if (prompt_->GetPermissionCount() > 0) {
[subtitleField_ setStringValue:base::SysUTF16ToNSString(
- prompt_->GetPermissionsHeading())];
+ prompt_->GetPermissionsHeader())];
// We display the permission warnings as a simple text string, separated by
// newlines.
@@ -289,6 +295,8 @@ void AppendRatingStarsShim(const SkBitmap* skiaImage, void* data) {
void ShowExtensionInstallDialogImpl(
Profile* profile,
ExtensionInstallUI::Delegate* delegate,
+ const Extension* extension,
+ SkBitmap* icon,
const ExtensionInstallUI::Prompt& prompt) {
Browser* browser = BrowserList::GetLastActiveWithProfile(profile);
if (!browser) {
@@ -308,7 +316,9 @@ void ShowExtensionInstallDialogImpl(
[[ExtensionInstallDialogController alloc]
initWithParentWindow:native_window
profile:profile
+ extension:extension
delegate:delegate
+ icon:icon
prompt:prompt];
// TODO(mihaip): Switch this to be tab-modal (http://crbug.com/95455)
diff --git a/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller_unittest.mm b/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller_unittest.mm
index 7c1caaf..4b517ab 100644
--- a/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller_unittest.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -22,7 +22,6 @@
#import "testing/gtest_mac.h"
#include "testing/platform_test.h"
#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/gfx/image/image.h"
#include "webkit/glue/image_decoder.h"
@@ -45,10 +44,9 @@ public:
&file_contents);
webkit_glue::ImageDecoder decoder;
- SkBitmap bitmap = decoder.Decode(
+ icon_ = decoder.Decode(
reinterpret_cast<const unsigned char*>(file_contents.c_str()),
file_contents.length());
- icon_ = gfx::Image(new SkBitmap(bitmap));
}
void LoadExtension() {
@@ -72,7 +70,7 @@ public:
}
FilePath test_data_dir_;
- gfx::Image icon_;
+ SkBitmap icon_;
scoped_refptr<Extension> extension_;
};
@@ -111,14 +109,14 @@ TEST_F(ExtensionInstallDialogControllerTest, BasicsNormalCancel) {
std::vector<string16> permissions;
permissions.push_back(UTF8ToUTF16("warning 1"));
prompt.SetPermissions(permissions);
- prompt.set_extension(extension_.get());
- prompt.set_icon(icon_);
scoped_nsobject<ExtensionInstallDialogController>
controller([[ExtensionInstallDialogController alloc]
initWithParentWindow:test_window()
profile:profile()
+ extension:extension_.get()
delegate:&delegate
+ icon:&icon_
prompt:prompt]);
[controller window]; // force nib load
@@ -166,14 +164,14 @@ TEST_F(ExtensionInstallDialogControllerTest, BasicsNormalOK) {
std::vector<string16> permissions;
permissions.push_back(UTF8ToUTF16("warning 1"));
prompt.SetPermissions(permissions);
- prompt.set_extension(extension_.get());
- prompt.set_icon(icon_);
scoped_nsobject<ExtensionInstallDialogController>
controller([[ExtensionInstallDialogController alloc]
initWithParentWindow:test_window()
profile:profile()
+ extension:extension_.get()
delegate:&delegate
+ icon:&icon_
prompt:prompt]);
[controller window]; // force nib load
@@ -194,21 +192,19 @@ TEST_F(ExtensionInstallDialogControllerTest, MultipleWarnings) {
std::vector<string16> permissions;
permissions.push_back(UTF8ToUTF16("warning 1"));
one_warning_prompt.SetPermissions(permissions);
- one_warning_prompt.set_extension(extension_.get());
- one_warning_prompt.set_icon(icon_);
ExtensionInstallUI::Prompt two_warnings_prompt(
ExtensionInstallUI::INSTALL_PROMPT);
permissions.push_back(UTF8ToUTF16("warning 2"));
two_warnings_prompt.SetPermissions(permissions);
- two_warnings_prompt.set_extension(extension_.get());
- two_warnings_prompt.set_icon(icon_);
scoped_nsobject<ExtensionInstallDialogController>
controller1([[ExtensionInstallDialogController alloc]
initWithParentWindow:test_window()
profile:profile()
+ extension:extension_.get()
delegate:&delegate1
+ icon:&icon_
prompt:one_warning_prompt]);
[controller1 window]; // force nib load
@@ -217,7 +213,9 @@ TEST_F(ExtensionInstallDialogControllerTest, MultipleWarnings) {
controller2([[ExtensionInstallDialogController alloc]
initWithParentWindow:test_window()
profile:profile()
+ extension:extension_.get()
delegate:&delegate2
+ icon:&icon_
prompt:two_warnings_prompt]);
[controller2 window]; // force nib load
@@ -246,14 +244,14 @@ TEST_F(ExtensionInstallDialogControllerTest, BasicsSkinny) {
// No warnings should trigger skinny prompt.
ExtensionInstallUI::Prompt no_warnings_prompt(
ExtensionInstallUI::INSTALL_PROMPT);
- no_warnings_prompt.set_extension(extension_.get());
- no_warnings_prompt.set_icon(icon_);
scoped_nsobject<ExtensionInstallDialogController>
controller([[ExtensionInstallDialogController alloc]
initWithParentWindow:test_window()
profile:profile()
+ extension:extension_.get()
delegate:&delegate
+ icon:&icon_
prompt:no_warnings_prompt]);
[controller window]; // force nib load
@@ -292,14 +290,14 @@ TEST_F(ExtensionInstallDialogControllerTest, BasicsInline) {
ExtensionInstallUI::Prompt inline_prompt(
ExtensionInstallUI::INLINE_INSTALL_PROMPT);
inline_prompt.SetInlineInstallWebstoreData("1,000", 3.5, 200);
- inline_prompt.set_extension(extension_.get());
- inline_prompt.set_icon(icon_);
scoped_nsobject<ExtensionInstallDialogController>
controller([[ExtensionInstallDialogController alloc]
initWithParentWindow:test_window()
profile:profile()
+ extension:extension_.get()
delegate:&delegate
+ icon:&icon_
prompt:inline_prompt]);
[controller window]; // force nib load
diff --git a/chrome/browser/ui/gtk/extensions/bundle_installed_bubble_gtk.cc b/chrome/browser/ui/gtk/extensions/bundle_installed_bubble_gtk.cc
deleted file mode 100644
index b7f3be50..0000000
--- a/chrome/browser/ui/gtk/extensions/bundle_installed_bubble_gtk.cc
+++ /dev/null
@@ -1,157 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/gtk/extensions/bundle_installed_bubble_gtk.h"
-
-#include <string>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/message_loop.h"
-#include "base/i18n/rtl.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/gtk/browser_toolbar_gtk.h"
-#include "chrome/browser/ui/gtk/browser_window_gtk.h"
-#include "chrome/browser/ui/gtk/gtk_theme_service.h"
-#include "chrome/browser/ui/gtk/gtk_util.h"
-#include "grit/generated_resources.h"
-#include "grit/theme_resources.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/gfx/gtk_util.h"
-
-using extensions::BundleInstaller;
-
-namespace {
-
-// The horizontal spacing for the main content area.
-const int kHorizontalColumnSpacing = 10;
-
-// The vertical spacing for the text area.
-const int kTextColumnVerticalSpacing = 7;
-
-// The width of the content area.
-const int kContentWidth = 350;
-
-// The padding for list items.
-const int kListItemPadding = 2;
-
-// Padding between content and edge of bubble.
-const int kContentPadding = 12;
-
-} // namespace
-
-// static
-void BundleInstaller::ShowInstalledBubble(
- const BundleInstaller* bundle, Browser* browser) {
- new BundleInstalledBubbleGtk(bundle, browser);
-}
-
-BundleInstalledBubbleGtk::BundleInstalledBubbleGtk(
- const BundleInstaller* bundle, Browser* browser)
- : browser_(browser),
- bubble_(NULL) {
- AddRef(); // Balanced in Close().
- ShowInternal(bundle);
-}
-
-BundleInstalledBubbleGtk::~BundleInstalledBubbleGtk() {}
-
-void BundleInstalledBubbleGtk::ShowInternal(const BundleInstaller* bundle) {
- BrowserWindowGtk* browser_window =
- BrowserWindowGtk::GetBrowserWindowForNativeWindow(
- browser_->window()->GetNativeHandle());
-
- GtkThemeService* theme_provider = GtkThemeService::GetFrom(
- browser_->profile());
-
- // Anchor the bubble to the wrench menu.
- GtkWidget* reference_widget =
- browser_window->GetToolbar()->GetAppMenuButton();
-
- GtkWidget* bubble_content = gtk_hbox_new(FALSE, kHorizontalColumnSpacing);
- gtk_container_set_border_width(
- GTK_CONTAINER(bubble_content), kContentPadding);
-
- GtkWidget* text_column = gtk_vbox_new(FALSE, kTextColumnVerticalSpacing);
- gtk_box_pack_start(GTK_BOX(bubble_content), text_column, FALSE, FALSE, 0);
-
- InsertExtensionList(
- text_column, bundle, BundleInstaller::Item::STATE_INSTALLED);
- InsertExtensionList(text_column, bundle, BundleInstaller::Item::STATE_FAILED);
-
- // Close button
- GtkWidget* close_column = gtk_vbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX(bubble_content), close_column, FALSE, FALSE, 0);
- close_button_.reset(CustomDrawButton::CloseButton(theme_provider));
- g_signal_connect(close_button_->widget(), "clicked",
- G_CALLBACK(OnButtonClick), this);
- gtk_box_pack_start(GTK_BOX(close_column), close_button_->widget(),
- FALSE, FALSE, 0);
-
- BubbleGtk::ArrowLocationGtk arrow_location =
- !base::i18n::IsRTL() ? BubbleGtk::ARROW_LOCATION_TOP_RIGHT :
- BubbleGtk::ARROW_LOCATION_TOP_LEFT;
- gfx::Rect bounds = gtk_util::WidgetBounds(reference_widget);
-
- bubble_ = BubbleGtk::Show(reference_widget,
- &bounds,
- bubble_content,
- arrow_location,
- true, // match_system_theme
- true, // grab_input
- theme_provider,
- this);
-}
-
-void BundleInstalledBubbleGtk::InsertExtensionList(
- GtkWidget* parent,
- const BundleInstaller* bundle,
- BundleInstaller::Item::State state) {
- string16 heading = bundle->GetHeadingTextFor(state);
- BundleInstaller::ItemList items = bundle->GetItemsWithState(state);
- if (heading.empty() || items.empty())
- return;
-
- GtkWidget* heading_label = gtk_util::CreateBoldLabel(UTF16ToUTF8(heading));
- gtk_util::SetLabelWidth(heading_label, kContentWidth);
- gtk_box_pack_start(GTK_BOX(parent), heading_label, FALSE, FALSE, 0);
-
- for (size_t i = 0; i < items.size(); ++i) {
- string16 extension_name = UTF8ToUTF16(items[i].localized_name);
- base::i18n::AdjustStringForLocaleDirection(&extension_name);
-
- GtkWidget* extension_label = gtk_label_new(UTF16ToUTF8(
- l10n_util::GetStringFUTF16(
- IDS_EXTENSION_PERMISSION_LINE, extension_name)).c_str());
- gtk_util::SetLabelWidth(extension_label, kContentWidth);
- gtk_box_pack_start(GTK_BOX(parent), extension_label, false, false,
- kListItemPadding);
- }
-}
-
-void BundleInstalledBubbleGtk::BubbleClosing(BubbleGtk* bubble,
- bool closed_by_escape) {
- // We need to allow the bubble to close and remove the widgets from
- // the window before we call Release() because close_button_ depends
- // on all references being cleared before it is destroyed.
- MessageLoopForUI::current()->PostTask(
- FROM_HERE,
- base::Bind(&BundleInstalledBubbleGtk::Close, this));
-}
-
-void BundleInstalledBubbleGtk::Close() {
- bubble_ = NULL;
-
- Release(); // Balanced in BundleInstalledBubbleGtk().
-}
-
-void BundleInstalledBubbleGtk::OnButtonClick(GtkWidget* button,
- BundleInstalledBubbleGtk* bubble) {
- if (button == bubble->close_button_->widget())
- bubble->bubble_->Close();
- else
- NOTREACHED();
-}
diff --git a/chrome/browser/ui/gtk/extensions/bundle_installed_bubble_gtk.h b/chrome/browser/ui/gtk/extensions/bundle_installed_bubble_gtk.h
deleted file mode 100644
index f1b691b..0000000
--- a/chrome/browser/ui/gtk/extensions/bundle_installed_bubble_gtk.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_GTK_EXTENSIONS_BUNDLE_INSTALLED_BUBBLE_GTK_H_
-#define CHROME_BROWSER_UI_GTK_EXTENSIONS_BUNDLE_INSTALLED_BUBBLE_GTK_H_
-#pragma once
-
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-#include "chrome/browser/extensions/bundle_installer.h"
-#include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
-#include "chrome/browser/ui/gtk/custom_button.h"
-
-class Browser;
-
-// The GTK implementation of the bundle installed bubble. The bubble reports
-// which extensions and apps installed or failed when the bundle install
-// completes.
-class BundleInstalledBubbleGtk
- : public BubbleDelegateGtk,
- public base::RefCounted<BundleInstalledBubbleGtk> {
- public:
- // Displays an installed bubble in the |browser| for the |bundle|.
- BundleInstalledBubbleGtk(const extensions::BundleInstaller* bundle,
- Browser* browser);
- virtual ~BundleInstalledBubbleGtk();
-
- private:
- friend class base::RefCounted<BundleInstalledBubbleGtk>;
-
- // Assembles the content area of the bubble.
- void ShowInternal(const extensions::BundleInstaller* bundle);
-
- // The bubble lists the items that installed successfully and those that
- // failed. This assembles the lists for items in the given |state|.
- void InsertExtensionList(GtkWidget* parent,
- const extensions::BundleInstaller* bundle,
- extensions::BundleInstaller::Item::State state);
-
- // BubbleDelegateGtk, called when the bubble is about to close.
- virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE;
-
- // Closes the bubble.
- void Close();
-
- // Called when the user clicks the bubble's close button.
- static void OnButtonClick(GtkWidget* button,
- BundleInstalledBubbleGtk* bubble);
-
- Browser* browser_;
- scoped_ptr<CustomDrawButton> close_button_;
- BubbleGtk* bubble_;
-
- DISALLOW_COPY_AND_ASSIGN(BundleInstalledBubbleGtk);
-};
-
-#endif // CHROME_BROWSER_UI_GTK_EXTENSIONS_BUNDLE_INSTALLED_BUBBLE_GTK_H_
diff --git a/chrome/browser/ui/gtk/extensions/extension_install_dialog_gtk.cc b/chrome/browser/ui/gtk/extensions/extension_install_dialog_gtk.cc
index ad0582c..9b323f6 100644
--- a/chrome/browser/ui/gtk/extensions/extension_install_dialog_gtk.cc
+++ b/chrome/browser/ui/gtk/extensions/extension_install_dialog_gtk.cc
@@ -4,10 +4,8 @@
#include <gtk/gtk.h>
-#include "base/i18n/rtl.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/extensions/bundle_installer.h"
#include "chrome/browser/extensions/extension_install_dialog.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_list.h"
@@ -24,7 +22,6 @@
#include "ui/gfx/gtk_util.h"
using content::OpenURLParams;
-using extensions::BundleInstaller;
namespace {
@@ -34,7 +31,6 @@ const int kImageSize = 69;
// Additional padding (beyond on ui::kControlSpacing) all sides of each
// permission in the permissions list.
const int kPermissionsPadding = 2;
-const int kExtensionsPadding = kPermissionsPadding;
const double kRatingTextSize = 12.1; // 12.1px = 9pt @ 96dpi
@@ -54,6 +50,8 @@ class ExtensionInstallDialog {
public:
ExtensionInstallDialog(GtkWindow* parent,
ExtensionInstallUI::Delegate *delegate,
+ const Extension* extension,
+ SkBitmap* skia_icon,
const ExtensionInstallUI::Prompt& prompt);
private:
~ExtensionInstallDialog();
@@ -62,28 +60,25 @@ class ExtensionInstallDialog {
CHROMEGTK_CALLBACK_0(ExtensionInstallDialog, void, OnStoreLinkClick);
ExtensionInstallUI::Delegate* delegate_;
- std::string extension_id_; // Set for INLINE_INSTALL_PROMPT.
+ const Extension* extension_;
GtkWidget* dialog_;
};
ExtensionInstallDialog::ExtensionInstallDialog(
GtkWindow* parent,
ExtensionInstallUI::Delegate *delegate,
+ const Extension* extension,
+ SkBitmap* skia_icon,
const ExtensionInstallUI::Prompt& prompt)
: delegate_(delegate),
- dialog_(NULL) {
+ extension_(extension) {
bool show_permissions = prompt.GetPermissionCount() > 0;
bool is_inline_install =
prompt.type() == ExtensionInstallUI::INLINE_INSTALL_PROMPT;
- bool is_bundle_install =
- prompt.type() == ExtensionInstallUI::BUNDLE_INSTALL_PROMPT;
-
- if (is_inline_install)
- extension_id_ = prompt.extension()->id();
// Build the dialog.
dialog_ = gtk_dialog_new_with_buttons(
- UTF16ToUTF8(prompt.GetDialogTitle()).c_str(),
+ UTF16ToUTF8(prompt.GetDialogTitle(extension)).c_str(),
parent,
GTK_DIALOG_MODAL,
NULL);
@@ -126,7 +121,7 @@ ExtensionInstallDialog::ExtensionInstallDialog(
// Heading
GtkWidget* heading_label = gtk_util::CreateBoldLabel(
- UTF16ToUTF8(prompt.GetHeading().c_str()));
+ UTF16ToUTF8(prompt.GetHeading(extension_->name())).c_str());
gtk_label_set_line_wrap(GTK_LABEL(heading_label), true);
gtk_misc_set_alignment(GTK_MISC(heading_label), 0.0, 0.5);
gtk_box_pack_start(GTK_BOX(heading_vbox), heading_label, center_heading,
@@ -164,44 +159,21 @@ ExtensionInstallDialog::ExtensionInstallDialog(
G_CALLBACK(OnStoreLinkClickThunk), this);
}
- if (is_bundle_install) {
- // Add the list of extensions to be installed.
- GtkWidget* extensions_vbox = gtk_vbox_new(FALSE, ui::kControlSpacing);
- gtk_box_pack_start(GTK_BOX(heading_vbox), extensions_vbox, FALSE, FALSE,
- ui::kControlSpacing);
-
- BundleInstaller::ItemList items = prompt.bundle()->GetItemsWithState(
- BundleInstaller::Item::STATE_PENDING);
- for (size_t i = 0; i < items.size(); ++i) {
- string16 extension_name = UTF8ToUTF16(items[i].localized_name);
- base::i18n::AdjustStringForLocaleDirection(&extension_name);
-
- GtkWidget* extension_label = gtk_label_new(UTF16ToUTF8(
- l10n_util::GetStringFUTF16(
- IDS_EXTENSION_PERMISSION_LINE, extension_name)).c_str());
- gtk_util::SetLabelWidth(extension_label, kLeftColumnMinWidth);
- gtk_box_pack_start(GTK_BOX(extensions_vbox), extension_label,
- FALSE, FALSE, kExtensionsPadding);
- }
+ // Resize the icon if necessary.
+ SkBitmap scaled_icon = *skia_icon;
+ if (scaled_icon.width() > kImageSize || scaled_icon.height() > kImageSize) {
+ scaled_icon = skia::ImageOperations::Resize(scaled_icon,
+ skia::ImageOperations::RESIZE_LANCZOS3,
+ kImageSize, kImageSize);
}
- if (!is_bundle_install) {
- // Resize the icon if necessary.
- SkBitmap scaled_icon = prompt.icon();
- if (scaled_icon.width() > kImageSize || scaled_icon.height() > kImageSize) {
- scaled_icon = skia::ImageOperations::Resize(
- scaled_icon, skia::ImageOperations::RESIZE_LANCZOS3,
- kImageSize, kImageSize);
- }
-
- // Put icon in the right column.
- GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&scaled_icon);
- GtkWidget* icon = gtk_image_new_from_pixbuf(pixbuf);
- g_object_unref(pixbuf);
- gtk_box_pack_start(GTK_BOX(top_content_hbox), icon, FALSE, FALSE, 0);
- // Top justify the image.
- gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0);
- }
+ // Put icon in the right column.
+ GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&scaled_icon);
+ GtkWidget* icon = gtk_image_new_from_pixbuf(pixbuf);
+ g_object_unref(pixbuf);
+ gtk_box_pack_start(GTK_BOX(top_content_hbox), icon, FALSE, FALSE, 0);
+ // Top justify the image.
+ gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0);
// Permissions are shown separated by a divider for inline installs, or
// directly under the heading for regular installs (where we don't have
@@ -217,7 +189,7 @@ ExtensionInstallDialog::ExtensionInstallDialog(
}
GtkWidget* permissions_header = gtk_util::CreateBoldLabel(
- UTF16ToUTF8(prompt.GetPermissionsHeading()).c_str());
+ UTF16ToUTF8(prompt.GetPermissionsHeader()).c_str());
gtk_util::SetLabelWidth(permissions_header, kLeftColumnMinWidth);
gtk_box_pack_start(GTK_BOX(permissions_container), permissions_header,
FALSE, FALSE, 0);
@@ -255,7 +227,7 @@ void ExtensionInstallDialog::OnResponse(GtkWidget* dialog, int response_id) {
void ExtensionInstallDialog::OnStoreLinkClick(GtkWidget* sender) {
GURL store_url(
- extension_urls::GetWebstoreItemDetailURLPrefix() + extension_id_);
+ extension_urls::GetWebstoreItemDetailURLPrefix() + extension_->id());
BrowserList::GetLastActive()->OpenURL(OpenURLParams(
store_url, content::Referrer(), NEW_FOREGROUND_TAB,
content::PAGE_TRANSITION_LINK, false));
@@ -268,6 +240,8 @@ void ExtensionInstallDialog::OnStoreLinkClick(GtkWidget* sender) {
void ShowExtensionInstallDialogImpl(
Profile* profile,
ExtensionInstallUI::Delegate* delegate,
+ const Extension* extension,
+ SkBitmap* icon,
const ExtensionInstallUI::Prompt& prompt) {
Browser* browser = BrowserList::GetLastActiveWithProfile(profile);
if (!browser) {
@@ -282,5 +256,9 @@ void ShowExtensionInstallDialogImpl(
return;
}
- new ExtensionInstallDialog(browser_window->window(), delegate, prompt);
+ new ExtensionInstallDialog(browser_window->window(),
+ delegate,
+ extension,
+ icon,
+ prompt);
}
diff --git a/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc b/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc
index b20b812..de9ee65 100644
--- a/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc
+++ b/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc
@@ -68,6 +68,8 @@ class ExtensionInstallDialogView : public views::DialogDelegateView,
public views::LinkListener {
public:
ExtensionInstallDialogView(ExtensionInstallUI::Delegate* delegate,
+ const Extension* extension,
+ SkBitmap* skia_icon,
const ExtensionInstallUI::Prompt& prompt);
virtual ~ExtensionInstallDialogView();
@@ -91,6 +93,7 @@ class ExtensionInstallDialogView : public views::DialogDelegateView,
}
ExtensionInstallUI::Delegate* delegate_;
+ const Extension* extension_;
ExtensionInstallUI::Prompt prompt_;
DISALLOW_COPY_AND_ASSIGN(ExtensionInstallDialogView);
@@ -98,8 +101,11 @@ class ExtensionInstallDialogView : public views::DialogDelegateView,
ExtensionInstallDialogView::ExtensionInstallDialogView(
ExtensionInstallUI::Delegate* delegate,
+ const Extension* extension,
+ SkBitmap* skia_icon,
const ExtensionInstallUI::Prompt& prompt)
: delegate_(delegate),
+ extension_(extension),
prompt_(prompt) {
// Possible grid layouts:
// Inline install
@@ -158,7 +164,8 @@ ExtensionInstallDialogView::ExtensionInstallDialogView(
layout->StartRow(0, column_set_id);
- views::Label* heading = new views::Label(prompt.GetHeading());
+ views::Label* heading = new views::Label(
+ prompt.GetHeading(extension->name()));
heading->SetFont(heading->font().DeriveFont(kHeadingFontSizeDelta,
gfx::Font::BOLD));
heading->SetMultiLine(true);
@@ -167,13 +174,12 @@ ExtensionInstallDialogView::ExtensionInstallDialogView(
layout->AddView(heading);
// Scale down to icon size, but allow smaller icons (don't scale up).
- SkBitmap bitmap = prompt.icon();
- gfx::Size size(bitmap.width(), bitmap.height());
+ gfx::Size size(skia_icon->width(), skia_icon->height());
if (size.width() > kIconSize || size.height() > kIconSize)
size = gfx::Size(kIconSize, kIconSize);
views::ImageView* icon = new views::ImageView();
icon->SetImageSize(size);
- icon->SetImage(bitmap);
+ icon->SetImage(*skia_icon);
icon->SetHorizontalAlignment(views::ImageView::CENTER);
icon->SetVerticalAlignment(views::ImageView::CENTER);
int icon_row_span = 1;
@@ -229,7 +235,7 @@ ExtensionInstallDialogView::ExtensionInstallDialogView(
layout->StartRow(0, column_set_id);
views::Label* permissions_header = new views::Label(
- prompt.GetPermissionsHeading());
+ prompt.GetPermissionsHeader());
permissions_header->SetMultiLine(true);
permissions_header->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
permissions_header->SizeToFit(left_column_width);
@@ -285,7 +291,7 @@ ui::ModalType ExtensionInstallDialogView::GetModalType() const {
}
string16 ExtensionInstallDialogView::GetWindowTitle() const {
- return prompt_.GetDialogTitle();
+ return prompt_.GetDialogTitle(extension_);
}
views::View* ExtensionInstallDialogView::GetContentsView() {
@@ -294,8 +300,8 @@ views::View* ExtensionInstallDialogView::GetContentsView() {
void ExtensionInstallDialogView::LinkClicked(views::Link* source,
int event_flags) {
- GURL store_url(extension_urls::GetWebstoreItemDetailURLPrefix() +
- prompt_.extension()->id());
+ GURL store_url(
+ extension_urls::GetWebstoreItemDetailURLPrefix() + extension_->id());
OpenURLParams params(
store_url, Referrer(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK,
false);
@@ -306,6 +312,8 @@ void ExtensionInstallDialogView::LinkClicked(views::Link* source,
void ShowExtensionInstallDialogImpl(
Profile* profile,
ExtensionInstallUI::Delegate* delegate,
+ const Extension* extension,
+ SkBitmap* icon,
const ExtensionInstallUI::Prompt& prompt) {
#if defined(OS_CHROMEOS)
// Use a tabbed browser window as parent on ChromeOS.
@@ -325,7 +333,7 @@ void ShowExtensionInstallDialogImpl(
}
ExtensionInstallDialogView* dialog = new ExtensionInstallDialogView(
- delegate, prompt);
+ delegate, extension, icon, prompt);
views::Widget* window = browser::CreateViewsWindow(
browser_window->GetNativeHandle(), dialog, STYLE_GENERIC);
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 890501e..f38128f 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3172,8 +3172,6 @@
'browser/ui/gtk/download/download_started_animation_gtk.cc',
'browser/ui/gtk/edit_search_engine_dialog.cc',
'browser/ui/gtk/edit_search_engine_dialog.h',
- 'browser/ui/gtk/extensions/bundle_installed_bubble_gtk.cc',
- 'browser/ui/gtk/extensions/bundle_installed_bubble_gtk.h',
'browser/ui/gtk/extensions/extension_install_dialog_gtk.cc',
'browser/ui/gtk/extensions/extension_installed_bubble_gtk.cc',
'browser/ui/gtk/extensions/extension_installed_bubble_gtk.h',