| 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 #include "chrome/browser/chrome_browser_main.h" | 5 #include "chrome/browser/chrome_browser_main.h" |
| 6 | 6 |
| 7 #if defined(TOOLKIT_GTK) | 7 #if defined(TOOLKIT_GTK) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include <algorithm> | |
| 12 #include <string> | 11 #include <string> |
| 13 #include <vector> | 12 #include <vector> |
| 14 | 13 |
| 15 #include "base/at_exit.h" | 14 #include "base/at_exit.h" |
| 16 #include "base/bind.h" | 15 #include "base/bind.h" |
| 17 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 18 #include "base/debug/trace_event.h" | 17 #include "base/debug/trace_event.h" |
| 19 #include "base/file_path.h" | 18 #include "base/file_path.h" |
| 20 #include "base/file_util.h" | 19 #include "base/file_util.h" |
| 21 #include "base/metrics/field_trial.h" | 20 #include "base/metrics/field_trial.h" |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 StartupBrowserCreator::ProcessCommandLineAlreadyRunning( | 411 StartupBrowserCreator::ProcessCommandLineAlreadyRunning( |
| 413 command_line, current_directory); | 412 command_line, current_directory); |
| 414 return true; | 413 return true; |
| 415 } | 414 } |
| 416 | 415 |
| 417 bool HasImportSwitch(const CommandLine& command_line) { | 416 bool HasImportSwitch(const CommandLine& command_line) { |
| 418 return (command_line.HasSwitch(switches::kImport) || | 417 return (command_line.HasSwitch(switches::kImport) || |
| 419 command_line.HasSwitch(switches::kImportFromFile)); | 418 command_line.HasSwitch(switches::kImportFromFile)); |
| 420 } | 419 } |
| 421 | 420 |
| 422 #if defined(ENABLE_RLZ) | |
| 423 bool IsGoogleUrl(const GURL& url) { | |
| 424 return google_util::IsGoogleHomePageUrl(url.possibly_invalid_spec()); | |
| 425 } | |
| 426 #endif | |
| 427 | |
| 428 } // namespace | 421 } // namespace |
| 429 | 422 |
| 430 namespace chrome_browser { | 423 namespace chrome_browser { |
| 431 // This error message is not localized because we failed to load the | 424 // This error message is not localized because we failed to load the |
| 432 // localization data files. | 425 // localization data files. |
| 433 const char kMissingLocaleDataTitle[] = "Missing File Error"; | 426 const char kMissingLocaleDataTitle[] = "Missing File Error"; |
| 434 const char kMissingLocaleDataMessage[] = | 427 const char kMissingLocaleDataMessage[] = |
| 435 "Unable to find locale data files. Please reinstall."; | 428 "Unable to find locale data files. Please reinstall."; |
| 436 } // namespace chrome_browser | 429 } // namespace chrome_browser |
| 437 | 430 |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 // Verify that the profile is not on a network share and if so prepare to show | 1191 // Verify that the profile is not on a network share and if so prepare to show |
| 1199 // notification to the user. | 1192 // notification to the user. |
| 1200 if (NetworkProfileBubble::ShouldCheckNetworkProfile(profile_)) { | 1193 if (NetworkProfileBubble::ShouldCheckNetworkProfile(profile_)) { |
| 1201 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, | 1194 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, |
| 1202 base::Bind(&NetworkProfileBubble::CheckNetworkProfile, | 1195 base::Bind(&NetworkProfileBubble::CheckNetworkProfile, |
| 1203 profile_->GetPath())); | 1196 profile_->GetPath())); |
| 1204 } | 1197 } |
| 1205 #endif // OS_WIN | 1198 #endif // OS_WIN |
| 1206 | 1199 |
| 1207 #if defined(ENABLE_RLZ) && !defined(OS_CHROMEOS) | 1200 #if defined(ENABLE_RLZ) && !defined(OS_CHROMEOS) |
| 1208 // TODO(ivankr): do this on user login on ChromeOS. | |
| 1209 // Init the RLZ library. This just binds the dll and schedules a task on the | 1201 // Init the RLZ library. This just binds the dll and schedules a task on the |
| 1210 // file thread to be run sometime later. If this is the first run we record | 1202 // file thread to be run sometime later. If this is the first run we record |
| 1211 // the installation event. | 1203 // the installation event. |
| 1212 bool is_google_default_search = false; | |
| 1213 TemplateURLService* template_url_service = | |
| 1214 TemplateURLServiceFactory::GetForProfile(profile_); | |
| 1215 if (template_url_service) { | |
| 1216 const TemplateURL* url_template = | |
| 1217 template_url_service->GetDefaultSearchProvider(); | |
| 1218 is_google_default_search = | |
| 1219 url_template && url_template->url_ref().HasGoogleBaseURLs(); | |
| 1220 } | |
| 1221 | |
| 1222 PrefService* pref_service = profile_->GetPrefs(); | 1204 PrefService* pref_service = profile_->GetPrefs(); |
| 1223 bool is_google_homepage = google_util::IsGoogleHomePageUrl( | |
| 1224 pref_service->GetString(prefs::kHomePage)); | |
| 1225 | |
| 1226 bool is_google_in_startpages = false; | |
| 1227 SessionStartupPref session_startup_prefs = | |
| 1228 StartupBrowserCreator::GetSessionStartupPref(parsed_command_line(), | |
| 1229 profile_); | |
| 1230 if (session_startup_prefs.type == SessionStartupPref::URLS) { | |
| 1231 is_google_in_startpages = std::count_if(session_startup_prefs.urls.begin(), | |
| 1232 session_startup_prefs.urls.end(), | |
| 1233 IsGoogleUrl) > 0; | |
| 1234 } | |
| 1235 | |
| 1236 int ping_delay = is_first_run_ ? master_prefs_->ping_delay : | 1205 int ping_delay = is_first_run_ ? master_prefs_->ping_delay : |
| 1237 pref_service->GetInteger(first_run::GetPingDelayPrefName().c_str()); | 1206 pref_service->GetInteger(first_run::GetPingDelayPrefName().c_str()); |
| 1238 RLZTracker::InitRlzDelayed(is_first_run_, ping_delay, | 1207 RLZTracker::InitRlzFromProfileDelayed(profile_, is_first_run_, ping_delay); |
| 1239 is_google_default_search, is_google_homepage, | |
| 1240 is_google_in_startpages); | |
| 1241 | |
| 1242 // Prime the RLZ cache for the home page access point so that its avaiable | |
| 1243 // for the startup page if needed (i.e., when the startup page is set to | |
| 1244 // the home page). | |
| 1245 RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, NULL); | |
| 1246 #endif // defined(ENABLE_RLZ) && !defined(OS_CHROMEOS) | 1208 #endif // defined(ENABLE_RLZ) && !defined(OS_CHROMEOS) |
| 1247 | 1209 |
| 1248 // Configure modules that need access to resources. | 1210 // Configure modules that need access to resources. |
| 1249 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); | 1211 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); |
| 1250 | 1212 |
| 1251 // In unittest mode, this will do nothing. In normal mode, this will create | 1213 // In unittest mode, this will do nothing. In normal mode, this will create |
| 1252 // the global IntranetRedirectDetector instance, which will promptly go to | 1214 // the global IntranetRedirectDetector instance, which will promptly go to |
| 1253 // sleep for seven seconds (to avoid slowing startup), and wake up afterwards | 1215 // sleep for seven seconds (to avoid slowing startup), and wake up afterwards |
| 1254 // to see if it should do anything else. | 1216 // to see if it should do anything else. |
| 1255 // | 1217 // |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1650 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1612 if (base::win::GetVersion() <= base::win::VERSION_XP) |
| 1651 uma_name += "_XP"; | 1613 uma_name += "_XP"; |
| 1652 | 1614 |
| 1653 uma_name += "_PreRead_"; | 1615 uma_name += "_PreRead_"; |
| 1654 uma_name += pre_read_percentage; | 1616 uma_name += pre_read_percentage; |
| 1655 AddPreReadHistogramTime(uma_name.c_str(), time); | 1617 AddPreReadHistogramTime(uma_name.c_str(), time); |
| 1656 } | 1618 } |
| 1657 #endif | 1619 #endif |
| 1658 #endif | 1620 #endif |
| 1659 } | 1621 } |
| OLD | NEW |