Home | History | Annotate | Download | only in rlz
      1 // Copyright (c) 2010 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_RLZ_RLZ_H_
      6 #define CHROME_BROWSER_RLZ_RLZ_H_
      7 #pragma once
      8 
      9 #include "build/build_config.h"
     10 
     11 #if defined(OS_WIN)
     12 
     13 #include <string>
     14 
     15 #include "base/basictypes.h"
     16 #include "rlz/win/lib/rlz_lib.h"
     17 
     18 // RLZ is a library which is used to measure distribution scenarios.
     19 // Its job is to record certain lifetime events in the registry and to send
     20 // them encoded as a compact string at most twice. The sent data does
     21 // not contain information that can be used to identify a user or to infer
     22 // browsing habits. The API in this file is a wrapper around the open source
     23 // RLZ library which can be found at http://code.google.com/p/rlz.
     24 //
     25 // For partner or bundled installs, the RLZ might send more information
     26 // according to the terms disclosed in the EULA.
     27 
     28 class RLZTracker {
     29 
     30  public:
     31   // Like InitRlz() this function initializes the RLZ library services for use
     32   // in chrome. Besides binding the dll, it schedules a delayed task (delayed
     33   // by |delay| seconds) that performs the ping and registers some events
     34   // when 'first-run' is true.
     35   //
     36   // If the chrome brand is organic (no partners) then the RLZ library is not
     37   // loaded or initialized and the pings don't ocurr.
     38   static bool InitRlzDelayed(bool first_run, int delay);
     39 
     40   // Records an RLZ event. Some events can be access point independent.
     41   // Returns false it the event could not be recorded. Requires write access
     42   // to the HKCU registry hive on windows.
     43   static bool RecordProductEvent(rlz_lib::Product product,
     44                                  rlz_lib::AccessPoint point,
     45                                  rlz_lib::Event event_id);
     46 
     47   // Get the RLZ value of the access point.
     48   // Returns false if the rlz string could not be obtained. In some cases
     49   // an empty string can be returned which is not an error.
     50   static bool GetAccessPointRlz(rlz_lib::AccessPoint point, std::wstring* rlz);
     51 
     52   // Clear all events reported by this product. In Chrome this will be called
     53   // when it is un-installed.
     54   static bool ClearAllProductEvents(rlz_lib::Product product);
     55 
     56   // Invoked during shutdown to clean up any state created by RLZTracker.
     57   static void CleanupRlz();
     58 
     59  private:
     60   DISALLOW_IMPLICIT_CONSTRUCTORS(RLZTracker);
     61 };
     62 
     63 #endif  // defined(OS_WIN)
     64 
     65 #endif  // CHROME_BROWSER_RLZ_RLZ_H_
     66