Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: chrome/browser/rlz/rlz.cc

Issue 11412067: [rlz,cros] RLZ glue for ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile fix Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/message_loop.h" 15 #include "base/message_loop.h"
15 #include "base/string_util.h" 16 #include "base/string_util.h"
16 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
17 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/google/google_util.h" 19 #include "chrome/browser/google/google_util.h"
20 #include "chrome/browser/prefs/pref_service.h"
21 #include "chrome/browser/prefs/session_startup_pref.h"
19 #include "chrome/browser/search_engines/template_url.h" 22 #include "chrome/browser/search_engines/template_url.h"
20 #include "chrome/browser/search_engines/template_url_service.h" 23 #include "chrome/browser/search_engines/template_url_service.h"
21 #include "chrome/browser/search_engines/template_url_service_factory.h" 24 #include "chrome/browser/search_engines/template_url_service_factory.h"
25 #include "chrome/browser/ui/startup/startup_browser_creator.cc"
22 #include "chrome/common/chrome_notification_types.h" 26 #include "chrome/common/chrome_notification_types.h"
23 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/navigation_entry.h" 28 #include "content/public/browser/navigation_entry.h"
25 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
26 #include "net/http/http_util.h" 30 #include "net/http/http_util.h"
27 31
28 #if defined(OS_CHROMEOS) 32 #if defined(OS_CHROMEOS)
29 #include "base/threading/sequenced_worker_pool.h" 33 #include "base/threading/sequenced_worker_pool.h"
30 #endif 34 #endif
31 35
(...skipping 18 matching lines...) Expand all
50 } // namespace GoogleUpdateSettings 54 } // namespace GoogleUpdateSettings
51 #endif 55 #endif
52 56
53 using content::BrowserThread; 57 using content::BrowserThread;
54 using content::NavigationEntry; 58 using content::NavigationEntry;
55 59
56 namespace { 60 namespace {
57 61
58 const char kRlzThreadName[] = "RLZ_thread"; 62 const char kRlzThreadName[] = "RLZ_thread";
59 63
64 bool IsGoogleUrl(const GURL& url) {
65 return google_util::IsGoogleHomePageUrl(url.possibly_invalid_spec());
66 }
67
60 bool IsBrandOrganic(const std::string& brand) { 68 bool IsBrandOrganic(const std::string& brand) {
61 return brand.empty() || google_util::IsOrganic(brand); 69 return brand.empty() || google_util::IsOrganic(brand);
62 } 70 }
63 71
64 void RecordProductEvents(bool first_run, 72 void RecordProductEvents(bool first_run,
65 bool is_google_default_search, 73 bool is_google_default_search,
66 bool is_google_homepage, 74 bool is_google_homepage,
67 bool is_google_in_startpages, 75 bool is_google_in_startpages,
68 bool already_ran, 76 bool already_ran,
69 bool omnibox_used, 77 bool omnibox_used,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 // static 197 // static
190 bool RLZTracker::InitRlzDelayed(bool first_run, 198 bool RLZTracker::InitRlzDelayed(bool first_run,
191 int delay, 199 int delay,
192 bool is_google_default_search, 200 bool is_google_default_search,
193 bool is_google_homepage, 201 bool is_google_homepage,
194 bool is_google_in_startpages) { 202 bool is_google_in_startpages) {
195 return GetInstance()->Init(first_run, delay, is_google_default_search, 203 return GetInstance()->Init(first_run, delay, is_google_default_search,
196 is_google_homepage, is_google_in_startpages); 204 is_google_homepage, is_google_in_startpages);
197 } 205 }
198 206
207 // static
208 bool RLZTracker::InitRlzFromProfileDelayed(Profile* profile,
209 bool first_run,
210 int delay) {
211 bool is_google_default_search = false;
212 TemplateURLService* template_url_service =
213 TemplateURLServiceFactory::GetForProfile(profile);
214 if (template_url_service) {
215 const TemplateURL* url_template =
216 template_url_service->GetDefaultSearchProvider();
217 is_google_default_search =
218 url_template && url_template->url_ref().HasGoogleBaseURLs();
219 }
220
221 PrefService* pref_service = profile->GetPrefs();
222 bool is_google_homepage = google_util::IsGoogleHomePageUrl(
223 pref_service->GetString(prefs::kHomePage));
224
225 bool is_google_in_startpages = false;
226 SessionStartupPref session_startup_prefs =
227 StartupBrowserCreator::GetSessionStartupPref(
228 *CommandLine::ForCurrentProcess(), profile);
229 if (session_startup_prefs.type == SessionStartupPref::URLS) {
230 is_google_in_startpages = std::count_if(session_startup_prefs.urls.begin(),
231 session_startup_prefs.urls.end(),
232 IsGoogleUrl) > 0;
233 }
234
235 if (!InitRlzDelayed(first_run, delay,
236 is_google_default_search, is_google_homepage,
237 is_google_in_startpages)) {
238 return false;
239 }
240
241 // Prime the RLZ cache for the home page access point so that its avaiable
242 // for the startup page if needed (i.e., when the startup page is set to
243 // the home page).
244 GetAccessPointRlz(CHROME_HOME_PAGE, NULL);
245
246 return true;
247 }
248
199 bool RLZTracker::Init(bool first_run, 249 bool RLZTracker::Init(bool first_run,
200 int delay, 250 int delay,
201 bool is_google_default_search, 251 bool is_google_default_search,
202 bool is_google_homepage, 252 bool is_google_homepage,
203 bool is_google_in_startpages) { 253 bool is_google_in_startpages) {
204 first_run_ = first_run; 254 first_run_ = first_run;
205 is_google_default_search_ = is_google_default_search; 255 is_google_default_search_ = is_google_default_search;
206 is_google_homepage_ = is_google_homepage; 256 is_google_homepage_ = is_google_homepage;
207 is_google_in_startpages_ = is_google_in_startpages; 257 is_google_in_startpages_ = is_google_in_startpages;
208 258
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 string16* not_used = NULL; 569 string16* not_used = NULL;
520 blocking_task_runner_->PostTask( 570 blocking_task_runner_->PostTask(
521 FROM_HERE, 571 FROM_HERE,
522 base::Bind(base::IgnoreResult(&RLZTracker::GetAccessPointRlz), point, 572 base::Bind(base::IgnoreResult(&RLZTracker::GetAccessPointRlz), point,
523 not_used)); 573 not_used));
524 return true; 574 return true;
525 } 575 }
526 576
527 // static 577 // static
528 void RLZTracker::CleanupRlz() { 578 void RLZTracker::CleanupRlz() {
529 GetInstance()->rlz_cache_.clear(); 579 RLZTracker* instance = GetInstance();
530 GetInstance()->registrar_.RemoveAll(); 580 instance->rlz_cache_.clear();
581 instance->registrar_.RemoveAll();
582 #if defined(OS_CHROMEOS)
583 instance->blocking_task_runner_->PostTask(
584 FROM_HERE,
585 base::Bind(&rlz_lib::CleanupRlz));
586 #endif
587 instance->blocking_task_runner_ = NULL;
588 instance->rlz_thread_.Stop();
531 } 589 }
OLDNEW
« chrome/browser/chromeos/login/user_manager_impl.cc ('K') | « chrome/browser/rlz/rlz.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698