Skip to content

Commit

Permalink
Implement extension permission dialog experiments.
Browse files Browse the repository at this point in the history
This CL implements the 12 different screens in the mocks at
http://go/crx-dialog-experiment. Screenshots from the
implementation are at http://go/crx-dialog-experiment-screenshots.

BUG=326733
NOTRY=true

Review URL: https://codereview.chromium.org/103863009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242657 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
meacer@chromium.org committed Dec 28, 2013
1 parent 6952f00 commit 62a28d7
Show file tree
Hide file tree
Showing 8 changed files with 1,075 additions and 157 deletions.
50 changes: 50 additions & 0 deletions chrome/app/generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -5066,6 +5066,56 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_EXTENSIONS_DETAILS" desc="Tooltip for the button next to an extension that toggles showing details">
Details
</message>

<!-- Strings for the extensions permission dialog experiment -->
<!-- TODO(meacer): Remove these once the experiments are completed. -->
<message name="IDS_EXTENSION_PROMPT_EXPERIMENT_EXPLANATION1">
Do you trust this extension to use these privileges safely?
</message>
<message name="IDS_EXTENSION_PROMPT_EXPERIMENT_EXPLANATION2">
Once installed, this extension could potentially use these privileges to do malicious things to your web browsing experience. Are you sure you want to install this extension?
</message>
<message name="IDS_EXTENSION_PROMPT_EXPERIMENT_EXPLANATION3">
Are you sure you want to install this extension given that it requires these privileges?
</message>
<message name="IDS_EXTENSION_PROMPT_EXPERIMENT_EXPLANATION4">
Make sure that these privileges make sense for what you think the extension needs to do. If they do not, click Cancel.
</message>
<message name="IDS_EXTENSION_PROMPT_EXPERIMENT_EXPLANATION5">
Do you trust this extension to perform these actions?
</message>

<message name="IDS_EXTENSION_PROMPT_EXPERIMENT_INSTALL_BUTTON_TRUST" desc="Text for the install button on the extension install prompt (for experiment group 1)">
Yes, I trust this extension!
</message>
<message name="IDS_EXTENSION_PROMPT_EXPERIMENT_INSTALL_BUTTON_YES" desc="Text for the install button on the extension install prompt (for experiment group 2)">
Yes, install
</message>
<message name="IDS_EXTENSION_PROMPT_EXPERIMENT_INSTALL_BUTTON_SURE" desc="Text for the install button on the extension install prompt (for experiment group 3)">
Yes, I'm sure
</message>
<message name="IDS_EXTENSION_PROMPT_EXPERIMENT_INSTALL_BUTTON_TRUST2" desc="Text for the install button on the extension install prompt (for experiment group 4)">
Yes, I trust it
</message>
<message name="IDS_EXTENSION_PROMPT_EXPERIMENT_INSTALL_BUTTON_NOPE" desc="Text for the cancel button on the extension install prompt">
Nope, cancel
</message>
<message name="IDS_EXTENSION_PROMPT_EXPERIMENT_SHOW_DETAILS" desc="The label of the button which displays permission info when clicked">
Show details
</message>
<message name="IDS_EXTENSION_PROMPT_EXPERIMENT_SHOW_PERMISSIONS" desc="The label of the button which displays permission list when clicked">
Show permissions
</message>
<message name="IDS_EXTENSION_PROMPT_EXPERIMENT_CHECKBOX_INFO" desc="Text for the label that explains that user should check all checkboxes to process for installation.">
Please check all boxes to proceed.
</message>

<message name="IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS_EXPLANATION" desc="Extra explanation text for full access permission">
This extension can read and change all data on your computer and all websites including Google, Facebook, Yahoo, etc.
</message>
<message name="IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS_EXPLANATION" desc="Extra explanation text for all sites permission">
This extension can read and change your information on all websites including Google, Facebook, Yahoo, etc.
</message>

<!-- chrome://extension-info bubble -->
<message name="IDS_EXTENSION_SCRIPT_POPUP_IS_RUNNING" desc="The label in the extension info bubble that indicates the extension is running scripts on this page">
Expand Down
16 changes: 16 additions & 0 deletions chrome/browser/extensions/extension_install_prompt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ int ExtensionInstallPrompt::Prompt::GetDialogButtons() const {
return kButtons[type_];
}

