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

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

Issue 173463: Update of the extension install UI: (Closed)
Patch Set: mpcompelte comments Created 11 years, 4 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 2515b3699e69b8d4956da43b1ab05aeabf1ef12b..8bfd600139b8922b15b0283c6cc999b83c341db1 100644
--- a/chrome/browser/extensions/extension_install_ui.cc
+++ b/chrome/browser/extensions/extension_install_ui.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/extensions/extension.h"
#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
#if defined(OS_WIN)
#include "app/win_util.h"
@@ -24,6 +25,55 @@
#include <CoreFoundation/CFUserNotification.h>
#endif
+namespace {
+
+static std::wstring GetInstallWarning(Extension* extension) {
+ // If the extension has a plugin, it's easy: the plugin has the most severe
+ // warning.
+ if (!extension->plugins().empty())
+ return l10n_util::GetString(IDS_EXTENSION_PROMPT_WARNING_NEW_FULL_ACCESS);
+
+ // Otherwise, we go in descending order of severity: all hosts, several hosts,
+ // a single host, no hosts. For each of these, we also have a variation of the
+ // message for when api permissions are also requested.
+ if (extension->HasAccessToAllHosts()) {
+ if (extension->api_permissions().empty())
+ return l10n_util::GetString(IDS_EXTENSION_PROMPT_WARNING_NEW_ALL_HOSTS);
+ else
+ return l10n_util::GetString(
+ IDS_EXTENSION_PROMPT_WARNING_NEW_ALL_HOSTS_AND_BROWSER);
+ }
+
+ const std::set<std::string> hosts = extension->GetEffectiveHostPermissions();
+ if (hosts.size() > 1) {
+ if (extension->api_permissions().empty())
+ return l10n_util::GetString(
+ IDS_EXTENSION_PROMPT_WARNING_NEW_MULTIPLE_HOSTS);
+ else
+ return l10n_util::GetString(
+ IDS_EXTENSION_PROMPT_WARNING_NEW_MULTIPLE_HOSTS_AND_BROWSER);
+ }
+
+ if (hosts.size() == 1) {
+ if (extension->api_permissions().empty())
+ return l10n_util::GetStringF(
+ IDS_EXTENSION_PROMPT_WARNING_NEW_SINGLE_HOST,
+ UTF8ToWide(*hosts.begin()));
+ else
+ return l10n_util::GetStringF(
+ IDS_EXTENSION_PROMPT_WARNING_NEW_SINGLE_HOST_AND_BROWSER,
+ UTF8ToWide(*hosts.begin()));
+ }
+
+ DCHECK(hosts.size() == 0);
+ if (extension->api_permissions().empty())
+ return L"";
+ else
+ return l10n_util::GetString(IDS_EXTENSION_PROMPT_WARNING_NEW_BROWSER);
+}
+
+}
+
ExtensionInstallUI::ExtensionInstallUI(Profile* profile)
: profile_(profile), ui_loop_(MessageLoop::current()) {
}
@@ -47,7 +97,8 @@ void ExtensionInstallUI::ConfirmInstall(Delegate* delegate,
}
#if defined(OS_WIN)
- ShowExtensionInstallPrompt(profile_, delegate, extension, install_icon);
+ ShowExtensionInstallPrompt(profile_, delegate, extension, install_icon,
+ GetInstallWarning(extension));
#elif defined(OS_MACOSX)
// TODO(port): Implement nicer UI.

Powered by Google App Engine
This is Rietveld 408576698