summaryrefslogtreecommitdiffstats
path: root/base/nix
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-15 17:38:29 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-15 17:38:29 +0000
commitc032919dcaf3f150973de1904259a8afc742c3c1 (patch)
tree358cec8dd0324434e9ba7adf511fe645d5ad60a0 /base/nix
parent8c569022dc1953dd628c1266cb2ac2ec1912b949 (diff)
downloadchromium_src-c032919dcaf3f150973de1904259a8afc742c3c1.zip
chromium_src-c032919dcaf3f150973de1904259a8afc742c3c1.tar.gz
chromium_src-c032919dcaf3f150973de1904259a8afc742c3c1.tar.bz2
linux: Both gtk and the aura port should set the icon theme name.
BUG=176103 Review URL: https://codereview.chromium.org/12230026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182748 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/nix')
-rw-r--r--base/nix/mime_util_xdg.cc34
-rw-r--r--base/nix/mime_util_xdg.h10
2 files changed, 10 insertions, 34 deletions
diff --git a/base/nix/mime_util_xdg.cc b/base/nix/mime_util_xdg.cc
index 63760bd..affc46d 100644
--- a/base/nix/mime_util_xdg.cc
+++ b/base/nix/mime_util_xdg.cc
@@ -23,12 +23,6 @@
#include "base/threading/thread_restrictions.h"
#include "base/time.h"
-#if defined(TOOLKIT_GTK)
-#include <gtk/gtk.h> // NOLINT
-
-#include "base/message_loop.h"
-#endif
-
namespace {
class IconTheme;
@@ -67,12 +61,8 @@ class MimeUtilConstants {
base::TimeTicks last_check_time_;
-#if defined(TOOLKIT_GTK)
- // This is set by DetectGtkTheme(). We cache it so that we can access the
- // theme name from threads that aren't allowed to call
- // gtk_settings_get_default().
- std::string gtk_theme_name_;
-#endif
+ // The current icon theme, usually set through GTK theme integration.
+ std::string icon_theme_name_;
private:
MimeUtilConstants() {
@@ -535,12 +525,10 @@ void InitDefaultThemes() {
default_themes[1] = IconTheme::LoadTheme(kde_default_theme);
default_themes[2] = IconTheme::LoadTheme(kde_fallback_theme);
} else {
-#if defined(TOOLKIT_GTK)
// Assume it's Gnome and use GTK to figure out the theme.
default_themes[1] = IconTheme::LoadTheme(
- MimeUtilConstants::GetInstance()->gtk_theme_name_);
+ MimeUtilConstants::GetInstance()->icon_theme_name_);
default_themes[2] = IconTheme::LoadTheme("gnome");
-#endif
}
// hicolor needs to be last per icon theme spec.
default_themes[3] = IconTheme::LoadTheme("hicolor");
@@ -600,25 +588,15 @@ std::string GetDataMimeType(const std::string& data) {
return xdg_mime_get_mime_type_for_data(data.data(), data.length(), NULL);
}
-#if defined(TOOLKIT_GTK)
-void DetectGtkTheme() {
+void SetIconThemeName(const std::string& name) {
// If the theme name is already loaded, do nothing. Chrome doesn't respond
// to changes in the system theme, so we never need to set this more than
// once.
- if (!MimeUtilConstants::GetInstance()->gtk_theme_name_.empty())
+ if (!MimeUtilConstants::GetInstance()->icon_theme_name_.empty())
return;
- // We should only be called on the UI thread.
- DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type());
-
- gchar* gtk_theme_name;
- g_object_get(gtk_settings_get_default(),
- "gtk-icon-theme-name",
- &gtk_theme_name, NULL);
- MimeUtilConstants::GetInstance()->gtk_theme_name_.assign(gtk_theme_name);
- g_free(gtk_theme_name);
+ MimeUtilConstants::GetInstance()->icon_theme_name_ = name;
}
-#endif
FilePath GetMimeIcon(const std::string& mime_type, size_t size) {
base::ThreadRestrictions::AssertIOAllowed();
diff --git a/base/nix/mime_util_xdg.h b/base/nix/mime_util_xdg.h
index 79dba89..79eb782 100644
--- a/base/nix/mime_util_xdg.h
+++ b/base/nix/mime_util_xdg.h
@@ -25,12 +25,10 @@ BASE_EXPORT std::string GetFileMimeType(const FilePath& filepath);
// Get the mime type for a byte vector.
BASE_EXPORT std::string GetDataMimeType(const std::string& data);
-#if defined(TOOLKIT_GTK)
-// This detects the current GTK theme by calling gtk_settings_get_default().
-// It should only be executed on the UI thread and must be called before
-// GetMimeIcon().
-BASE_EXPORT void DetectGtkTheme();
-#endif
+// Sets the current icon theme that we've detected from the desktop
+// environment. Currently only works when we believe we're in a GTK
+// environment.
+BASE_EXPORT void SetIconThemeName(const std::string& name);
// Gets the file name for an icon given the mime type and icon pixel size.
// Where an icon is a square image of |size| x |size|.