Home | History | Annotate | Download | only in experience_sampling_private
      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.
      4 
      5 #ifndef CHROME_BROWSER_EXTENSIONS_API_EXPERIENCE_SAMPLING_PRIVATE_EXPERIENCE_SAMPLING_H_
      6 #define CHROME_BROWSER_EXTENSIONS_API_EXPERIENCE_SAMPLING_PRIVATE_EXPERIENCE_SAMPLING_H_
      7 
      8 #include "chrome/common/extensions/api/experience_sampling_private.h"
      9 
     10 namespace content {
     11 class BrowserContext;
     12 }
     13 
     14 class GURL;
     15 
     16 namespace extensions {
     17 
     18 using api::experience_sampling_private::UIElement;
     19 
     20 class ExperienceSamplingEvent {
     21  public:
     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[];
     28 
     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[];
     34 
     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
     37   // scoped_ptr::get().
     38   static scoped_ptr<ExperienceSamplingEvent> Create(
     39       const std::string& element_name,
     40       const GURL& destination,
     41       const GURL& referrer);
     42 
     43   static scoped_ptr<ExperienceSamplingEvent> Create(
     44       const std::string& element_name);
     45 
     46   ExperienceSamplingEvent(const std::string& element_name,
     47                           const GURL& destination,
     48                           const GURL& referrer,
     49                           content::BrowserContext* browser_context);
     50   ~ExperienceSamplingEvent();
     51 
     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
     55   // event.
     56   void CreateUserDecisionEvent(const std::string& decision_name);
     57 
     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;
     63   }
     64 
     65  private:
     66   bool has_viewed_details_;
     67   bool has_viewed_learn_more_;
     68   content::BrowserContext* browser_context_;
     69   UIElement ui_element_;
     70 
     71   DISALLOW_COPY_AND_ASSIGN(ExperienceSamplingEvent);
     72 };
     73 
     74 }  // namespace extensions
     75 
     76 #endif  // CHROME_BROWSER_EXTENSIONS_API_EXPERIENCE_SAMPLING_PRIVATE_EXPERIENCE_SAMPLING_H_
     77