| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_RENDERER_RENDER_VIEW_H_ | 5 #ifndef CHROME_RENDERER_RENDER_VIEW_H_ |
| 6 #define CHROME_RENDERER_RENDER_VIEW_H_ | 6 #define CHROME_RENDERER_RENDER_VIEW_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 struct WebFindOptions; | 84 struct WebFindOptions; |
| 85 } | 85 } |
| 86 | 86 |
| 87 // We need to prevent a page from trying to create infinite popups. It is not | 87 // We need to prevent a page from trying to create infinite popups. It is not |
| 88 // as simple as keeping a count of the number of immediate children | 88 // as simple as keeping a count of the number of immediate children |
| 89 // popups. Having an html file that window.open()s itself would create | 89 // popups. Having an html file that window.open()s itself would create |
| 90 // an unlimited chain of RenderViews who only have one RenderView child. | 90 // an unlimited chain of RenderViews who only have one RenderView child. |
| 91 // | 91 // |
| 92 // Therefore, each new top level RenderView creates a new counter and shares it | 92 // Therefore, each new top level RenderView creates a new counter and shares it |
| 93 // with all its children and grandchildren popup RenderViews created with | 93 // with all its children and grandchildren popup RenderViews created with |
| 94 // CreateWebView() to have a sort of global limit for the page so no more than | 94 // createView() to have a sort of global limit for the page so no more than |
| 95 // kMaximumNumberOfPopups popups are created. | 95 // kMaximumNumberOfPopups popups are created. |
| 96 // | 96 // |
| 97 // This is a RefCounted holder of an int because I can't say | 97 // This is a RefCounted holder of an int because I can't say |
| 98 // scoped_refptr<int>. | 98 // scoped_refptr<int>. |
| 99 typedef base::RefCountedData<int> SharedRenderViewCounter; | 99 typedef base::RefCountedData<int> SharedRenderViewCounter; |
| 100 | 100 |
| 101 // | 101 // |
| 102 // RenderView is an object that manages a WebView object, and provides a | 102 // RenderView is an object that manages a WebView object, and provides a |
| 103 // communication interface with an embedding application process | 103 // communication interface with an embedding application process |
| 104 // | 104 // |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 PrintWebViewHelper* print_helper() { | 159 PrintWebViewHelper* print_helper() { |
| 160 return print_helper_.get(); | 160 return print_helper_.get(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 // IPC::Channel::Listener | 163 // IPC::Channel::Listener |
| 164 virtual void OnMessageReceived(const IPC::Message& msg); | 164 virtual void OnMessageReceived(const IPC::Message& msg); |
| 165 | 165 |
| 166 // WebViewDelegate | 166 // WebViewDelegate |
| 167 virtual bool CanAcceptLoadDrops() const; | 167 virtual bool CanAcceptLoadDrops() const; |
| 168 virtual void RunJavaScriptAlert(WebKit::WebFrame* webframe, | |
| 169 const std::wstring& message); | |
| 170 virtual bool RunJavaScriptConfirm(WebKit::WebFrame* webframe, | |
| 171 const std::wstring& message); | |
| 172 virtual bool RunJavaScriptPrompt(WebKit::WebFrame* webframe, | |
| 173 const std::wstring& message, | |
| 174 const std::wstring& default_value, | |
| 175 std::wstring* result); | |
| 176 virtual bool RunBeforeUnloadConfirm(WebKit::WebFrame* webframe, | |
| 177 const std::wstring& message); | |
| 178 virtual void QueryFormFieldAutofill(const std::wstring& field_name, | 168 virtual void QueryFormFieldAutofill(const std::wstring& field_name, |
| 179 const std::wstring& text, | 169 const std::wstring& text, |
| 180 int64 node_id); | 170 int64 node_id); |
| 181 virtual void RemoveStoredAutofillEntry(const std::wstring& field_name, | 171 virtual void RemoveStoredAutofillEntry(const std::wstring& field_name, |
| 182 const std::wstring& text); | 172 const std::wstring& text); |
| 183 virtual void UpdateTargetURL(WebView* webview, | |
| 184 const GURL& url); | |
| 185 virtual void RunFileChooser(bool multi_select, | 173 virtual void RunFileChooser(bool multi_select, |
| 186 const string16& title, | 174 const string16& title, |
| 187 const FilePath& initial_filename, | 175 const FilePath& initial_filename, |
| 188 WebFileChooserCallback* file_chooser); | 176 WebFileChooserCallback* file_chooser); |
| 189 virtual void AddMessageToConsole(WebView* webview, | |
| 190 const std::wstring& message, | |
| 191 unsigned int line_no, | |
| 192 const std::wstring& source_id); | |
| 193 virtual void DidStartLoading(WebView* webview); | |
| 194 virtual void DidStopLoading(WebView* webview); | |
| 195 virtual void LoadNavigationErrorPage( | 177 virtual void LoadNavigationErrorPage( |
| 196 WebKit::WebFrame* frame, | 178 WebKit::WebFrame* frame, |
| 197 const WebKit::WebURLRequest& failed_request, | 179 const WebKit::WebURLRequest& failed_request, |
| 198 const WebKit::WebURLError& error, | 180 const WebKit::WebURLError& error, |
| 199 const std::string& html, | 181 const std::string& html, |
| 200 bool replace); | 182 bool replace); |
| 201 virtual void DidCreateScriptContextForFrame(WebKit::WebFrame* webframe); | 183 virtual void DidCreateScriptContextForFrame(WebKit::WebFrame* webframe); |
| 202 virtual void DidDestroyScriptContextForFrame(WebKit::WebFrame* webframe); | 184 virtual void DidDestroyScriptContextForFrame(WebKit::WebFrame* webframe); |
| 203 virtual void DidCreateIsolatedScriptContext(WebKit::WebFrame* webframe); | 185 virtual void DidCreateIsolatedScriptContext(WebKit::WebFrame* webframe); |
| 204 virtual WebView* CreateWebView(WebView* webview, | |
| 205 bool user_gesture, | |
| 206 const GURL& creator_url); | |
| 207 virtual WebKit::WebWidget* CreatePopupWidget( | |
| 208 WebView* webview, | |
| 209 bool activatable); | |
| 210 virtual WebKit::WebWidget* CreatePopupWidgetWithInfo( | |
| 211 WebView* webview, | |
| 212 const WebKit::WebPopupMenuInfo& info); | |
| 213 virtual void OnMissingPluginStatus( | 186 virtual void OnMissingPluginStatus( |
| 214 WebPluginDelegateProxy* delegate, | 187 WebPluginDelegateProxy* delegate, |
| 215 int status); | 188 int status); |
| 216 virtual void DidDownloadImage(int id, | 189 virtual void DidDownloadImage(int id, |
| 217 const GURL& image_url, | 190 const GURL& image_url, |
| 218 bool errored, | 191 bool errored, |
| 219 const SkBitmap& image); | 192 const SkBitmap& image); |
| 220 virtual void ShowContextMenu(WebView* webview, | 193 virtual void ShowContextMenu(WebView* webview, |
| 221 ContextNodeType node_type, | 194 ContextNodeType node_type, |
| 222 int x, | 195 int x, |
| 223 int y, | 196 int y, |
| 224 const GURL& link_url, | 197 const GURL& link_url, |
| 225 const GURL& src_url, | 198 const GURL& src_url, |
| 226 const GURL& page_url, | 199 const GURL& page_url, |
| 227 const GURL& frame_url, | 200 const GURL& frame_url, |
| 228 const ContextMenuMediaParams& media_params, | 201 const ContextMenuMediaParams& media_params, |
| 229 const std::wstring& selection_text, | 202 const std::wstring& selection_text, |
| 230 const std::wstring& misspelled_word, | 203 const std::wstring& misspelled_word, |
| 231 int edit_flags, | 204 int edit_flags, |
| 232 const std::string& security_info, | 205 const std::string& security_info, |
| 233 const std::string& frame_charset); | 206 const std::string& frame_charset); |
| 234 virtual void StartDragging(WebView* webview, | |
| 235 const WebKit::WebPoint &mouseCoords, | |
| 236 const WebKit::WebDragData& drag_data, | |
| 237 WebKit::WebDragOperationsMask operations_mask); | |
| 238 virtual void TakeFocus(WebView* webview, bool reverse); | |
| 239 virtual void NavigateBackForwardSoon(int offset); | |
| 240 virtual int GetHistoryBackListCount(); | |
| 241 virtual int GetHistoryForwardListCount(); | |
| 242 virtual void SetTooltipText(WebView* webview, | |
| 243 const std::wstring& tooltip_text, | |
| 244 WebKit::WebTextDirection text_direction_hint); | |
| 245 virtual void UpdateInspectorSettings(const std::wstring& raw_settings); | 207 virtual void UpdateInspectorSettings(const std::wstring& raw_settings); |
| 246 virtual WebDevToolsAgentDelegate* GetWebDevToolsAgentDelegate(); | 208 virtual WebDevToolsAgentDelegate* GetWebDevToolsAgentDelegate(); |
| 247 virtual void ReportFindInPageMatchCount(int count, int request_id, | 209 virtual void ReportFindInPageMatchCount(int count, int request_id, |
| 248 bool final_update); | 210 bool final_update); |
| 249 virtual void ReportFindInPageSelection(int request_id, | 211 virtual void ReportFindInPageSelection(int request_id, |
| 250 int active_match_ordinal, | 212 int active_match_ordinal, |
| 251 const WebKit::WebRect& selection); | 213 const WebKit::WebRect& selection); |
| 252 virtual bool WasOpenedByUserGesture() const; | 214 virtual bool WasOpenedByUserGesture() const; |
| 253 virtual void FocusAccessibilityObject(WebCore::AccessibilityObject* acc_obj); | 215 virtual void FocusAccessibilityObject(WebCore::AccessibilityObject* acc_obj); |
| 254 virtual void SpellCheck(const std::wstring& word, | 216 virtual void SpellCheck(const std::wstring& word, |
| 255 int* misspell_location, | 217 int* misspell_location, |
| 256 int* misspell_length); | 218 int* misspell_length); |
| 257 virtual std::wstring GetAutoCorrectWord(const std::wstring& word); | 219 virtual std::wstring GetAutoCorrectWord(const std::wstring& word); |
| 258 virtual void UpdateSpellingUIWithMisspelledWord(const std::wstring& word); | 220 virtual void UpdateSpellingUIWithMisspelledWord(const std::wstring& word); |
| 259 virtual void ShowSpellingUI(bool show); | 221 virtual void ShowSpellingUI(bool show); |
| 260 virtual void ScriptedPrint(WebKit::WebFrame* frame); | |
| 261 virtual void UserMetricsRecordAction(const std::wstring& action); | 222 virtual void UserMetricsRecordAction(const std::wstring& action); |
| 262 virtual void DnsPrefetch(const std::vector<std::string>& host_names); | 223 virtual void DnsPrefetch(const std::vector<std::string>& host_names); |
| 263 virtual bool HandleCurrentKeyboardEvent(); | 224 virtual bool HandleCurrentKeyboardEvent(); |
| 264 | 225 |
| 226 // WebKit::WebViewClient |
| 227 virtual WebView* createView(WebKit::WebFrame* creator); |
| 228 virtual WebKit::WebWidget* createPopupMenu(bool activatable); |
| 229 virtual WebKit::WebWidget* createPopupMenu( |
| 230 const WebKit::WebPopupMenuInfo& info); |
| 231 virtual void didAddMessageToConsole( |
| 232 const WebKit::WebConsoleMessage& message, |
| 233 const WebKit::WebString& source_name, unsigned source_line); |
| 234 virtual void printPage(WebKit::WebFrame* frame); |
| 235 virtual void didStartLoading(); |
| 236 virtual void didStopLoading(); |
| 237 virtual void runModalAlertDialog( |
| 238 WebKit::WebFrame* frame, const WebKit::WebString& message); |
| 239 virtual bool runModalConfirmDialog( |
| 240 WebKit::WebFrame* frame, const WebKit::WebString& message); |
| 241 virtual bool runModalPromptDialog( |
| 242 WebKit::WebFrame* frame, const WebKit::WebString& message, |
| 243 const WebKit::WebString& default_value, WebKit::WebString* actual_value); |
| 244 virtual bool runModalBeforeUnloadDialog( |
| 245 WebKit::WebFrame* frame, const WebKit::WebString& message); |
| 246 virtual void setStatusText(const WebKit::WebString& text); |
| 247 virtual void setMouseOverURL(const WebKit::WebURL& url); |
| 248 virtual void setToolTipText( |
| 249 const WebKit::WebString& text, WebKit::WebTextDirection hint); |
| 250 virtual void startDragging( |
| 251 const WebKit::WebPoint& from, const WebKit::WebDragData& data, |
| 252 WebKit::WebDragOperationsMask mask); |
| 253 virtual void focusNext(); |
| 254 virtual void focusPrevious(); |
| 255 virtual void navigateBackForwardSoon(int offset); |
| 256 virtual int historyBackListCount(); |
| 257 virtual int historyForwardListCount(); |
| 258 virtual void didAddHistoryItem(); |
| 259 |
| 265 // WebKit::WebWidgetClient | 260 // WebKit::WebWidgetClient |
| 266 // Most methods are handled by RenderWidget. | 261 // Most methods are handled by RenderWidget. |
| 267 virtual void show(WebKit::WebNavigationPolicy policy); | 262 virtual void show(WebKit::WebNavigationPolicy policy); |
| 268 virtual void closeWidgetSoon(); | 263 virtual void closeWidgetSoon(); |
| 269 virtual void runModal(); | 264 virtual void runModal(); |
| 270 | 265 |
| 271 // WebKit::WebEditingClient | 266 // WebKit::WebEditingClient |
| 272 virtual bool shouldBeginEditing(const WebKit::WebRange& range); | 267 virtual bool shouldBeginEditing(const WebKit::WebRange& range); |
| 273 virtual bool shouldEndEditing(const WebKit::WebRange& range); | 268 virtual bool shouldEndEditing(const WebKit::WebRange& range); |
| 274 virtual bool shouldInsertNode( | 269 virtual bool shouldInsertNode( |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 GURL GetAlternateErrorPageURL( | 692 GURL GetAlternateErrorPageURL( |
| 698 const GURL& failed_url, ErrorPageType error_type); | 693 const GURL& failed_url, ErrorPageType error_type); |
| 699 bool MaybeLoadAlternateErrorPage( | 694 bool MaybeLoadAlternateErrorPage( |
| 700 WebKit::WebFrame* frame, const WebKit::WebURLError& error, bool replace); | 695 WebKit::WebFrame* frame, const WebKit::WebURLError& error, bool replace); |
| 701 std::string GetAltHTMLForTemplate( | 696 std::string GetAltHTMLForTemplate( |
| 702 const DictionaryValue& error_strings, int template_resource_id) const; | 697 const DictionaryValue& error_strings, int template_resource_id) const; |
| 703 void AltErrorPageFinished( | 698 void AltErrorPageFinished( |
| 704 WebKit::WebFrame* frame, const WebKit::WebURLError& original_error, | 699 WebKit::WebFrame* frame, const WebKit::WebURLError& original_error, |
| 705 const std::string& html); | 700 const std::string& html); |
| 706 | 701 |
| 707 virtual void DidAddHistoryItem(); | |
| 708 | |
| 709 // Decodes a data: URL image or returns an empty image in case of failure. | 702 // Decodes a data: URL image or returns an empty image in case of failure. |
| 710 SkBitmap ImageFromDataUrl(const GURL&) const; | 703 SkBitmap ImageFromDataUrl(const GURL&) const; |
| 711 | 704 |
| 712 void DumpLoadHistograms() const; | 705 void DumpLoadHistograms() const; |
| 713 | 706 |
| 714 // Scan the given frame for password forms and send them up to the browser. | 707 // Scan the given frame for password forms and send them up to the browser. |
| 715 void SendPasswordForms(WebKit::WebFrame* frame); | 708 void SendPasswordForms(WebKit::WebFrame* frame); |
| 716 | 709 |
| 717 void Print(WebKit::WebFrame* frame, bool script_initiated); | 710 void Print(WebKit::WebFrame* frame, bool script_initiated); |
| 718 | 711 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 scoped_ptr<WebFileChooserCallback> file_chooser_; | 826 scoped_ptr<WebFileChooserCallback> file_chooser_; |
| 834 | 827 |
| 835 int history_back_list_count_; | 828 int history_back_list_count_; |
| 836 int history_forward_list_count_; | 829 int history_forward_list_count_; |
| 837 | 830 |
| 838 // True if the page has any frame-level unload or beforeunload listeners. | 831 // True if the page has any frame-level unload or beforeunload listeners. |
| 839 bool has_unload_listener_; | 832 bool has_unload_listener_; |
| 840 | 833 |
| 841 // The total number of unrequested popups that exist and can be followed back | 834 // The total number of unrequested popups that exist and can be followed back |
| 842 // to a common opener. This count is shared among all RenderViews created | 835 // to a common opener. This count is shared among all RenderViews created |
| 843 // with CreateWebView(). All popups are treated as unrequested until | 836 // with createView(). All popups are treated as unrequested until |
| 844 // specifically instructed otherwise by the Browser process. | 837 // specifically instructed otherwise by the Browser process. |
| 845 scoped_refptr<SharedRenderViewCounter> shared_popup_counter_; | 838 scoped_refptr<SharedRenderViewCounter> shared_popup_counter_; |
| 846 | 839 |
| 847 // Whether this is a top level window (instead of a popup). Top level windows | 840 // Whether this is a top level window (instead of a popup). Top level windows |
| 848 // shouldn't count against their own |shared_popup_counter_|. | 841 // shouldn't count against their own |shared_popup_counter_|. |
| 849 bool decrement_shared_popup_at_destruction_; | 842 bool decrement_shared_popup_at_destruction_; |
| 850 | 843 |
| 851 // TODO(port): revisit once we have accessibility | 844 // TODO(port): revisit once we have accessibility |
| 852 #if defined(OS_WIN) | 845 #if defined(OS_WIN) |
| 853 // Handles accessibility requests into the renderer side, as well as | 846 // Handles accessibility requests into the renderer side, as well as |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 WebPreferences webkit_preferences_; | 924 WebPreferences webkit_preferences_; |
| 932 | 925 |
| 933 // Stores edit commands associated to the next key event. | 926 // Stores edit commands associated to the next key event. |
| 934 // Shall be cleared as soon as the next key event is processed. | 927 // Shall be cleared as soon as the next key event is processed. |
| 935 EditCommands edit_commands_; | 928 EditCommands edit_commands_; |
| 936 | 929 |
| 937 DISALLOW_COPY_AND_ASSIGN(RenderView); | 930 DISALLOW_COPY_AND_ASSIGN(RenderView); |
| 938 }; | 931 }; |
| 939 | 932 |
| 940 #endif // CHROME_RENDERER_RENDER_VIEW_H_ | 933 #endif // CHROME_RENDERER_RENDER_VIEW_H_ |
| OLD | NEW |