summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/experience_sampling_private/experience_sampling.h
blob: 398b0c496b5aafcaa256001cb2a0fc150e58e1f3 (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
// Copyright 2014 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_API_EXPERIENCE_SAMPLING_PRIVATE_EXPERIENCE_SAMPLING_H_
#define CHROME_BROWSER_EXTENSIONS_API_EXPERIENCE_SAMPLING_PRIVATE_EXPERIENCE_SAMPLING_H_

#include "base/macros.h"
#include "chrome/common/extensions/api/experience_sampling_private.h"

namespace content {
class BrowserContext;
}

class GURL;

namespace extensions {

using api::experience_sampling_private::UIElement;

class ExperienceSamplingEvent {
 public:
  // String constants for user decision events.
  static const char kProceed[];
  static const char kDeny[];
  static const char kIgnore[];
  static const char kCancel[];
  static const char kReload[];

  // String constants for event names.
  static const char kMaliciousDownload[];
  static const char kDangerousDownload[];
  static const char kDownloadDangerPrompt[];
  static const char kExtensionInstallDialog[];

  // The Create() functions can return an empty scoped_ptr if they cannot find
  // the BrowserContext. Code using them should check the scoped pointer using
  // scoped_ptr::get().
  static scoped_ptr<ExperienceSamplingEvent> Create(
      const std::string& element_name,
      const GURL& destination,
      const GURL& referrer);

  static scoped_ptr<ExperienceSamplingEvent> Create(
      const std::string& element_name);

  ExperienceSamplingEvent(const std::string& element_name,
                          const GURL& destination,
                          const GURL& referrer,
                          content::BrowserContext* browser_context);
  ~ExperienceSamplingEvent();

  // Sends an extension API event for the user seeing this event.
  void CreateOnDisplayedEvent();
  // Sends an extension API event for the user making a decision about this
  // event.
  void CreateUserDecisionEvent(const std::string& decision_name);

  bool has_viewed_details() const { return has_viewed_details_; }
  void set_has_viewed_details(bool viewed) { has_viewed_details_ = viewed; }
  bool has_viewed_learn_more() const { return has_viewed_learn_more_; }
  void set_has_viewed_learn_more(bool viewed) {
    has_viewed_learn_more_ = viewed;
  }

 private:
  bool has_viewed_details_;
  bool has_viewed_learn_more_;
  content::BrowserContext* browser_context_;
  UIElement ui_element_;

  DISALLOW_COPY_AND_ASSIGN(ExperienceSamplingEvent);
};

}  // namespace extensions

#endif  // CHROME_BROWSER_EXTENSIONS_API_EXPERIENCE_SAMPLING_PRIVATE_EXPERIENCE_SAMPLING_H_