| 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/first_run/first_run.h" | 5 #include "chrome/browser/first_run/first_run.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 if (IsOrganicFirstRun() && !local_state_file_exists) { | 231 if (IsOrganicFirstRun() && !local_state_file_exists) { |
| 232 // The home page string may be set in the preferences, but the user should | 232 // The home page string may be set in the preferences, but the user should |
| 233 // initially use Chrome with the NTP as home page in organic builds. | 233 // initially use Chrome with the NTP as home page in organic builds. |
| 234 profile->GetPrefs()->SetBoolean(prefs::kHomePageIsNewTabPage, true); | 234 profile->GetPrefs()->SetBoolean(prefs::kHomePageIsNewTabPage, true); |
| 235 ShowFirstRunDialog(profile, randomize_search_engine_experiment); | 235 ShowFirstRunDialog(profile, randomize_search_engine_experiment); |
| 236 } | 236 } |
| 237 | 237 |
| 238 if (make_chrome_default) | 238 if (make_chrome_default) |
| 239 ShellIntegration::SetAsDefaultBrowser(); | 239 ShellIntegration::SetAsDefaultBrowser(); |
| 240 | 240 |
| 241 // Don't display the minimal bubble if there is no default search provider. | 241 // Display the first run bubble if there is a default search provider. |
| 242 TemplateURLService* search_engines_model = | 242 TemplateURLService* template_url = |
| 243 TemplateURLServiceFactory::GetForProfile(profile); | 243 TemplateURLServiceFactory::GetForProfile(profile); |
| 244 if (search_engines_model && | 244 if (template_url && template_url->GetDefaultSearchProvider()) |
| 245 search_engines_model->GetDefaultSearchProvider()) { | |
| 246 SetShowFirstRunBubblePref(true); | 245 SetShowFirstRunBubblePref(true); |
| 247 // Set the first run bubble to minimal. | |
| 248 SetMinimalFirstRunBubblePref(); | |
| 249 } | |
| 250 SetShowWelcomePagePref(); | 246 SetShowWelcomePagePref(); |
| 251 SetPersonalDataManagerFirstRunPref(); | 247 SetPersonalDataManagerFirstRunPref(); |
| 252 } | 248 } |
| 253 #endif // !defined(USE_AURA) | 249 #endif // !defined(USE_AURA) |
| 254 | 250 |
| 255 int ImportBookmarkFromFileIfNeeded(Profile* profile, | 251 int ImportBookmarkFromFileIfNeeded(Profile* profile, |
| 256 const CommandLine& cmdline) { | 252 const CommandLine& cmdline) { |
| 257 int return_code = true; | 253 int return_code = true; |
| 258 if (cmdline.HasSwitch(switches::kImportFromFile)) { | 254 if (cmdline.HasSwitch(switches::kImportFromFile)) { |
| 259 // Silently import preset bookmarks from file. | 255 // Silently import preset bookmarks from file. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 FilePath first_run_sentinel; | 289 FilePath first_run_sentinel; |
| 294 if (!internal::GetFirstRunSentinelFilePath(&first_run_sentinel)) | 290 if (!internal::GetFirstRunSentinelFilePath(&first_run_sentinel)) |
| 295 return false; | 291 return false; |
| 296 return file_util::Delete(first_run_sentinel, false); | 292 return file_util::Delete(first_run_sentinel, false); |
| 297 } | 293 } |
| 298 | 294 |
| 299 bool SetShowFirstRunBubblePref(bool show_bubble) { | 295 bool SetShowFirstRunBubblePref(bool show_bubble) { |
| 300 PrefService* local_state = g_browser_process->local_state(); | 296 PrefService* local_state = g_browser_process->local_state(); |
| 301 if (!local_state) | 297 if (!local_state) |
| 302 return false; | 298 return false; |
| 303 if (!local_state->HasPrefPath(prefs::kShouldShowFirstRunBubble)) | 299 local_state->SetBoolean(prefs::kShouldShowFirstRunBubble, show_bubble); |
| 304 local_state->SetBoolean(prefs::kShouldShowFirstRunBubble, show_bubble); | |
| 305 return true; | 300 return true; |
| 306 } | 301 } |
| 307 | 302 |
| 308 bool SetMinimalFirstRunBubblePref() { | |
| 309 PrefService* local_state = g_browser_process->local_state(); | |
| 310 if (!local_state) | |
| 311 return false; | |
| 312 if (!local_state->FindPreference(prefs::kShouldUseMinimalFirstRunBubble)) { | |
| 313 local_state->RegisterBooleanPref(prefs::kShouldUseMinimalFirstRunBubble, | |
| 314 false); | |
| 315 local_state->SetBoolean(prefs::kShouldUseMinimalFirstRunBubble, true); | |
| 316 } | |
| 317 return true; | |
| 318 } | |
| 319 | |
| 320 bool SetShowWelcomePagePref() { | 303 bool SetShowWelcomePagePref() { |
| 321 PrefService* local_state = g_browser_process->local_state(); | 304 PrefService* local_state = g_browser_process->local_state(); |
| 322 if (!local_state) | 305 if (!local_state) |
| 323 return false; | 306 return false; |
| 324 if (!local_state->FindPreference(prefs::kShouldShowWelcomePage)) { | 307 if (!local_state->FindPreference(prefs::kShouldShowWelcomePage)) { |
| 325 local_state->RegisterBooleanPref(prefs::kShouldShowWelcomePage, false); | 308 local_state->RegisterBooleanPref(prefs::kShouldShowWelcomePage, false); |
| 326 local_state->SetBoolean(prefs::kShouldShowWelcomePage, true); | 309 local_state->SetBoolean(prefs::kShouldShowWelcomePage, true); |
| 327 } | 310 } |
| 328 return true; | 311 return true; |
| 329 } | 312 } |
| 330 | 313 |
| 331 bool SetPersonalDataManagerFirstRunPref() { | 314 bool SetPersonalDataManagerFirstRunPref() { |
| 332 PrefService* local_state = g_browser_process->local_state(); | 315 PrefService* local_state = g_browser_process->local_state(); |
| 333 if (!local_state) | 316 if (!local_state) |
| 334 return false; | 317 return false; |
| 335 if (!local_state->FindPreference( | 318 if (!local_state->FindPreference( |
| 336 prefs::kAutofillPersonalDataManagerFirstRun)) { | 319 prefs::kAutofillPersonalDataManagerFirstRun)) { |
| 337 local_state->RegisterBooleanPref( | 320 local_state->RegisterBooleanPref( |
| 338 prefs::kAutofillPersonalDataManagerFirstRun, false); | 321 prefs::kAutofillPersonalDataManagerFirstRun, false); |
| 339 local_state->SetBoolean(prefs::kAutofillPersonalDataManagerFirstRun, true); | 322 local_state->SetBoolean(prefs::kAutofillPersonalDataManagerFirstRun, true); |
| 340 } | 323 } |
| 341 return true; | 324 return true; |
| 342 } | 325 } |
| 343 | 326 |
| 344 bool SetOEMFirstRunBubblePref() { | |
| 345 PrefService* local_state = g_browser_process->local_state(); | |
| 346 if (!local_state) | |
| 347 return false; | |
| 348 if (!local_state->FindPreference(prefs::kShouldUseOEMFirstRunBubble)) { | |
| 349 local_state->RegisterBooleanPref(prefs::kShouldUseOEMFirstRunBubble, false); | |
| 350 local_state->SetBoolean(prefs::kShouldUseOEMFirstRunBubble, true); | |
| 351 } | |
| 352 return true; | |
| 353 } | |
| 354 | |
| 355 bool ShouldShowSearchEngineSelector(const TemplateURLService* model) { | 327 bool ShouldShowSearchEngineSelector(const TemplateURLService* model) { |
| 356 return model && !model->is_default_search_managed(); | 328 return model && !model->is_default_search_managed(); |
| 357 } | 329 } |
| 358 | 330 |
| 359 } // namespace first_run | 331 } // namespace first_run |
| 360 | 332 |
| 361 // FirstRun ------------------------------------------------------------------- | 333 // FirstRun ------------------------------------------------------------------- |
| 362 | 334 |
| 363 FirstRun::MasterPrefs::MasterPrefs() | 335 FirstRun::MasterPrefs::MasterPrefs() |
| 364 : ping_delay(0), | 336 : ping_delay(0), |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 VLOG(1) << "EULA : no collection"; | 392 VLOG(1) << "EULA : no collection"; |
| 421 GoogleUpdateSettings::SetCollectStatsConsent(false); | 393 GoogleUpdateSettings::SetCollectStatsConsent(false); |
| 422 } else if (retcode == installer::EULA_ACCEPTED_OPT_IN) { | 394 } else if (retcode == installer::EULA_ACCEPTED_OPT_IN) { |
| 423 VLOG(1) << "EULA : collection consent"; | 395 VLOG(1) << "EULA : collection consent"; |
| 424 GoogleUpdateSettings::SetCollectStatsConsent(true); | 396 GoogleUpdateSettings::SetCollectStatsConsent(true); |
| 425 } | 397 } |
| 426 } | 398 } |
| 427 } | 399 } |
| 428 #endif | 400 #endif |
| 429 | 401 |
| 430 if (prefs.GetBool(installer::master_preferences::kAltFirstRunBubble, | |
| 431 &value) && value) { | |
| 432 first_run::SetOEMFirstRunBubblePref(); | |
| 433 } | |
| 434 | |
| 435 FilePath user_prefs = GetDefaultPrefFilePath(true, user_data_dir); | 402 FilePath user_prefs = GetDefaultPrefFilePath(true, user_data_dir); |
| 436 if (user_prefs.empty()) | 403 if (user_prefs.empty()) |
| 437 return true; | 404 return true; |
| 438 | 405 |
| 439 // The master prefs are regular prefs so we can just copy the file | 406 // The master prefs are regular prefs so we can just copy the file |
| 440 // to the default place and they just work. | 407 // to the default place and they just work. |
| 441 if (!file_util::CopyFile(master_prefs, user_prefs)) | 408 if (!file_util::CopyFile(master_prefs, user_prefs)) |
| 442 return true; | 409 return true; |
| 443 | 410 |
| 444 #if defined(OS_WIN) | 411 #if defined(OS_WIN) |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 } | 566 } |
| 600 } else { | 567 } else { |
| 601 if (g_browser_process->local_state()->GetBoolean( | 568 if (g_browser_process->local_state()->GetBoolean( |
| 602 prefs::kDefaultBrowserSettingEnabled)) { | 569 prefs::kDefaultBrowserSettingEnabled)) { |
| 603 ShellIntegration::SetAsDefaultBrowser(); | 570 ShellIntegration::SetAsDefaultBrowser(); |
| 604 } | 571 } |
| 605 } | 572 } |
| 606 | 573 |
| 607 return false; | 574 return false; |
| 608 } | 575 } |
| OLD | NEW |