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> |
(...skipping 11 matching lines...) Expand all Loading... | |
22 #include "base/third_party/xdg_mime/xdgmime.h" | 22 #include "base/third_party/xdg_mime/xdgmime.h" |
23 #include "base/threading/thread_restrictions.h" | 23 #include "base/threading/thread_restrictions.h" |
24 #include "base/time.h" | 24 #include "base/time.h" |
25 | 25 |
26 #if defined(TOOLKIT_GTK) | 26 #if defined(TOOLKIT_GTK) |
27 #include <gtk/gtk.h> // NOLINT | 27 #include <gtk/gtk.h> // NOLINT |
28 | 28 |
29 #include "base/message_loop.h" | 29 #include "base/message_loop.h" |
30 #endif | 30 #endif |
31 | 31 |
32 namespace base { | |
33 namespace nix { | |
34 | |
32 namespace { | 35 namespace { |
33 | 36 |
34 class IconTheme; | 37 class IconTheme; |
35 | 38 |
36 // None of the XDG stuff is thread-safe, so serialize all access under | 39 // None of the XDG stuff is thread-safe, so serialize all access under |
37 // this lock. | 40 // this lock. |
38 base::LazyInstance<base::Lock>::Leaky | 41 base::LazyInstance<base::Lock>::Leaky |
39 g_mime_util_xdg_lock = LAZY_INSTANCE_INITIALIZER; | 42 g_mime_util_xdg_lock = LAZY_INSTANCE_INITIALIZER; |
40 | 43 |
41 class MimeUtilConstants { | 44 class MimeUtilConstants { |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
506 | 509 |
507 // Initialize the list of default themes. | 510 // Initialize the list of default themes. |
508 void InitDefaultThemes() { | 511 void InitDefaultThemes() { |
509 IconTheme** default_themes = | 512 IconTheme** default_themes = |
510 MimeUtilConstants::GetInstance()->default_themes_; | 513 MimeUtilConstants::GetInstance()->default_themes_; |
511 | 514 |
512 scoped_ptr<base::Environment> env(base::Environment::Create()); | 515 scoped_ptr<base::Environment> env(base::Environment::Create()); |
513 base::nix::DesktopEnvironment desktop_env = | 516 base::nix::DesktopEnvironment desktop_env = |
514 base::nix::GetDesktopEnvironment(env.get()); | 517 base::nix::GetDesktopEnvironment(env.get()); |
515 if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE3 || | 518 if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE3 || |
516 desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4) { | 519 desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4) { |
jar (doing other things)
2013/02/13 03:15:56
nit: perhaps the base::nix on the above 4 lines, a
brettw
2013/02/13 20:45:34
I'll fix the extra "base::" and do a new patch. I
| |
517 // KDE | 520 // KDE |
518 std::string kde_default_theme; | 521 std::string kde_default_theme; |
519 std::string kde_fallback_theme; | 522 std::string kde_fallback_theme; |
520 | 523 |
521 // TODO(thestig): Figure out how to get the current icon theme on KDE. | 524 // TODO(thestig): Figure out how to get the current icon theme on KDE. |
522 // Setting stored in ~/.kde/share/config/kdeglobals under Icons -> Theme. | 525 // Setting stored in ~/.kde/share/config/kdeglobals under Icons -> Theme. |
523 default_themes[0] = NULL; | 526 default_themes[0] = NULL; |
524 | 527 |
525 // Try some reasonable defaults for KDE. | 528 // Try some reasonable defaults for KDE. |
526 if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE3) { | 529 if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE3) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
576 return LookupFallbackIcon(icon_name); | 579 return LookupFallbackIcon(icon_name); |
577 } | 580 } |
578 | 581 |
579 MimeUtilConstants::~MimeUtilConstants() { | 582 MimeUtilConstants::~MimeUtilConstants() { |
580 for (size_t i = 0; i < kDefaultThemeNum; i++) | 583 for (size_t i = 0; i < kDefaultThemeNum; i++) |
581 delete default_themes_[i]; | 584 delete default_themes_[i]; |
582 } | 585 } |
583 | 586 |
584 } // namespace | 587 } // namespace |
585 | 588 |
586 namespace base { | |
587 namespace nix { | |
588 | |
589 std::string GetFileMimeType(const FilePath& filepath) { | 589 std::string GetFileMimeType(const FilePath& filepath) { |
590 if (filepath.empty()) | 590 if (filepath.empty()) |
591 return std::string(); | 591 return std::string(); |
592 base::ThreadRestrictions::AssertIOAllowed(); | 592 base::ThreadRestrictions::AssertIOAllowed(); |
593 base::AutoLock scoped_lock(g_mime_util_xdg_lock.Get()); | 593 base::AutoLock scoped_lock(g_mime_util_xdg_lock.Get()); |
594 return xdg_mime_get_mime_type_from_file_name(filepath.value().c_str()); | 594 return xdg_mime_get_mime_type_from_file_name(filepath.value().c_str()); |
595 } | 595 } |
596 | 596 |
597 std::string GetDataMimeType(const std::string& data) { | 597 std::string GetDataMimeType(const std::string& data) { |
598 base::ThreadRestrictions::AssertIOAllowed(); | 598 base::ThreadRestrictions::AssertIOAllowed(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
668 icon_file = LookupIconInDefaultTheme(icon_names[i], size); | 668 icon_file = LookupIconInDefaultTheme(icon_names[i], size); |
669 if (!icon_file.empty()) | 669 if (!icon_file.empty()) |
670 return icon_file; | 670 return icon_file; |
671 } | 671 } |
672 } | 672 } |
673 return FilePath(); | 673 return FilePath(); |
674 } | 674 } |
675 | 675 |
676 } // namespace nix | 676 } // namespace nix |
677 } // namespace base | 677 } // namespace base |
OLD | NEW |