diff options
author | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-03 12:13:08 +0000 |
---|---|---|
committer | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-03 12:13:08 +0000 |
commit | 0df3012fff2579aa4c09378fec0873f5c4589aab (patch) | |
tree | f63ad10d3efae0c81c3240293e20e7b003ea281b /chrome | |
parent | ce29eeeb501db818f8f91158fd0f740a9673db61 (diff) | |
download | chromium_src-0df3012fff2579aa4c09378fec0873f5c4589aab.zip chromium_src-0df3012fff2579aa4c09378fec0873f5c4589aab.tar.gz chromium_src-0df3012fff2579aa4c09378fec0873f5c4589aab.tar.bz2 |
Implement InspectorClient's Settings API.
This CL implements InspectorClient's API for reading / writing inspector settings. Here is how this is done:
- inspector_client_impl.cc caches / serializes preferences into raw strings. It supports all kinds of settings except for string vector. I did not implement it since a) it requires more escaping b) I think we should get rid of it upstream. It then passes serialized settings string over IPC.
- There is a dedicated IPC message called UpdateInspectorSettings that takes care of settings update.
Two things I don't like:
1) reading settings and writing settings follow different paths: WebPreferences interface for read, delegate -> IPC for write. WebPreferences on read is used since these settings are needed very early in the page cycle. delegate -> IPC on write is the only option.
2) this looks like too much code on the Chrome side for functionality like this. Is there a more generic way of settings and persisting WebKit's preferences in Chrome? Should there be one?
Review URL: http://codereview.chromium.org/119041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17473 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 7 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.h | 1 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host_delegate.h | 3 | ||||
-rw-r--r-- | chrome/browser/tab_contents/render_view_host_delegate_helper.cc | 2 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 7 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.h | 1 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 2 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 | ||||
-rw-r--r-- | chrome/common/render_messages.h | 2 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 4 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 4 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 2 |
12 files changed, 36 insertions, 0 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 1e3e031..56ea409 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -732,6 +732,8 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateEncoding, OnMsgUpdateEncoding) IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTargetURL, OnMsgUpdateTargetURL) IPC_MESSAGE_HANDLER(ViewHostMsg_Thumbnail, OnMsgThumbnail) + IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateInspectorSettings, + OnUpdateInspectorSettings); IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnMsgClose) IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnMsgRequestMove) IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartLoading, OnMsgDidStartLoading) @@ -984,6 +986,11 @@ void RenderViewHost::OnMsgThumbnail(const GURL& url, delegate_->UpdateThumbnail(url, bitmap, score); } +void RenderViewHost::OnUpdateInspectorSettings( + const std::wstring& raw_settings) { + delegate_->UpdateInspectorSettings(raw_settings); +} + void RenderViewHost::OnMsgClose() { delegate_->Close(this); } diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index c28af30..14c03c1 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -527,6 +527,7 @@ class RenderViewHost : public RenderWidgetHost { const std::wstring& source_id); void OnDebuggerOutput(const std::wstring& output); void DidDebugAttach(); + void OnUpdateInspectorSettings(const std::wstring& raw_settings); void OnForwardToDevToolsAgent(const IPC::Message& message); void OnForwardToDevToolsClient(const IPC::Message& message); void OnUserMetricsRecordAction(const std::wstring& action); diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index 7668b9c..c2488b2 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -205,6 +205,9 @@ class RenderViewHostDelegate { const SkBitmap& bitmap, const ThumbnailScore& score) { } + // Inspector settings were changes and should be persisted. + virtual void UpdateInspectorSettings(const std::wstring& raw_settings) { } + // The page is trying to close the RenderView's representation in the client. virtual void Close(RenderViewHost* render_view_host) { } diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc index 6132743..f0608bc 100644 --- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc +++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc @@ -142,6 +142,8 @@ WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs( prefs->GetBoolean(prefs::kWebKitDomPasteEnabled); web_prefs.shrinks_standalone_images_to_fit = prefs->GetBoolean(prefs::kWebKitShrinksStandaloneImagesToFit); + web_prefs.inspector_settings = + prefs->GetString(prefs::kWebKitInspectorSettings); { // Command line switches are used for preferences with no user interface. const CommandLine& command_line = *CommandLine::ForCurrentProcess(); diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index b0d5b71..db05c00 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -364,6 +364,8 @@ void TabContents::RegisterUserPrefs(PrefService* prefs) { pref_defaults.shrinks_standalone_images_to_fit); prefs->RegisterBooleanPref(prefs::kWebKitDeveloperExtrasEnabled, pref_defaults.developer_extras_enabled); + prefs->RegisterStringPref(prefs::kWebKitInspectorSettings, + pref_defaults.inspector_settings); prefs->RegisterBooleanPref(prefs::kWebKitTextAreasAreResizable, pref_defaults.text_areas_are_resizable); prefs->RegisterBooleanPref(prefs::kWebKitJavaEnabled, @@ -1774,6 +1776,11 @@ void TabContents::UpdateThumbnail(const GURL& url, } } +void TabContents::UpdateInspectorSettings(const std::wstring& raw_settings) { + profile()->GetPrefs()->SetString(prefs::kWebKitInspectorSettings, + raw_settings); +} + void TabContents::Close(RenderViewHost* rvh) { // Ignore this if it comes from a RenderViewHost that we aren't showing. if (delegate() && rvh == render_view_host()) diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index 7e3a70f..c43a919 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -758,6 +758,7 @@ class TabContents : public PageNavigator, virtual void UpdateThumbnail(const GURL& url, const SkBitmap& bitmap, const ThumbnailScore& score); + virtual void UpdateInspectorSettings(const std::wstring& raw_settings); virtual void Close(RenderViewHost* render_view_host); virtual void RequestMove(const gfx::Rect& new_bounds); virtual void DidStartLoading(RenderViewHost* render_view_host); diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 3ef102c..fd227a8 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -117,6 +117,8 @@ const wchar_t kWebKitShrinksStandaloneImagesToFit[] = L"webkit.webprefs.shrinks_standalone_images_to_fit"; const wchar_t kWebKitDeveloperExtrasEnabled[] = L"webkit.webprefs.developer_extras_enabled"; +const wchar_t kWebKitInspectorSettings[] = + L"webkit.webprefs.inspector_settings"; const wchar_t kWebKitUsesUniversalDetector[] = L"webkit.webprefs.uses_universal_detector"; const wchar_t kWebKitTextAreasAreResizable[] = diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 2114b0b..3a12f57 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -44,6 +44,7 @@ extern const wchar_t kWebKitPluginsEnabled[]; extern const wchar_t kWebKitDomPasteEnabled[]; extern const wchar_t kWebKitShrinksStandaloneImagesToFit[]; extern const wchar_t kWebKitDeveloperExtrasEnabled[]; +extern const wchar_t kWebKitInspectorSettings[]; extern const wchar_t kWebKitUsesUniversalDetector[]; extern const wchar_t kWebKitTextAreasAreResizable[]; extern const wchar_t kWebKitJavaEnabled[]; diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 4511b0e..ee42f58 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -1523,6 +1523,7 @@ struct ParamTraits<WebPreferences> { WriteParam(m, p.plugins_enabled); WriteParam(m, p.dom_paste_enabled); WriteParam(m, p.developer_extras_enabled); + WriteParam(m, p.inspector_settings); WriteParam(m, p.shrinks_standalone_images_to_fit); WriteParam(m, p.uses_universal_detector); WriteParam(m, p.text_areas_are_resizable); @@ -1552,6 +1553,7 @@ struct ParamTraits<WebPreferences> { ReadParam(m, iter, &p->plugins_enabled) && ReadParam(m, iter, &p->dom_paste_enabled) && ReadParam(m, iter, &p->developer_extras_enabled) && + ReadParam(m, iter, &p->inspector_settings) && ReadParam(m, iter, &p->shrinks_standalone_images_to_fit) && ReadParam(m, iter, &p->uses_universal_detector) && ReadParam(m, iter, &p->text_areas_are_resizable) && diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 5faeb51..2559381 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -1092,6 +1092,10 @@ IPC_BEGIN_MESSAGES(ViewHost) IPC_MESSAGE_ROUTED1(ViewHostMsg_DebuggerOutput, std::wstring /* msg */) + // Stores new inspector settings in the profile. + IPC_MESSAGE_ROUTED1(ViewHostMsg_UpdateInspectorSettings, + std::wstring /* raw_settings */) + // Wraps an IPC message that's destined to the DevToolsClient on // DevToolsAgent->browser hop. IPC_MESSAGE_ROUTED1(ViewHostMsg_ForwardToDevToolsClient, diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 750b9ba..ea92604 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -2539,6 +2539,10 @@ void RenderView::DownloadUrl(const GURL& url, const GURL& referrer) { Send(new ViewHostMsg_DownloadUrl(routing_id_, url, referrer)); } +void RenderView::UpdateInspectorSettings(const std::wstring& raw_settings) { + Send(new ViewHostMsg_UpdateInspectorSettings(routing_id_, raw_settings)); +} + WebDevToolsAgentDelegate* RenderView::GetWebDevToolsAgentDelegate() { return devtools_agent_.get(); } diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 744ef73..0702fbe 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -291,6 +291,8 @@ class RenderView : public RenderWidget, virtual void DownloadUrl(const GURL& url, const GURL& referrer); + virtual void UpdateInspectorSettings(const std::wstring& raw_settings); + virtual WebDevToolsAgentDelegate* GetWebDevToolsAgentDelegate(); virtual void PasteFromSelectionClipboard(); |