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

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: Stuff 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 // Returns the global task runner that sequences all the file operations of
178 // FILE thread. When |is_following_set_as_default| is true, The default state 179 // the worker.
gab 2017/05/30 19:22:21 It's not just operations of this DefaultProtocolCl
Patrick Monette 2017/05/31 16:13:57 Done.
179 // will be reported to UMA as the result of the set-as-default operation. 180 scoped_refptr<base::SequencedTaskRunner> GetTaskRunner();
gab 2017/05/30 19:22:21 static
Patrick Monette 2017/05/31 16:13:57 Done.
181
182 // Checks whether Chrome is the default web client. Always called on a
183 // blocking sequence. When |is_following_set_as_default| is true, The default
184 // state will be reported to UMA as the result of the set-as-default
185 // operation.
180 void CheckIsDefault(bool is_following_set_as_default); 186 void CheckIsDefault(bool is_following_set_as_default);
181 187
182 // Sets Chrome as the default web client. Always called on the FILE thread. 188 // Sets Chrome as the default web client. Always called on a blocking
189 // sequence.
183 void SetAsDefault(); 190 void SetAsDefault();
184 191
185 // Implementation of CheckIsDefault() and SetAsDefault() for subclasses. 192 // Implementation of CheckIsDefault() and SetAsDefault() for subclasses.
186 virtual DefaultWebClientState CheckIsDefaultImpl() = 0; 193 virtual DefaultWebClientState CheckIsDefaultImpl() = 0;
187 194
188 // The callback may be run synchronously or at an arbitrary time later on this 195 // The callback may be run synchronously or at an arbitrary time later on this
189 // thread. 196 // thread.
190 // Note: Subclasses MUST make sure |on_finished_callback| is executed. 197 // Note: Subclasses MUST make sure |on_finished_callback| is executed.
191 virtual void SetAsDefaultImpl(const base::Closure& on_finished_callback) = 0; 198 virtual void SetAsDefaultImpl(const base::Closure& on_finished_callback) = 0;
192 199
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 void SetAsDefaultImpl(const base::Closure& on_finished_callback) override; 255 void SetAsDefaultImpl(const base::Closure& on_finished_callback) override;
249 256
250 std::string protocol_; 257 std::string protocol_;
251 258
252 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker); 259 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker);
253 }; 260 };
254 261
255 } // namespace shell_integration 262 } // namespace shell_integration
256 263
257 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_ 264 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698