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 6edea039fb956cf9d851fdcf134f12ceba0b4d20..b646252b2fbd506880b8f2d7f1cbf2610c5f8ad1 100644 |
--- a/chrome/browser/extensions/extension_install_prompt.cc |
+++ b/chrome/browser/extensions/extension_install_prompt.cc |
@@ -101,7 +101,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, |
IDS_EXTENSION_PROMPT_REPAIR_BUTTON, |
@@ -229,6 +229,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), |
@@ -272,6 +273,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; |
} |
} |
@@ -337,8 +341,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; |
} |
@@ -351,12 +354,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; |
} |
@@ -370,6 +373,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; |
+ } 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(); |
@@ -412,13 +427,31 @@ base::string16 ExtensionInstallPrompt::Prompt::GetRetainedFilesHeading() const { |
IDS_EXTENSION_PROMPT_RETAINED_FILES_FEW, |
IDS_EXTENSION_PROMPT_RETAINED_FILES_MANY, |
}; |
- std::vector<int> message_ids; |
- for (size_t i = 0; i < arraysize(kRetainedFilesMessageIDs); i++) { |
- message_ids.push_back(kRetainedFilesMessageIDs[i]); |
- } |
+ std::vector<int> message_ids( |
+ kRetainedFilesMessageIDs, |
+ kRetainedFilesMessageIDs + arraysize(kRetainedFilesMessageIDs)); |
+ |
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( |
+ kRetainedDevicesMessageIDs, |
+ kRetainedDevicesMessageIDs + arraysize(kRetainedDevicesMessageIDs)); |
+ |
+ return l10n_util::GetPluralStringFUTF16(message_ids, |
+ GetRetainedDeviceCount()); |
+} |
+ |
bool ExtensionInstallPrompt::Prompt::ShouldShowPermissions() const { |
return GetPermissionCount(ALL_PERMISSIONS) > 0 || |
type_ == POST_INSTALL_PERMISSIONS_PROMPT; |
@@ -530,6 +563,8 @@ bool ExtensionInstallPrompt::Prompt::GetIsShowingDetails( |
return withheld_prompt_permissions_.is_showing_details[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; |
} |
@@ -544,6 +579,20 @@ base::string16 ExtensionInstallPrompt::Prompt::GetRetainedFile(size_t index) |
return retained_files_[index].AsUTF16Unsafe(); |
} |
+size_t ExtensionInstallPrompt::Prompt::GetRetainedDeviceCount() const { |
+ return retained_device_messages_.size(); |
+} |
+ |
+base::string16 ExtensionInstallPrompt::Prompt::GetRetainedDeviceMessageString( |
+ size_t index) const { |
+ CHECK_LT(index, retained_device_messages_.size()); |
+ return retained_device_messages_[index]; |
+} |
+ |
+bool ExtensionInstallPrompt::Prompt::ShouldDisplayRevokeButton() const { |
+ return !retained_files_.empty() || !retained_device_messages_.empty(); |
+} |
+ |
ExtensionInstallPrompt::Prompt::InstallPromptPermissions& |
ExtensionInstallPrompt::Prompt::GetPermissionsForType( |
PermissionsType permissions_type) { |
@@ -753,11 +802,13 @@ 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; |
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(); |