Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: chrome/installer/util/shell_util.cc

Issue 1878313003: Convert //chrome/installer from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert decompress.cc in mini_installer. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // This file defines functions that integrate Chrome in Windows shell. These 5 // This file defines functions that integrate Chrome in Windows shell. These
6 // functions can be used by Chrome as well as Chrome installer. All of the 6 // functions can be used by Chrome as well as Chrome installer. All of the
7 // work is done by the local functions defined in anonymous namespace in 7 // work is done by the local functions defined in anonymous namespace in
8 // this class. 8 // this class.
9 9
10 #include "chrome/installer/util/shell_util.h" 10 #include "chrome/installer/util/shell_util.h"
11 11
12 #include <windows.h> 12 #include <windows.h>
13 #include <shlobj.h> 13 #include <shlobj.h>
14 #include <shobjidl.h> 14 #include <shobjidl.h>
15 15
16 #include <limits> 16 #include <limits>
17 #include <memory>
17 #include <string> 18 #include <string>
18 19
19 #include "base/bind.h" 20 #include "base/bind.h"
20 #include "base/command_line.h" 21 #include "base/command_line.h"
21 #include "base/files/file_enumerator.h" 22 #include "base/files/file_enumerator.h"
22 #include "base/files/file_path.h" 23 #include "base/files/file_path.h"
23 #include "base/files/file_util.h" 24 #include "base/files/file_util.h"
24 #include "base/lazy_instance.h" 25 #include "base/lazy_instance.h"
25 #include "base/logging.h" 26 #include "base/logging.h"
26 #include "base/macros.h" 27 #include "base/macros.h"
27 #include "base/md5.h" 28 #include "base/md5.h"
28 #include "base/memory/scoped_ptr.h"
29 #include "base/memory/scoped_vector.h" 29 #include "base/memory/scoped_vector.h"
30 #include "base/metrics/sparse_histogram.h" 30 #include "base/metrics/sparse_histogram.h"
31 #include "base/path_service.h" 31 #include "base/path_service.h"
32 #include "base/strings/string16.h" 32 #include "base/strings/string16.h"
33 #include "base/strings/string_number_conversions.h" 33 #include "base/strings/string_number_conversions.h"
34 #include "base/strings/string_split.h" 34 #include "base/strings/string_split.h"
35 #include "base/strings/string_util.h" 35 #include "base/strings/string_util.h"
36 #include "base/strings/stringprintf.h" 36 #include "base/strings/stringprintf.h"
37 #include "base/strings/utf_string_conversions.h" 37 #include "base/strings/utf_string_conversions.h"
38 #include "base/synchronization/cancellation_flag.h" 38 #include "base/synchronization/cancellation_flag.h"
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 // equivalent to being called with |overwrite_existing| false.) 533 // equivalent to being called with |overwrite_existing| false.)
534 void GetAppDefaultRegistrationEntries(const base::string16& prog_id, 534 void GetAppDefaultRegistrationEntries(const base::string16& prog_id,
535 const base::string16& ext, 535 const base::string16& ext,
536 bool overwrite_existing, 536 bool overwrite_existing,
537 ScopedVector<RegistryEntry>* entries) { 537 ScopedVector<RegistryEntry>* entries) {
538 // Set the default value of HKEY_CURRENT_USER\Software\Classes\EXT to this 538 // Set the default value of HKEY_CURRENT_USER\Software\Classes\EXT to this
539 // class's name. 539 // class's name.
540 base::string16 key_name(ShellUtil::kRegClasses); 540 base::string16 key_name(ShellUtil::kRegClasses);
541 key_name.push_back(base::FilePath::kSeparators[0]); 541 key_name.push_back(base::FilePath::kSeparators[0]);
542 key_name.append(ext); 542 key_name.append(ext);
543 scoped_ptr<RegistryEntry> default_association( 543 std::unique_ptr<RegistryEntry> default_association(
544 new RegistryEntry(key_name, prog_id)); 544 new RegistryEntry(key_name, prog_id));
545 if (overwrite_existing || 545 if (overwrite_existing ||
546 !default_association->KeyExistsInRegistry(RegistryEntry::LOOK_IN_HKCU)) { 546 !default_association->KeyExistsInRegistry(RegistryEntry::LOOK_IN_HKCU)) {
547 entries->push_back(default_association.release()); 547 entries->push_back(default_association.release());
548 } 548 }
549 } 549 }
550 550
551 // This method returns a list of all the user level registry entries that are 551 // This method returns a list of all the user level registry entries that are
552 // needed to make Chromium the default handler for a protocol on XP. 552 // needed to make Chromium the default handler for a protocol on XP.
553 void GetXPStyleUserProtocolEntries(const base::string16& protocol, 553 void GetXPStyleUserProtocolEntries(const base::string16& protocol,
(...skipping 1773 matching lines...) Expand 10 before | Expand all | Expand 10 after
2327 HKEY_CURRENT_USER, key_path, WorkItem::kWow64Default); 2327 HKEY_CURRENT_USER, key_path, WorkItem::kWow64Default);
2328 2328
2329 // TODO(mgiuca): Remove the extension association entries. This requires that 2329 // TODO(mgiuca): Remove the extension association entries. This requires that
2330 // the extensions associated with a particular prog_id are stored in that 2330 // the extensions associated with a particular prog_id are stored in that
2331 // prog_id's key. 2331 // prog_id's key.
2332 } 2332 }
2333 2333
2334 // static 2334 // static
2335 bool ShellUtil::AddRegistryEntries(HKEY root, 2335 bool ShellUtil::AddRegistryEntries(HKEY root,
2336 const ScopedVector<RegistryEntry>& entries) { 2336 const ScopedVector<RegistryEntry>& entries) {
2337 scoped_ptr<WorkItemList> items(WorkItem::CreateWorkItemList()); 2337 std::unique_ptr<WorkItemList> items(WorkItem::CreateWorkItemList());
2338 2338
2339 for (ScopedVector<RegistryEntry>::const_iterator itr = entries.begin(); 2339 for (ScopedVector<RegistryEntry>::const_iterator itr = entries.begin();
2340 itr != entries.end(); ++itr) 2340 itr != entries.end(); ++itr)
2341 (*itr)->AddToWorkItemList(root, items.get()); 2341 (*itr)->AddToWorkItemList(root, items.get());
2342 2342
2343 // Apply all the registry changes and if there is a problem, rollback 2343 // Apply all the registry changes and if there is a problem, rollback
2344 if (!items->Do()) { 2344 if (!items->Do()) {
2345 items->Rollback(); 2345 items->Rollback();
2346 return false; 2346 return false;
2347 } 2347 }
2348 return true; 2348 return true;
2349 } 2349 }
OLDNEW
« no previous file with comments | « chrome/installer/util/set_reg_value_work_item_unittest.cc ('k') | chrome/installer/util/shell_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698