15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This code glues the RLZ library DLL with Chrome. It allows Chrome to work 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// with or without the DLL being present. If the DLL is not present the 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// functions do nothing and just return false. 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/rlz/rlz.h" 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <algorithm> 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/bind.h" 142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/command_line.h" 152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/debug/trace_event.h" 169ab5563a3196760eb381d102cbb2bc0f7abc6a50Ben Murdoch#include "base/message_loop/message_loop.h" 172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/prefs/pref_service.h" 18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string_util.h" 19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/utf_string_conversions.h" 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/browser_process.h" 217dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "chrome/browser/chrome_notification_types.h" 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/google/google_util.h" 232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/prefs/session_startup_pref.h" 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/search_engines/template_url.h" 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/search_engines/template_url_service.h" 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/search_engines/template_url_service_factory.h" 272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/startup/startup_browser_creator.h" 282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/common/chrome_switches.h" 292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/common/pref_names.h" 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/browser_thread.h" 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/navigation_entry.h" 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_service.h" 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/http/http_util.h" 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN) 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/installer/util/google_update_settings.h" 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace GoogleUpdateSettings { 39d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles)static bool GetLanguage(base::string16* language) { 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(thakis): Implement. 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NOTIMPLEMENTED(); 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return false; 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The referral program is defunct and not used. No need to implement these 462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// functions on non-Win platforms. 47d57369da7c6519fef57db42085f7b42d4c8845c1Torne (Richard Coles)static bool GetReferral(base::string16* referral) { 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return true; 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)static bool ClearReferral() { 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return true; 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace GoogleUpdateSettings 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using content::BrowserThread; 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using content::NavigationEntry; 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace { 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Maximum and minimum delay for financial ping we would allow to be set through 622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// master preferences. Somewhat arbitrary, may need to be adjusted in future. 632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const base::TimeDelta kMaxInitDelay = base::TimeDelta::FromSeconds(200); 642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const base::TimeDelta kMinInitDelay = base::TimeDelta::FromSeconds(20); 652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool IsBrandOrganic(const std::string& brand) { 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return brand.empty() || google_util::IsOrganic(brand); 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void RecordProductEvents(bool first_run, 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_google_default_search, 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_google_homepage, 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_google_in_startpages, 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool already_ran, 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool omnibox_used, 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool homepage_used) { 772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) TRACE_EVENT0("RLZ", "RecordProductEvents"); 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Record the installation of chrome. We call this all the time but the rlz 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // lib should ignore all but the first one. 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::RecordProductEvent(rlz_lib::CHROME, 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RLZTracker::CHROME_OMNIBOX, 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::INSTALL); 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::RecordProductEvent(rlz_lib::CHROME, 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RLZTracker::CHROME_HOME_PAGE, 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::INSTALL); 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!already_ran) { 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Do the initial event recording if is the first run or if we have an 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // empty rlz which means we haven't got a chance to do it. 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) char omnibox_rlz[rlz_lib::kMaxRlzLength + 1]; 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!rlz_lib::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, omnibox_rlz, 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::kMaxRlzLength)) { 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) omnibox_rlz[0] = 0; 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Record if google is the initial search provider and/or home page. 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if ((first_run || omnibox_rlz[0] == 0) && is_google_default_search) { 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::RecordProductEvent(rlz_lib::CHROME, 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RLZTracker::CHROME_OMNIBOX, 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::SET_TO_GOOGLE); 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) char homepage_rlz[rlz_lib::kMaxRlzLength + 1]; 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!rlz_lib::GetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, homepage_rlz, 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::kMaxRlzLength)) { 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) homepage_rlz[0] = 0; 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if ((first_run || homepage_rlz[0] == 0) && 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) (is_google_homepage || is_google_in_startpages)) { 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::RecordProductEvent(rlz_lib::CHROME, 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RLZTracker::CHROME_HOME_PAGE, 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::SET_TO_GOOGLE); 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Record first user interaction with the omnibox. We call this all the 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // time but the rlz lib should ingore all but the first one. 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (omnibox_used) { 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::RecordProductEvent(rlz_lib::CHROME, 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RLZTracker::CHROME_OMNIBOX, 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::FIRST_SEARCH); 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Record first user interaction with the home page. We call this all the 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // time but the rlz lib should ingore all but the first one. 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (homepage_used || is_google_in_startpages) { 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::RecordProductEvent(rlz_lib::CHROME, 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RLZTracker::CHROME_HOME_PAGE, 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::FIRST_SEARCH); 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)bool SendFinancialPing(const std::string& brand, 135a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16& lang, 136a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16& referral) { 1371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) rlz_lib::AccessPoint points[] = {RLZTracker::CHROME_OMNIBOX, 1381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) RLZTracker::CHROME_HOME_PAGE, 1391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) rlz_lib::NO_ACCESS_POINT}; 1401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) std::string lang_ascii(UTF16ToASCII(lang)); 1411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) std::string referral_ascii(UTF16ToASCII(referral)); 1421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) std::string product_signature; 1431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#if defined(OS_CHROMEOS) 1441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) product_signature = "chromeos"; 1451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#else 1461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) product_signature = "chrome"; 1471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#endif 1481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return rlz_lib::SendFinancialPing(rlz_lib::CHROME, points, 1491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) product_signature.c_str(), 1501e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) brand.c_str(), referral_ascii.c_str(), 1511e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) lang_ascii.c_str(), false, true); 1521e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 1531e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(OS_WIN) 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const rlz_lib::AccessPoint RLZTracker::CHROME_OMNIBOX = 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::CHROME_OMNIBOX; 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const rlz_lib::AccessPoint RLZTracker::CHROME_HOME_PAGE = 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::CHROME_HOME_PAGE; 1631e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#elif defined(OS_IOS) 1641e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// static 1651e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)const rlz_lib::AccessPoint RLZTracker::CHROME_OMNIBOX = 1661e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) rlz_lib::CHROME_IOS_OMNIBOX; 1671e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// static 1681e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)const rlz_lib::AccessPoint RLZTracker::CHROME_HOME_PAGE = 1691e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) rlz_lib::CHROME_IOS_HOME_PAGE; 1702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#elif defined(OS_MACOSX) 1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const rlz_lib::AccessPoint RLZTracker::CHROME_OMNIBOX = 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::CHROME_MAC_OMNIBOX; 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const rlz_lib::AccessPoint RLZTracker::CHROME_HOME_PAGE = 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::CHROME_MAC_HOME_PAGE; 1772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#elif defined(OS_CHROMEOS) 1782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static 1792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const rlz_lib::AccessPoint RLZTracker::CHROME_OMNIBOX = 1802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) rlz_lib::CHROMEOS_OMNIBOX; 1812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static 1822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const rlz_lib::AccessPoint RLZTracker::CHROME_HOME_PAGE = 1832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) rlz_lib::CHROMEOS_HOME_PAGE; 1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1861e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)RLZTracker* RLZTracker::tracker_ = NULL; 1871e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static 1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)RLZTracker* RLZTracker::GetInstance() { 1901e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return tracker_ ? tracker_ : Singleton<RLZTracker>::get(); 1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)RLZTracker::RLZTracker() 1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) : first_run_(false), 1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) send_ping_immediately_(false), 1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) is_google_default_search_(false), 1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) is_google_homepage_(false), 1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) is_google_in_startpages_(false), 1992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) worker_pool_token_(BrowserThread::GetBlockingPool()->GetSequenceToken()), 2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) already_ran_(false), 2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) omnibox_used_(false), 2022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) homepage_used_(false), 2032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) min_init_delay_(kMinInitDelay) { 2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)RLZTracker::~RLZTracker() { 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool RLZTracker::InitRlzDelayed(bool first_run, 2112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool send_ping_immediately, 2122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::TimeDelta delay, 2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_google_default_search, 2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_google_homepage, 2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_google_in_startpages) { 2162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return GetInstance()->Init(first_run, send_ping_immediately, delay, 2172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) is_google_default_search, is_google_homepage, 2182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) is_google_in_startpages); 2192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static 2222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool RLZTracker::InitRlzFromProfileDelayed(Profile* profile, 2232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool first_run, 2242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool send_ping_immediately, 2252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::TimeDelta delay) { 2262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool is_google_default_search = false; 2272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) TemplateURLService* template_url_service = 2282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) TemplateURLServiceFactory::GetForProfile(profile); 2292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (template_url_service) { 2302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const TemplateURL* url_template = 2312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) template_url_service->GetDefaultSearchProvider(); 2322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) is_google_default_search = 2332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) url_template && url_template->url_ref().HasGoogleBaseURLs(); 2342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 2352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) PrefService* pref_service = profile->GetPrefs(); 2372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool is_google_homepage = google_util::IsGoogleHomePageUrl( 238eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch GURL(pref_service->GetString(prefs::kHomePage))); 2392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool is_google_in_startpages = false; 2411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#if !defined(OS_IOS) 2421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // iOS does not have a notion of startpages. 2432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) SessionStartupPref session_startup_prefs = 2442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) StartupBrowserCreator::GetSessionStartupPref( 2452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *CommandLine::ForCurrentProcess(), profile); 2462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (session_startup_prefs.type == SessionStartupPref::URLS) { 247eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch is_google_in_startpages = 248eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch std::count_if(session_startup_prefs.urls.begin(), 249eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch session_startup_prefs.urls.end(), 250eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch google_util::IsGoogleHomePageUrl) > 0; 2512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 2521e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#endif 2532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (!InitRlzDelayed(first_run, send_ping_immediately, delay, 2552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) is_google_default_search, is_google_homepage, 2562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) is_google_in_startpages)) { 2572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return false; 2582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 2592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Prime the RLZ cache for the home page access point so that its avaiable 2612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // for the startup page if needed (i.e., when the startup page is set to 2622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // the home page). 2632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetAccessPointRlz(CHROME_HOME_PAGE, NULL); 2642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return true; 2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool RLZTracker::Init(bool first_run, 2692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool send_ping_immediately, 2702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::TimeDelta delay, 2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_google_default_search, 2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_google_homepage, 2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_google_in_startpages) { 2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) first_run_ = first_run; 2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) is_google_default_search_ = is_google_default_search; 2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) is_google_homepage_ = is_google_homepage; 2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) is_google_in_startpages_ = is_google_in_startpages; 2782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) send_ping_immediately_ = send_ping_immediately; 2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Enable zero delays for testing. 2812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType)) 2822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EnableZeroDelayForTesting(); 2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) delay = std::min(kMaxInitDelay, std::max(min_init_delay_, delay)); 2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (google_util::GetBrand(&brand_) && !IsBrandOrganic(brand_)) { 2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Register for notifications from the omnibox so that we can record when 2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the user performs a first search. 2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, 2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::NotificationService::AllSources()); 2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Register for notifications from navigations, to see if the user has used 2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the home page. 2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, 2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::NotificationService::AllSources()); 2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) google_util::GetReactivationBrand(&reactivation_brand_); 2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 299c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) net::URLRequestContextGetter* context_getter = 300c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) g_browser_process->system_request_context(); 301c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 302c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Could be NULL; don't run if so. RLZ will try again next restart. 303c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) if (context_getter) { 304c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) rlz_lib::SetURLRequestContext(context_getter); 305c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ScheduleDelayedInit(delay); 306c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) } 3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return true; 3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RLZTracker::ScheduleDelayedInit(base::TimeDelta delay) { 3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The RLZTracker is a singleton object that outlives any runnable tasks 3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // that will be queued up. 3142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) BrowserThread::GetBlockingPool()->PostDelayedSequencedWorkerTask( 3152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) worker_pool_token_, 3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) FROM_HERE, 3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::Bind(&RLZTracker::DelayedInit, base::Unretained(this)), 3182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) delay); 3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void RLZTracker::DelayedInit() { 3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool schedule_ping = false; 3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // For organic brandcodes do not use rlz at all. Empty brandcode usually 3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // means a chromium install. This is ok. 3262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (!IsBrandOrganic(brand_)) { 3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RecordProductEvents(first_run_, is_google_default_search_, 3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) is_google_homepage_, is_google_in_startpages_, 3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) already_ran_, omnibox_used_, homepage_used_); 3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) schedule_ping = true; 3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If chrome has been reactivated, record the events for this brand 3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // as well. 3352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (!IsBrandOrganic(reactivation_brand_)) { 3362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) rlz_lib::SupplementaryBranding branding(reactivation_brand_.c_str()); 3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RecordProductEvents(first_run_, is_google_default_search_, 3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) is_google_homepage_, is_google_in_startpages_, 3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) already_ran_, omnibox_used_, homepage_used_); 3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) schedule_ping = true; 3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) already_ran_ = true; 3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (schedule_ping) 3461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) ScheduleFinancialPing(); 3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)void RLZTracker::ScheduleFinancialPing() { 350ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch BrowserThread::GetBlockingPool()->PostSequencedWorkerTaskWithShutdownBehavior( 3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) worker_pool_token_, 3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) FROM_HERE, 3531e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) base::Bind(&RLZTracker::PingNowImpl, base::Unretained(this)), 354ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); 3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3571e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)void RLZTracker::PingNowImpl() { 3581e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) TRACE_EVENT0("RLZ", "RLZTracker::PingNowImpl"); 359a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16 lang; 3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GoogleUpdateSettings::GetLanguage(&lang); 3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (lang.empty()) 3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lang = ASCIIToUTF16("en"); 363a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16 referral; 3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GoogleUpdateSettings::GetReferral(&referral); 3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3661e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (!IsBrandOrganic(brand_) && SendFinancialPing(brand_, lang, referral)) { 3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GoogleUpdateSettings::ClearReferral(); 3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) { 3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::AutoLock lock(cache_lock_); 3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_cache_.clear(); 3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Prime the RLZ cache for the access points we are interested in. 3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, NULL); 3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, NULL); 3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (!IsBrandOrganic(reactivation_brand_)) { 3802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) rlz_lib::SupplementaryBranding branding(reactivation_brand_.c_str()); 3811e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) SendFinancialPing(reactivation_brand_, lang, referral); 3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool RLZTracker::SendFinancialPing(const std::string& brand, 386a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16& lang, 387a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16& referral) { 3881e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return ::SendFinancialPing(brand, lang, referral); 3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void RLZTracker::Observe(int type, 3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NotificationSource& source, 3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NotificationDetails& details) { 3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) switch (type) { 3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) case chrome::NOTIFICATION_OMNIBOX_OPENED_URL: 3961e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) RecordFirstSearch(CHROME_OMNIBOX); 3975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) registrar_.Remove(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, 3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::NotificationService::AllSources()); 3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) break; 4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) case content::NOTIFICATION_NAV_ENTRY_PENDING: { 4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const NavigationEntry* entry = 4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::Details<content::NavigationEntry>(details).ptr(); 4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (entry != NULL && 4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ((entry->GetTransitionType() & 4055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::PAGE_TRANSITION_HOME_PAGE) != 0)) { 4061e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) RecordFirstSearch(CHROME_HOME_PAGE); 4075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING, 4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::NotificationService::AllSources()); 4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) break; 4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) default: 4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NOTREACHED(); 4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) break; 4155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static 4191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)bool RLZTracker::RecordProductEvent(rlz_lib::Product product, 4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::AccessPoint point, 4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_lib::Event event_id) { 4221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return GetInstance()->RecordProductEventImpl(product, point, event_id); 4232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 4242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool RLZTracker::RecordProductEventImpl(rlz_lib::Product product, 4262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) rlz_lib::AccessPoint point, 4272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) rlz_lib::Event event_id) { 4281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Make sure we don't access disk outside of the I/O thread. 4291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // In such case we repost the task on the right thread and return error. 4301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (ScheduleRecordProductEvent(product, point, event_id)) 4311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return true; 4321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool ret = rlz_lib::RecordProductEvent(product, point, event_id); 4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If chrome has been reactivated, record the event for this brand as well. 4362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (!reactivation_brand_.empty()) { 4372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) rlz_lib::SupplementaryBranding branding(reactivation_brand_.c_str()); 4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ret &= rlz_lib::RecordProductEvent(product, point, event_id); 4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return ret; 4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)bool RLZTracker::ScheduleRecordProductEvent(rlz_lib::Product product, 4452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) rlz_lib::AccessPoint point, 4462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) rlz_lib::Event event_id) { 4471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) 4481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return false; 4491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 450ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch BrowserThread::GetBlockingPool()->PostSequencedWorkerTaskWithShutdownBehavior( 4512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) worker_pool_token_, 4522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) FROM_HERE, 4531e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) base::Bind(base::IgnoreResult(&RLZTracker::RecordProductEvent), 454ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch product, point, event_id), 455ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); 4561e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 4571e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return true; 4582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 4592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4601e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)void RLZTracker::RecordFirstSearch(rlz_lib::AccessPoint point) { 4611e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Make sure we don't access disk outside of the I/O thread. 4621e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // In such case we repost the task on the right thread and return error. 4631e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (ScheduleRecordFirstSearch(point)) 4641e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return; 4651e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 4662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool* record_used = point == CHROME_OMNIBOX ? 4672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) &omnibox_used_ : &homepage_used_; 4682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Try to record event now, else set the flag to try later when we 4702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // attempt the ping. 4711e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (!RecordProductEvent(rlz_lib::CHROME, point, rlz_lib::FIRST_SEARCH)) 4722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *record_used = true; 4732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) else if (send_ping_immediately_ && point == CHROME_OMNIBOX) 4742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ScheduleDelayedInit(base::TimeDelta()); 4752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 4762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4771e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)bool RLZTracker::ScheduleRecordFirstSearch(rlz_lib::AccessPoint point) { 4781e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) 4791e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return false; 480ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch BrowserThread::GetBlockingPool()->PostSequencedWorkerTaskWithShutdownBehavior( 4812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) worker_pool_token_, 4822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) FROM_HERE, 4831e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) base::Bind(&RLZTracker::RecordFirstSearch, 484ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch base::Unretained(this), point), 485ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); 4861e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return true; 4872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 4882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static 4905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)std::string RLZTracker::GetAccessPointHttpHeader(rlz_lib::AccessPoint point) { 4912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) TRACE_EVENT0("RLZ", "RLZTracker::GetAccessPointHttpHeader"); 4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string extra_headers; 493a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16 rlz_string; 4945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RLZTracker::GetAccessPointRlz(point, &rlz_string); 4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!rlz_string.empty()) { 4965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) net::HttpUtil::AppendHeaderIfMissing("X-Rlz-String", 4975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) UTF16ToUTF8(rlz_string), 4985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) &extra_headers); 4995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 5005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return extra_headers; 5025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5041e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// GetAccessPointRlz() caches RLZ strings for all access points. If we had 5051e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// a successful ping, then we update the cached value. 5065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool RLZTracker::GetAccessPointRlz(rlz_lib::AccessPoint point, 507a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16* rlz) { 5082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) TRACE_EVENT0("RLZ", "RLZTracker::GetAccessPointRlz"); 5091e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return GetInstance()->GetAccessPointRlzImpl(point, rlz); 5104e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)} 5115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// GetAccessPointRlz() caches RLZ strings for all access points. If we had 5131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// a successful ping, then we update the cached value. 5141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)bool RLZTracker::GetAccessPointRlzImpl(rlz_lib::AccessPoint point, 515a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16* rlz) { 5161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // If the RLZ string for the specified access point is already cached, 5171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // simply return its value. 5181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) { 5191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) base::AutoLock lock(cache_lock_); 5201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (rlz_cache_.find(point) != rlz_cache_.end()) { 5211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (rlz) 5221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) *rlz = rlz_cache_[point]; 5231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return true; 5241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) } 5251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) } 5261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 5271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Make sure we don't access disk outside of the I/O thread. 5281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // In such case we repost the task on the right thread and return error. 5291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (ScheduleGetAccessPointRlz(point)) 5301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return false; 5311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 5325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) char str_rlz[rlz_lib::kMaxRlzLength + 1]; 5335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!rlz_lib::GetAccessPointRlz(point, str_rlz, rlz_lib::kMaxRlzLength)) 5341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return false; 5355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 536a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16 rlz_local(ASCIIToUTF16(std::string(str_rlz))); 5371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (rlz) 5381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) *rlz = rlz_local; 5391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 5405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::AutoLock lock(cache_lock_); 5415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rlz_cache_[point] = rlz_local; 5421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return true; 5435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)bool RLZTracker::ScheduleGetAccessPointRlz(rlz_lib::AccessPoint point) { 5461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) 5471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return false; 5481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 549a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16* not_used = NULL; 550ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch BrowserThread::GetBlockingPool()->PostSequencedWorkerTaskWithShutdownBehavior( 5515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) worker_pool_token_, 5525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) FROM_HERE, 5531e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) base::Bind(base::IgnoreResult(&RLZTracker::GetAccessPointRlz), point, 5541e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) not_used), 555ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); 5561e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return true; 5575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(OS_CHROMEOS) 5602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static 5612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RLZTracker::ClearRlzState() { 5621e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) GetInstance()->ClearRlzStateImpl(); 5632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 5642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RLZTracker::ClearRlzStateImpl() { 5661e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (ScheduleClearRlzState()) 5671e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return; 5682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) rlz_lib::ClearAllProductEvents(rlz_lib::CHROME); 5692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 5702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5711e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)bool RLZTracker::ScheduleClearRlzState() { 5721e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) 5731e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return false; 5741e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 575ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch BrowserThread::GetBlockingPool()->PostSequencedWorkerTaskWithShutdownBehavior( 5762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) worker_pool_token_, 5772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) FROM_HERE, 5782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::Bind(&RLZTracker::ClearRlzStateImpl, 579ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch base::Unretained(this)), 580ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); 5811e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return true; 5822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 5832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 5842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static 5865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void RLZTracker::CleanupRlz() { 5871e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) GetInstance()->rlz_cache_.clear(); 5881e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) GetInstance()->registrar_.RemoveAll(); 589c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) rlz_lib::SetURLRequestContext(NULL); 5905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static 5932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void RLZTracker::EnableZeroDelayForTesting() { 5942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GetInstance()->min_init_delay_ = base::TimeDelta(); 5952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 596