diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-03 05:01:26 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-03 05:01:26 +0000 |
commit | 8922e1ff7ac33a3f88079e1e6d3ae8671602a952 (patch) | |
tree | a842ba34b909f84e7f3db6d60235504ad7887db2 /chrome | |
parent | 4b7d9b47a1adac0daa198761c01fc42ff1d9b394 (diff) | |
download | chromium_src-8922e1ff7ac33a3f88079e1e6d3ae8671602a952.zip chromium_src-8922e1ff7ac33a3f88079e1e6d3ae8671602a952.tar.gz chromium_src-8922e1ff7ac33a3f88079e1e6d3ae8671602a952.tar.bz2 |
More WebView / WebViewDelegate cleanup.
Moves a bunch of methods from glue to the WebKit API.
R=dglazkov
BUG=10033
TEST=none
Review URL: http://codereview.chromium.org/246079
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27941 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 2 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.h | 2 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host_delegate.h | 2 | ||||
-rw-r--r-- | chrome/browser/tab_contents/render_view_host_delegate_helper.cc | 4 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 6 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.h | 2 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 2 | ||||
-rw-r--r-- | chrome/renderer/print_web_view_helper.h | 2 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 92 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 15 |
10 files changed, 70 insertions, 59 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index e793a7b..9d693df 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -990,7 +990,7 @@ void RenderViewHost::OnMsgThumbnail(const GURL& url, } void RenderViewHost::OnUpdateInspectorSettings( - const std::wstring& raw_settings) { + const std::string& raw_settings) { delegate_->UpdateInspectorSettings(raw_settings); } diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index 72ee9eb..8fff7cf 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -539,7 +539,7 @@ class RenderViewHost : public RenderWidgetHost, int32 line_no, const std::wstring& source_id); - void OnUpdateInspectorSettings(const std::wstring& raw_settings); + void OnUpdateInspectorSettings(const std::string& raw_settings); void OnForwardToDevToolsAgent(const IPC::Message& message); void OnForwardToDevToolsClient(const IPC::Message& message); void OnActivateDevToolsWindow(); diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index d31d94c..96ed816 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -434,7 +434,7 @@ class RenderViewHostDelegate { const ThumbnailScore& score) {} // Inspector settings were changes and should be persisted. - virtual void UpdateInspectorSettings(const std::wstring& raw_settings) {} + virtual void UpdateInspectorSettings(const std::string& 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 1e0feb4..bf5386e 100644 --- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc +++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc @@ -147,8 +147,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); + web_prefs.inspector_settings = WideToUTF8( + 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 6fd8877..f220074 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -396,7 +396,7 @@ void TabContents::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(prefs::kWebKitShrinksStandaloneImagesToFit, pref_defaults.shrinks_standalone_images_to_fit); prefs->RegisterStringPref(prefs::kWebKitInspectorSettings, - pref_defaults.inspector_settings); + UTF8ToWide(pref_defaults.inspector_settings)); prefs->RegisterBooleanPref(prefs::kWebKitTextAreasAreResizable, pref_defaults.text_areas_are_resizable); prefs->RegisterBooleanPref(prefs::kWebKitJavaEnabled, @@ -2117,9 +2117,9 @@ void TabContents::UpdateThumbnail(const GURL& url, } } -void TabContents::UpdateInspectorSettings(const std::wstring& raw_settings) { +void TabContents::UpdateInspectorSettings(const std::string& raw_settings) { profile()->GetPrefs()->SetString(prefs::kWebKitInspectorSettings, - raw_settings); + UTF8ToWide(raw_settings)); } void TabContents::Close(RenderViewHost* rvh) { diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index 83613ba..7fb4822 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -867,7 +867,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 UpdateInspectorSettings(const std::string& 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/render_messages_internal.h b/chrome/common/render_messages_internal.h index b639d0a..ad27705 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -1296,7 +1296,7 @@ IPC_BEGIN_MESSAGES(ViewHost) // Stores new inspector settings in the profile. IPC_MESSAGE_ROUTED1(ViewHostMsg_UpdateInspectorSettings, - std::wstring /* raw_settings */) + std::string /* raw_settings */) // Wraps an IPC message that's destined to the DevToolsClient on // DevToolsAgent->browser hop. diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h index a7f0ec4..6124257 100644 --- a/chrome/renderer/print_web_view_helper.h +++ b/chrome/renderer/print_web_view_helper.h @@ -166,6 +166,7 @@ class PrintWebViewHelper : public WebViewDelegate { virtual WebKit::WebString autoCorrectWord( const WebKit::WebString& misspelled_word); virtual void showSpellingUI(bool show) {} + virtual bool isShowingSpellingUI() { return false; } virtual void updateSpellingUIWithMisspelledWord( const WebKit::WebString& word) {} virtual void runModalAlertDialog( @@ -196,6 +197,7 @@ class PrintWebViewHelper : public WebViewDelegate { virtual int historyBackListCount() { return 0; } virtual int historyForwardListCount() { return 0; } virtual void didAddHistoryItem() {} + virtual void didUpdateInspectorSettings() {} // WebKit::WebWidgetClient virtual void didInvalidateRect(const WebKit::WebRect&) {} diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 2ef79b5..89fba21 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -218,6 +218,7 @@ RenderView::RenderView(RenderThreadBase* render_thread, decrement_shared_popup_at_destruction_(false), form_field_autofill_request_id_(0), popup_notification_visible_(false), + spelling_panel_visible_(false), delay_seconds_for_form_state_sync_(kDefaultDelaySecondsForFormStateSync), preferred_width_(0), send_preferred_width_changes_(false), @@ -886,7 +887,7 @@ void RenderView::OnToggleSpellPanel(bool is_currently_visible) { return; // We need to tell the webView whether the spelling panel is visible or not so // that it won't need to make ipc calls later. - webview()->SetSpellingPanelVisibility(is_currently_visible); + spelling_panel_visible_ = is_currently_visible; webview()->focusedFrame()->executeCommand( WebString::fromUTF8("ToggleSpellPanel")); } @@ -1547,6 +1548,10 @@ void RenderView::showSpellingUI(bool show) { Send(new ViewHostMsg_ShowSpellingPanel(routing_id_, show)); } +bool RenderView::isShowingSpellingUI() { + return spelling_panel_visible_; +} + void RenderView::updateSpellingUIWithMisspelledWord(const WebString& word) { Send(new ViewHostMsg_UpdateSpellingPanelWithMisspelledWord( routing_id_, UTF16ToWideHack(word))); @@ -1675,6 +1680,11 @@ void RenderView::didAddHistoryItem() { history_forward_list_count_ = 0; } +void RenderView::didUpdateInspectorSettings() { + Send(new ViewHostMsg_UpdateInspectorSettings( + routing_id_, webview()->inspectorSettings().utf8())); +} + // WebKit::WebWidgetClient ---------------------------------------------------- // We are supposed to get a single call to Show for a newly created RenderView @@ -2319,6 +2329,44 @@ void RenderView::didChangeContentsSize(WebFrame* frame, const WebSize& size) { } } +void RenderView::reportFindInPageMatchCount(int request_id, int count, + bool final_update) { + // If we have a message that has been queued up, then we should just replace + // it. The ACK from the browser will make sure it gets sent when the browser + // wants it. + if (queued_find_reply_message_.get()) { + IPC::Message* msg = new ViewHostMsg_Find_Reply( + routing_id_, + request_id, + count, + gfx::Rect(), + -1, // Don't update active match ordinal. + final_update); + queued_find_reply_message_.reset(msg); + } else { + // Send the search result over to the browser process. + Send(new ViewHostMsg_Find_Reply( + routing_id_, + request_id, + count, + gfx::Rect(), + -1, // // Don't update active match ordinal. + final_update)); + } +} + +void RenderView::reportFindInPageSelection(int request_id, + int active_match_ordinal, + const WebRect& selection_rect) { + // Send the search result over to the browser process. + Send(new ViewHostMsg_Find_Reply(routing_id_, + request_id, + -1, + selection_rect, + active_match_ordinal, + false)); +} + // webkit_glue::WebPluginPageDelegate ----------------------------------------- webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate( @@ -2700,44 +2748,6 @@ void RenderView::OnDeterminePageText() { determine_page_text_after_loading_stops_ = true; } -void RenderView::ReportFindInPageMatchCount(int count, int request_id, - bool final_update) { - // If we have a message that has been queued up, then we should just replace - // it. The ACK from the browser will make sure it gets sent when the browser - // wants it. - if (queued_find_reply_message_.get()) { - IPC::Message* msg = new ViewHostMsg_Find_Reply( - routing_id_, - request_id, - count, - gfx::Rect(), - -1, // Don't update active match ordinal. - final_update); - queued_find_reply_message_.reset(msg); - } else { - // Send the search result over to the browser process. - Send(new ViewHostMsg_Find_Reply( - routing_id_, - request_id, - count, - gfx::Rect(), - -1, // // Don't update active match ordinal. - final_update)); - } -} - -void RenderView::ReportFindInPageSelection(int request_id, - int active_match_ordinal, - const WebRect& selection_rect) { - // Send the search result over to the browser process. - Send(new ViewHostMsg_Find_Reply(routing_id_, - request_id, - -1, - selection_rect, - active_match_ordinal, - false)); -} - bool RenderView::WasOpenedByUserGesture() const { return opened_by_user_gesture_; } @@ -2772,10 +2782,6 @@ void RenderView::OnResetPageEncodingToDefault() { webview()->setPageEncoding(no_encoding); } -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 3f41c23..5a7dcdd 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -192,13 +192,7 @@ class RenderView : public RenderWidget, int edit_flags, const std::string& security_info, const std::string& frame_charset); - virtual void UpdateInspectorSettings(const std::wstring& raw_settings); virtual WebDevToolsAgentDelegate* GetWebDevToolsAgentDelegate(); - virtual void ReportFindInPageMatchCount(int count, int request_id, - bool final_update); - virtual void ReportFindInPageSelection(int request_id, - int active_match_ordinal, - const WebKit::WebRect& selection); virtual bool WasOpenedByUserGesture() const; virtual void FocusAccessibilityObject(WebCore::AccessibilityObject* acc_obj); virtual void UserMetricsRecordAction(const std::wstring& action); @@ -246,6 +240,7 @@ class RenderView : public RenderWidget, virtual WebKit::WebString autoCorrectWord( const WebKit::WebString& misspelled_word); virtual void showSpellingUI(bool show); + virtual bool isShowingSpellingUI(); virtual void updateSpellingUIWithMisspelledWord( const WebKit::WebString& word); virtual void runModalAlertDialog( @@ -271,6 +266,7 @@ class RenderView : public RenderWidget, virtual int historyBackListCount(); virtual int historyForwardListCount(); virtual void didAddHistoryItem(); + virtual void didUpdateInspectorSettings(); // WebKit::WebWidgetClient // Most methods are handled by RenderWidget. @@ -349,6 +345,10 @@ class RenderView : public RenderWidget, virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame* frame); virtual void didChangeContentsSize( WebKit::WebFrame* frame, const WebKit::WebSize& size); + virtual void reportFindInPageMatchCount( + int request_id, int count, bool final_update); + virtual void reportFindInPageSelection( + int request_id, int active_match_ordinal, const WebKit::WebRect& sel); // webkit_glue::WebPluginPageDelegate virtual webkit_glue::WebPluginDelegate* CreatePluginDelegate( @@ -878,6 +878,9 @@ class RenderView : public RenderWidget, // from the Browser process telling us otherwise. bool popup_notification_visible_; + // True if the browser is showing the spelling panel for us. + bool spelling_panel_visible_; + // Time in seconds of the delay between syncing page state such as form // elements and scroll position. This timeout allows us to avoid spamming the // browser process with every little thing that changes. This normally doesn't |