Upstream version 7.35.139.0
[platform/framework/web/crosswalk.git] / src / chrome / installer / setup / setup_main.cc
index 4a3741c..c3f2f93 100644 (file)
@@ -35,6 +35,7 @@
 #include "base/win/windows_version.h"
 #include "breakpad/src/client/windows/handler/exception_handler.h"
 #include "chrome/common/chrome_constants.h"
+#include "chrome/common/chrome_paths.h"
 #include "chrome/common/chrome_switches.h"
 #include "chrome/installer/setup/archive_patch_helper.h"
 #include "chrome/installer/setup/install.h"
@@ -664,11 +665,6 @@ installer::InstallStatus UninstallProducts(
     const CommandLine& cmd_line) {
   const Products& products = installer_state.products();
 
-  // Decide whether Active Setup should be triggered and/or system-level Chrome
-  // should be launched post-uninstall. This needs to be done outside the
-  // UninstallProduct calls as some of them might terminate the processes
-  // launched by a previous one otherwise...
-  bool trigger_active_setup = false;
   // System-level Chrome will be launched via this command if its program gets
   // set below.
   CommandLine system_level_cmd(CommandLine::NO_PROGRAM);
@@ -689,17 +685,6 @@ installer::InstallStatus UninstallProducts(
           installer::GetChromeInstallPath(true, dist)
               .Append(installer::kChromeExe));
       system_level_cmd.SetProgram(system_exe_path);
-
-      base::FilePath first_run_sentinel;
-      InstallUtil::GetSentinelFilePath(
-          chrome::kFirstRunSentinel, dist, &first_run_sentinel);
-      if (base::PathExists(first_run_sentinel)) {
-        // If the Chrome being self-destructed has already undergone First Run,
-        // trigger Active Setup and make sure the system-level Chrome doesn't go
-        // through first run.
-        trigger_active_setup = true;
-        system_level_cmd.AppendSwitch(::switches::kCancelFirstRun);
-      }
     }
   }
   if (installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES)) {
@@ -730,7 +715,10 @@ installer::InstallStatus UninstallProducts(
   // delete them.
   installer::DeleteChromeDirectoriesIfEmpty(installer_state.target_path());
 
-  if (trigger_active_setup)
+  // Trigger Active Setup if it was requested for the chrome product. This needs
+  // to be done after the UninstallProduct calls as some of them might
+  // otherwise terminate the process launched by TriggerActiveSetupCommand().
+  if (chrome && cmd_line.HasSwitch(installer::switches::kTriggerActiveSetup))
     InstallUtil::TriggerActiveSetupCommand();
 
   if (!system_level_cmd.GetProgram().empty())
@@ -867,13 +855,13 @@ installer::InstallStatus ShowEULADialog(const base::string16& inner_frame) {
 // accepted.
 bool CreateEULASentinel(BrowserDistribution* dist) {
   base::FilePath eula_sentinel;
-  if (!InstallUtil::GetSentinelFilePath(installer::kEULASentinelFile,
-                                        dist, &eula_sentinel)) {
+  if (!InstallUtil::GetSentinelFilePath(installer::kEULASentinelFile, dist,
+                                        &eula_sentinel)) {
     return false;
   }
 
   return (base::CreateDirectory(eula_sentinel.DirName()) &&
-          file_util::WriteFile(eula_sentinel, "", 0) != -1);
+          base::WriteFile(eula_sentinel, "", 0) != -1);
 }
 
 void ActivateMetroChrome() {
@@ -1212,6 +1200,20 @@ bool HandleNonInstallCmdLineOptions(const InstallationState& original_state,
     } else {
       *exit_code = installer::PATCH_INVALID_ARGUMENTS;
     }
+  } else if (cmd_line.HasSwitch(installer::switches::kReenableAutoupdates)) {
+    // setup.exe has been asked to attempt to reenable updates for Chrome.
+    // Figure out whether we should do so for the multi binaries or the main
+    // Chrome product.
+    BrowserDistribution::Type dist_type = BrowserDistribution::CHROME_BROWSER;
+    if (installer_state->is_multi_install())
+      dist_type = BrowserDistribution::CHROME_BINARIES;
+
+    BrowserDistribution* dist =
+        BrowserDistribution::GetSpecificDistribution(dist_type);
+    bool updates_enabled =
+        GoogleUpdateSettings::ReenableAutoupdatesForApp(dist->GetAppGuid());
+    *exit_code = updates_enabled ? installer::REENABLE_UPDATES_SUCCEEDED :
+                                   installer::REENABLE_UPDATES_FAILED;
   } else {
     handled = false;
   }
@@ -1686,10 +1688,19 @@ InstallStatus InstallProductsHelper(
 
 int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
                     wchar_t* command_line, int show_command) {
+  // Check to see if the CPU is supported before doing anything else. There's
+  // very little than can safely be accomplished if the CPU isn't supported
+  // since dependent libraries (e.g., base) may use invalid instructions.
+  if (!installer::IsProcessorSupported())
+    return installer::CPU_NOT_SUPPORTED;
+
   // The exit manager is in charge of calling the dtors of singletons.
   base::AtExitManager exit_manager;
   CommandLine::Init(0, NULL);
 
+  // install_util uses chrome paths.
+  chrome::RegisterPathProvider();
+
   const MasterPreferences& prefs = MasterPreferences::ForCurrentProcess();
   installer::InitInstallerLogging(prefs);