Chromium Code Reviews| Index: base/mime_util_xdg.cc |
| =================================================================== |
| --- base/mime_util_xdg.cc (revision 107991) |
| +++ base/mime_util_xdg.cc (working copy) |
| @@ -13,12 +13,14 @@ |
| #include <map> |
| #include <vector> |
| +#include "base/environment.h" |
| #include "base/file_util.h" |
| #include "base/lazy_instance.h" |
| #include "base/logging.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/memory/singleton.h" |
| #include "base/message_loop.h" |
| +#include "base/nix/xdg_util.h" |
| #include "base/string_split.h" |
| #include "base/string_util.h" |
| #include "base/synchronization/lock.h" |
| @@ -485,8 +487,11 @@ |
| IconTheme** default_themes = |
| MimeUtilConstants::GetInstance()->default_themes_; |
| - char* env = getenv("KDE_FULL_SESSION"); |
| - if (env) { |
| + scoped_ptr<base::Environment> env(base::Environment::Create()); |
| + base::nix::DesktopEnvironment desktop_env = |
| + base::nix::GetDesktopEnvironment(env.get()); |
| + if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE3 || |
| + desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4) { |
| // KDE |
| std::string kde_default_theme; |
| std::string kde_fallback_theme; |
| @@ -496,8 +501,7 @@ |
| default_themes[0] = NULL; |
| // Try some reasonable defaults for KDE. |
| - env = getenv("KDE_SESSION_VERSION"); |
| - if (!env || env[0] != '4') { |
| + if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE3) { |
| // KDE 3 |
| kde_default_theme = "default.kde"; |
| kde_fallback_theme = "crystalsvg"; |
| @@ -615,8 +619,11 @@ |
| icon_names.push_back("gnome-mime-" + icon_name); |
| // Try "deb" for "application/x-deb" in KDE 3. |
| - icon_name = mime_type.substr(mime_type.find("/x-") + 3); |
| - icon_names.push_back(icon_name); |
| + size_t x_substr_pos = mime_type.find("/x-"); |
| + if (x_substr_pos != std::string::npos) { |
|
willchan no longer on Chromium
2011/11/01 20:54:49
This is a new change that isn't explained by the c
Lei Zhang
2011/11/01 21:03:29
This is the "Also fix a case where we look up bad
willchan no longer on Chromium
2011/11/01 21:04:15
Sorry, I missed that. Explanation sounds great.
|
| + icon_name = mime_type.substr(x_substr_pos + 3); |
| + icon_names.push_back(icon_name); |
| + } |
| // Try generic name like text-x-generic. |
| icon_name = mime_type.substr(0, mime_type.find('/')) + "-x-generic"; |