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

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

Issue 580363002: Update app info and install prompt UI to show retained devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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_prompt.cc
diff --git a/chrome/browser/extensions/extension_install_prompt.cc b/chrome/browser/extensions/extension_install_prompt.cc
index dec1aa54f3b756b3d1ba147b74b8179e6c912cf0..73c66eeb0f59899d7272a532e10c84c2558c7abe 100644
--- a/chrome/browser/extensions/extension_install_prompt.cc
+++ b/chrome/browser/extensions/extension_install_prompt.cc
@@ -91,7 +91,7 @@ static const int kAcceptButtonIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = {
IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON,
IDS_EXTENSION_PROMPT_PERMISSIONS_BUTTON,
0, // External installs use different strings for extensions/apps.
- IDS_EXTENSION_PROMPT_PERMISSIONS_CLEAR_RETAINED_FILES_BUTTON,
+ 0, // Different strings depending on the files and devices retained.
IDS_EXTENSION_PROMPT_LAUNCH_BUTTON,
IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON,
};
@@ -207,6 +207,7 @@ std::string ExtensionInstallPrompt::PromptTypeToString(PromptType type) {
ExtensionInstallPrompt::Prompt::Prompt(PromptType type)
: type_(type),
is_showing_details_for_retained_files_(false),
+ is_showing_details_for_retained_devices_(false),
extension_(NULL),
bundle_(NULL),
average_rating_(0.0),
@@ -242,6 +243,9 @@ void ExtensionInstallPrompt::Prompt::SetIsShowingDetails(
case RETAINED_FILES_DETAILS:
is_showing_details_for_retained_files_ = is_showing_details;
break;
+ case RETAINED_DEVICES_DETAILS:
+ is_showing_details_for_retained_devices_ = is_showing_details;
+ break;
}
}
@@ -302,8 +306,7 @@ base::string16 ExtensionInstallPrompt::Prompt::GetHeading() const {
}
int ExtensionInstallPrompt::Prompt::GetDialogButtons() const {
- if (type_ == POST_INSTALL_PERMISSIONS_PROMPT &&
- ShouldDisplayRevokeFilesButton()) {
+ if (type_ == POST_INSTALL_PERMISSIONS_PROMPT && ShouldDisplayRevokeButton()) {
return kButtons[type_] | ui::DIALOG_BUTTON_OK;
}
@@ -316,12 +319,12 @@ bool ExtensionInstallPrompt::Prompt::ShouldShowExplanationText() const {
}
bool ExtensionInstallPrompt::Prompt::HasAcceptButtonLabel() const {
+ if (type_ == POST_INSTALL_PERMISSIONS_PROMPT)
+ return ShouldDisplayRevokeButton();
+
if (kAcceptButtonIds[type_] == 0)
return false;
- if (type_ == POST_INSTALL_PERMISSIONS_PROMPT)
- return ShouldDisplayRevokeFilesButton();
-
return true;
}
@@ -335,6 +338,18 @@ base::string16 ExtensionInstallPrompt::Prompt::GetAcceptButtonLabel() const {
else
id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_EXTENSION;
return l10n_util::GetStringUTF16(id);
+ } else if (type_ == POST_INSTALL_PERMISSIONS_PROMPT) {
+ int id = -1;
+ if (GetRetainedFileCount() && GetRetainedDeviceCount()) {
+ id =
+ IDS_EXTENSION_PROMPT_PERMISSIONS_CLEAR_RETAINED_FILES_AND_DEVICES_BUTTON;
tapted 2014/09/19 04:09:09 (hm I guess clang-format put a line-break there to
+ } else if (GetRetainedFileCount()) {
+ id = IDS_EXTENSION_PROMPT_PERMISSIONS_CLEAR_RETAINED_FILES_BUTTON;
+ } else {
+ DCHECK_LT(0U, GetRetainedDeviceCount());
+ id = IDS_EXTENSION_PROMPT_PERMISSIONS_CLEAR_RETAINED_DEVICES_BUTTON;
+ }
+ return l10n_util::GetStringUTF16(id);
}
if (ShouldShowExplanationText())
return experiment_->GetOkButtonText();
@@ -374,6 +389,24 @@ base::string16 ExtensionInstallPrompt::Prompt::GetRetainedFilesHeading() const {
return l10n_util::GetPluralStringFUTF16(message_ids, GetRetainedFileCount());
}
+base::string16 ExtensionInstallPrompt::Prompt::GetRetainedDevicesHeading()
+ const {
+ const int kRetainedDevicesMessageIDs[6] = {
+ IDS_EXTENSION_PROMPT_RETAINED_DEVICES_DEFAULT,
+ IDS_EXTENSION_PROMPT_RETAINED_DEVICE_SINGULAR,
+ IDS_EXTENSION_PROMPT_RETAINED_DEVICES_ZERO,
+ IDS_EXTENSION_PROMPT_RETAINED_DEVICES_TWO,
+ IDS_EXTENSION_PROMPT_RETAINED_DEVICES_FEW,
+ IDS_EXTENSION_PROMPT_RETAINED_DEVICES_MANY,
+ };
+ std::vector<int> message_ids;
tapted 2014/09/19 04:09:09 (optional) I would have used the iterator begin/en
Reilly Grant (use Gerrit) 2014/09/19 19:30:09 Done.
+ for (size_t i = 0; i < arraysize(kRetainedDevicesMessageIDs); i++) {
+ message_ids.push_back(kRetainedDevicesMessageIDs[i]);
+ }
+ return l10n_util::GetPluralStringFUTF16(message_ids,
+ GetRetainedDeviceCount());
+}
+
bool ExtensionInstallPrompt::Prompt::ShouldShowPermissions() const {
return GetPermissionCount() > 0 || type_ == POST_INSTALL_PERMISSIONS_PROMPT;
}
@@ -451,6 +484,8 @@ bool ExtensionInstallPrompt::Prompt::GetIsShowingDetails(
return is_showing_details_for_permissions_[index];
case RETAINED_FILES_DETAILS:
return is_showing_details_for_retained_files_;
+ case RETAINED_DEVICES_DETAILS:
+ return is_showing_details_for_retained_devices_;
}
return false;
}
@@ -465,8 +500,19 @@ base::string16 ExtensionInstallPrompt::Prompt::GetRetainedFile(size_t index)
return retained_files_[index].AsUTF16Unsafe();
}
-bool ExtensionInstallPrompt::Prompt::ShouldDisplayRevokeFilesButton() const {
- return !retained_files_.empty();
+size_t ExtensionInstallPrompt::Prompt::GetRetainedDeviceCount() const {
+ return retained_device_messages_.size();
+}
+
+bool ExtensionInstallPrompt::Prompt::ShouldDisplayRevokeButton() const {
+ return !retained_files_.empty() || !retained_device_messages_.empty();
+}
+
+const base::string16&
tapted 2014/09/19 04:09:09 nit: maybe return a value? just for consistency wi
Reilly Grant (use Gerrit) 2014/09/19 19:30:09 Done.
+ExtensionInstallPrompt::Prompt::GetRetainedDeviceMessageString(
+ size_t index) const {
+ CHECK_LT(index, retained_device_messages_.size());
+ return retained_device_messages_[index];
}
ExtensionInstallPrompt::ShowParams::ShowParams(content::WebContents* contents)
@@ -662,12 +708,14 @@ void ExtensionInstallPrompt::ConfirmPermissions(
void ExtensionInstallPrompt::ReviewPermissions(
Delegate* delegate,
const Extension* extension,
- const std::vector<base::FilePath>& retained_file_paths) {
+ const std::vector<base::FilePath>& retained_file_paths,
+ const std::vector<base::string16>& retained_device_messages) {
DCHECK(ui_loop_ == base::MessageLoop::current());
extension_ = extension;
permissions_ = extension->permissions_data()->active_permissions();
prompt_ = new Prompt(POST_INSTALL_PERMISSIONS_PROMPT);
prompt_->set_retained_files(retained_file_paths);
+ prompt_->set_retained_device_messages(retained_device_messages);
delegate_ = delegate;
LoadImageIfNeeded();

Powered by Google App Engine
This is Rietveld 408576698