| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 247 |
| 248 std::vector<std::string> argv; | 248 std::vector<std::string> argv; |
| 249 argv.push_back("xdg-settings"); | 249 argv.push_back("xdg-settings"); |
| 250 argv.push_back("set"); | 250 argv.push_back("set"); |
| 251 argv.push_back("default-web-browser"); | 251 argv.push_back("default-web-browser"); |
| 252 argv.push_back(GetDesktopName(env.get())); | 252 argv.push_back(GetDesktopName(env.get())); |
| 253 return LaunchXdgUtility(argv); | 253 return LaunchXdgUtility(argv); |
| 254 } | 254 } |
| 255 | 255 |
| 256 // static | 256 // static |
| 257 ShellIntegration::DefaultBrowserState ShellIntegration::IsDefaultBrowser() { | 257 bool ShellIntegration::SetAsDefaultProtocolClient(const std::string& protocol) { |
| 258 // TODO(benwells): Implement this for Linux - crbug.com/83557 |
| 259 return false; |
| 260 } |
| 261 |
| 262 // static |
| 263 ShellIntegration::DefaultWebClientState ShellIntegration::IsDefaultBrowser() { |
| 258 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 264 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 259 | 265 |
| 260 scoped_ptr<base::Environment> env(base::Environment::Create()); | 266 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 261 | 267 |
| 262 std::vector<std::string> argv; | 268 std::vector<std::string> argv; |
| 263 argv.push_back("xdg-settings"); | 269 argv.push_back("xdg-settings"); |
| 264 argv.push_back("check"); | 270 argv.push_back("check"); |
| 265 argv.push_back("default-web-browser"); | 271 argv.push_back("default-web-browser"); |
| 266 argv.push_back(GetDesktopName(env.get())); | 272 argv.push_back(GetDesktopName(env.get())); |
| 267 | 273 |
| 268 std::string reply; | 274 std::string reply; |
| 269 if (!base::GetAppOutput(CommandLine(argv), &reply)) { | 275 if (!base::GetAppOutput(CommandLine(argv), &reply)) { |
| 270 // xdg-settings failed: we can't determine or set the default browser. | 276 // xdg-settings failed: we can't determine or set the default browser. |
| 271 return UNKNOWN_DEFAULT_BROWSER; | 277 return UNKNOWN_DEFAULT_WEB_CLIENT; |
| 272 } | 278 } |
| 273 | 279 |
| 274 // Allow any reply that starts with "yes". | 280 // Allow any reply that starts with "yes". |
| 275 return (reply.find("yes") == 0) ? IS_DEFAULT_BROWSER : NOT_DEFAULT_BROWSER; | 281 return (reply.find("yes") == 0) ? |
| 282 IS_DEFAULT_WEB_CLIENT : NOT_DEFAULT_WEB_CLIENT; |
| 276 } | 283 } |
| 277 | 284 |
| 278 // static | 285 // static |
| 286 ShellIntegration::DefaultWebClientState |
| 287 ShellIntegration::IsDefaultProtocolClient(const std::string& protocol) { |
| 288 // TODO(benwells): Implement this for Linux - crbug.com/83557 |
| 289 return UNKNOWN_DEFAULT_WEB_CLIENT; |
| 290 } |
| 291 |
| 292 // static |
| 279 bool ShellIntegration::IsFirefoxDefaultBrowser() { | 293 bool ShellIntegration::IsFirefoxDefaultBrowser() { |
| 280 std::vector<std::string> argv; | 294 std::vector<std::string> argv; |
| 281 argv.push_back("xdg-settings"); | 295 argv.push_back("xdg-settings"); |
| 282 argv.push_back("get"); | 296 argv.push_back("get"); |
| 283 argv.push_back("default-web-browser"); | 297 argv.push_back("default-web-browser"); |
| 284 | 298 |
| 285 std::string browser; | 299 std::string browser; |
| 286 // We don't care about the return value here. | 300 // We don't care about the return value here. |
| 287 base::GetAppOutput(CommandLine(argv), &browser); | 301 base::GetAppOutput(CommandLine(argv), &browser); |
| 288 return browser.find("irefox") != std::string::npos; | 302 return browser.find("irefox") != std::string::npos; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 shortcut_info.extension_id, | 503 shortcut_info.extension_id, |
| 490 shortcut_info.title, | 504 shortcut_info.title, |
| 491 icon_name); | 505 icon_name); |
| 492 | 506 |
| 493 if (shortcut_info.create_on_desktop) | 507 if (shortcut_info.create_on_desktop) |
| 494 CreateShortcutOnDesktop(shortcut_filename, contents); | 508 CreateShortcutOnDesktop(shortcut_filename, contents); |
| 495 | 509 |
| 496 if (shortcut_info.create_in_applications_menu) | 510 if (shortcut_info.create_in_applications_menu) |
| 497 CreateShortcutInApplicationsMenu(shortcut_filename, contents); | 511 CreateShortcutInApplicationsMenu(shortcut_filename, contents); |
| 498 } | 512 } |
| OLD | NEW |