| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // This code glues the RLZ library DLL with Chrome. It allows Chrome to work | 5 // This code glues the RLZ library DLL with Chrome. It allows Chrome to work |
| 6 // with or without the DLL being present. If the DLL is not present the | 6 // with or without the DLL being present. If the DLL is not present the |
| 7 // functions do nothing and just return false. | 7 // functions do nothing and just return false. |
| 8 | 8 |
| 9 #include "chrome/browser/rlz/rlz.h" | 9 #include "chrome/browser/rlz/rlz.h" |
| 10 | 10 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/debug/trace_event.h" | 15 #include "base/debug/trace_event.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
| 18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/chrome_notification_types.h" | 21 #include "chrome/browser/chrome_notification_types.h" |
| 22 #include "chrome/browser/google/google_brand.h" |
| 22 #include "chrome/browser/google/google_util.h" | 23 #include "chrome/browser/google/google_util.h" |
| 23 #include "chrome/browser/omnibox/omnibox_log.h" | 24 #include "chrome/browser/omnibox/omnibox_log.h" |
| 24 #include "chrome/browser/prefs/session_startup_pref.h" | 25 #include "chrome/browser/prefs/session_startup_pref.h" |
| 25 #include "chrome/browser/search_engines/template_url.h" | 26 #include "chrome/browser/search_engines/template_url.h" |
| 26 #include "chrome/browser/search_engines/template_url_service.h" | 27 #include "chrome/browser/search_engines/template_url_service.h" |
| 27 #include "chrome/browser/search_engines/template_url_service_factory.h" | 28 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 28 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 29 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 29 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 31 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 58 using content::NavigationEntry; | 59 using content::NavigationEntry; |
| 59 | 60 |
| 60 namespace { | 61 namespace { |
| 61 | 62 |
| 62 // Maximum and minimum delay for financial ping we would allow to be set through | 63 // Maximum and minimum delay for financial ping we would allow to be set through |
| 63 // master preferences. Somewhat arbitrary, may need to be adjusted in future. | 64 // master preferences. Somewhat arbitrary, may need to be adjusted in future. |
| 64 const base::TimeDelta kMaxInitDelay = base::TimeDelta::FromSeconds(200); | 65 const base::TimeDelta kMaxInitDelay = base::TimeDelta::FromSeconds(200); |
| 65 const base::TimeDelta kMinInitDelay = base::TimeDelta::FromSeconds(20); | 66 const base::TimeDelta kMinInitDelay = base::TimeDelta::FromSeconds(20); |
| 66 | 67 |
| 67 bool IsBrandOrganic(const std::string& brand) { | 68 bool IsBrandOrganic(const std::string& brand) { |
| 68 return brand.empty() || google_util::IsOrganic(brand); | 69 return brand.empty() || google_brand::IsOrganic(brand); |
| 69 } | 70 } |
| 70 | 71 |
| 71 void RecordProductEvents(bool first_run, | 72 void RecordProductEvents(bool first_run, |
| 72 bool is_google_default_search, | 73 bool is_google_default_search, |
| 73 bool is_google_homepage, | 74 bool is_google_homepage, |
| 74 bool is_google_in_startpages, | 75 bool is_google_in_startpages, |
| 75 bool already_ran, | 76 bool already_ran, |
| 76 bool omnibox_used, | 77 bool omnibox_used, |
| 77 bool homepage_used, | 78 bool homepage_used, |
| 78 bool app_list_used) { | 79 bool app_list_used) { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 is_google_homepage_ = is_google_homepage; | 285 is_google_homepage_ = is_google_homepage; |
| 285 is_google_in_startpages_ = is_google_in_startpages; | 286 is_google_in_startpages_ = is_google_in_startpages; |
| 286 send_ping_immediately_ = send_ping_immediately; | 287 send_ping_immediately_ = send_ping_immediately; |
| 287 | 288 |
| 288 // Enable zero delays for testing. | 289 // Enable zero delays for testing. |
| 289 if (CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType)) | 290 if (CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType)) |
| 290 EnableZeroDelayForTesting(); | 291 EnableZeroDelayForTesting(); |
| 291 | 292 |
| 292 delay = std::min(kMaxInitDelay, std::max(min_init_delay_, delay)); | 293 delay = std::min(kMaxInitDelay, std::max(min_init_delay_, delay)); |
| 293 | 294 |
| 294 if (google_util::GetBrand(&brand_) && !IsBrandOrganic(brand_)) { | 295 if (google_brand::GetBrand(&brand_) && !IsBrandOrganic(brand_)) { |
| 295 // Register for notifications from the omnibox so that we can record when | 296 // Register for notifications from the omnibox so that we can record when |
| 296 // the user performs a first search. | 297 // the user performs a first search. |
| 297 registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, | 298 registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, |
| 298 content::NotificationService::AllSources()); | 299 content::NotificationService::AllSources()); |
| 299 | 300 |
| 300 #if !defined(OS_IOS) | 301 #if !defined(OS_IOS) |
| 301 // Register for notifications from navigations, to see if the user has used | 302 // Register for notifications from navigations, to see if the user has used |
| 302 // the home page. | 303 // the home page. |
| 303 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, | 304 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, |
| 304 content::NotificationService::AllSources()); | 305 content::NotificationService::AllSources()); |
| 305 #endif // !defined(OS_IOS) | 306 #endif // !defined(OS_IOS) |
| 306 } | 307 } |
| 307 google_util::GetReactivationBrand(&reactivation_brand_); | 308 google_brand::GetReactivationBrand(&reactivation_brand_); |
| 308 | 309 |
| 309 net::URLRequestContextGetter* context_getter = | 310 net::URLRequestContextGetter* context_getter = |
| 310 g_browser_process->system_request_context(); | 311 g_browser_process->system_request_context(); |
| 311 | 312 |
| 312 // Could be NULL; don't run if so. RLZ will try again next restart. | 313 // Could be NULL; don't run if so. RLZ will try again next restart. |
| 313 if (context_getter) { | 314 if (context_getter) { |
| 314 rlz_lib::SetURLRequestContext(context_getter); | 315 rlz_lib::SetURLRequestContext(context_getter); |
| 315 ScheduleDelayedInit(delay); | 316 ScheduleDelayedInit(delay); |
| 316 } | 317 } |
| 317 | 318 |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 void RLZTracker::EnableZeroDelayForTesting() { | 629 void RLZTracker::EnableZeroDelayForTesting() { |
| 629 GetInstance()->min_init_delay_ = base::TimeDelta(); | 630 GetInstance()->min_init_delay_ = base::TimeDelta(); |
| 630 } | 631 } |
| 631 | 632 |
| 632 #if !defined(OS_IOS) | 633 #if !defined(OS_IOS) |
| 633 // static | 634 // static |
| 634 void RLZTracker::RecordAppListSearch() { | 635 void RLZTracker::RecordAppListSearch() { |
| 635 GetInstance()->RecordFirstSearch(RLZTracker::ChromeAppList()); | 636 GetInstance()->RecordFirstSearch(RLZTracker::ChromeAppList()); |
| 636 } | 637 } |
| 637 #endif | 638 #endif |
| OLD | NEW |