| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 // TODO(port): move more code in back from the first_run_win.cc module. | 9 // TODO(port): move more code in back from the first_run_win.cc module. |
| 10 | 10 |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 // Bookmarks are never imported unless specifically turned on. | 199 // Bookmarks are never imported unless specifically turned on. |
| 200 if (installer_util::GetDistroBooleanPreference(prefs.get(), | 200 if (installer_util::GetDistroBooleanPreference(prefs.get(), |
| 201 installer_util::master_preferences::kDistroImportBookmarksPref, &value) | 201 installer_util::master_preferences::kDistroImportBookmarksPref, &value) |
| 202 && value) { | 202 && value) { |
| 203 out_prefs->do_import_items |= importer::FAVORITES; | 203 out_prefs->do_import_items |= importer::FAVORITES; |
| 204 } | 204 } |
| 205 | 205 |
| 206 if (installer_util::GetDistroBooleanPreference(prefs.get(), | 206 if (installer_util::GetDistroBooleanPreference(prefs.get(), |
| 207 installer_util::master_preferences::kMakeChromeDefaultForUser, &value) && | 207 installer_util::master_preferences::kMakeChromeDefaultForUser, &value) && |
| 208 value) | 208 value) |
| 209 ShellIntegration::SetAsDefaultBrowser(); | 209 out_prefs->make_chrome_default = true; |
| 210 | 210 |
| 211 // TODO(mirandac): Refactor skip-first-run-ui process into regular first run | 211 // TODO(mirandac): Refactor skip-first-run-ui process into regular first run |
| 212 // import process. http://crbug.com/49647 | 212 // import process. http://crbug.com/49647 |
| 213 // Note we are skipping all other master preferences if skip-first-run-ui | 213 // Note we are skipping all other master preferences if skip-first-run-ui |
| 214 // is *not* specified. (That is, we continue only if skipping first run ui.) | 214 // is *not* specified. (That is, we continue only if skipping first run ui.) |
| 215 if (!installer_util::GetDistroBooleanPreference(prefs.get(), | 215 if (!installer_util::GetDistroBooleanPreference(prefs.get(), |
| 216 installer_util::master_preferences::kDistroSkipFirstRunPref, &value) || | 216 installer_util::master_preferences::kDistroSkipFirstRunPref, &value) || |
| 217 !value) | 217 !value) |
| 218 return true; | 218 return true; |
| 219 | 219 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 if (!import_bookmarks_path.empty()) { | 275 if (!import_bookmarks_path.empty()) { |
| 276 // There are bookmarks to import from a file. | 276 // There are bookmarks to import from a file. |
| 277 FilePath path = FilePath::FromWStringHack(UTF8ToWide( | 277 FilePath path = FilePath::FromWStringHack(UTF8ToWide( |
| 278 import_bookmarks_path)); | 278 import_bookmarks_path)); |
| 279 if (!FirstRun::ImportBookmarks(path)) { | 279 if (!FirstRun::ImportBookmarks(path)) { |
| 280 LOG(WARNING) << "silent bookmark import failed"; | 280 LOG(WARNING) << "silent bookmark import failed"; |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 #endif | 283 #endif |
| 284 | 284 |
| 285 if (installer_util::GetDistroBooleanPreference(prefs.get(), |
| 286 installer_util::master_preferences::kMakeChromeDefaultForUser, &value) && |
| 287 value) |
| 288 ShellIntegration::SetAsDefaultBrowser(); |
| 289 |
| 285 return false; | 290 return false; |
| 286 } | 291 } |
| 287 | 292 |
| 288 // static | 293 // static |
| 289 bool FirstRun::IsChromeFirstRun() { | 294 bool FirstRun::IsChromeFirstRun() { |
| 290 if (first_run_ != FIRST_RUN_UNKNOWN) | 295 if (first_run_ != FIRST_RUN_UNKNOWN) |
| 291 return first_run_ == FIRST_RUN_TRUE; | 296 return first_run_ == FIRST_RUN_TRUE; |
| 292 | 297 |
| 293 FilePath first_run_sentinel; | 298 FilePath first_run_sentinel; |
| 294 if (!GetFirstRunSentinelFilePath(&first_run_sentinel) || | 299 if (!GetFirstRunSentinelFilePath(&first_run_sentinel) || |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 // TODO(avi): port the relevant pieces and enable this. | 464 // TODO(avi): port the relevant pieces and enable this. |
| 460 #if !defined(OS_MACOSX) | 465 #if !defined(OS_MACOSX) |
| 461 // static | 466 // static |
| 462 void FirstRun::AutoImport( | 467 void FirstRun::AutoImport( |
| 463 Profile* profile, | 468 Profile* profile, |
| 464 bool homepage_defined, | 469 bool homepage_defined, |
| 465 int import_items, | 470 int import_items, |
| 466 int dont_import_items, | 471 int dont_import_items, |
| 467 bool search_engine_experiment, | 472 bool search_engine_experiment, |
| 468 bool randomize_search_engine_experiment, | 473 bool randomize_search_engine_experiment, |
| 474 bool make_chrome_default, |
| 469 ProcessSingleton* process_singleton) { | 475 ProcessSingleton* process_singleton) { |
| 470 // We need to avoid dispatching new tabs when we are importing because | 476 // We need to avoid dispatching new tabs when we are importing because |
| 471 // that will lead to data corruption or a crash. Because there is no UI for | 477 // that will lead to data corruption or a crash. Because there is no UI for |
| 472 // the import process, we pass NULL as the window to bring to the foreground | 478 // the import process, we pass NULL as the window to bring to the foreground |
| 473 // when a CopyData message comes in; this causes the message to be silently | 479 // when a CopyData message comes in; this causes the message to be silently |
| 474 // discarded, which is the correct behavior during the import process. | 480 // discarded, which is the correct behavior during the import process. |
| 475 process_singleton->Lock(NULL); | 481 process_singleton->Lock(NULL); |
| 476 | 482 |
| 477 PlatformSetup(); | 483 PlatformSetup(); |
| 478 | 484 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 bool local_state_file_exists = file_util::PathExists(local_state_path); | 528 bool local_state_file_exists = file_util::PathExists(local_state_path); |
| 523 | 529 |
| 524 if (IsOrganic() && !local_state_file_exists) { | 530 if (IsOrganic() && !local_state_file_exists) { |
| 525 // The home page string may be set in the preferences, but the user should | 531 // The home page string may be set in the preferences, but the user should |
| 526 // initially use Chrome with the NTP as home page in organic builds. | 532 // initially use Chrome with the NTP as home page in organic builds. |
| 527 profile->GetPrefs()->SetBoolean(prefs::kHomePageIsNewTabPage, true); | 533 profile->GetPrefs()->SetBoolean(prefs::kHomePageIsNewTabPage, true); |
| 528 | 534 |
| 529 ShowFirstRunDialog(profile, randomize_search_engine_experiment); | 535 ShowFirstRunDialog(profile, randomize_search_engine_experiment); |
| 530 } | 536 } |
| 531 | 537 |
| 538 if (make_chrome_default) |
| 539 ShellIntegration::SetAsDefaultBrowser(); |
| 540 |
| 532 FirstRun::SetShowFirstRunBubblePref(true); | 541 FirstRun::SetShowFirstRunBubblePref(true); |
| 533 // Set the first run bubble to minimal. | 542 // Set the first run bubble to minimal. |
| 534 FirstRun::SetMinimalFirstRunBubblePref(); | 543 FirstRun::SetMinimalFirstRunBubblePref(); |
| 535 FirstRun::SetShowWelcomePagePref(); | 544 FirstRun::SetShowWelcomePagePref(); |
| 536 | 545 |
| 537 process_singleton->Unlock(); | 546 process_singleton->Unlock(); |
| 538 FirstRun::CreateSentinel(); | 547 FirstRun::CreateSentinel(); |
| 539 } | 548 } |
| 540 #endif // !defined(OS_MACOSX) | 549 #endif // !defined(OS_MACOSX) |
| OLD | NEW |