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/shell_integration.h" | 5 #include "chrome/browser/shell_integration.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
14 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
18 | 18 |
19 using content::BrowserThread; | 19 using content::BrowserThread; |
20 | 20 |
21 bool ShellIntegration::CanSetAsDefaultProtocolClient() { | 21 ShellIntegration::DefaultSettingsChangePermission |
| 22 ShellIntegration::CanSetAsDefaultProtocolClient() { |
22 // Allowed as long as the browser can become the operating system default | 23 // Allowed as long as the browser can become the operating system default |
23 // browser. | 24 // browser. |
24 return CanSetAsDefaultBrowser(); | 25 return CanSetAsDefaultBrowser(); |
25 } | 26 } |
26 | 27 |
27 ShellIntegration::ShortcutInfo::ShortcutInfo() | 28 ShellIntegration::ShortcutInfo::ShortcutInfo() |
28 : is_platform_app(false), | 29 : is_platform_app(false), |
29 create_on_desktop(false), | 30 create_on_desktop(false), |
30 create_in_applications_menu(false), | 31 create_in_applications_menu(false), |
31 create_in_quick_launch_bar(false) { | 32 create_in_quick_launch_bar(false) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 86 } |
86 } else { | 87 } else { |
87 // Use '--app=url' instead of just 'url' to launch the browser with minimal | 88 // Use '--app=url' instead of just 'url' to launch the browser with minimal |
88 // chrome. | 89 // chrome. |
89 // Note: Do not change this flag! Old Gears shortcuts will break if you do! | 90 // Note: Do not change this flag! Old Gears shortcuts will break if you do! |
90 new_cmd_line.AppendSwitchASCII(switches::kApp, url.spec()); | 91 new_cmd_line.AppendSwitchASCII(switches::kApp, url.spec()); |
91 } | 92 } |
92 return new_cmd_line; | 93 return new_cmd_line; |
93 } | 94 } |
94 | 95 |
| 96 #if !defined(OS_WIN) |
| 97 // static |
| 98 bool ShellIntegration::SetAsDefaultBrowserInteractive() { |
| 99 return false; |
| 100 } |
| 101 #endif |
| 102 |
95 /////////////////////////////////////////////////////////////////////////////// | 103 /////////////////////////////////////////////////////////////////////////////// |
96 // ShellIntegration::DefaultWebClientWorker | 104 // ShellIntegration::DefaultWebClientWorker |
97 // | 105 // |
98 | 106 |
99 ShellIntegration::DefaultWebClientWorker::DefaultWebClientWorker( | 107 ShellIntegration::DefaultWebClientWorker::DefaultWebClientWorker( |
100 DefaultWebClientObserver* observer) | 108 DefaultWebClientObserver* observer) |
101 : observer_(observer) { | 109 : observer_(observer) { |
102 } | 110 } |
103 | 111 |
104 void ShellIntegration::DefaultWebClientWorker::StartCheckIsDefault() { | 112 void ShellIntegration::DefaultWebClientWorker::StartCheckIsDefault() { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // The worker has finished everything it needs to do, so free the observer | 155 // The worker has finished everything it needs to do, so free the observer |
148 // if we own it. | 156 // if we own it. |
149 if (observer_ && observer_->IsOwnedByWorker()) { | 157 if (observer_ && observer_->IsOwnedByWorker()) { |
150 delete observer_; | 158 delete observer_; |
151 observer_ = NULL; | 159 observer_ = NULL; |
152 } | 160 } |
153 } | 161 } |
154 | 162 |
155 void ShellIntegration::DefaultWebClientWorker::ExecuteSetAsDefault() { | 163 void ShellIntegration::DefaultWebClientWorker::ExecuteSetAsDefault() { |
156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 164 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
157 SetAsDefault(); | 165 SetAsDefault(observer_ && observer_->IsInteractiveSetDefaultPermitted()); |
158 BrowserThread::PostTask( | 166 BrowserThread::PostTask( |
159 BrowserThread::UI, FROM_HERE, | 167 BrowserThread::UI, FROM_HERE, |
160 base::Bind( | 168 base::Bind( |
161 &DefaultWebClientWorker::CompleteSetAsDefault, this)); | 169 &DefaultWebClientWorker::CompleteSetAsDefault, this)); |
162 } | 170 } |
163 | 171 |
164 void ShellIntegration::DefaultWebClientWorker::CompleteSetAsDefault() { | 172 void ShellIntegration::DefaultWebClientWorker::CompleteSetAsDefault() { |
165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
166 // Set as default completed, check again to make sure it stuck... | 174 // Set as default completed, check again to make sure it stuck... |
167 StartCheckIsDefault(); | 175 StartCheckIsDefault(); |
(...skipping 28 matching lines...) Expand all Loading... |
196 } | 204 } |
197 | 205 |
198 /////////////////////////////////////////////////////////////////////////////// | 206 /////////////////////////////////////////////////////////////////////////////// |
199 // DefaultBrowserWorker, private: | 207 // DefaultBrowserWorker, private: |
200 | 208 |
201 ShellIntegration::DefaultWebClientState | 209 ShellIntegration::DefaultWebClientState |
202 ShellIntegration::DefaultBrowserWorker::CheckIsDefault() { | 210 ShellIntegration::DefaultBrowserWorker::CheckIsDefault() { |
203 return ShellIntegration::IsDefaultBrowser(); | 211 return ShellIntegration::IsDefaultBrowser(); |
204 } | 212 } |
205 | 213 |
206 void ShellIntegration::DefaultBrowserWorker::SetAsDefault() { | 214 void ShellIntegration::DefaultBrowserWorker::SetAsDefault( |
207 ShellIntegration::SetAsDefaultBrowser(); | 215 bool interactive_permitted) { |
| 216 ShellIntegration::DefaultSettingsChangePermission change_permissions = |
| 217 ShellIntegration::CanSetAsDefaultBrowser(); |
| 218 |
| 219 switch (change_permissions) { |
| 220 case ShellIntegration::CHANGE_DEFAULT_UNATTENDED: |
| 221 ShellIntegration::SetAsDefaultBrowser(); |
| 222 break; |
| 223 case ShellIntegration::CHANGE_DEFAULT_INTERACTIVE: |
| 224 if (interactive_permitted) |
| 225 ShellIntegration::SetAsDefaultBrowserInteractive(); |
| 226 break; |
| 227 default: |
| 228 NOTREACHED(); |
| 229 } |
208 } | 230 } |
209 | 231 |
210 /////////////////////////////////////////////////////////////////////////////// | 232 /////////////////////////////////////////////////////////////////////////////// |
211 // ShellIntegration::DefaultProtocolClientWorker | 233 // ShellIntegration::DefaultProtocolClientWorker |
212 // | 234 // |
213 | 235 |
214 ShellIntegration::DefaultProtocolClientWorker::DefaultProtocolClientWorker( | 236 ShellIntegration::DefaultProtocolClientWorker::DefaultProtocolClientWorker( |
215 DefaultWebClientObserver* observer, const std::string& protocol) | 237 DefaultWebClientObserver* observer, const std::string& protocol) |
216 : DefaultWebClientWorker(observer), | 238 : DefaultWebClientWorker(observer), |
217 protocol_(protocol) { | 239 protocol_(protocol) { |
218 } | 240 } |
219 | 241 |
220 /////////////////////////////////////////////////////////////////////////////// | 242 /////////////////////////////////////////////////////////////////////////////// |
221 // DefaultProtocolClientWorker, private: | 243 // DefaultProtocolClientWorker, private: |
222 | 244 |
223 ShellIntegration::DefaultWebClientState | 245 ShellIntegration::DefaultWebClientState |
224 ShellIntegration::DefaultProtocolClientWorker::CheckIsDefault() { | 246 ShellIntegration::DefaultProtocolClientWorker::CheckIsDefault() { |
225 return ShellIntegration::IsDefaultProtocolClient(protocol_); | 247 return ShellIntegration::IsDefaultProtocolClient(protocol_); |
226 } | 248 } |
227 | 249 |
228 void ShellIntegration::DefaultProtocolClientWorker::SetAsDefault() { | 250 void ShellIntegration::DefaultProtocolClientWorker::SetAsDefault( |
| 251 bool interactive_permitted) { |
229 ShellIntegration::SetAsDefaultProtocolClient(protocol_); | 252 ShellIntegration::SetAsDefaultProtocolClient(protocol_); |
230 } | 253 } |
OLD | NEW |