Commit b027e8a6 authored by thestig@chromium.org's avatar thestig@chromium.org

Linux: Use the existing desktop environment detection code in mime_util_xdg.cc...

Linux: Use the existing desktop environment detection code in mime_util_xdg.cc instead of its own version. Also fix a case where we look up bad icon names.

BUG=none
TEST=none

Review URL: http://codereview.chromium.org/8431018

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108185 0039d316-1c4b-4281-b951-d872f2087c98
parent b9e97cf0
...@@ -13,12 +13,14 @@ ...@@ -13,12 +13,14 @@
#include <map> #include <map>
#include <vector> #include <vector>
#include "base/environment.h"
#include "base/file_util.h" #include "base/file_util.h"
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/nix/xdg_util.h"
#include "base/string_split.h" #include "base/string_split.h"
#include "base/string_util.h" #include "base/string_util.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
...@@ -486,8 +488,11 @@ void InitDefaultThemes() { ...@@ -486,8 +488,11 @@ void InitDefaultThemes() {
IconTheme** default_themes = IconTheme** default_themes =
MimeUtilConstants::GetInstance()->default_themes_; MimeUtilConstants::GetInstance()->default_themes_;
char* env = getenv("KDE_FULL_SESSION"); scoped_ptr<base::Environment> env(base::Environment::Create());
if (env) { 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 // KDE
std::string kde_default_theme; std::string kde_default_theme;
std::string kde_fallback_theme; std::string kde_fallback_theme;
...@@ -497,8 +502,7 @@ void InitDefaultThemes() { ...@@ -497,8 +502,7 @@ void InitDefaultThemes() {
default_themes[0] = NULL; default_themes[0] = NULL;
// Try some reasonable defaults for KDE. // Try some reasonable defaults for KDE.
env = getenv("KDE_SESSION_VERSION"); if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE3) {
if (!env || env[0] != '4') {
// KDE 3 // KDE 3
kde_default_theme = "default.kde"; kde_default_theme = "default.kde";
kde_fallback_theme = "crystalsvg"; kde_fallback_theme = "crystalsvg";
...@@ -616,8 +620,11 @@ FilePath GetMimeIcon(const std::string& mime_type, size_t size) { ...@@ -616,8 +620,11 @@ FilePath GetMimeIcon(const std::string& mime_type, size_t size) {
icon_names.push_back("gnome-mime-" + icon_name); icon_names.push_back("gnome-mime-" + icon_name);
// Try "deb" for "application/x-deb" in KDE 3. // Try "deb" for "application/x-deb" in KDE 3.
icon_name = mime_type.substr(mime_type.find("/x-") + 3); size_t x_substr_pos = mime_type.find("/x-");
icon_names.push_back(icon_name); if (x_substr_pos != std::string::npos) {
icon_name = mime_type.substr(x_substr_pos + 3);
icon_names.push_back(icon_name);
}
// Try generic name like text-x-generic. // Try generic name like text-x-generic.
icon_name = mime_type.substr(0, mime_type.find('/')) + "-x-generic"; icon_name = mime_type.substr(0, mime_type.find('/')) + "-x-generic";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment