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 return false; | |
Mark Mentovai
2011/05/23 00:23:52
Is there a bug filed to track adding this feature
benwells
2011/05/24 06:10:38
Done.
| |
259 } | |
260 | |
261 // static | |
262 ShellIntegration::DefaultClientAppState ShellIntegration::IsDefaultBrowser() { | |
258 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 263 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
259 | 264 |
260 scoped_ptr<base::Environment> env(base::Environment::Create()); | 265 scoped_ptr<base::Environment> env(base::Environment::Create()); |
261 | 266 |
262 std::vector<std::string> argv; | 267 std::vector<std::string> argv; |
263 argv.push_back("xdg-settings"); | 268 argv.push_back("xdg-settings"); |
264 argv.push_back("check"); | 269 argv.push_back("check"); |
265 argv.push_back("default-web-browser"); | 270 argv.push_back("default-web-browser"); |
266 argv.push_back(GetDesktopName(env.get())); | 271 argv.push_back(GetDesktopName(env.get())); |
267 | 272 |
268 std::string reply; | 273 std::string reply; |
269 if (!base::GetAppOutput(CommandLine(argv), &reply)) { | 274 if (!base::GetAppOutput(CommandLine(argv), &reply)) { |
270 // xdg-settings failed: we can't determine or set the default browser. | 275 // xdg-settings failed: we can't determine or set the default browser. |
271 return UNKNOWN_DEFAULT_BROWSER; | 276 return UNKNOWN_DEFAULT_CLIENT_APP; |
272 } | 277 } |
273 | 278 |
274 // Allow any reply that starts with "yes". | 279 // Allow any reply that starts with "yes". |
275 return (reply.find("yes") == 0) ? IS_DEFAULT_BROWSER : NOT_DEFAULT_BROWSER; | 280 return (reply.find("yes") == 0) ? |
281 IS_DEFAULT_CLIENT_APP : NOT_DEFAULT_CLIENT_APP; | |
276 } | 282 } |
277 | 283 |
278 // static | 284 // static |
285 ShellIntegration::DefaultClientAppState | |
286 ShellIntegration::IsDefaultProtocolClient(const std::string& protocol) { | |
287 return UNKNOWN_DEFAULT_CLIENT_APP; | |
288 } | |
289 | |
290 // static | |
279 bool ShellIntegration::IsFirefoxDefaultBrowser() { | 291 bool ShellIntegration::IsFirefoxDefaultBrowser() { |
280 std::vector<std::string> argv; | 292 std::vector<std::string> argv; |
281 argv.push_back("xdg-settings"); | 293 argv.push_back("xdg-settings"); |
282 argv.push_back("get"); | 294 argv.push_back("get"); |
283 argv.push_back("default-web-browser"); | 295 argv.push_back("default-web-browser"); |
284 | 296 |
285 std::string browser; | 297 std::string browser; |
286 // We don't care about the return value here. | 298 // We don't care about the return value here. |
287 base::GetAppOutput(CommandLine(argv), &browser); | 299 base::GetAppOutput(CommandLine(argv), &browser); |
288 return browser.find("irefox") != std::string::npos; | 300 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, | 501 shortcut_info.extension_id, |
490 shortcut_info.title, | 502 shortcut_info.title, |
491 icon_name); | 503 icon_name); |
492 | 504 |
493 if (shortcut_info.create_on_desktop) | 505 if (shortcut_info.create_on_desktop) |
494 CreateShortcutOnDesktop(shortcut_filename, contents); | 506 CreateShortcutOnDesktop(shortcut_filename, contents); |
495 | 507 |
496 if (shortcut_info.create_in_applications_menu) | 508 if (shortcut_info.create_in_applications_menu) |
497 CreateShortcutInApplicationsMenu(shortcut_filename, contents); | 509 CreateShortcutInApplicationsMenu(shortcut_filename, contents); |
498 } | 510 } |
OLD | NEW |