172a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen// Copyright (c) 2011 The Chromium Authors. All rights reserved. 2bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen// Use of this source code is governed by a BSD-style license that can be 3bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen// found in the LICENSE file. 4bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen 5bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen#include "chrome/browser/first_run/first_run.h" 6bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen 7bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen#include "base/command_line.h" 8bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen#include "base/file_path.h" 9bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen#include "base/file_util.h" 10bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen#include "base/path_service.h" 11bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen#include "base/process_util.h" 12bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen#include "base/string_piece.h" 13bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen#include "base/string_util.h" 14bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen#include "base/utf_string_conversions.h" 15ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "chrome/browser/browser_process.h" 16bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen#include "chrome/browser/shell_integration.h" 17bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen#include "chrome/common/chrome_switches.h" 18bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen#include "chrome/installer/util/google_update_settings.h" 19ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "content/common/result_codes.h" 20bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen#include "googleurl/src/gurl.h" 2172a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#include "ui/base/ui_base_switches.h" 22bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen 23bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen// TODO(port): This is just a piece of the silent import functionality from 24bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen// ImportSettings for Windows. It would be nice to get the rest of it ported. 25bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsenbool FirstRun::ImportBookmarks(const FilePath& import_bookmarks_path) { 26bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen const CommandLine& cmdline = *CommandLine::ForCurrentProcess(); 27bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen CommandLine import_cmd(cmdline.GetProgram()); 28bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen 29bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen // Propagate user data directory switch. 30bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen if (cmdline.HasSwitch(switches::kUserDataDir)) { 31bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen import_cmd.AppendSwitchPath(switches::kUserDataDir, 32bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen cmdline.GetSwitchValuePath(switches::kUserDataDir)); 33bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen } 34bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen // Since ImportSettings is called before the local state is stored on disk 35bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen // we pass the language as an argument. GetApplicationLocale checks the 36bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen // current command line as fallback. 37bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen import_cmd.AppendSwitchASCII(switches::kLang, 38bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen g_browser_process->GetApplicationLocale()); 39bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen 40bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen import_cmd.CommandLine::AppendSwitchPath(switches::kImportFromFile, 41bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen import_bookmarks_path); 42bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen // Time to launch the process that is going to do the import. We'll wait 43bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen // for the process to return. 44bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen return base::LaunchApp(import_cmd, true, false, NULL); 45bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen} 46bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen 47bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen// static 48ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenbool FirstRun::IsOrganicFirstRun() { 49bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen // We treat all installs as organic. 50bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen return true; 51bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen} 52bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen 53bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen// static 54bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsenvoid FirstRun::PlatformSetup() { 55bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen // Things that Windows does here (creating a desktop icon, for example) are 56bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen // handled at install time on Linux. 57bda42a81ee5f9b20d2bebedcf0bbef1e30e5b293Kristian Monsen} 58