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

Side by Side Diff: chrome/browser/shell_integration_linux.cc

Issue 18286004: Move PathExists to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/shell_integration.cc ('k') | chrome/browser/shell_integration_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 545 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
546 546
547 base::FilePath shortcut_filename = GetExtensionShortcutFilename( 547 base::FilePath shortcut_filename = GetExtensionShortcutFilename(
548 profile_path, extension_id); 548 profile_path, extension_id);
549 DCHECK(!shortcut_filename.empty()); 549 DCHECK(!shortcut_filename.empty());
550 ShellIntegration::ShortcutLocations locations; 550 ShellIntegration::ShortcutLocations locations;
551 551
552 // Determine whether there is a shortcut on desktop. 552 // Determine whether there is a shortcut on desktop.
553 if (!desktop_path.empty()) { 553 if (!desktop_path.empty()) {
554 locations.on_desktop = 554 locations.on_desktop =
555 file_util::PathExists(desktop_path.Append(shortcut_filename)); 555 base::PathExists(desktop_path.Append(shortcut_filename));
556 } 556 }
557 557
558 // Determine whether there is a shortcut in the applications directory. 558 // Determine whether there is a shortcut in the applications directory.
559 std::string shortcut_contents; 559 std::string shortcut_contents;
560 if (GetExistingShortcutContents(env, shortcut_filename, &shortcut_contents)) { 560 if (GetExistingShortcutContents(env, shortcut_filename, &shortcut_contents)) {
561 // Whether this counts as "hidden" or "in_applications_menu" depends on 561 // Whether this counts as "hidden" or "in_applications_menu" depends on
562 // whether it contains NoDisplay=true. 562 // whether it contains NoDisplay=true.
563 if (GetNoDisplayFromDesktopFile(shortcut_contents)) 563 if (GetNoDisplayFromDesktopFile(shortcut_contents))
564 locations.hidden = true; 564 locations.hidden = true;
565 else 565 else
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 } 598 }
599 } else { 599 } else {
600 search_paths.push_back(base::FilePath("/usr/local/share")); 600 search_paths.push_back(base::FilePath("/usr/local/share"));
601 search_paths.push_back(base::FilePath("/usr/share")); 601 search_paths.push_back(base::FilePath("/usr/share"));
602 } 602 }
603 603
604 for (std::vector<base::FilePath>::const_iterator i = search_paths.begin(); 604 for (std::vector<base::FilePath>::const_iterator i = search_paths.begin();
605 i != search_paths.end(); ++i) { 605 i != search_paths.end(); ++i) {
606 base::FilePath path = i->Append("applications").Append(desktop_filename); 606 base::FilePath path = i->Append("applications").Append(desktop_filename);
607 VLOG(1) << "Looking for desktop file in " << path.value(); 607 VLOG(1) << "Looking for desktop file in " << path.value();
608 if (file_util::PathExists(path)) { 608 if (base::PathExists(path)) {
609 VLOG(1) << "Found desktop file at " << path.value(); 609 VLOG(1) << "Found desktop file at " << path.value();
610 return file_util::ReadFileToString(path, output); 610 return file_util::ReadFileToString(path, output);
611 } 611 }
612 } 612 }
613 613
614 return false; 614 return false;
615 } 615 }
616 616
617 base::FilePath GetWebShortcutFilename(const GURL& url) { 617 base::FilePath GetWebShortcutFilename(const GURL& url) {
618 // Use a prefix, because xdg-desktop-menu requires it. 618 // Use a prefix, because xdg-desktop-menu requires it.
619 std::string filename = 619 std::string filename =
620 std::string(chrome::kBrowserProcessExecutableName) + "-" + url.spec(); 620 std::string(chrome::kBrowserProcessExecutableName) + "-" + url.spec();
621 file_util::ReplaceIllegalCharactersInPath(&filename, '_'); 621 file_util::ReplaceIllegalCharactersInPath(&filename, '_');
622 622
623 base::FilePath desktop_path; 623 base::FilePath desktop_path;
624 if (!PathService::Get(base::DIR_USER_DESKTOP, &desktop_path)) 624 if (!PathService::Get(base::DIR_USER_DESKTOP, &desktop_path))
625 return base::FilePath(); 625 return base::FilePath();
626 626
627 base::FilePath filepath = desktop_path.Append(filename); 627 base::FilePath filepath = desktop_path.Append(filename);
628 base::FilePath alternative_filepath(filepath.value() + ".desktop"); 628 base::FilePath alternative_filepath(filepath.value() + ".desktop");
629 for (size_t i = 1; i < 100; ++i) { 629 for (size_t i = 1; i < 100; ++i) {
630 if (file_util::PathExists(base::FilePath(alternative_filepath))) { 630 if (base::PathExists(base::FilePath(alternative_filepath))) {
631 alternative_filepath = base::FilePath( 631 alternative_filepath = base::FilePath(
632 filepath.value() + "_" + base::IntToString(i) + ".desktop"); 632 filepath.value() + "_" + base::IntToString(i) + ".desktop");
633 } else { 633 } else {
634 return base::FilePath(alternative_filepath).BaseName(); 634 return base::FilePath(alternative_filepath).BaseName();
635 } 635 }
636 } 636 }
637 637
638 return base::FilePath(); 638 return base::FilePath();
639 } 639 }
640 640
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 // Delete shortcuts from |kDirectoryFilename|. 868 // Delete shortcuts from |kDirectoryFilename|.
869 // Note that it is possible that shortcuts were not created in the Chrome Apps 869 // Note that it is possible that shortcuts were not created in the Chrome Apps
870 // directory (depending on the value of |applications_menu_subdir| when they 870 // directory (depending on the value of |applications_menu_subdir| when they
871 // were created). It doesn't matter: this will still delete the shortcut even 871 // were created). It doesn't matter: this will still delete the shortcut even
872 // if it isn't in the directory. 872 // if it isn't in the directory.
873 DeleteShortcutInApplicationsMenu(shortcut_filename, 873 DeleteShortcutInApplicationsMenu(shortcut_filename,
874 base::FilePath(kDirectoryFilename)); 874 base::FilePath(kDirectoryFilename));
875 } 875 }
876 876
877 } // namespace ShellIntegrationLinux 877 } // namespace ShellIntegrationLinux
OLDNEW
« no previous file with comments | « chrome/browser/shell_integration.cc ('k') | chrome/browser/shell_integration_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698