OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/installer/setup/chrome_frame_quick_enable.h" | 5 #include "chrome/installer/setup/chrome_frame_quick_enable.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/scoped_temp_dir.h" |
10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
11 #include "base/win/registry.h" | 12 #include "base/win/registry.h" |
12 #include "chrome/installer/setup/install_worker.h" | 13 #include "chrome/installer/setup/install_worker.h" |
13 #include "chrome/installer/util/google_update_constants.h" | 14 #include "chrome/installer/util/google_update_constants.h" |
14 #include "chrome/installer/util/install_util.h" | 15 #include "chrome/installer/util/install_util.h" |
15 #include "chrome/installer/util/installation_state.h" | 16 #include "chrome/installer/util/installation_state.h" |
16 #include "chrome/installer/util/installer_state.h" | 17 #include "chrome/installer/util/installer_state.h" |
17 #include "chrome/installer/util/product.h" | 18 #include "chrome/installer/util/product.h" |
18 #include "chrome/installer/util/work_item.h" | 19 #include "chrome/installer/util/work_item.h" |
19 #include "chrome/installer/util/work_item_list.h" | 20 #include "chrome/installer/util/work_item_list.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 if (status == FIRST_INSTALL_SUCCESS) { | 73 if (status == FIRST_INSTALL_SUCCESS) { |
73 scoped_ptr<Product> multi_cf(new Product( | 74 scoped_ptr<Product> multi_cf(new Product( |
74 BrowserDistribution::GetSpecificDistribution( | 75 BrowserDistribution::GetSpecificDistribution( |
75 BrowserDistribution::CHROME_FRAME))); | 76 BrowserDistribution::CHROME_FRAME))); |
76 multi_cf->SetOption(installer::kOptionMultiInstall, true); | 77 multi_cf->SetOption(installer::kOptionMultiInstall, true); |
77 Product* cf = installer_state->AddProduct(&multi_cf); | 78 Product* cf = installer_state->AddProduct(&multi_cf); |
78 if (!cf) { | 79 if (!cf) { |
79 LOG(ERROR) << "AddProduct failed"; | 80 LOG(ERROR) << "AddProduct failed"; |
80 status = INSTALL_FAILED; | 81 status = INSTALL_FAILED; |
81 } else { | 82 } else { |
| 83 ScopedTempDir temp_path; |
| 84 if (!temp_path.CreateUniqueTempDir()) { |
| 85 PLOG(ERROR) << "Failed to create Temp directory"; |
| 86 return INSTALL_FAILED; |
| 87 } |
82 scoped_ptr<WorkItemList> item_list(WorkItem::CreateWorkItemList()); | 88 scoped_ptr<WorkItemList> item_list(WorkItem::CreateWorkItemList()); |
83 const ProductState* chrome_state = | 89 const ProductState* chrome_state = |
84 machine_state.GetProductState(installer_state->system_install(), | 90 machine_state.GetProductState(installer_state->system_install(), |
85 BrowserDistribution::CHROME_BROWSER); | 91 BrowserDistribution::CHROME_BROWSER); |
86 DCHECK(chrome_state); // Checked in CheckQuickEnablePreconditions. | 92 DCHECK(chrome_state); // Checked in CheckQuickEnablePreconditions. |
87 | 93 |
88 // Temporarily remove Chrome from the product list. | 94 // Temporarily remove Chrome from the product list. |
89 // This is so that the operations below do not affect the installation | 95 // This is so that the operations below do not affect the installation |
90 // state of Chrome. | 96 // state of Chrome. |
91 installer_state->RemoveProduct( | 97 installer_state->RemoveProduct( |
92 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER)); | 98 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER)); |
93 | 99 |
94 FilePath setup_path(chrome_state->GetSetupPath()); | 100 FilePath setup_path(chrome_state->GetSetupPath()); |
95 const Version& new_version = chrome_state->version(); | 101 const Version& new_version = chrome_state->version(); |
96 FilePath new_chrome_exe( | 102 FilePath new_chrome_exe( |
97 installer_state->target_path().Append(installer::kChromeNewExe)); | 103 installer_state->target_path().Append(installer::kChromeNewExe)); |
98 | 104 |
99 // This creates the uninstallation entry for GCF. | 105 // This creates the uninstallation entry for GCF. |
100 AddUninstallShortcutWorkItems(*installer_state, setup_path, new_version, | 106 AddUninstallShortcutWorkItems(*installer_state, setup_path, new_version, |
101 item_list.get(), *cf); | 107 item_list.get(), *cf); |
102 AddVersionKeyWorkItems(installer_state->root_key(), cf->distribution(), | 108 AddVersionKeyWorkItems(installer_state->root_key(), cf->distribution(), |
103 new_version, item_list.get()); | 109 new_version, item_list.get()); |
104 AddChromeFrameWorkItems(machine_state, *installer_state, setup_path, | 110 AddChromeFrameWorkItems(machine_state, *installer_state, setup_path, |
105 new_version, *cf, item_list.get()); | 111 new_version, *cf, item_list.get()); |
106 | 112 |
107 const Version* opv = chrome_state->old_version(); | 113 const Version* opv = chrome_state->old_version(); |
108 AppendPostInstallTasks(*installer_state, setup_path, new_chrome_exe, opv, | 114 AppendPostInstallTasks(*installer_state, setup_path, new_chrome_exe, opv, |
109 new_version, item_list.get()); | 115 new_version, temp_path.path(), item_list.get()); |
110 | 116 |
111 // Before updating the channel values, add Chrome back to the mix so that | 117 // Before updating the channel values, add Chrome back to the mix so that |
112 // all multi-installed products' channel values get updated. | 118 // all multi-installed products' channel values get updated. |
113 installer_state->AddProductFromState(BrowserDistribution::CHROME_BROWSER, | 119 installer_state->AddProductFromState(BrowserDistribution::CHROME_BROWSER, |
114 *chrome_state); | 120 *chrome_state); |
115 AddGoogleUpdateWorkItems(*installer_state, item_list.get()); | 121 AddGoogleUpdateWorkItems(*installer_state, item_list.get()); |
116 | 122 |
117 if (!item_list->Do()) { | 123 if (!item_list->Do()) { |
118 item_list->Rollback(); | 124 item_list->Rollback(); |
119 status = INSTALL_FAILED; | 125 status = INSTALL_FAILED; |
120 } else { | 126 } else { |
121 DCHECK_EQ(FIRST_INSTALL_SUCCESS, status); | 127 DCHECK_EQ(FIRST_INSTALL_SUCCESS, status); |
122 VLOG(1) << "Chrome Frame successfully activated."; | 128 VLOG(1) << "Chrome Frame successfully activated."; |
123 } | 129 } |
124 } | 130 } |
125 } | 131 } |
126 | 132 |
127 return status; | 133 return status; |
128 } | 134 } |
129 | 135 |
130 } // namespace installer | 136 } // namespace installer |
OLD | NEW |