Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1221)

Side by Side Diff: content/renderer/render_view.h

Issue 6873040: Move the content settings code out of RenderView, since it belongs in the Chrome layer. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 CONTENT_RENDERER_RENDER_VIEW_H_ 5 #ifndef CONTENT_RENDERER_RENDER_VIEW_H_
6 #define CONTENT_RENDERER_RENDER_VIEW_H_ 6 #define CONTENT_RENDERER_RENDER_VIEW_H_
7 #pragma once 7 #pragma once
8 8
9 #include <deque> 9 #include <deque>
10 #include <map> 10 #include <map>
11 #include <queue> 11 #include <queue>
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "base/gtest_prod_util.h" 17 #include "base/gtest_prod_util.h"
18 #include "base/id_map.h" 18 #include "base/id_map.h"
19 #include "base/memory/linked_ptr.h" 19 #include "base/memory/linked_ptr.h"
20 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
21 #include "base/observer_list.h" 21 #include "base/observer_list.h"
22 #include "base/timer.h" 22 #include "base/timer.h"
23 #include "build/build_config.h" 23 #include "build/build_config.h"
24 #include "chrome/common/content_settings.h"
25 #include "content/renderer/renderer_webcookiejar_impl.h" 24 #include "content/renderer/renderer_webcookiejar_impl.h"
26 #include "content/common/edit_command.h" 25 #include "content/common/edit_command.h"
27 #include "content/common/navigation_gesture.h" 26 #include "content/common/navigation_gesture.h"
28 #include "content/common/page_zoom.h" 27 #include "content/common/page_zoom.h"
29 #include "content/common/renderer_preferences.h" 28 #include "content/common/renderer_preferences.h"
30 #include "content/renderer/pepper_plugin_delegate_impl.h" 29 #include "content/renderer/pepper_plugin_delegate_impl.h"
31 #include "content/renderer/render_widget.h" 30 #include "content/renderer/render_widget.h"
32 #include "ipc/ipc_platform_file.h" 31 #include "ipc/ipc_platform_file.h"
33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityNotif ication.h" 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityNotif ication.h"
34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 243
245 // Adds the given file chooser request to the file_chooser_completion_ queue 244 // Adds the given file chooser request to the file_chooser_completion_ queue
246 // (see that var for more) and requests the chooser be displayed if there are 245 // (see that var for more) and requests the chooser be displayed if there are
247 // no other waiting items in the queue. 246 // no other waiting items in the queue.
248 // 247 //
249 // Returns true if the chooser was successfully scheduled. False means we 248 // Returns true if the chooser was successfully scheduled. False means we
250 // didn't schedule anything. 249 // didn't schedule anything.
251 bool ScheduleFileChooser(const ViewHostMsg_RunFileChooser_Params& params, 250 bool ScheduleFileChooser(const ViewHostMsg_RunFileChooser_Params& params,
252 WebKit::WebFileChooserCompletion* completion); 251 WebKit::WebFileChooserCompletion* completion);
253 252
254 // Sets the content settings that back allowScripts(), allowImages(), and
255 // allowPlugins().
256 void SetContentSettings(const ContentSettings& settings);
257
258 // Sets whether the renderer should report load progress to the browser. 253 // Sets whether the renderer should report load progress to the browser.
259 void SetReportLoadProgressEnabled(bool enabled); 254 void SetReportLoadProgressEnabled(bool enabled);
260 255
261 // Gets the focused node. If no such node exists then the node will be isNull. 256 // Gets the focused node. If no such node exists then the node will be isNull.
262 WebKit::WebNode GetFocusedNode() const; 257 WebKit::WebNode GetFocusedNode() const;
263 258
264 // Returns true if the parameter node is a textfield, text area or a content 259 // Returns true if the parameter node is a textfield, text area or a content
265 // editable div. 260 // editable div.
266 bool IsEditableNode(const WebKit::WebNode& node); 261 bool IsEditableNode(const WebKit::WebNode& node);
267 262
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 const WebKit::WebString& name, unsigned long long documentId); 434 const WebKit::WebString& name, unsigned long long documentId);
440 virtual WebKit::WebMediaPlayer* createMediaPlayer( 435 virtual WebKit::WebMediaPlayer* createMediaPlayer(
441 WebKit::WebFrame* frame, 436 WebKit::WebFrame* frame,
442 WebKit::WebMediaPlayerClient* client); 437 WebKit::WebMediaPlayerClient* client);
443 virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost( 438 virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
444 WebKit::WebFrame* frame, 439 WebKit::WebFrame* frame,
445 WebKit::WebApplicationCacheHostClient* client); 440 WebKit::WebApplicationCacheHostClient* client);
446 virtual WebKit::WebCookieJar* cookieJar(WebKit::WebFrame* frame); 441 virtual WebKit::WebCookieJar* cookieJar(WebKit::WebFrame* frame);
447 virtual void frameDetached(WebKit::WebFrame* frame); 442 virtual void frameDetached(WebKit::WebFrame* frame);
448 virtual void willClose(WebKit::WebFrame* frame); 443 virtual void willClose(WebKit::WebFrame* frame);
449 virtual bool allowImages(WebKit::WebFrame* frame, bool enabled_per_settings);
450 virtual bool allowPlugins(WebKit::WebFrame* frame, bool enabled_per_settings);
451 virtual void loadURLExternally(WebKit::WebFrame* frame, 444 virtual void loadURLExternally(WebKit::WebFrame* frame,
452 const WebKit::WebURLRequest& request, 445 const WebKit::WebURLRequest& request,
453 WebKit::WebNavigationPolicy policy); 446 WebKit::WebNavigationPolicy policy);
454 virtual WebKit::WebNavigationPolicy decidePolicyForNavigation( 447 virtual WebKit::WebNavigationPolicy decidePolicyForNavigation(
455 WebKit::WebFrame* frame, 448 WebKit::WebFrame* frame,
456 const WebKit::WebURLRequest& request, 449 const WebKit::WebURLRequest& request,
457 WebKit::WebNavigationType type, 450 WebKit::WebNavigationType type,
458 const WebKit::WebNode&, 451 const WebKit::WebNode&,
459 WebKit::WebNavigationPolicy default_policy, 452 WebKit::WebNavigationPolicy default_policy,
460 bool is_redirect); 453 bool is_redirect);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 virtual void didLoadResourceFromMemoryCache( 517 virtual void didLoadResourceFromMemoryCache(
525 WebKit::WebFrame* frame, 518 WebKit::WebFrame* frame,
526 const WebKit::WebURLRequest& request, 519 const WebKit::WebURLRequest& request,
527 const WebKit::WebURLResponse&); 520 const WebKit::WebURLResponse&);
528 virtual void didDisplayInsecureContent(WebKit::WebFrame* frame); 521 virtual void didDisplayInsecureContent(WebKit::WebFrame* frame);
529 virtual void didRunInsecureContent( 522 virtual void didRunInsecureContent(
530 WebKit::WebFrame* frame, 523 WebKit::WebFrame* frame,
531 const WebKit::WebSecurityOrigin& origin, 524 const WebKit::WebSecurityOrigin& origin,
532 const WebKit::WebURL& target); 525 const WebKit::WebURL& target);
533 526
527 virtual bool allowImages(WebKit::WebFrame* frame, bool enabled_per_settings);
528 virtual bool allowPlugins(WebKit::WebFrame* frame, bool enabled_per_settings);
534 virtual bool allowScript(WebKit::WebFrame* frame, bool enabled_per_settings); 529 virtual bool allowScript(WebKit::WebFrame* frame, bool enabled_per_settings);
535 virtual bool allowDatabase(WebKit::WebFrame* frame, 530 virtual bool allowDatabase(WebKit::WebFrame* frame,
536 const WebKit::WebString& name, 531 const WebKit::WebString& name,
537 const WebKit::WebString& display_name, 532 const WebKit::WebString& display_name,
538 unsigned long estimated_size); 533 unsigned long estimated_size);
539 virtual void didNotAllowScript(WebKit::WebFrame* frame); 534 virtual void didNotAllowScript(WebKit::WebFrame* frame);
540 virtual void didNotAllowPlugins(WebKit::WebFrame* frame); 535 virtual void didNotAllowPlugins(WebKit::WebFrame* frame);
541 virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame* frame); 536 virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame* frame);
542 virtual void didCreateScriptContext(WebKit::WebFrame* frame); 537 virtual void didCreateScriptContext(WebKit::WebFrame* frame);
543 virtual void didDestroyScriptContext(WebKit::WebFrame* frame); 538 virtual void didDestroyScriptContext(WebKit::WebFrame* frame);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, LastCommittedUpdateState); 632 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, LastCommittedUpdateState);
638 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnHandleKeyboardEvent); 633 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnHandleKeyboardEvent);
639 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnImeStateChanged); 634 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnImeStateChanged);
640 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnNavStateChanged); 635 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnNavStateChanged);
641 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnSetTextDirection); 636 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnSetTextDirection);
642 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, UpdateTargetURLWithInvalidURL); 637 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, UpdateTargetURLWithInvalidURL);
643 #if defined(OS_MACOSX) 638 #if defined(OS_MACOSX)
644 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, MacTestCmdUp); 639 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, MacTestCmdUp);
645 #endif 640 #endif
646 641
647 typedef std::map<GURL, ContentSettings> HostContentSettings;
648 typedef std::map<GURL, double> HostZoomLevels; 642 typedef std::map<GURL, double> HostZoomLevels;
649 643
650 // Identifies an accessibility notification from webkit. 644 // Identifies an accessibility notification from webkit.
651 struct RendererAccessibilityNotification { 645 struct RendererAccessibilityNotification {
652 public: 646 public:
653 bool ShouldIncludeChildren(); 647 bool ShouldIncludeChildren();
654 648
655 // The webkit glue id of the accessibility object. 649 // The webkit glue id of the accessibility object.
656 int32 id; 650 int32 id;
657 651
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 void OnResetPageEncodingToDefault(); 790 void OnResetPageEncodingToDefault();
797 void OnScriptEvalRequest(const string16& frame_xpath, 791 void OnScriptEvalRequest(const string16& frame_xpath,
798 const string16& jscript, 792 const string16& jscript,
799 int id, 793 int id,
800 bool notify_result); 794 bool notify_result);
801 void OnSelectAll(); 795 void OnSelectAll();
802 void OnSetAccessibilityFocus(int acc_obj_id); 796 void OnSetAccessibilityFocus(int acc_obj_id);
803 void OnSetActive(bool active); 797 void OnSetActive(bool active);
804 void OnSetAltErrorPageURL(const GURL& gurl); 798 void OnSetAltErrorPageURL(const GURL& gurl);
805 void OnSetBackground(const SkBitmap& background); 799 void OnSetBackground(const SkBitmap& background);
806 void OnSetContentSettingsForLoadingURL(
807 const GURL& url,
808 const ContentSettings& content_settings);
809 void OnSetWebUIProperty(const std::string& name, const std::string& value); 800 void OnSetWebUIProperty(const std::string& name, const std::string& value);
810 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands); 801 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
811 void OnSetInitialFocus(bool reverse); 802 void OnSetInitialFocus(bool reverse);
812 void OnScrollFocusedEditableNodeIntoView(); 803 void OnScrollFocusedEditableNodeIntoView();
813 void OnSetPageEncoding(const std::string& encoding_name); 804 void OnSetPageEncoding(const std::string& encoding_name);
814 void OnSetRendererPrefs(const RendererPreferences& renderer_prefs); 805 void OnSetRendererPrefs(const RendererPreferences& renderer_prefs);
815 #if defined(OS_MACOSX) 806 #if defined(OS_MACOSX)
816 void OnSetWindowVisibility(bool visible); 807 void OnSetWindowVisibility(bool visible);
817 #endif 808 #endif
818 void OnSetZoomLevel(double zoom_level); 809 void OnSetZoomLevel(double zoom_level);
(...skipping 10 matching lines...) Expand all
829 const gfx::Rect& view_frame); 820 const gfx::Rect& view_frame);
830 void OnSelectPopupMenuItem(int selected_index); 821 void OnSelectPopupMenuItem(int selected_index);
831 #endif 822 #endif
832 void OnZoom(PageZoom::Function function); 823 void OnZoom(PageZoom::Function function);
833 824
834 // Adding a new message handler? Please add it in alphabetical order above 825 // Adding a new message handler? Please add it in alphabetical order above
835 // and put it in the same position in the .cc file. 826 // and put it in the same position in the .cc file.
836 827
837 // Misc private functions ---------------------------------------------------- 828 // Misc private functions ----------------------------------------------------
838 829
839 // Helper method that returns if the user wants to block content of type
840 // |content_type|.
841 bool AllowContentType(ContentSettingsType settings_type);
842
843 void AltErrorPageFinished(WebKit::WebFrame* frame, 830 void AltErrorPageFinished(WebKit::WebFrame* frame,
844 const WebKit::WebURLError& original_error, 831 const WebKit::WebURLError& original_error,
845 const std::string& html); 832 const std::string& html);
846 833
847 // Check whether the preferred size has changed. This is called periodically 834 // Check whether the preferred size has changed. This is called periodically
848 // by preferred_size_change_timer_. 835 // by preferred_size_change_timer_.
849 void CheckPreferredSize(); 836 void CheckPreferredSize();
850 837
851 // Resets the |content_blocked_| array. 838 // This callback is triggered when DownloadFavicon completes, either
852 void ClearBlockedContentSettings(); 839 // succesfully or with a failure. See DownloadFavicon for more
840 // details.
841 void DidDownloadFavicon(webkit_glue::ImageResourceFetcher* fetcher,
842 const SkBitmap& image);
853 843
854 // Sends an IPC notification that the specified content type was blocked. 844 // Requests to download a favicon image. When done, the RenderView
855 // If the content type requires it, |resource_identifier| names the specific 845 // is notified by way of DidDownloadFavicon. Returns true if the
856 // resource that was blocked (the plugin path in the case of plugins), 846 // request was successfully started, false otherwise. id is used to
857 // otherwise it's the empty string. 847 // uniquely identify the request and passed back to the
858 void DidBlockContentType(ContentSettingsType settings_type, 848 // DidDownloadFavicon method. If the image has multiple frames, the
859 const std::string& resource_identifier); 849 // frame whose size is image_size is returned. If the image doesn't
850 // have a frame at the specified size, the first is returned.
851 bool DownloadFavicon(int id, const GURL& image_url, int image_size);
860 852
861 GURL GetAlternateErrorPageURL(const GURL& failed_url, 853 GURL GetAlternateErrorPageURL(const GURL& failed_url,
862 ErrorPageType error_type); 854 ErrorPageType error_type);
863 855
864 // Locates a sub frame with given xpath 856 // Locates a sub frame with given xpath
865 WebKit::WebFrame* GetChildFrame(const std::wstring& frame_xpath) const; 857 WebKit::WebFrame* GetChildFrame(const std::wstring& frame_xpath) const;
866 858
867 WebUIBindings* GetWebUIBindings(); 859 WebUIBindings* GetWebUIBindings();
868 860
869 // Should only be called if this object wraps a PluginDocument. 861 // Should only be called if this object wraps a PluginDocument.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 // --------------------------------------------------------------------------- 897 // ---------------------------------------------------------------------------
906 // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put 898 // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put
907 // it in the same order in the .cc file as it was in the header. 899 // it in the same order in the .cc file as it was in the header.
908 // --------------------------------------------------------------------------- 900 // ---------------------------------------------------------------------------
909 901
910 // Settings ------------------------------------------------------------------ 902 // Settings ------------------------------------------------------------------
911 903
912 WebPreferences webkit_preferences_; 904 WebPreferences webkit_preferences_;
913 RendererPreferences renderer_preferences_; 905 RendererPreferences renderer_preferences_;
914 906
915 HostContentSettings host_content_settings_;
916 HostZoomLevels host_zoom_levels_; 907 HostZoomLevels host_zoom_levels_;
917 908
918 // Whether content state (such as form state, scroll position and page 909 // Whether content state (such as form state, scroll position and page
919 // contents) should be sent to the browser immediately. This is normally 910 // contents) should be sent to the browser immediately. This is normally
920 // false, but set to true by some tests. 911 // false, but set to true by some tests.
921 bool send_content_state_immediately_; 912 bool send_content_state_immediately_;
922 913
923 // Stores if loading of images, scripts, and plugins is allowed.
924 ContentSettings current_content_settings_;
925
926 // Bitwise-ORed set of extra bindings that have been enabled. See 914 // Bitwise-ORed set of extra bindings that have been enabled. See
927 // BindingsPolicy for details. 915 // BindingsPolicy for details.
928 int enabled_bindings_; 916 int enabled_bindings_;
929 917
930 // The alternate error page URL, if one exists. 918 // The alternate error page URL, if one exists.
931 GURL alternate_error_page_url_; 919 GURL alternate_error_page_url_;
932 920
933 // If true, we send IPC messages when |preferred_size_| changes. 921 // If true, we send IPC messages when |preferred_size_| changes.
934 bool send_preferred_size_changes_; 922 bool send_preferred_size_changes_;
935 923
(...skipping 24 matching lines...) Expand all
960 // opener. If so, we may want to load pages in a separate process. See 948 // opener. If so, we may want to load pages in a separate process. See
961 // decidePolicyForNavigation for details. 949 // decidePolicyForNavigation for details.
962 bool opener_suppressed_; 950 bool opener_suppressed_;
963 951
964 // If we are handling a top-level client-side redirect, this tracks the URL 952 // If we are handling a top-level client-side redirect, this tracks the URL
965 // of the page that initiated it. Specifically, when a load is committed this 953 // of the page that initiated it. Specifically, when a load is committed this
966 // is used to determine if that load originated from a client-side redirect. 954 // is used to determine if that load originated from a client-side redirect.
967 // It is empty if there is no top-level client-side redirect. 955 // It is empty if there is no top-level client-side redirect.
968 GURL completed_client_redirect_src_; 956 GURL completed_client_redirect_src_;
969 957
970 // Stores if images, scripts, and plugins have actually been blocked.
971 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES];
972
973 // Holds state pertaining to a navigation that we initiated. This is held by 958 // Holds state pertaining to a navigation that we initiated. This is held by
974 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_ 959 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_
975 // as a temporary holder for the state until the WebDataSource corresponding 960 // as a temporary holder for the state until the WebDataSource corresponding
976 // to the new navigation is created. See DidCreateDataSource. 961 // to the new navigation is created. See DidCreateDataSource.
977 scoped_ptr<NavigationState> pending_navigation_state_; 962 scoped_ptr<NavigationState> pending_navigation_state_;
978 963
979 // Timer used to delay the updating of nav state (see SyncNavigationState). 964 // Timer used to delay the updating of nav state (see SyncNavigationState).
980 base::OneShotTimer<RenderView> nav_state_sync_timer_; 965 base::OneShotTimer<RenderView> nav_state_sync_timer_;
981 966
982 // True if the RenderView is currently prerendering a page. 967 // True if the RenderView is currently prerendering a page.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 // bunch of stuff, you should probably create a helper class and put your 1165 // bunch of stuff, you should probably create a helper class and put your
1181 // data and methods on that to avoid bloating RenderView more. You can use 1166 // data and methods on that to avoid bloating RenderView more. You can use
1182 // the Observer interface to filter IPC messages and receive frame change 1167 // the Observer interface to filter IPC messages and receive frame change
1183 // notifications. 1168 // notifications.
1184 // --------------------------------------------------------------------------- 1169 // ---------------------------------------------------------------------------
1185 1170
1186 DISALLOW_COPY_AND_ASSIGN(RenderView); 1171 DISALLOW_COPY_AND_ASSIGN(RenderView);
1187 }; 1172 };
1188 1173
1189 #endif // CONTENT_RENDERER_RENDER_VIEW_H_ 1174 #endif // CONTENT_RENDERER_RENDER_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698