bool ExtensionInstallPrompt::Prompt::ShouldShowExplanationText() const {
return type_ == INSTALL_PROMPT &&
extension_->is_extension() && experiment_ && experiment_->text_only();
}

bool ExtensionInstallPrompt::Prompt::HasAcceptButtonLabel() const {
if (kAcceptButtonIds[type_] == 0)
return false;
Expand All @@ -333,15 +338,21 @@ base::string16 ExtensionInstallPrompt::Prompt::GetAcceptButtonLabel() const {
id = IDS_EXTENSION_EXTERNAL_INSTALL_PROMPT_ACCEPT_BUTTON_EXTENSION;
return l10n_util::GetStringUTF16(id);
}
if (ShouldShowExplanationText())
return experiment_->GetOkButtonText();
return l10n_util::GetStringUTF16(kAcceptButtonIds[type_]);
}

bool ExtensionInstallPrompt::Prompt::HasAbortButtonLabel() const {
if (ShouldShowExplanationText())
return true;
return kAbortButtonIds[type_] > 0;
}

base::string16 ExtensionInstallPrompt::Prompt::GetAbortButtonLabel() const {
CHECK(HasAbortButtonLabel());
if (ShouldShowExplanationText())
return experiment_->GetCancelButtonText();
return l10n_util::GetStringUTF16(kAbortButtonIds[type_]);
}

Expand Down Expand Up @@ -785,6 +796,11 @@ void ExtensionInstallPrompt::OnMintTokenFailure(
}

void ExtensionInstallPrompt::ShowConfirmation() {
if (prompt_.type() == INSTALL_PROMPT)
prompt_.set_experiment(ExtensionInstallPromptExperiment::Find());
else
prompt_.set_experiment(ExtensionInstallPromptExperiment::ControlGroup());

if (permissions_.get() &&
(!extension_ ||
!extensions::PermissionsData::ShouldSkipPermissionWarnings(
Expand Down
14 changes: 14 additions & 0 deletions chrome/browser/extensions/extension_install_prompt.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "chrome/browser/extensions/crx_installer_error.h"
#include "chrome/browser/extensions/extension_install_prompt_experiment.h"
#include "extensions/common/url_pattern.h"
#include "google_apis/gaia/oauth2_mint_token_flow.h"
#include "google_apis/gaia/oauth2_token_service.h"
Expand Down Expand Up @@ -51,6 +52,8 @@ class ExtensionInstallPrompt
public OAuth2TokenService::Consumer,
public base::SupportsWeakPtr<ExtensionInstallPrompt> {
public:
// This enum is associated with Extensions.InstallPrompt_Type UMA histogram.
// Do not modify existing values and add new values only to the end.
enum PromptType {
UNSET_PROMPT_TYPE = -1,
INSTALL_PROMPT = 0,
Expand Down Expand Up @@ -109,6 +112,7 @@ class ExtensionInstallPrompt
base::string16 GetRetainedFilesHeading() const;

bool ShouldShowPermissions() const;
bool ShouldShowExplanationText() const;

// Getters for webstore metadata. Only populated when the type is
// INLINE_INSTALL_PROMPT.
Expand Down Expand Up @@ -151,6 +155,14 @@ class ExtensionInstallPrompt
const gfx::Image& icon() const { return icon_; }
void set_icon(const gfx::Image& icon) { icon_ = icon; }

const ExtensionInstallPromptExperiment* experiment() const {
return experiment_;
}

void set_experiment(ExtensionInstallPromptExperiment* experiment) {
experiment_ = experiment;
}

private:
bool ShouldDisplayRevokeFilesButton() const;

Expand Down Expand Up @@ -191,6 +203,8 @@ class ExtensionInstallPrompt
bool show_user_count_;

std::vector<base::FilePath> retained_files_;

scoped_refptr<ExtensionInstallPromptExperiment> experiment_;
};

static const int kMinExtensionRating = 0;
Expand Down
Loading

0 comments on commit 62a28d7

Please sign in to comment.