diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-04 02:07:02 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-04 02:07:02 +0000 |
commit | d626039c56c514d99c464f37e4621371ef4846da (patch) | |
tree | bcad41f4ff83c85838a835c5d645d556deaed995 /chrome | |
parent | 4e2c7cb18c64b8ecf5823206493a3701dccf8d56 (diff) | |
download | chromium_src-d626039c56c514d99c464f37e4621371ef4846da.zip chromium_src-d626039c56c514d99c464f37e4621371ef4846da.tar.gz chromium_src-d626039c56c514d99c464f37e4621371ef4846da.tar.bz2 |
Make the default RendererPreferences smarter.
Change the default RenderViewHostDelegate::GetRendererPrefs to a singleton because initialization may not always be cheap (we assume copying is, however).
BUG=29043
TEST=if you focus a link in an extension popup, you can actually see the focus ring (the focus ring had been set to 0x000000 color)
Review URL: http://codereview.chromium.org/458013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33775 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/extensions/extension_host.cc | 5 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host.h | 1 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host_delegate.cc | 9 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host_delegate.h | 2 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 3 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view.h | 3 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view_gtk.cc | 4 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view_gtk.h | 1 | ||||
-rw-r--r-- | chrome/browser/views/notifications/balloon_view_host.h | 2 | ||||
-rw-r--r-- | chrome/common/platform_util.h | 3 | ||||
-rw-r--r-- | chrome/common/platform_util_linux.cc | 11 | ||||
-rw-r--r-- | chrome/common/platform_util_mac.mm | 4 | ||||
-rw-r--r-- | chrome/common/platform_util_win.cc | 4 |
13 files changed, 37 insertions, 15 deletions
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 136feb2..1aa6ac8 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -32,6 +32,7 @@ #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" @@ -414,6 +415,10 @@ void ExtensionHost::Close(RenderViewHost* render_view_host) { } } +RendererPreferences ExtensionHost::GetRendererPrefs() const { + return platform_util::GetInitedRendererPreferences(); +} + WebPreferences ExtensionHost::GetWebkitPrefs() { PrefService* prefs = render_view_host()->process()->profile()->GetPrefs(); const bool kIsDomUI = true; diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h index e3ae680..35fc89e 100644 --- a/chrome/browser/extensions/extension_host.h +++ b/chrome/browser/extensions/extension_host.h @@ -119,6 +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() const; // RenderViewHostDelegate::View virtual void CreateNewWindow(int route_id); diff --git a/chrome/browser/renderer_host/render_view_host_delegate.cc b/chrome/browser/renderer_host/render_view_host_delegate.cc index 304d729..8f424db 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.cc +++ b/chrome/browser/renderer_host/render_view_host_delegate.cc @@ -5,10 +5,15 @@ #include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "base/gfx/rect.h" +#include "base/singleton.h" #include "chrome/common/renderer_preferences.h" #include "googleurl/src/gurl.h" #include "webkit/glue/webpreferences.h" +#if defined(OS_LINUX) +#include "chrome/common/gtk_util.h" +#endif + RenderViewHostDelegate::View* RenderViewHostDelegate::GetViewDelegate() { return NULL; } @@ -68,10 +73,6 @@ GURL RenderViewHostDelegate::GetAlternateErrorPageURL() const { return GURL(); } -RendererPreferences RenderViewHostDelegate::GetRendererPrefs() const { - return RendererPreferences(); -} - WebPreferences RenderViewHostDelegate::GetWebkitPrefs() { return WebPreferences(); } diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index e8004bd..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() const; + 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/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 300be68d..964bff1 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -259,6 +259,7 @@ TabContents::TabContents(Profile* profile, last_javascript_message_dismissal_(), suppress_javascript_messages_(false), is_showing_before_unload_dialog_(false), + 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. @@ -302,8 +303,6 @@ TabContents::TabContents(Profile* profile, // Set-up the showing of the omnibox search infobar if applicable. if (OmniboxSearchHint::IsEnabled(profile)) omnibox_search_hint_.reset(new OmniboxSearchHint(this)); - - view_->InitRendererPrefs(&renderer_preferences_); } TabContents::~TabContents() { diff --git a/chrome/browser/tab_contents/tab_contents_view.h b/chrome/browser/tab_contents/tab_contents_view.h index 79bee6d..4f55ab5 100644 --- a/chrome/browser/tab_contents/tab_contents_view.h +++ b/chrome/browser/tab_contents/tab_contents_view.h @@ -60,9 +60,6 @@ class TabContentsView : public RenderViewHostDelegate::View { // dialog boxes. virtual gfx::NativeWindow GetTopLevelNativeWindow() const = 0; - // Initialize the passed-in renderer preferences. - virtual void InitRendererPrefs(RendererPreferences* prefs) {} - // Computes the rectangle for the native widget that contains the contents of // the tab relative to its parent. virtual void GetContainerBounds(gfx::Rect *out) const = 0; diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/tab_contents/tab_contents_view_gtk.cc index 54ee481..d0a2635 100644 --- a/chrome/browser/tab_contents/tab_contents_view_gtk.cc +++ b/chrome/browser/tab_contents/tab_contents_view_gtk.cc @@ -234,10 +234,6 @@ gfx::NativeWindow TabContentsViewGtk::GetTopLevelNativeWindow() const { return window ? GTK_WINDOW(window) : NULL; } -void TabContentsViewGtk::InitRendererPrefs(RendererPreferences* prefs) { - gtk_util::InitRendererPrefsFromGtkSettings(prefs); -} - void TabContentsViewGtk::GetContainerBounds(gfx::Rect* out) const { // This is used for positioning the download shelf arrow animation, // as well as sizing some other widgets in Windows. In GTK the size is diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.h b/chrome/browser/tab_contents/tab_contents_view_gtk.h index d4bc0cf..6e60232 100644 --- a/chrome/browser/tab_contents/tab_contents_view_gtk.h +++ b/chrome/browser/tab_contents/tab_contents_view_gtk.h @@ -53,7 +53,6 @@ class TabContentsViewGtk : public TabContentsView, virtual gfx::NativeView GetNativeView() const; virtual gfx::NativeView GetContentNativeView() const; virtual gfx::NativeWindow GetTopLevelNativeWindow() const; - virtual void InitRendererPrefs(RendererPreferences* prefs); virtual void GetContainerBounds(gfx::Rect* out) const; virtual void SetPageTitle(const std::wstring& title); virtual void OnTabCrashed(); diff --git a/chrome/browser/views/notifications/balloon_view_host.h b/chrome/browser/views/notifications/balloon_view_host.h index fb9e2e1..b9e5a0c 100644 --- a/chrome/browser/views/notifications/balloon_view_host.h +++ b/chrome/browser/views/notifications/balloon_view_host.h @@ -9,6 +9,7 @@ #include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "chrome/browser/renderer_host/site_instance.h" #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" +#include "chrome/common/renderer_preferences.h" #include "views/controls/native/native_view_host.h" #include "webkit/glue/webpreferences.h" @@ -82,6 +83,7 @@ class BalloonViewHost : public views::NativeViewHost, virtual void HandleMouseEvent() {} virtual void HandleMouseLeave() {} virtual void UpdatePreferredSize(const gfx::Size& pref_size) {} + virtual RendererPreferences GetRendererPrefs() const { return RendererPreferences(); } // Accessors. RenderViewHost* render_view_host() const { return render_view_host_; } diff --git a/chrome/common/platform_util.h b/chrome/common/platform_util.h index 0a042f2..fbe1ba6 100644 --- a/chrome/common/platform_util.h +++ b/chrome/common/platform_util.h @@ -7,6 +7,7 @@ #include "app/gfx/native_widget_types.h" #include "base/string16.h" +#include "chrome/common/renderer_preferences.h" class FilePath; class GURL; @@ -44,6 +45,8 @@ void SimpleErrorBox(gfx::NativeWindow parent, const string16& title, const string16& message); +RendererPreferences GetInitedRendererPreferences(); + } #endif // CHROME_COMMON_PLATFORM_UTIL_H_ diff --git a/chrome/common/platform_util_linux.cc b/chrome/common/platform_util_linux.cc index 9f0e346..021d6a1 100644 --- a/chrome/common/platform_util_linux.cc +++ b/chrome/common/platform_util_linux.cc @@ -8,6 +8,7 @@ #include "base/file_util.h" #include "base/process_util.h" +#include "base/singleton.h" #include "base/string_util.h" #include "chrome/common/gtk_util.h" #include "chrome/common/process_watcher.h" @@ -87,4 +88,14 @@ void SimpleErrorBox(gfx::NativeWindow parent, gtk_widget_show_all(dialog); } +RendererPreferences GetInitedRendererPreferences() { + RendererPreferences* prefs = Singleton<RendererPreferences>::get(); + static bool inited = false; + if (!inited) { + gtk_util::InitRendererPrefsFromGtkSettings(prefs); + inited = true; + } + return *prefs; +} + } // namespace platform_util diff --git a/chrome/common/platform_util_mac.mm b/chrome/common/platform_util_mac.mm index 2c9883a..db474a2 100644 --- a/chrome/common/platform_util_mac.mm +++ b/chrome/common/platform_util_mac.mm @@ -84,4 +84,8 @@ void SimpleErrorBox(gfx::NativeWindow parent, [alert runModal]; } +RendererPreferences GetInitedRendererPreferences() { + return RendererPreferences(); +} + } // namespace platform_util diff --git a/chrome/common/platform_util_win.cc b/chrome/common/platform_util_win.cc index 1b1b666..6ddd47c 100644 --- a/chrome/common/platform_util_win.cc +++ b/chrome/common/platform_util_win.cc @@ -157,4 +157,8 @@ void SimpleErrorBox(gfx::NativeWindow parent, win_util::MessageBox(parent, message, title, MB_OK | MB_SETFOREGROUND); } +RendererPreferences GetInitedRendererPreferences() { + return RendererPreferences(); +} + } // namespace platform_util |