Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Unified Diff: base/mime_util_xdg.cc

Issue 8431018: Linux: Use the existing desktop environment detection code in mime_util_xdg.cc instead of its own... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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";
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698