| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ios/chrome/browser/ios_chrome_main_parts.h" | 5 #include "ios/chrome/browser/ios_chrome_main_parts.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/feature_list.h" | 8 #include "base/feature_list.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "ios/chrome/browser/metrics/field_trial_synchronizer.h" | 45 #include "ios/chrome/browser/metrics/field_trial_synchronizer.h" |
| 46 #include "ios/chrome/browser/open_from_clipboard/create_clipboard_recent_content
.h" | 46 #include "ios/chrome/browser/open_from_clipboard/create_clipboard_recent_content
.h" |
| 47 #include "ios/chrome/browser/pref_names.h" | 47 #include "ios/chrome/browser/pref_names.h" |
| 48 #include "ios/chrome/browser/translate/translate_service_ios.h" | 48 #include "ios/chrome/browser/translate/translate_service_ios.h" |
| 49 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 49 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 50 #include "ios/web/public/web_thread.h" | 50 #include "ios/web/public/web_thread.h" |
| 51 #include "net/base/network_change_notifier.h" | 51 #include "net/base/network_change_notifier.h" |
| 52 #include "net/http/http_network_layer.h" | 52 #include "net/http/http_network_layer.h" |
| 53 #include "net/http/http_stream_factory.h" | 53 #include "net/http/http_stream_factory.h" |
| 54 #include "net/url_request/url_request.h" | 54 #include "net/url_request/url_request.h" |
| 55 #include "rlz/features/features.h" |
| 55 #include "ui/base/l10n/l10n_util_mac.h" | 56 #include "ui/base/l10n/l10n_util_mac.h" |
| 56 #include "ui/base/resource/resource_bundle.h" | 57 #include "ui/base/resource/resource_bundle.h" |
| 57 | 58 |
| 58 #if defined(ENABLE_RLZ) | 59 #if BUILDFLAG(ENABLE_RLZ) |
| 59 #include "components/rlz/rlz_tracker.h" // nogncheck | 60 #include "components/rlz/rlz_tracker.h" // nogncheck |
| 60 #include "ios/chrome/browser/rlz/rlz_tracker_delegate_impl.h" // nogncheck | 61 #include "ios/chrome/browser/rlz/rlz_tracker_delegate_impl.h" // nogncheck |
| 61 #endif | 62 #endif |
| 62 | 63 |
| 63 #if !defined(__has_feature) || !__has_feature(objc_arc) | 64 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 64 #error "This file requires ARC support." | 65 #error "This file requires ARC support." |
| 65 #endif | 66 #endif |
| 66 | 67 |
| 67 IOSChromeMainParts::IOSChromeMainParts( | 68 IOSChromeMainParts::IOSChromeMainParts( |
| 68 const base::CommandLine& parsed_command_line) | 69 const base::CommandLine& parsed_command_line) |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 CreateClipboardRecentContentIOS().release()); | 166 CreateClipboardRecentContentIOS().release()); |
| 166 | 167 |
| 167 // Ensure that the browser state is initialized. | 168 // Ensure that the browser state is initialized. |
| 168 EnsureBrowserStateKeyedServiceFactoriesBuilt(); | 169 EnsureBrowserStateKeyedServiceFactoriesBuilt(); |
| 169 ios::GetChromeBrowserProvider()->AssertBrowserContextKeyedFactoriesBuilt(); | 170 ios::GetChromeBrowserProvider()->AssertBrowserContextKeyedFactoriesBuilt(); |
| 170 ios::ChromeBrowserStateManager* browser_state_manager = | 171 ios::ChromeBrowserStateManager* browser_state_manager = |
| 171 application_context_->GetChromeBrowserStateManager(); | 172 application_context_->GetChromeBrowserStateManager(); |
| 172 ios::ChromeBrowserState* last_used_browser_state = | 173 ios::ChromeBrowserState* last_used_browser_state = |
| 173 browser_state_manager->GetLastUsedBrowserState(); | 174 browser_state_manager->GetLastUsedBrowserState(); |
| 174 | 175 |
| 175 #if defined(ENABLE_RLZ) | 176 #if BUILDFLAG(ENABLE_RLZ) |
| 176 // Init the RLZ library. This just schedules a task on the file thread to be | 177 // Init the RLZ library. This just schedules a task on the file thread to be |
| 177 // run sometime later. If this is the first run we record the installation | 178 // run sometime later. If this is the first run we record the installation |
| 178 // event. | 179 // event. |
| 179 int ping_delay = last_used_browser_state->GetPrefs()->GetInteger( | 180 int ping_delay = last_used_browser_state->GetPrefs()->GetInteger( |
| 180 FirstRun::GetPingDelayPrefName()); | 181 FirstRun::GetPingDelayPrefName()); |
| 181 // Negative ping delay means to send ping immediately after a first search is | 182 // Negative ping delay means to send ping immediately after a first search is |
| 182 // recorded. | 183 // recorded. |
| 183 rlz::RLZTracker::SetRlzDelegate(base::WrapUnique(new RLZTrackerDelegateImpl)); | 184 rlz::RLZTracker::SetRlzDelegate(base::WrapUnique(new RLZTrackerDelegateImpl)); |
| 184 rlz::RLZTracker::InitRlzDelayed( | 185 rlz::RLZTracker::InitRlzDelayed( |
| 185 FirstRun::IsChromeFirstRun(), ping_delay < 0, | 186 FirstRun::IsChromeFirstRun(), ping_delay < 0, |
| 186 base::TimeDelta::FromMilliseconds(abs(ping_delay)), | 187 base::TimeDelta::FromMilliseconds(abs(ping_delay)), |
| 187 RLZTrackerDelegateImpl::IsGoogleDefaultSearch(last_used_browser_state), | 188 RLZTrackerDelegateImpl::IsGoogleDefaultSearch(last_used_browser_state), |
| 188 RLZTrackerDelegateImpl::IsGoogleHomepage(last_used_browser_state), | 189 RLZTrackerDelegateImpl::IsGoogleHomepage(last_used_browser_state), |
| 189 RLZTrackerDelegateImpl::IsGoogleInStartpages(last_used_browser_state)); | 190 RLZTrackerDelegateImpl::IsGoogleInStartpages(last_used_browser_state)); |
| 190 #endif // defined(ENABLE_RLZ) | 191 #endif // BUILDFLAG(ENABLE_RLZ) |
| 191 | 192 |
| 192 TranslateServiceIOS::Initialize(); | 193 TranslateServiceIOS::Initialize(); |
| 193 language_usage_metrics::LanguageUsageMetrics::RecordAcceptLanguages( | 194 language_usage_metrics::LanguageUsageMetrics::RecordAcceptLanguages( |
| 194 last_used_browser_state->GetPrefs()->GetString(prefs::kAcceptLanguages)); | 195 last_used_browser_state->GetPrefs()->GetString(prefs::kAcceptLanguages)); |
| 195 language_usage_metrics::LanguageUsageMetrics::RecordApplicationLanguage( | 196 language_usage_metrics::LanguageUsageMetrics::RecordApplicationLanguage( |
| 196 application_context_->GetApplicationLocale()); | 197 application_context_->GetApplicationLocale()); |
| 197 | 198 |
| 198 // Request new variations seed information from server. | 199 // Request new variations seed information from server. |
| 199 variations::VariationsService* variations_service = | 200 variations::VariationsService* variations_service = |
| 200 application_context_->GetVariationsService(); | 201 application_context_->GetVariationsService(); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 302 |
| 302 void IOSChromeMainParts::StartMetricsRecording() { | 303 void IOSChromeMainParts::StartMetricsRecording() { |
| 303 bool wifiOnly = local_state_->GetBoolean(prefs::kMetricsReportingWifiOnly); | 304 bool wifiOnly = local_state_->GetBoolean(prefs::kMetricsReportingWifiOnly); |
| 304 bool isConnectionCellular = net::NetworkChangeNotifier::IsConnectionCellular( | 305 bool isConnectionCellular = net::NetworkChangeNotifier::IsConnectionCellular( |
| 305 net::NetworkChangeNotifier::GetConnectionType()); | 306 net::NetworkChangeNotifier::GetConnectionType()); |
| 306 bool mayUpload = !wifiOnly || !isConnectionCellular; | 307 bool mayUpload = !wifiOnly || !isConnectionCellular; |
| 307 | 308 |
| 308 application_context_->GetMetricsServicesManager()->UpdateUploadPermissions( | 309 application_context_->GetMetricsServicesManager()->UpdateUploadPermissions( |
| 309 mayUpload); | 310 mayUpload); |
| 310 } | 311 } |
| OLD | NEW |