Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / extensions / extension_install_prompt_experiment.h
blob630c1d1a2ac5376e49e8651d65b5f4f271cd11b7
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_EXPERIMENT_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_EXPERIMENT_H_
8 #include "base/memory/ref_counted.h"
10 // Represents a permission dialog experiment.
11 // TODO(meacer): Remove this class once the ExtensionPermissionDialog
12 // experiment is completed (http://crbug.com/308748).
13 class ExtensionInstallPromptExperiment
14 : public base::RefCounted<ExtensionInstallPromptExperiment> {
15 public:
16 ExtensionInstallPromptExperiment(unsigned int group_id, unsigned int flags);
18 // Returns an experiment instance configured by the server. The ownership of
19 // the returned pointer is passed to the caller.
20 static ExtensionInstallPromptExperiment* Find();
22 // Returns an experiment instance for the control group. The ownership of the
23 // returned pointer is passed to the caller.
24 static ExtensionInstallPromptExperiment* ControlGroup();
26 // Returns true if this is a text only experiment. A text only experiment
27 // only adds an explanation text at the bottom of the permission dialog
28 // and changes the text on the add/cancel buttons.
29 bool text_only() const;
31 // The explanation text to be added for text only experiments.
32 base::string16 GetExplanationText() const;
34 // The text for the accept button for text only experiments.
35 base::string16 GetOkButtonText() const;
37 // The text for the cancel button for text only experiments.
38 base::string16 GetCancelButtonText() const;
40 // Returns true if the text color should be highlighted for the given
41 // permission message.
42 bool ShouldHighlightText(const base::string16& message) const;
44 // Returns true if the text background should be highlighted for the given
45 // permission message.
46 bool ShouldHighlightBackground(const base::string16& message) const;
48 // Returns true if there should be a "Show details" link at the bottom of the
49 // permission dialog.
50 bool show_details_link() const;
52 // Returns true if there should be checkboxes next to permissions for the
53 // user to click.
54 bool show_checkboxes() const;
56 // Returns true if the permission list should be hidden by default and can
57 // be expanded when necessary.
58 bool should_show_expandable_permission_list() const;
60 // Returns true if the experiment should show inline explanations for
61 // permissions.
62 bool should_show_inline_explanations() const;
64 // Returns the inline explanation text for the given permission warning.
65 // Returns empty string if there is no corresponding inline explanation.
66 base::string16 GetInlineExplanation(const base::string16& message) const;
68 private:
69 friend class base::RefCounted<ExtensionInstallPromptExperiment>;
70 ~ExtensionInstallPromptExperiment();
72 // Group id of the experiment. The zeroth group is the control group.
73 const unsigned int group_id_;
74 // Bitmask for the changes done to the UI by the experiment. An experiment can
75 // change multiple parts of the UI.
76 const unsigned int flags_;
78 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallPromptExperiment);
81 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_EXPERIMENT_H_