summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_install_prompt_experiment.h
blob: 630c1d1a2ac5376e49e8651d65b5f4f271cd11b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_EXPERIMENT_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_EXPERIMENT_H_

#include "base/memory/ref_counted.h"

// Represents a permission dialog experiment.
// TODO(meacer): Remove this class once the ExtensionPermissionDialog
// experiment is completed (http://crbug.com/308748).
class ExtensionInstallPromptExperiment
    : public base::RefCounted<ExtensionInstallPromptExperiment> {
 public:
  ExtensionInstallPromptExperiment(unsigned int group_id, unsigned int flags);

  // Returns an experiment instance configured by the server. The ownership of
  // the returned pointer is passed to the caller.
  static ExtensionInstallPromptExperiment* Find();

  // Returns an experiment instance for the control group. The ownership of the
  // returned pointer is passed to the caller.
  static ExtensionInstallPromptExperiment* ControlGroup();

  // Returns true if this is a text only experiment. A text only experiment
  // only adds an explanation text at the bottom of the permission dialog
  // and changes the text on the add/cancel buttons.
  bool text_only() const;

  // The explanation text to be added for text only experiments.
  base::string16 GetExplanationText() const;

  // The text for the accept button for text only experiments.
  base::string16 GetOkButtonText() const;

  // The text for the cancel button for text only experiments.
  base::string16 GetCancelButtonText() const;

  // Returns true if the text color should be highlighted for the given
  // permission message.
  bool ShouldHighlightText(const base::string16& message) const;

  // Returns true if the text background should be highlighted for the given
  // permission message.
  bool ShouldHighlightBackground(const base::string16& message) const;

  // Returns true if there should be a "Show details" link at the bottom of the
  // permission dialog.
  bool show_details_link() const;

  // Returns true if there should be checkboxes next to permissions for the
  // user to click.
  bool show_checkboxes() const;

  // Returns true if the permission list should be hidden by default and can
  // be expanded when necessary.
  bool should_show_expandable_permission_list() const;

  // Returns true if the experiment should show inline explanations for
  // permissions.
  bool should_show_inline_explanations() const;

  // Returns the inline explanation text for the given permission warning.
  // Returns empty string if there is no corresponding inline explanation.
  base::string16 GetInlineExplanation(const base::string16& message) const;

 private:
  friend class base::RefCounted<ExtensionInstallPromptExperiment>;
  ~ExtensionInstallPromptExperiment();

  // Group id of the experiment. The zeroth group is the control group.
  const unsigned int group_id_;
  // Bitmask for the changes done to the UI by the experiment. An experiment can
  // change multiple parts of the UI.
  const unsigned int flags_;

  DISALLOW_COPY_AND_ASSIGN(ExtensionInstallPromptExperiment);
};

#endif  // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_EXPERIMENT_H_