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_linux.h" | 5 #include "chrome/browser/shell_integration_linux.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <glib.h> | 8 #include <glib.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 // When calling this script we first try to use the script on PATH. If that | 272 // When calling this script we first try to use the script on PATH. If that |
273 // fails we then try to use the script that we have included. This gives | 273 // fails we then try to use the script that we have included. This gives |
274 // scripts on the system priority over ours, as distribution vendors may have | 274 // scripts on the system priority over ours, as distribution vendors may have |
275 // tweaked the script, but still allows our copy to be used if the script on the | 275 // tweaked the script, but still allows our copy to be used if the script on the |
276 // system fails, as the system copy may be missing capabilities of the Chrome | 276 // system fails, as the system copy may be missing capabilities of the Chrome |
277 // copy. | 277 // copy. |
278 | 278 |
279 // If |protocol| is empty this function sets Chrome as the default browser, | 279 // If |protocol| is empty this function sets Chrome as the default browser, |
280 // otherwise it sets Chrome as the default handler application for |protocol|. | 280 // otherwise it sets Chrome as the default handler application for |protocol|. |
281 bool SetDefaultWebClient(const std::string& protocol) { | 281 bool SetDefaultWebClient(const std::string& protocol) { |
| 282 #if defined(OS_CHROMEOS) |
| 283 return true; |
| 284 #else |
282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 285 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
283 | 286 |
284 scoped_ptr<base::Environment> env(base::Environment::Create()); | 287 scoped_ptr<base::Environment> env(base::Environment::Create()); |
285 | 288 |
286 std::vector<std::string> argv; | 289 std::vector<std::string> argv; |
287 argv.push_back(kXdgSettings); | 290 argv.push_back(kXdgSettings); |
288 argv.push_back("set"); | 291 argv.push_back("set"); |
289 if (protocol.empty()) { | 292 if (protocol.empty()) { |
290 argv.push_back(kXdgSettingsDefaultBrowser); | 293 argv.push_back(kXdgSettingsDefaultBrowser); |
291 } else { | 294 } else { |
292 argv.push_back(kXdgSettingsDefaultSchemeHandler); | 295 argv.push_back(kXdgSettingsDefaultSchemeHandler); |
293 argv.push_back(protocol); | 296 argv.push_back(protocol); |
294 } | 297 } |
295 argv.push_back(ShellIntegrationLinux::GetDesktopName(env.get())); | 298 argv.push_back(ShellIntegrationLinux::GetDesktopName(env.get())); |
296 | 299 |
297 int exit_code; | 300 int exit_code; |
298 bool ran_ok = LaunchXdgUtility(argv, &exit_code); | 301 bool ran_ok = LaunchXdgUtility(argv, &exit_code); |
299 if (ran_ok && exit_code == EXIT_XDG_SETTINGS_SYNTAX_ERROR) { | 302 if (ran_ok && exit_code == EXIT_XDG_SETTINGS_SYNTAX_ERROR) { |
300 if (GetChromeVersionOfScript(kXdgSettings, &argv[0])) { | 303 if (GetChromeVersionOfScript(kXdgSettings, &argv[0])) { |
301 ran_ok = LaunchXdgUtility(argv, &exit_code); | 304 ran_ok = LaunchXdgUtility(argv, &exit_code); |
302 } | 305 } |
303 } | 306 } |
304 | 307 |
305 return ran_ok && exit_code == EXIT_SUCCESS; | 308 return ran_ok && exit_code == EXIT_SUCCESS; |
| 309 #endif |
306 } | 310 } |
307 | 311 |
308 // If |protocol| is empty this function checks if Chrome is the default browser, | 312 // If |protocol| is empty this function checks if Chrome is the default browser, |
309 // otherwise it checks if Chrome is the default handler application for | 313 // otherwise it checks if Chrome is the default handler application for |
310 // |protocol|. | 314 // |protocol|. |
311 ShellIntegration::DefaultWebClientState GetIsDefaultWebClient( | 315 ShellIntegration::DefaultWebClientState GetIsDefaultWebClient( |
312 const std::string& protocol) { | 316 const std::string& protocol) { |
| 317 #if defined(OS_CHROMEOS) |
| 318 return ShellIntegration::IS_DEFAULT_WEB_CLIENT; |
| 319 #else |
313 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 320 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
314 | 321 |
315 scoped_ptr<base::Environment> env(base::Environment::Create()); | 322 scoped_ptr<base::Environment> env(base::Environment::Create()); |
316 | 323 |
317 std::vector<std::string> argv; | 324 std::vector<std::string> argv; |
318 argv.push_back(kXdgSettings); | 325 argv.push_back(kXdgSettings); |
319 argv.push_back("check"); | 326 argv.push_back("check"); |
320 if (protocol.empty()) { | 327 if (protocol.empty()) { |
321 argv.push_back(kXdgSettingsDefaultBrowser); | 328 argv.push_back(kXdgSettingsDefaultBrowser); |
322 } else { | 329 } else { |
(...skipping 14 matching lines...) Expand all Loading... |
337 } | 344 } |
338 | 345 |
339 if (!ran_ok || success_code != EXIT_SUCCESS) { | 346 if (!ran_ok || success_code != EXIT_SUCCESS) { |
340 // xdg-settings failed: we can't determine or set the default browser. | 347 // xdg-settings failed: we can't determine or set the default browser. |
341 return ShellIntegration::UNKNOWN_DEFAULT_WEB_CLIENT; | 348 return ShellIntegration::UNKNOWN_DEFAULT_WEB_CLIENT; |
342 } | 349 } |
343 | 350 |
344 // Allow any reply that starts with "yes". | 351 // Allow any reply that starts with "yes". |
345 return (reply.find("yes") == 0) ? ShellIntegration::IS_DEFAULT_WEB_CLIENT : | 352 return (reply.find("yes") == 0) ? ShellIntegration::IS_DEFAULT_WEB_CLIENT : |
346 ShellIntegration::NOT_DEFAULT_WEB_CLIENT; | 353 ShellIntegration::NOT_DEFAULT_WEB_CLIENT; |
| 354 #endif |
347 } | 355 } |
348 | 356 |
349 } // namespace | 357 } // namespace |
350 | 358 |
351 // static | 359 // static |
352 bool ShellIntegration::CanSetAsDefaultBrowser() { | 360 bool ShellIntegration::CanSetAsDefaultBrowser() { |
353 return true; | 361 return true; |
354 } | 362 } |
355 | 363 |
356 // static | 364 // static |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 success = CreateShortcutOnDesktop(shortcut_filename, contents); | 638 success = CreateShortcutOnDesktop(shortcut_filename, contents); |
631 | 639 |
632 if (shortcut_info.create_in_applications_menu) | 640 if (shortcut_info.create_in_applications_menu) |
633 success = CreateShortcutInApplicationsMenu(shortcut_filename, contents) && | 641 success = CreateShortcutInApplicationsMenu(shortcut_filename, contents) && |
634 success; | 642 success; |
635 | 643 |
636 return success; | 644 return success; |
637 } | 645 } |
638 | 646 |
639 } // namespace ShellIntegrationLinux | 647 } // namespace ShellIntegrationLinux |
OLD | NEW |