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

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

Issue 9456019: Add GTK interface for installing bundles of extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compile Created 8 years, 10 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
« no previous file with comments | « chrome/browser/extensions/bundle_installer.h ('k') | chrome/browser/extensions/crx_installer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/bundle_installer.cc
diff --git a/chrome/browser/extensions/bundle_installer.cc b/chrome/browser/extensions/bundle_installer.cc
index 8772b0b4d09af2fb29b8ddc76080c71a78e7795f..7da31420fba971c9ef7787a079d18b796d8c00b8 100644
--- a/chrome/browser/extensions/bundle_installer.cc
+++ b/chrome/browser/extensions/bundle_installer.cc
@@ -4,18 +4,23 @@
#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;
@@ -50,6 +55,35 @@ 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
@@ -127,11 +161,39 @@ 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_GTK)
// static
void BundleInstaller::ShowInstalledBubble(
const BundleInstaller* bundle, Browser* browser) {
// TODO(jstritar): provide platform specific implementations.
}
+#endif
void BundleInstaller::ParseManifests() {
if (items_.empty()) {
@@ -189,13 +251,18 @@ void BundleInstaller::ShowPrompt() {
permissions, dummy_extensions_[i]->required_permission_set());
}
- // TODO(jstritar): show the actual prompt.
- if (g_auto_approve_for_test == PROCEED)
+ 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
- InstallUIAbort(false);
+ } else {
+ ExtensionInstallUI::Prompt prompt(
+ ExtensionInstallUI::BUNDLE_INSTALL_PROMPT);
+ prompt.SetPermissions(permissions->GetWarningMessages());
+ prompt.set_bundle(this);
+
+ ShowExtensionInstallDialog(profile_, this, prompt);
+ }
}
void BundleInstaller::ShowInstalledBubbleIfDone() {
@@ -262,6 +329,9 @@ 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();
}
« no previous file with comments | « chrome/browser/extensions/bundle_installer.h ('k') | chrome/browser/extensions/crx_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698