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

Side by Side Diff: chrome/browser/shell_integration.h

Issue 2888693003: Remove the usage of BrowserThread::FILE in the shell_integration* files (Closed)
Patch Set: Add SequenceChecker and make all calls to SetAsDefault share a sequence Created 3 years, 6 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 #ifndef CHROME_BROWSER_SHELL_INTEGRATION_H_ 5 #ifndef CHROME_BROWSER_SHELL_INTEGRATION_H_
6 #define CHROME_BROWSER_SHELL_INTEGRATION_H_ 6 #define CHROME_BROWSER_SHELL_INTEGRATION_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "ui/gfx/image/image_family.h" 16 #include "ui/gfx/image/image_family.h"
17 #include "url/gurl.h" 17 #include "url/gurl.h"
18 18
19 namespace base { 19 namespace base {
20 class CommandLine; 20 class CommandLine;
21 class SequencedTaskRunner;
21 } 22 }
22 23
23 namespace shell_integration { 24 namespace shell_integration {
24 25
25 // Sets Chrome as the default browser (only for the current user). Returns false 26 // Sets Chrome as the default browser (only for the current user). Returns false
26 // if this operation fails. This does not work on Windows version 8 or higher. 27 // if this operation fails. This does not work on Windows version 8 or higher.
27 // Prefer to use the DefaultBrowserWorker class below since it works on all OSs. 28 // Prefer to use the DefaultBrowserWorker class below since it works on all OSs.
28 bool SetAsDefaultBrowser(); 29 bool SetAsDefaultBrowser();
29 30
30 // Sets Chrome as the default client application for the given protocol 31 // Sets Chrome as the default client application for the given protocol
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 base::string16 GetAppShortcutsSubdirName(); 123 base::string16 GetAppShortcutsSubdirName();
123 #endif 124 #endif
124 125
125 // The type of callback used to communicate processing state to consumers of 126 // The type of callback used to communicate processing state to consumers of
126 // DefaultBrowserWorker and DefaultProtocolClientWorker. 127 // DefaultBrowserWorker and DefaultProtocolClientWorker.
127 using DefaultWebClientWorkerCallback = 128 using DefaultWebClientWorkerCallback =
128 base::Callback<void(DefaultWebClientState)>; 129 base::Callback<void(DefaultWebClientState)>;
129 130
130 // Helper objects that handle checking if Chrome is the default browser 131 // Helper objects that handle checking if Chrome is the default browser
131 // or application for a url protocol on Windows and Linux, and also setting 132 // or application for a url protocol on Windows and Linux, and also setting
132 // it as the default. These operations are performed asynchronously on the 133 // it as the default. These operations are performed asynchronously on a
133 // file thread since registry access (on Windows) or the preference database 134 // blocking sequence since registry access (on Windows) or the preference
134 // (on Linux) are involved and this can be slow. 135 // database (on Linux) are involved and this can be slow.
135 // By default, the worker will present the user with an interactive flow if 136 // By default, the worker will present the user with an interactive flow if
136 // required by the platform. This can be suppressed via 137 // required by the platform. This can be suppressed via
137 // set_interactive_permitted(), in which case an attempt to set Chrome as 138 // set_interactive_permitted(), in which case an attempt to set Chrome as
138 // the default handler will silently fail on such platforms. 139 // the default handler will silently fail on such platforms.
139 class DefaultWebClientWorker 140 class DefaultWebClientWorker
140 : public base::RefCountedThreadSafe<DefaultWebClientWorker> { 141 : public base::RefCountedThreadSafe<DefaultWebClientWorker> {
141 public: 142 public:
142 // Controls whether the worker can use user interaction to set the default 143 // Controls whether the worker can use user interaction to set the default
143 // web client. If false, the set-as-default operation will fail on OS where 144 // web client. If false, the set-as-default operation will fail on OS where
144 // it is required. 145 // it is required.
(...skipping 22 matching lines...) Expand all
167 // |is_following_set_as_default| is true, |state| will be reported to UMA as 168 // |is_following_set_as_default| is true, |state| will be reported to UMA as
168 // the result of the set-as-default operation. 169 // the result of the set-as-default operation.
169 void OnCheckIsDefaultComplete(DefaultWebClientState state, 170 void OnCheckIsDefaultComplete(DefaultWebClientState state,
170 bool is_following_set_as_default); 171 bool is_following_set_as_default);
171 172
172 // When false, the operation to set as default will fail for interactive 173 // When false, the operation to set as default will fail for interactive
173 // flows. 174 // flows.
174 bool interactive_permitted_ = true; 175 bool interactive_permitted_ = true;
175 176
176 private: 177 private:
177 // Checks whether Chrome is the default web client. Always called on the 178 scoped_refptr<base::SequencedTaskRunner> GetSetDefaultTaskRunner();
gab 2017/05/26 18:44:06 "GetSet" sounds weird (took me a while to see this
Patrick Monette 2017/05/29 18:54:14 Good suggestion, but I used GetTaskRunner() since
178 // FILE thread. When |is_following_set_as_default| is true, The default state 179
179 // will be reported to UMA as the result of the set-as-default operation. 180 // Checks whether Chrome is the default web client. Always called on the a
gab 2017/05/26 18:44:06 "the a"
Patrick Monette 2017/05/29 18:54:14 Done.
181 // blocking sequence. When |is_following_set_as_default| is true, The default
182 // state will be reported to UMA as the result of the set-as-default
183 // operation.
180 void CheckIsDefault(bool is_following_set_as_default); 184 void CheckIsDefault(bool is_following_set_as_default);
181 185
182 // Sets Chrome as the default web client. Always called on the FILE thread. 186 // Sets Chrome as the default web client. Always called on a blocking
187 // sequence.
183 void SetAsDefault(); 188 void SetAsDefault();
184 189
185 // Implementation of CheckIsDefault() and SetAsDefault() for subclasses. 190 // Implementation of CheckIsDefault() and SetAsDefault() for subclasses.
186 virtual DefaultWebClientState CheckIsDefaultImpl() = 0; 191 virtual DefaultWebClientState CheckIsDefaultImpl() = 0;
187 192
188 // The callback may be run synchronously or at an arbitrary time later on this 193 // The callback may be run synchronously or at an arbitrary time later on this
189 // thread. 194 // thread.
190 // Note: Subclasses MUST make sure |on_finished_callback| is executed. 195 // Note: Subclasses MUST make sure |on_finished_callback| is executed.
191 virtual void SetAsDefaultImpl(const base::Closure& on_finished_callback) = 0; 196 virtual void SetAsDefaultImpl(const base::Closure& on_finished_callback) = 0;
192 197
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 void SetAsDefaultImpl(const base::Closure& on_finished_callback) override; 253 void SetAsDefaultImpl(const base::Closure& on_finished_callback) override;
249 254
250 std::string protocol_; 255 std::string protocol_;
251 256
252 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker); 257 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker);
253 }; 258 };
254 259
255 } // namespace shell_integration 260 } // namespace shell_integration
256 261
257 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_ 262 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698