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 "base/nix/mime_util_xdg.h" | 5 #include "base/nix/mime_util_xdg.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
| 12 #include "base/base_paths.h" |
12 #include "base/environment.h" | 13 #include "base/environment.h" |
13 #include "base/file_util.h" | 14 #include "base/file_util.h" |
14 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
16 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/singleton.h" | 18 #include "base/memory/singleton.h" |
18 #include "base/nix/xdg_util.h" | 19 #include "base/nix/xdg_util.h" |
| 20 #include "base/path_service.h" |
19 #include "base/strings/string_split.h" | 21 #include "base/strings/string_split.h" |
20 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
21 #include "base/synchronization/lock.h" | 23 #include "base/synchronization/lock.h" |
22 #include "base/third_party/xdg_mime/xdgmime.h" | 24 #include "base/third_party/xdg_mime/xdgmime.h" |
23 #include "base/threading/thread_restrictions.h" | 25 #include "base/threading/thread_restrictions.h" |
24 #include "base/time/time.h" | 26 #include "base/time/time.h" |
25 | 27 |
26 namespace base { | 28 namespace base { |
27 namespace nix { | 29 namespace nix { |
28 | 30 |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 // For a xdg directory |dir|, add the appropriate icon sub-directories. | 408 // For a xdg directory |dir|, add the appropriate icon sub-directories. |
407 void AddXDGDataDir(const FilePath& dir) { | 409 void AddXDGDataDir(const FilePath& dir) { |
408 if (!DirectoryExists(dir)) | 410 if (!DirectoryExists(dir)) |
409 return; | 411 return; |
410 TryAddIconDir(dir.Append("icons")); | 412 TryAddIconDir(dir.Append("icons")); |
411 TryAddIconDir(dir.Append("pixmaps")); | 413 TryAddIconDir(dir.Append("pixmaps")); |
412 } | 414 } |
413 | 415 |
414 // Add all the xdg icon directories. | 416 // Add all the xdg icon directories. |
415 void InitIconDir() { | 417 void InitIconDir() { |
416 FilePath home = GetHomeDir(); | 418 FilePath home; |
| 419 PathService::Get(base::DIR_HOME, &home); |
417 if (!home.empty()) { | 420 if (!home.empty()) { |
418 FilePath legacy_data_dir(home); | 421 FilePath legacy_data_dir(home); |
419 legacy_data_dir = legacy_data_dir.AppendASCII(".icons"); | 422 legacy_data_dir = legacy_data_dir.AppendASCII(".icons"); |
420 if (DirectoryExists(legacy_data_dir)) | 423 if (DirectoryExists(legacy_data_dir)) |
421 TryAddIconDir(legacy_data_dir); | 424 TryAddIconDir(legacy_data_dir); |
422 } | 425 } |
423 const char* env = getenv("XDG_DATA_HOME"); | 426 const char* env = getenv("XDG_DATA_HOME"); |
424 if (env) { | 427 if (env) { |
425 AddXDGDataDir(FilePath(env)); | 428 AddXDGDataDir(FilePath(env)); |
426 } else if (!home.empty()) { | 429 } else if (!home.empty()) { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 icon_file = LookupIconInDefaultTheme(icon_names[i], size); | 648 icon_file = LookupIconInDefaultTheme(icon_names[i], size); |
646 if (!icon_file.empty()) | 649 if (!icon_file.empty()) |
647 return icon_file; | 650 return icon_file; |
648 } | 651 } |
649 } | 652 } |
650 return FilePath(); | 653 return FilePath(); |
651 } | 654 } |
652 | 655 |
653 } // namespace nix | 656 } // namespace nix |
654 } // namespace base | 657 } // namespace base |
OLD | NEW |