OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/mime_util.h" | 5 #include "base/mime_util.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 #include <sys/time.h> | 8 #include <sys/time.h> |
9 #include <time.h> | 9 #include <time.h> |
10 | 10 |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 void AddXDGDataDir(const FilePath& dir) { | 389 void AddXDGDataDir(const FilePath& dir) { |
390 if (!file_util::DirectoryExists(dir)) | 390 if (!file_util::DirectoryExists(dir)) |
391 return; | 391 return; |
392 TryAddIconDir(dir.Append("icons")); | 392 TryAddIconDir(dir.Append("icons")); |
393 TryAddIconDir(dir.Append("pixmaps")); | 393 TryAddIconDir(dir.Append("pixmaps")); |
394 } | 394 } |
395 | 395 |
396 // Add all the xdg icon directories. | 396 // Add all the xdg icon directories. |
397 void InitIconDir() { | 397 void InitIconDir() { |
398 Singleton<MimeUtilConstants>::get()->icon_dirs_->clear(); | 398 Singleton<MimeUtilConstants>::get()->icon_dirs_->clear(); |
399 const char* home = getenv("HOME"); | 399 FilePath home = file_util::GetHomeDir(); |
400 if (home) { | 400 if (!home.empty()) { |
401 FilePath legacy_data_dir(home); | 401 FilePath legacy_data_dir(home); |
402 legacy_data_dir = legacy_data_dir.AppendASCII(".icons"); | 402 legacy_data_dir = legacy_data_dir.AppendASCII(".icons"); |
403 if (file_util::DirectoryExists(legacy_data_dir)) | 403 if (file_util::DirectoryExists(legacy_data_dir)) |
404 TryAddIconDir(legacy_data_dir); | 404 TryAddIconDir(legacy_data_dir); |
405 } | 405 } |
406 const char* env = getenv("XDG_DATA_HOME"); | 406 const char* env = getenv("XDG_DATA_HOME"); |
407 if (env) { | 407 if (env) { |
408 AddXDGDataDir(FilePath(env)); | 408 AddXDGDataDir(FilePath(env)); |
409 } else if (home) { | 409 } else if (!home.empty()) { |
410 FilePath local_data_dir(home); | 410 FilePath local_data_dir(home); |
411 local_data_dir = local_data_dir.AppendASCII(".local"); | 411 local_data_dir = local_data_dir.AppendASCII(".local"); |
412 local_data_dir = local_data_dir.AppendASCII("share"); | 412 local_data_dir = local_data_dir.AppendASCII("share"); |
413 AddXDGDataDir(local_data_dir); | 413 AddXDGDataDir(local_data_dir); |
414 } | 414 } |
415 | 415 |
416 env = getenv("XDG_DATA_DIRS"); | 416 env = getenv("XDG_DATA_DIRS"); |
417 if (!env) { | 417 if (!env) { |
418 AddXDGDataDir(FilePath("/usr/local/share")); | 418 AddXDGDataDir(FilePath("/usr/local/share")); |
419 AddXDGDataDir(FilePath("/usr/share")); | 419 AddXDGDataDir(FilePath("/usr/share")); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 } else { | 610 } else { |
611 icon_file = LookupIconInDefaultTheme(icon_names[i], size); | 611 icon_file = LookupIconInDefaultTheme(icon_names[i], size); |
612 if (!icon_file.empty()) | 612 if (!icon_file.empty()) |
613 return icon_file; | 613 return icon_file; |
614 } | 614 } |
615 } | 615 } |
616 return FilePath(); | 616 return FilePath(); |
617 } | 617 } |
618 | 618 |
619 } // namespace mime_util | 619 } // namespace mime_util |
OLD | NEW |