diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-09 20:26:43 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-09 20:26:43 +0000 |
commit | b5ac37f3cc4b85b8f7cee0b7ba61640b4a7673b5 (patch) | |
tree | 8e2a9f96f9671cb92b9362f0954df0b44595c533 /chrome/browser | |
parent | 37a649305d53e4be8862da1d84797d44655acd51 (diff) | |
download | chromium_src-b5ac37f3cc4b85b8f7cee0b7ba61640b4a7673b5.zip chromium_src-b5ac37f3cc4b85b8f7cee0b7ba61640b4a7673b5.tar.gz chromium_src-b5ac37f3cc4b85b8f7cee0b7ba61640b4a7673b5.tar.bz2 |
rollback r34183
tbr=asargent
Review URL: http://codereview.chromium.org/482002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34187 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/chromeos/main_menu.cc | 4 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host.cc | 6 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host.h | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_theme_provider.cc | 89 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_theme_provider.h | 7 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 5 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host_delegate.h | 2 | ||||
-rw-r--r-- | chrome/browser/renderer_preferences_util.cc | 30 | ||||
-rw-r--r-- | chrome/browser/renderer_preferences_util.h | 18 | ||||
-rw-r--r-- | chrome/browser/tab_contents/interstitial_page.cc | 4 | ||||
-rw-r--r-- | chrome/browser/tab_contents/interstitial_page.h | 2 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 6 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.h | 2 |
13 files changed, 14 insertions, 163 deletions
diff --git a/chrome/browser/chromeos/main_menu.cc b/chrome/browser/chromeos/main_menu.cc index 5547f28..9f6cd15 100644 --- a/chrome/browser/chromeos/main_menu.cc +++ b/chrome/browser/chromeos/main_menu.cc @@ -20,9 +20,9 @@ #include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" #include "chrome/browser/renderer_host/site_instance.h" -#include "chrome/browser/renderer_preferences_util.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" +#include "chrome/common/platform_util.h" #include "grit/app_resources.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -245,7 +245,7 @@ void MainMenu::RequestMove(const gfx::Rect& new_bounds) { } RendererPreferences MainMenu::GetRendererPrefs() const { - return renderer_preferences_util::GetInitedRendererPreferences(); + return platform_util::GetInitedRendererPreferences(); } void MainMenu::CreateNewWindow(int route_id) { diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 589a4ca..0ad3a9e 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -27,12 +27,12 @@ #include "chrome/browser/renderer_host/render_widget_host.h" #include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/browser/renderer_host/site_instance.h" -#include "chrome/browser/renderer_preferences_util.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/common/bindings_policy.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/notification_service.h" +#include "chrome/common/platform_util.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "chrome/common/view_types.h" @@ -415,8 +415,8 @@ void ExtensionHost::Close(RenderViewHost* render_view_host) { } } -RendererPreferences ExtensionHost::GetRendererPrefs(Profile* profile) const { - return renderer_preferences_util::GetInitedRendererPreferences(profile); +RendererPreferences ExtensionHost::GetRendererPrefs() const { + return platform_util::GetInitedRendererPreferences(); } WebPreferences ExtensionHost::GetWebkitPrefs() { diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h index 21939ba..76f20d2 100644 --- a/chrome/browser/extensions/extension_host.h +++ b/chrome/browser/extensions/extension_host.h @@ -119,7 +119,7 @@ class ExtensionHost : public ExtensionPopupHost::PopupDelegate, IPC::Message* reply_msg, bool* did_suppress_message); virtual void Close(RenderViewHost* render_view_host); - virtual RendererPreferences GetRendererPrefs(Profile* profile) const; + virtual RendererPreferences GetRendererPrefs() const; // RenderViewHostDelegate::View virtual void CreateNewWindow(int route_id); diff --git a/chrome/browser/gtk/gtk_theme_provider.cc b/chrome/browser/gtk/gtk_theme_provider.cc index 4f35110..c12ec92 100644 --- a/chrome/browser/gtk/gtk_theme_provider.cc +++ b/chrome/browser/gtk/gtk_theme_provider.cc @@ -176,95 +176,6 @@ GdkColor GtkThemeProvider::GetBorderColor() const { return color; } -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; - } - - // Create window containing scrollbar elements - GtkWidget* window = gtk_window_new(GTK_WINDOW_POPUP); - GtkWidget* fixed = gtk_fixed_new(); - GtkWidget* scrollbar = gtk_hscrollbar_new(NULL); - gtk_container_add(GTK_CONTAINER(window), fixed); - gtk_container_add(GTK_CONTAINER(fixed), scrollbar); - gtk_widget_realize(window); - gtk_widget_realize(scrollbar); - - // Draw scrollbar thumb part and track into offscreen image - int kWidth = 100; - int kHeight = 20; - GtkStyle* style = gtk_rc_get_style(scrollbar); - GdkPixmap* pm = gdk_pixmap_new(window->window, kWidth, kHeight, -1); - GdkRectangle rect = { 0, 0, kWidth, kHeight }; - unsigned char data[3*kWidth*kHeight]; - for (int i = 0; i < 3; ++i) { - if (i < 2) { - // Thumb part - gtk_paint_slider(style, pm, - i == 0 ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL, - GTK_SHADOW_OUT, &rect, scrollbar, "slider", 0, 0, - kWidth, kHeight, GTK_ORIENTATION_HORIZONTAL); - } else { - // Track - gtk_paint_box(style, pm, GTK_STATE_ACTIVE, GTK_SHADOW_IN, &rect, - scrollbar, "trough-upper", 0, 0, kWidth, kHeight); - } - GdkPixbuf* pb = gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, - FALSE, 8, kWidth, kHeight, - 3*kWidth, 0, 0); - gdk_pixbuf_get_from_drawable(pb, pm, NULL, 0, 0, 0, 0, kWidth, kHeight); - - // Sample pixels - int components[3] = { 0 }; - for (int y = 2; y < kHeight-2; ++y) { - for (int c = 0; c < 3; ++c) { - // Sample a vertical slice of pixels at about one-thirds from the - // left edge. This allows us to avoid any fixed graphics that might be - // located at the edges or in the center of the scrollbar. - // Each pixel is made up of a red, green, and blue component; taking up - // a total of three bytes. - components[c] += data[3*(kWidth/3 + y*kWidth) + c]; - } - } - GdkColor* color = i == 0 ? thumb_active_color : - i == 1 ? thumb_inactive_color : - track_color; - color->pixel = 0; - // We sampled pixels across the full height of the image, ignoring a two - // pixel border. In some themes, the border has a completely different - // color which we do not want to factor into our average color computation. - // - // We now need to scale the colors from the 0..255 range, to the wider - // 0..65535 range, and we need to actually compute the average color; so, - // we divide by the total number of pixels in the sample. - color->red = components[0] * 65535 / (255*(kHeight-4)); - color->green = components[1] * 65535 / (255*(kHeight-4)); - color->blue = components[2] * 65535 / (255*(kHeight-4)); - - g_object_unref(pb); - } - g_object_unref(pm); - - gtk_widget_destroy(window); -} - CairoCachedSurface* GtkThemeProvider::GetSurfaceNamed( int id, GtkWidget* widget_on_display) { GdkDisplay* display = gtk_widget_get_display(widget_on_display); diff --git a/chrome/browser/gtk/gtk_theme_provider.h b/chrome/browser/gtk/gtk_theme_provider.h index 60d72e7..f39902e 100644 --- a/chrome/browser/gtk/gtk_theme_provider.h +++ b/chrome/browser/gtk/gtk_theme_provider.h @@ -65,13 +65,6 @@ class GtkThemeProvider : public BrowserThemeProvider, // label. Used for borders between GTK stuff and the webcontent. GdkColor GetBorderColor() const; - // This method returns averages of the thumb part and of the track colors. - // Used when rendering scrollbars. - static void GetScrollbarColors(GdkColor* thumb_active_color, - GdkColor* thumb_inactive_color, - GdkColor* track_color, - bool use_gtk_theme); - // Expose the inner label. Only used for testing. GtkWidget* fake_label() { return fake_label_.get(); } diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index ed6b80e..a473519 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -207,7 +207,7 @@ bool RenderViewHost::CreateRenderView( } Send(new ViewMsg_New(GetNativeViewId(), - delegate_->GetRendererPrefs(process()->profile()), + delegate_->GetRendererPrefs(), webkit_prefs, routing_id())); @@ -234,8 +234,7 @@ bool RenderViewHost::IsRenderViewLive() const { void RenderViewHost::SyncRendererPrefs() { Send(new ViewMsg_SetRendererPrefs(routing_id(), - delegate_->GetRendererPrefs( - process()->profile()))); + delegate_->GetRendererPrefs())); } void RenderViewHost::Navigate(const ViewMsg_Navigate_Params& params) { diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index 1862006..a3d75c6 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -528,7 +528,7 @@ class RenderViewHostDelegate { // Return a dummy RendererPreferences object that will be used by the renderer // associated with the owning RenderViewHost. - virtual RendererPreferences GetRendererPrefs(Profile* profile) const = 0; + virtual RendererPreferences GetRendererPrefs() const = 0; // Returns a WebPreferences object that will be used by the renderer // associated with the owning render view host. diff --git a/chrome/browser/renderer_preferences_util.cc b/chrome/browser/renderer_preferences_util.cc deleted file mode 100644 index d3ef9a4..0000000 --- a/chrome/browser/renderer_preferences_util.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/renderer_preferences_util.h" - -#include "base/singleton.h" -#include "chrome/browser/profile.h" - -#if defined(OS_LINUX) -#include "chrome/browser/gtk/gtk_theme_provider.h" -#include "chrome/common/gtk_util.h" -#endif - -namespace renderer_preferences_util { - -RendererPreferences GetInitedRendererPreferences(Profile* profile) { - RendererPreferences* prefs = Singleton<RendererPreferences>::get(); -#if defined(OS_LINUX) - static bool inited = false; - if (!inited) { - gtk_util::InitRendererPrefsFromGtkSettings(prefs, - GtkThemeProvider::GetFrom(profile)->UseGtkTheme()); - inited = true; - } -#endif - return *prefs; -} - -} // renderer_preferences_util diff --git a/chrome/browser/renderer_preferences_util.h b/chrome/browser/renderer_preferences_util.h deleted file mode 100644 index 0a36c9d..0000000 --- a/chrome/browser/renderer_preferences_util.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_RENDERER_PREFERENCES_UTIL_H_ -#define CHROME_BROWSER_RENDERER_PREFERENCES_UTIL_H_ - -#include "chrome/common/renderer_preferences.h" - -class Profile; - -namespace renderer_preferences_util { - -RendererPreferences GetInitedRendererPreferences(Profile* profile); - -} // namespace renderer_preferences_util - -#endif // CHROME_BROWSER_RENDERER_PREFERENCES_UTIL_H_ diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index 1af79b6..aae90da 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -23,7 +23,6 @@ #include "chrome/browser/tab_contents/tab_contents_view.h" #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" @@ -144,8 +143,7 @@ InterstitialPage::InterstitialPage(TabContents* tab, DCHECK(new_navigation || !tab->controller().pending_entry()); #if defined(TOOLKIT_GTK) - gtk_util::InitRendererPrefsFromGtkSettings(&renderer_preferences_, - GtkThemeProvider::GetFrom(tab->profile())->UseGtkTheme()); + gtk_util::InitRendererPrefsFromGtkSettings(&renderer_preferences_); #endif } diff --git a/chrome/browser/tab_contents/interstitial_page.h b/chrome/browser/tab_contents/interstitial_page.h index 0312131..aff6a74 100644 --- a/chrome/browser/tab_contents/interstitial_page.h +++ b/chrome/browser/tab_contents/interstitial_page.h @@ -107,7 +107,7 @@ class InterstitialPage : public NotificationObserver, const std::wstring& title); virtual void DomOperationResponse(const std::string& json_string, int automation_id); - virtual RendererPreferences GetRendererPrefs(Profile* profile) const { + virtual RendererPreferences GetRendererPrefs() const { return renderer_preferences_; } diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 30b393d..964bff1 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -45,7 +45,6 @@ #include "chrome/browser/renderer_host/resource_request_details.h" #include "chrome/browser/renderer_host/site_instance.h" #include "chrome/browser/renderer_host/web_cache_manager.h" -#include "chrome/browser/renderer_preferences_util.h" #include "chrome/browser/tab_contents/infobar_delegate.h" #include "chrome/browser/tab_contents/interstitial_page.h" #include "chrome/browser/tab_contents/navigation_entry.h" @@ -260,8 +259,7 @@ 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_(platform_util::GetInitedRendererPreferences()), opener_dom_ui_type_(DOMUIFactory::kNoDOMUI) { #if defined(OS_CHROMEOS) // Make sure the thumbnailer is started before starting the render manager. @@ -1884,7 +1882,7 @@ RenderViewHostDelegate::AutoFill* TabContents::GetAutoFillDelegate() { return autofill_manager_.get(); } -RendererPreferences TabContents::GetRendererPrefs(Profile* profile) const { +RendererPreferences TabContents::GetRendererPrefs() const { return renderer_preferences_; } diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index 18f0d44..072e430 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -903,7 +903,7 @@ class TabContents : public PageNavigator, virtual void PageHasOSDD(RenderViewHost* render_view_host, int32 page_id, const GURL& url, bool autodetected); virtual GURL GetAlternateErrorPageURL() const; - virtual RendererPreferences GetRendererPrefs(Profile* profile) const; + virtual RendererPreferences GetRendererPrefs() const; virtual WebPreferences GetWebkitPrefs(); virtual void OnJSOutOfMemory(); virtual void OnCrossSiteResponse(int new_render_process_host_id, |