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

Side by Side Diff: chrome/browser/conflicts/installed_programs_win.h

Issue 2854983002: Add the ThirdPartyModules.Uninstallable histogram. (Closed)
Patch Set: Created 3 years, 7 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CONFLICTS_INSTALLED_PROGRAMS_WIN_H_
6 #define CHROME_BROWSER_CONFLICTS_INSTALLED_PROGRAMS_WIN_H_
7
8 #include <memory>
9 #include <utility>
10 #include <vector>
11
12 #include "base/callback_forward.h"
13 #include "base/containers/flat_map.h"
14 #include "base/files/file_path.h"
15 #include "base/macros.h"
16 #include "base/memory/weak_ptr.h"
17 #include "base/strings/string16.h"
18
19 class InstalledPrograms {
chrisha 2017/05/02 21:28:25 Some class documentation might be useful. How is t
Patrick Monette 2017/05/29 22:04:55 I added documentation. I feel like only a small de
20 public:
21 // This structure has the same representation than the internal state of
chrisha 2017/05/02 21:28:25 as* the internal
Patrick Monette 2017/05/29 22:04:55 I got rid of InternalData.
22 // InstalledPrograms. It is created on a background sequenced and passed back
chrisha 2017/05/02 21:28:25 sequence*
Patrick Monette 2017/05/29 22:04:55 Ditto.
23 // on the sequence that this instance was initialized.
24 struct InternalData {
chrisha 2017/05/02 21:28:25 Is there a reason why we don't simply document the
Patrick Monette 2017/05/29 22:04:55 No longer applicable.
25 std::vector<base::string16> program_names;
26 std::vector<std::pair<base::FilePath, size_t>> dll_map;
27 std::vector<std::pair<base::FilePath, size_t>> install_locations;
28 };
29
30 InstalledPrograms();
31 ~InstalledPrograms();
32
33 // Initializes this class on a background sequence.
34 void Initialize(const base::Closure& on_initialized_callback);
chrisha 2017/05/02 21:28:25 Invokes the callback on the background sequence, o
35
36 // Given a |dll|, checks if it matches with an installed program on the user's
37 // machine and return the matching program name. Do not call this before the
38 // initialization is done.
39 bool GetInstalledProgramName(const base::FilePath& dll,
40 base::string16* program_name);
41
42 private:
43 // Generates an InternalData instance. Should be called on a background
44 // sequence.
chrisha 2017/05/02 21:28:25 Document the fact that these will be used by Initi
45 static std::unique_ptr<InternalData> GetInternalData();
46 void OnInternalDataReceived(const base::Closure& on_initialized_callback,
47 std::unique_ptr<InternalData> internal_data);
48
49 // Used to assert that initialization was completed before calling
50 // GetInstalledProgramName().
51 bool initialized_;
52
53 // Program names are stored in this vector because multiple entries in
54 // dll_map_ could point to the same one. This is to avoid duplicating them.
55 std::vector<base::string16> program_names_;
56 struct FilePathLess {
57 bool operator()(const base::FilePath& lhs, const base::FilePath& rhs) const;
58 };
59
60 // Contains all the dll files from programs installed via Microsoft Installer.
61 base::flat_map<base::FilePath, size_t, FilePathLess> dll_map_;
chrisha 2017/05/02 21:28:25 Is there a reason why we use a flat_map here and a
Patrick Monette 2017/05/29 22:04:55 Switched both to flat_map.
62
63 // For some programs, the best information available is the directory of the
64 // installation.
65 std::vector<std::pair<base::FilePath, size_t>> install_locations_;
66
67 base::WeakPtrFactory<InstalledPrograms> weak_ptr_factory_;
68
69 DISALLOW_COPY_AND_ASSIGN(InstalledPrograms);
70 };
71
72 #endif // CHROME_BROWSER_CONFLICTS_INSTALLED_PROGRAMS_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698