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/component_updater/pnacl/pnacl_component_installer.h" | 5 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h" |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/files/file_enumerator.h" | |
13 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
14 #include "base/json/json_file_value_serializer.h" | 13 #include "base/json/json_file_value_serializer.h" |
15 #include "base/logging.h" | 14 #include "base/logging.h" |
16 #include "base/path_service.h" | 15 #include "base/path_service.h" |
17 #include "base/string_util.h" | 16 #include "base/string_util.h" |
18 #include "base/values.h" | 17 #include "base/values.h" |
19 #include "base/version.h" | 18 #include "base/version.h" |
20 #include "base/win/windows_version.h" | 19 #include "base/win/windows_version.h" |
21 #include "build/build_config.h" | 20 #include "build/build_config.h" |
22 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // If we don't have Pnacl installed, this is the version we claim. | 119 // If we don't have Pnacl installed, this is the version we claim. |
121 const char kNullVersion[] = "0.0.0.0"; | 120 const char kNullVersion[] = "0.0.0.0"; |
122 | 121 |
123 bool GetLatestPnaclDirectory(PnaclComponentInstaller* pci, | 122 bool GetLatestPnaclDirectory(PnaclComponentInstaller* pci, |
124 base::FilePath* latest_dir, | 123 base::FilePath* latest_dir, |
125 Version* latest_version, | 124 Version* latest_version, |
126 std::vector<base::FilePath>* older_dirs) { | 125 std::vector<base::FilePath>* older_dirs) { |
127 // Enumerate all versions starting from the base directory. | 126 // Enumerate all versions starting from the base directory. |
128 base::FilePath base_dir = pci->GetPnaclBaseDirectory(); | 127 base::FilePath base_dir = pci->GetPnaclBaseDirectory(); |
129 bool found = false; | 128 bool found = false; |
130 base::FileEnumerator | 129 file_util::FileEnumerator |
131 file_enumerator(base_dir, false, base::FileEnumerator::DIRECTORIES); | 130 file_enumerator(base_dir, false, file_util::FileEnumerator::DIRECTORIES); |
132 for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); | 131 for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); |
133 path = file_enumerator.Next()) { | 132 path = file_enumerator.Next()) { |
134 Version version(path.BaseName().MaybeAsASCII()); | 133 Version version(path.BaseName().MaybeAsASCII()); |
135 if (!version.IsValid()) | 134 if (!version.IsValid()) |
136 continue; | 135 continue; |
137 if (found) { | 136 if (found) { |
138 if (version.CompareTo(*latest_version) > 0) { | 137 if (version.CompareTo(*latest_version) > 0) { |
139 older_dirs->push_back(*latest_dir); | 138 older_dirs->push_back(*latest_dir); |
140 *latest_dir = path; | 139 *latest_dir = path; |
141 *latest_version = version; | 140 *latest_version = version; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 // No need to check the commandline flags again here. | 428 // No need to check the commandline flags again here. |
430 // We could only have gotten here after RegisterPnaclComponent | 429 // We could only have gotten here after RegisterPnaclComponent |
431 // found --enable-pnacl, since that is where we create the profile_observer_, | 430 // found --enable-pnacl, since that is where we create the profile_observer_, |
432 // which in turn calls ReRegisterPnacl. | 431 // which in turn calls ReRegisterPnacl. |
433 DCHECK(per_user_); | 432 DCHECK(per_user_); |
434 // Figure out profile information, before proceeding to look for files. | 433 // Figure out profile information, before proceeding to look for files. |
435 BrowserThread::PostTask( | 434 BrowserThread::PostTask( |
436 BrowserThread::UI, FROM_HERE, | 435 BrowserThread::UI, FROM_HERE, |
437 base::Bind(&GetProfileInformation, this)); | 436 base::Bind(&GetProfileInformation, this)); |
438 } | 437 } |
OLD | NEW |