1 // Copyright 2014 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_API_EXPERIENCE_SAMPLING_PRIVATE_EXPERIENCE_SAMPLING_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_EXPERIENCE_SAMPLING_PRIVATE_EXPERIENCE_SAMPLING_H_
8 #include "chrome/common/extensions/api/experience_sampling_private.h"
16 namespace extensions
{
18 using api::experience_sampling_private::UIElement
;
20 class ExperienceSamplingEvent
{
22 // String constants for user decision events.
23 static const char kProceed
[];
24 static const char kDeny
[];
25 static const char kIgnore
[];
26 static const char kCancel
[];
27 static const char kReload
[];
29 // String constants for event names.
30 static const char kMaliciousDownload
[];
31 static const char kDangerousDownload
[];
32 static const char kDownloadDangerPrompt
[];
33 static const char kExtensionInstallDialog
[];
35 // The Create() functions can return an empty scoped_ptr if they cannot find
36 // the BrowserContext. Code using them should check the scoped pointer using
38 static scoped_ptr
<ExperienceSamplingEvent
> Create(
39 const std::string
& element_name
,
40 const GURL
& destination
,
41 const GURL
& referrer
);
43 static scoped_ptr
<ExperienceSamplingEvent
> Create(
44 const std::string
& element_name
);
46 ExperienceSamplingEvent(const std::string
& element_name
,
47 const GURL
& destination
,
49 content::BrowserContext
* browser_context
);
50 ~ExperienceSamplingEvent();
52 // Sends an extension API event for the user seeing this event.
53 void CreateOnDisplayedEvent();
54 // Sends an extension API event for the user making a decision about this
56 void CreateUserDecisionEvent(const std::string
& decision_name
);
58 bool has_viewed_details() const { return has_viewed_details_
; }
59 void set_has_viewed_details(bool viewed
) { has_viewed_details_
= viewed
; }
60 bool has_viewed_learn_more() const { return has_viewed_learn_more_
; }
61 void set_has_viewed_learn_more(bool viewed
) {
62 has_viewed_learn_more_
= viewed
;
66 bool has_viewed_details_
;
67 bool has_viewed_learn_more_
;
68 content::BrowserContext
* browser_context_
;
69 UIElement ui_element_
;
71 DISALLOW_COPY_AND_ASSIGN(ExperienceSamplingEvent
);
74 } // namespace extensions
76 #endif // CHROME_BROWSER_EXTENSIONS_API_EXPERIENCE_SAMPLING_PRIVATE_EXPERIENCE_SAMPLING_H_