diff options
-rw-r--r-- | chrome/browser/chromeos/main_menu.cc | 4 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host.cc | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_theme_provider.cc | 40 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_theme_provider.h | 28 | ||||
-rw-r--r-- | chrome/browser/renderer_preferences_util.cc | 23 | ||||
-rw-r--r-- | chrome/browser/renderer_preferences_util.h | 3 | ||||
-rw-r--r-- | chrome/browser/tab_contents/interstitial_page.cc | 10 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 8 | ||||
-rw-r--r-- | chrome/common/gtk_util.cc | 29 | ||||
-rw-r--r-- | chrome/common/gtk_util.h | 7 |
10 files changed, 77 insertions, 79 deletions
diff --git a/chrome/browser/chromeos/main_menu.cc b/chrome/browser/chromeos/main_menu.cc index f4bdcaf..a2ec8c5 100644 --- a/chrome/browser/chromeos/main_menu.cc +++ b/chrome/browser/chromeos/main_menu.cc @@ -245,7 +245,9 @@ void MainMenu::RequestMove(const gfx::Rect& new_bounds) { } RendererPreferences MainMenu::GetRendererPrefs(Profile* profile) const { - return renderer_preferences_util::GetInitedRendererPreferences(profile); + RendererPreferences preferences; + renderer_preferences_util::UpdateFromSystemSettings(&preferences, profile); + return preferences; } void MainMenu::CreateNewWindow(int route_id) { diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index e905291..d7716be 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -428,7 +428,9 @@ void ExtensionHost::Close(RenderViewHost* render_view_host) { } RendererPreferences ExtensionHost::GetRendererPrefs(Profile* profile) const { - return renderer_preferences_util::GetInitedRendererPreferences(profile); + RendererPreferences preferences; + renderer_preferences_util::UpdateFromSystemSettings(&preferences, profile); + return preferences; } WebPreferences ExtensionHost::GetWebkitPrefs() { diff --git a/chrome/browser/gtk/gtk_theme_provider.cc b/chrome/browser/gtk/gtk_theme_provider.cc index 971be0c..3c0efec 100644 --- a/chrome/browser/gtk/gtk_theme_provider.cc +++ b/chrome/browser/gtk/gtk_theme_provider.cc @@ -171,11 +171,13 @@ void GtkThemeProvider::InitThemesFor(NotificationObserver* observer) { void GtkThemeProvider::SetTheme(Extension* extension) { profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, false); + LoadDefaultValues(); BrowserThemeProvider::SetTheme(extension); } void GtkThemeProvider::UseDefaultTheme() { profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, false); + LoadDefaultValues(); BrowserThemeProvider::UseDefaultTheme(); } @@ -238,26 +240,7 @@ GdkColor GtkThemeProvider::GetBorderColor() const { void GtkThemeProvider::GetScrollbarColors(GdkColor* thumb_active_color, GdkColor* thumb_inactive_color, - GdkColor* track_color, - bool use_gtk_theme) { - if (!use_gtk_theme) { - // If using the default non-GTK colors, pick some reasonable choices of - // different greys. - thumb_active_color->pixel = 0; - thumb_active_color->red = 64250; - thumb_active_color->green = 63736; - thumb_active_color->blue = 62965; - thumb_inactive_color->pixel = 0; - thumb_inactive_color->red = 61680; - thumb_inactive_color->green = 60395; - thumb_inactive_color->blue = 58853; - track_color->pixel = 0; - track_color->red = 58339; - track_color->green = 56797; - track_color->blue = 55512; - return; - } - + GdkColor* track_color) { // Create window containing scrollbar elements GtkWidget* window = gtk_window_new(GTK_WINDOW_POPUP); GtkWidget* fixed = gtk_fixed_new(); @@ -390,6 +373,7 @@ void GtkThemeProvider::LoadThemePrefs() { if (use_gtk_) { LoadGtkValues(); } else { + LoadDefaultValues(); BrowserThemeProvider::LoadThemePrefs(); } } @@ -556,6 +540,22 @@ void GtkThemeProvider::LoadGtkValues() { &inactive_frame_color); SetTintToExactColor(BrowserThemeProvider::TINT_FRAME_INCOGNITO_INACTIVE, &inactive_frame_color); + + focus_ring_color_ = GdkToSkColor(&button_color); + GdkColor thumb_active_color, thumb_inactive_color, track_color; + GtkThemeProvider::GetScrollbarColors(&thumb_active_color, + &thumb_inactive_color, + &track_color); + thumb_active_color_ = GdkToSkColor(&thumb_active_color); + thumb_inactive_color_ = GdkToSkColor(&thumb_inactive_color); + track_color_ = GdkToSkColor(&track_color); +} + +void GtkThemeProvider::LoadDefaultValues() { + focus_ring_color_ = SkColorSetARGB(255, 229, 151, 0); + thumb_active_color_ = SkColorSetRGB(250, 248, 245); + thumb_inactive_color_ = SkColorSetRGB(240, 235, 229); + track_color_ = SkColorSetRGB(227, 221, 216); } void GtkThemeProvider::SetThemeColorFromGtk(int id, GdkColor* color) { diff --git a/chrome/browser/gtk/gtk_theme_provider.h b/chrome/browser/gtk/gtk_theme_provider.h index 44fed99..87e3fe2 100644 --- a/chrome/browser/gtk/gtk_theme_provider.h +++ b/chrome/browser/gtk/gtk_theme_provider.h @@ -72,8 +72,7 @@ class GtkThemeProvider : public BrowserThemeProvider, // Used when rendering scrollbars. static void GetScrollbarColors(GdkColor* thumb_active_color, GdkColor* thumb_inactive_color, - GdkColor* track_color, - bool use_gtk_theme); + GdkColor* track_color); // Expose the inner label. Only used for testing. GtkWidget* fake_label() { return fake_label_.get(); } @@ -83,9 +82,16 @@ class GtkThemeProvider : public BrowserThemeProvider, // to send the image to the server on each expose. CairoCachedSurface* GetSurfaceNamed(int id, GtkWidget* widget_on_display); - // These functions do not add a ref to the returned pixbuf, and it should not be - // unreffed. - // If |native| is true, get the GTK_STOCK version of the icon. + // Returns colors that we pass to webkit to match the system theme. + const SkColor& get_focus_ring_color() const { return focus_ring_color_; } + const SkColor& get_thumb_active_color() const { return thumb_active_color_; } + const SkColor& get_thumb_inactive_color() const { + return thumb_inactive_color_; + } + const SkColor& get_track_color() const { return track_color_; } + + // These functions do not add a ref to the returned pixbuf, and it should not + // be unreffed. If |native| is true, get the GTK_STOCK version of the icon. static GdkPixbuf* GetFolderIcon(bool native); static GdkPixbuf* GetDefaultFavicon(bool native); @@ -108,8 +114,13 @@ class GtkThemeProvider : public BrowserThemeProvider, GtkStyle* previous_style, GtkThemeProvider* provider); + // Extracts colors and tints from the GTK theme, both for the + // BrowserThemeProvider interface and the colors we send to webkit. void LoadGtkValues(); + // Sets the values that we send to webkit to safe defaults. + void LoadDefaultValues(); + // Sets the underlying theme colors/tints from a GTK color. void SetThemeColorFromGtk(int id, GdkColor* color); void SetThemeTintFromGtk(int id, GdkColor* color); @@ -154,6 +165,13 @@ class GtkThemeProvider : public BrowserThemeProvider, ColorMap colors_; TintMap tints_; + // Colors that we pass to WebKit. These are generated each time the theme + // changes. + SkColor focus_ring_color_; + SkColor thumb_active_color_; + SkColor thumb_inactive_color_; + SkColor track_color_; + // Image cache of lazily created images, created when requested by // GetBitmapNamed(). mutable ImageCache gtk_images_; diff --git a/chrome/browser/renderer_preferences_util.cc b/chrome/browser/renderer_preferences_util.cc index d3ef9a4..de9f711 100644 --- a/chrome/browser/renderer_preferences_util.cc +++ b/chrome/browser/renderer_preferences_util.cc @@ -4,7 +4,6 @@ #include "chrome/browser/renderer_preferences_util.h" -#include "base/singleton.h" #include "chrome/browser/profile.h" #if defined(OS_LINUX) @@ -14,17 +13,19 @@ namespace renderer_preferences_util { -RendererPreferences GetInitedRendererPreferences(Profile* profile) { - RendererPreferences* prefs = Singleton<RendererPreferences>::get(); +void UpdateFromSystemSettings(RendererPreferences* prefs, Profile* profile) { #if defined(OS_LINUX) - static bool inited = false; - if (!inited) { - gtk_util::InitRendererPrefsFromGtkSettings(prefs, - GtkThemeProvider::GetFrom(profile)->UseGtkTheme()); - inited = true; - } -#endif - return *prefs; + gtk_util::UpdateGtkFontSettings(prefs); + +#if !defined(TOOLKIT_VIEWS) + GtkThemeProvider* provider = GtkThemeProvider::GetFrom(profile); + + prefs->focus_ring_color = provider->get_focus_ring_color(); + prefs->thumb_active_color = provider->get_thumb_active_color(); + prefs->thumb_inactive_color = provider->get_thumb_inactive_color(); + prefs->track_color = provider->get_track_color(); +#endif // !defined(TOOLKIT_VIEWS) +#endif // defined(OS_LINUX) } } // renderer_preferences_util diff --git a/chrome/browser/renderer_preferences_util.h b/chrome/browser/renderer_preferences_util.h index 0a36c9d..697ae2a 100644 --- a/chrome/browser/renderer_preferences_util.h +++ b/chrome/browser/renderer_preferences_util.h @@ -11,7 +11,8 @@ class Profile; namespace renderer_preferences_util { -RendererPreferences GetInitedRendererPreferences(Profile* profile); +// Copies system configuration preferences into |prefs|. +void UpdateFromSystemSettings(RendererPreferences* prefs, Profile* profile); } // namespace renderer_preferences_util diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index d3da46e..55972f3 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -17,6 +17,7 @@ #include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/browser/renderer_host/resource_dispatcher_host.h" #include "chrome/browser/renderer_host/site_instance.h" +#include "chrome/browser/renderer_preferences_util.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/tab_contents.h" @@ -24,7 +25,6 @@ #include "chrome/common/bindings_policy.h" #if defined(TOOLKIT_GTK) #include "chrome/browser/gtk/gtk_theme_provider.h" -#include "chrome/common/gtk_util.h" #endif #include "chrome/common/notification_service.h" #include "grit/browser_resources.h" @@ -137,17 +137,15 @@ InterstitialPage::InterstitialPage(TabContents* tab, resource_dispatcher_host_notified_(false), ALLOW_THIS_IN_INITIALIZER_LIST(rvh_view_delegate_( new InterstitialPageRVHViewDelegate(this))) { + renderer_preferences_util::UpdateFromSystemSettings( + &renderer_preferences_, tab_->profile()); + InitInterstitialPageMap(); // It would be inconsistent to create an interstitial with no new navigation // (which is the case when the interstitial was triggered by a sub-resource on // a page) when we have a pending entry (in the process of loading a new top // frame). DCHECK(new_navigation || !tab->controller().pending_entry()); - -#if defined(TOOLKIT_GTK) - gtk_util::InitRendererPrefsFromGtkSettings(&renderer_preferences_, - GtkThemeProvider::GetFrom(tab->profile())->UseGtkTheme()); -#endif } InterstitialPage::~InterstitialPage() { diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 39a25f2..10efa22 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -258,9 +258,11 @@ TabContents::TabContents(Profile* profile, last_javascript_message_dismissal_(), suppress_javascript_messages_(false), is_showing_before_unload_dialog_(false), - renderer_preferences_( - renderer_preferences_util::GetInitedRendererPreferences(profile)), + renderer_preferences_(), opener_dom_ui_type_(DOMUIFactory::kNoDOMUI) { + renderer_preferences_util::UpdateFromSystemSettings( + &renderer_preferences_, profile); + #if defined(OS_CHROMEOS) // Make sure the thumbnailer is started before starting the render manager. // The thumbnailer will want to listen for RVH creations, one of which will @@ -2589,6 +2591,8 @@ void TabContents::Observe(NotificationType type, #if defined(OS_LINUX) case NotificationType::BROWSER_THEME_CHANGED: { + renderer_preferences_util::UpdateFromSystemSettings( + &renderer_preferences_, profile()); render_view_host()->SyncRendererPrefs(); break; } diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc index 5b078fb..75a5acf 100644 --- a/chrome/common/gtk_util.cc +++ b/chrome/common/gtk_util.cc @@ -440,8 +440,7 @@ GtkWidget* IndentWidget(GtkWidget* content) { return content_alignment; } -void InitRendererPrefsFromGtkSettings(RendererPreferences* prefs, - bool use_gtk_theme) { +void UpdateGtkFontSettings(RendererPreferences* prefs) { DCHECK(prefs); gint antialias = 0; @@ -490,32 +489,6 @@ void InitRendererPrefsFromGtkSettings(RendererPreferences* prefs, } } - static GtkWidget* fixed = gtk_fixed_new(); - GtkStyle* style = gtk_rc_get_style(fixed); - // base[SELECTED] seems more appropriate but in practice it is often too light - // to be easily visible. - GdkColor color = style->bg[GTK_STATE_SELECTED]; - prefs->focus_ring_color = - SkColorSetRGB(color.red / 257, color.green / 257, color.blue / 257); - - GdkColor thumb_active_color, thumb_inactive_color, track_color; - GtkThemeProvider::GetScrollbarColors(&thumb_active_color, - &thumb_inactive_color, - &track_color, - use_gtk_theme); - prefs->thumb_active_color = - SkColorSetRGB(thumb_active_color.red / 257, - thumb_active_color.green / 257, - thumb_active_color.blue / 257); - prefs->thumb_inactive_color = - SkColorSetRGB(thumb_inactive_color.red / 257, - thumb_inactive_color.green / 257, - thumb_inactive_color.blue / 257); - prefs->track_color = - SkColorSetRGB(track_color.red / 257, - track_color.green / 257, - track_color.blue / 257); - if (hint_style) g_free(hint_style); if (rgba_style) diff --git a/chrome/common/gtk_util.h b/chrome/common/gtk_util.h index 4eab8c6..f92c3ad 100644 --- a/chrome/common/gtk_util.h +++ b/chrome/common/gtk_util.h @@ -156,10 +156,9 @@ void SetLabelColor(GtkWidget* label, const GdkColor* color); // Adds the given widget to an alignment identing it by |kGroupIndent|. GtkWidget* IndentWidget(GtkWidget* content); -// Initialize the font settings in |prefs| (used when creating new renderers) -// based on GtkSettings (which itself comes from XSETTINGS). -void InitRendererPrefsFromGtkSettings(RendererPreferences* prefs, - bool use_gtk_theme); +// Sets (or resets) the font settings in |prefs| (used when creating new +// renderers) based on GtkSettings (which itself comes from XSETTINGS). +void UpdateGtkFontSettings(RendererPreferences* prefs); // Get the current location of the mouse cursor relative to the screen. gfx::Point ScreenPoint(GtkWidget* widget); |