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

Unified Diff: base/mime_util_linux.cc

Issue 173216: Move gtk_settings_get_default() call to the UI thread. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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 | « base/mime_util.h ('k') | chrome/browser/icon_loader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/mime_util_linux.cc
===================================================================
--- base/mime_util_linux.cc (revision 23879)
+++ base/mime_util_linux.cc (working copy)
@@ -15,6 +15,7 @@
#include "base/file_util.h"
#include "base/logging.h"
+#include "base/message_loop.h"
#include "base/scoped_ptr.h"
#include "base/singleton.h"
#include "base/string_util.h"
@@ -46,6 +47,11 @@
time_t last_check_time_;
+ // 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_;
+
private:
MimeUtilConstants()
: kUpdateInterval(5),
@@ -489,13 +495,9 @@
default_themes[2] = IconTheme::LoadTheme(kde_fallback_theme);
} else {
// Assume it's Gnome and use GTK to figure out the theme.
- gchar* gtk_theme_name;
- g_object_get(gtk_settings_get_default(),
- "gtk-icon-theme-name",
- &gtk_theme_name, NULL);
- default_themes[1] = IconTheme::LoadTheme(gtk_theme_name);
+ default_themes[1] = IconTheme::LoadTheme(
+ Singleton<MimeUtilConstants>::get()->gtk_theme_name_);
default_themes[2] = IconTheme::LoadTheme("gnome");
- g_free(gtk_theme_name);
}
// hicolor needs to be last per icon theme spec.
default_themes[3] = IconTheme::LoadTheme("hicolor");
@@ -550,6 +552,24 @@
return xdg_mime_get_mime_type_for_data(data.data(), data.length(), NULL);
}
+void DetectGtkTheme() {
+ // 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 (!Singleton<MimeUtilConstants>::get()->gtk_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);
+ Singleton<MimeUtilConstants>::get()->gtk_theme_name_.assign(gtk_theme_name);
+ g_free(gtk_theme_name);
+}
+
FilePath GetMimeIcon(const std::string& mime_type, size_t size) {
std::vector<std::string> icon_names;
std::string icon_name;
« no previous file with comments | « base/mime_util.h ('k') | chrome/browser/icon_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698