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

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 "chrome/common/search_provider.h" 24 #include "chrome/common/search_provider.h"
26 #include "chrome/common/view_types.h" 25 #include "chrome/common/view_types.h"
27 #include "content/renderer/renderer_webcookiejar_impl.h" 26 #include "content/renderer/renderer_webcookiejar_impl.h"
28 #include "content/common/edit_command.h" 27 #include "content/common/edit_command.h"
29 #include "content/common/navigation_gesture.h" 28 #include "content/common/navigation_gesture.h"
30 #include "content/common/page_zoom.h" 29 #include "content/common/page_zoom.h"
31 #include "content/common/renderer_preferences.h" 30 #include "content/common/renderer_preferences.h"
32 #include "content/renderer/pepper_plugin_delegate_impl.h" 31 #include "content/renderer/pepper_plugin_delegate_impl.h"
33 #include "content/renderer/render_widget.h" 32 #include "content/renderer/render_widget.h"
34 #include "ipc/ipc_platform_file.h" 33 #include "ipc/ipc_platform_file.h"
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 265
267 // Adds the given file chooser request to the file_chooser_completion_ queue 266 // Adds the given file chooser request to the file_chooser_completion_ queue
268 // (see that var for more) and requests the chooser be displayed if there are 267 // (see that var for more) and requests the chooser be displayed if there are
269 // no other waiting items in the queue. 268 // no other waiting items in the queue.
270 // 269 //
271 // Returns true if the chooser was successfully scheduled. False means we 270 // Returns true if the chooser was successfully scheduled. False means we
272 // didn't schedule anything. 271 // didn't schedule anything.
273 bool ScheduleFileChooser(const ViewHostMsg_RunFileChooser_Params& params, 272 bool ScheduleFileChooser(const ViewHostMsg_RunFileChooser_Params& params,
274 WebKit::WebFileChooserCompletion* completion); 273 WebKit::WebFileChooserCompletion* completion);
275 274
276 // Sets the content settings that back allowScripts(), allowImages(), and
277 // allowPlugins().
278 void SetContentSettings(const ContentSettings& settings);
279
280 // Notifies the browser that the given action has been performed. This is 275 // Notifies the browser that the given action has been performed. This is
281 // aggregated to the user metrics service. 276 // aggregated to the user metrics service.
282 void UserMetricsRecordAction(const std::string& action); 277 void UserMetricsRecordAction(const std::string& action);
283 278
284 // Sets whether the renderer should report load progress to the browser. 279 // Sets whether the renderer should report load progress to the browser.
285 void SetReportLoadProgressEnabled(bool enabled); 280 void SetReportLoadProgressEnabled(bool enabled);
286 281
287 // Gets the focused node. If no such node exists then the node will be isNull. 282 // Gets the focused node. If no such node exists then the node will be isNull.
288 WebKit::WebNode GetFocusedNode() const; 283 WebKit::WebNode GetFocusedNode() const;
289 284
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 const WebKit::WebString& name, unsigned long long documentId); 441 const WebKit::WebString& name, unsigned long long documentId);
447 virtual WebKit::WebMediaPlayer* createMediaPlayer( 442 virtual WebKit::WebMediaPlayer* createMediaPlayer(
448 WebKit::WebFrame* frame, 443 WebKit::WebFrame* frame,
449 WebKit::WebMediaPlayerClient* client); 444 WebKit::WebMediaPlayerClient* client);
450 virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost( 445 virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
451 WebKit::WebFrame* frame, 446 WebKit::WebFrame* frame,
452 WebKit::WebApplicationCacheHostClient* client); 447 WebKit::WebApplicationCacheHostClient* client);
453 virtual WebKit::WebCookieJar* cookieJar(WebKit::WebFrame* frame); 448 virtual WebKit::WebCookieJar* cookieJar(WebKit::WebFrame* frame);
454 virtual void frameDetached(WebKit::WebFrame* frame); 449 virtual void frameDetached(WebKit::WebFrame* frame);
455 virtual void willClose(WebKit::WebFrame* frame); 450 virtual void willClose(WebKit::WebFrame* frame);
456 virtual bool allowImages(WebKit::WebFrame* frame, bool enabled_per_settings);
457 virtual bool allowPlugins(WebKit::WebFrame* frame, bool enabled_per_settings);
458 virtual void loadURLExternally(WebKit::WebFrame* frame, 451 virtual void loadURLExternally(WebKit::WebFrame* frame,
459 const WebKit::WebURLRequest& request, 452 const WebKit::WebURLRequest& request,
460 WebKit::WebNavigationPolicy policy); 453 WebKit::WebNavigationPolicy policy);
461 virtual WebKit::WebNavigationPolicy decidePolicyForNavigation( 454 virtual WebKit::WebNavigationPolicy decidePolicyForNavigation(
462 WebKit::WebFrame* frame, 455 WebKit::WebFrame* frame,
463 const WebKit::WebURLRequest& request, 456 const WebKit::WebURLRequest& request,
464 WebKit::WebNavigationType type, 457 WebKit::WebNavigationType type,
465 const WebKit::WebNode&, 458 const WebKit::WebNode&,
466 WebKit::WebNavigationPolicy default_policy, 459 WebKit::WebNavigationPolicy default_policy,
467 bool is_redirect); 460 bool is_redirect);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 virtual void didLoadResourceFromMemoryCache( 524 virtual void didLoadResourceFromMemoryCache(
532 WebKit::WebFrame* frame, 525 WebKit::WebFrame* frame,
533 const WebKit::WebURLRequest& request, 526 const WebKit::WebURLRequest& request,
534 const WebKit::WebURLResponse&); 527 const WebKit::WebURLResponse&);
535 virtual void didDisplayInsecureContent(WebKit::WebFrame* frame); 528 virtual void didDisplayInsecureContent(WebKit::WebFrame* frame);
536 virtual void didRunInsecureContent( 529 virtual void didRunInsecureContent(
537 WebKit::WebFrame* frame, 530 WebKit::WebFrame* frame,
538 const WebKit::WebSecurityOrigin& origin, 531 const WebKit::WebSecurityOrigin& origin,
539 const WebKit::WebURL& target); 532 const WebKit::WebURL& target);
540 533
534 virtual bool allowImages(WebKit::WebFrame* frame, bool enabled_per_settings);
535 virtual bool allowPlugins(WebKit::WebFrame* frame, bool enabled_per_settings);
541 virtual bool allowScript(WebKit::WebFrame* frame, bool enabled_per_settings); 536 virtual bool allowScript(WebKit::WebFrame* frame, bool enabled_per_settings);
542 virtual bool allowDatabase(WebKit::WebFrame* frame, 537 virtual bool allowDatabase(WebKit::WebFrame* frame,
543 const WebKit::WebString& name, 538 const WebKit::WebString& name,
544 const WebKit::WebString& display_name, 539 const WebKit::WebString& display_name,
545 unsigned long estimated_size); 540 unsigned long estimated_size);
546 virtual void didNotAllowScript(WebKit::WebFrame* frame); 541 virtual void didNotAllowScript(WebKit::WebFrame* frame);
547 virtual void didNotAllowPlugins(WebKit::WebFrame* frame); 542 virtual void didNotAllowPlugins(WebKit::WebFrame* frame);
548 virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame* frame); 543 virtual void didExhaustMemoryAvailableForScript(WebKit::WebFrame* frame);
549 virtual void didCreateScriptContext(WebKit::WebFrame* frame); 544 virtual void didCreateScriptContext(WebKit::WebFrame* frame);
550 virtual void didDestroyScriptContext(WebKit::WebFrame* frame); 545 virtual void didDestroyScriptContext(WebKit::WebFrame* frame);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, LastCommittedUpdateState); 645 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, LastCommittedUpdateState);
651 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnHandleKeyboardEvent); 646 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnHandleKeyboardEvent);
652 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnImeStateChanged); 647 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnImeStateChanged);
653 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnNavStateChanged); 648 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnNavStateChanged);
654 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnSetTextDirection); 649 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, OnSetTextDirection);
655 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, UpdateTargetURLWithInvalidURL); 650 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, UpdateTargetURLWithInvalidURL);
656 #if defined(OS_MACOSX) 651 #if defined(OS_MACOSX)
657 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, MacTestCmdUp); 652 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, MacTestCmdUp);
658 #endif 653 #endif
659 654
660 typedef std::map<GURL, ContentSettings> HostContentSettings;
661 typedef std::map<GURL, double> HostZoomLevels; 655 typedef std::map<GURL, double> HostZoomLevels;
662 656
663 // Identifies an accessibility notification from webkit. 657 // Identifies an accessibility notification from webkit.
664 struct RendererAccessibilityNotification { 658 struct RendererAccessibilityNotification {
665 public: 659 public:
666 bool ShouldIncludeChildren(); 660 bool ShouldIncludeChildren();
667 661
668 // The webkit glue id of the accessibility object. 662 // The webkit glue id of the accessibility object.
669 int32 id; 663 int32 id;
670 664
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 void OnResetPageEncodingToDefault(); 818 void OnResetPageEncodingToDefault();
825 void OnScriptEvalRequest(const string16& frame_xpath, 819 void OnScriptEvalRequest(const string16& frame_xpath,
826 const string16& jscript, 820 const string16& jscript,
827 int id, 821 int id,
828 bool notify_result); 822 bool notify_result);
829 void OnSelectAll(); 823 void OnSelectAll();
830 void OnSetAccessibilityFocus(int acc_obj_id); 824 void OnSetAccessibilityFocus(int acc_obj_id);
831 void OnSetActive(bool active); 825 void OnSetActive(bool active);
832 void OnSetAltErrorPageURL(const GURL& gurl); 826 void OnSetAltErrorPageURL(const GURL& gurl);
833 void OnSetBackground(const SkBitmap& background); 827 void OnSetBackground(const SkBitmap& background);
834 void OnSetContentSettingsForLoadingURL(
835 const GURL& url,
836 const ContentSettings& content_settings);
837 void OnSetWebUIProperty(const std::string& name, const std::string& value); 828 void OnSetWebUIProperty(const std::string& name, const std::string& value);
838 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands); 829 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
839 void OnSetInitialFocus(bool reverse); 830 void OnSetInitialFocus(bool reverse);
840 void OnScrollFocusedEditableNodeIntoView(); 831 void OnScrollFocusedEditableNodeIntoView();
841 void OnSetPageEncoding(const std::string& encoding_name); 832 void OnSetPageEncoding(const std::string& encoding_name);
842 void OnSetRendererPrefs(const RendererPreferences& renderer_prefs); 833 void OnSetRendererPrefs(const RendererPreferences& renderer_prefs);
843 #if defined(OS_MACOSX) 834 #if defined(OS_MACOSX)
844 void OnSetWindowVisibility(bool visible); 835 void OnSetWindowVisibility(bool visible);
845 #endif 836 #endif
846 void OnSetZoomLevel(double zoom_level); 837 void OnSetZoomLevel(double zoom_level);
(...skipping 12 matching lines...) Expand all
859 void OnSelectPopupMenuItem(int selected_index); 850 void OnSelectPopupMenuItem(int selected_index);
860 #endif 851 #endif
861 void OnZoom(PageZoom::Function function); 852 void OnZoom(PageZoom::Function function);
862 void OnJavaScriptStressTestControl(int cmd, int param); 853 void OnJavaScriptStressTestControl(int cmd, int param);
863 854
864 // Adding a new message handler? Please add it in alphabetical order above 855 // Adding a new message handler? Please add it in alphabetical order above
865 // and put it in the same position in the .cc file. 856 // and put it in the same position in the .cc file.
866 857
867 // Misc private functions ---------------------------------------------------- 858 // Misc private functions ----------------------------------------------------
868 859
869 // Helper method that returns if the user wants to block content of type
870 // |content_type|.
871 bool AllowContentType(ContentSettingsType settings_type);
872
873 void AltErrorPageFinished(WebKit::WebFrame* frame, 860 void AltErrorPageFinished(WebKit::WebFrame* frame,
874 const WebKit::WebURLError& original_error, 861 const WebKit::WebURLError& original_error,
875 const std::string& html); 862 const std::string& html);
876 863
877 // Exposes the DOMAutomationController object that allows JS to send 864 // Exposes the DOMAutomationController object that allows JS to send
878 // information to the browser process. 865 // information to the browser process.
879 void BindDOMAutomationController(WebKit::WebFrame* webframe); 866 void BindDOMAutomationController(WebKit::WebFrame* webframe);
880 867
881 // Check whether the preferred size has changed. This is called periodically 868 // Check whether the preferred size has changed. This is called periodically
882 // by preferred_size_change_timer_. 869 // by preferred_size_change_timer_.
883 void CheckPreferredSize(); 870 void CheckPreferredSize();
884 871
885 // Resets the |content_blocked_| array.
886 void ClearBlockedContentSettings();
887
888 // Create a new NPAPI plugin. 872 // Create a new NPAPI plugin.
889 WebKit::WebPlugin* CreateNPAPIPlugin(WebKit::WebFrame* frame, 873 WebKit::WebPlugin* CreateNPAPIPlugin(WebKit::WebFrame* frame,
890 const WebKit::WebPluginParams& params, 874 const WebKit::WebPluginParams& params,
891 const FilePath& path, 875 const FilePath& path,
892 const std::string& mime_type); 876 const std::string& mime_type);
893 877
894 // Create a new Pepper plugin. 878 // Create a new Pepper plugin.
895 WebKit::WebPlugin* CreatePepperPlugin( 879 WebKit::WebPlugin* CreatePepperPlugin(
896 WebKit::WebFrame* frame, 880 WebKit::WebFrame* frame,
897 const WebKit::WebPluginParams& params, 881 const WebKit::WebPluginParams& params,
898 const FilePath& path, 882 const FilePath& path,
899 webkit::ppapi::PluginModule* pepper_module); 883 webkit::ppapi::PluginModule* pepper_module);
900 884
901 // Sends an IPC notification that the specified content type was blocked.
902 // If the content type requires it, |resource_identifier| names the specific
903 // resource that was blocked (the plugin path in the case of plugins),
904 // otherwise it's the empty string.
905 void DidBlockContentType(ContentSettingsType settings_type,
906 const std::string& resource_identifier);
907
908 // This callback is triggered when DownloadFavicon completes, either 885 // This callback is triggered when DownloadFavicon completes, either
909 // succesfully or with a failure. See DownloadFavicon for more 886 // succesfully or with a failure. See DownloadFavicon for more
910 // details. 887 // details.
911 void DidDownloadFavicon(webkit_glue::ImageResourceFetcher* fetcher, 888 void DidDownloadFavicon(webkit_glue::ImageResourceFetcher* fetcher,
912 const SkBitmap& image); 889 const SkBitmap& image);
913 890
914 // Requests to download a favicon image. When done, the RenderView 891 // Requests to download a favicon image. When done, the RenderView
915 // is notified by way of DidDownloadFavicon. Returns true if the 892 // is notified by way of DidDownloadFavicon. Returns true if the
916 // request was successfully started, false otherwise. id is used to 893 // request was successfully started, false otherwise. id is used to
917 // uniquely identify the request and passed back to the 894 // uniquely identify the request and passed back to the
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 // --------------------------------------------------------------------------- 955 // ---------------------------------------------------------------------------
979 // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put 956 // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put
980 // it in the same order in the .cc file as it was in the header. 957 // it in the same order in the .cc file as it was in the header.
981 // --------------------------------------------------------------------------- 958 // ---------------------------------------------------------------------------
982 959
983 // Settings ------------------------------------------------------------------ 960 // Settings ------------------------------------------------------------------
984 961
985 WebPreferences webkit_preferences_; 962 WebPreferences webkit_preferences_;
986 RendererPreferences renderer_preferences_; 963 RendererPreferences renderer_preferences_;
987 964
988 HostContentSettings host_content_settings_;
989 HostZoomLevels host_zoom_levels_; 965 HostZoomLevels host_zoom_levels_;
990 966
991 // Whether content state (such as form state, scroll position and page 967 // Whether content state (such as form state, scroll position and page
992 // contents) should be sent to the browser immediately. This is normally 968 // contents) should be sent to the browser immediately. This is normally
993 // false, but set to true by some tests. 969 // false, but set to true by some tests.
994 bool send_content_state_immediately_; 970 bool send_content_state_immediately_;
995 971
996 // Stores if loading of images, scripts, and plugins is allowed.
997 ContentSettings current_content_settings_;
998
999 // Bitwise-ORed set of extra bindings that have been enabled. See 972 // Bitwise-ORed set of extra bindings that have been enabled. See
1000 // BindingsPolicy for details. 973 // BindingsPolicy for details.
1001 int enabled_bindings_; 974 int enabled_bindings_;
1002 975
1003 // The alternate error page URL, if one exists. 976 // The alternate error page URL, if one exists.
1004 GURL alternate_error_page_url_; 977 GURL alternate_error_page_url_;
1005 978
1006 // If true, we send IPC messages when |preferred_size_| changes. 979 // If true, we send IPC messages when |preferred_size_| changes.
1007 bool send_preferred_size_changes_; 980 bool send_preferred_size_changes_;
1008 981
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 // opener. If so, we may want to load pages in a separate process. See 1015 // opener. If so, we may want to load pages in a separate process. See
1043 // decidePolicyForNavigation for details. 1016 // decidePolicyForNavigation for details.
1044 bool opener_suppressed_; 1017 bool opener_suppressed_;
1045 1018
1046 // If we are handling a top-level client-side redirect, this tracks the URL 1019 // If we are handling a top-level client-side redirect, this tracks the URL
1047 // of the page that initiated it. Specifically, when a load is committed this 1020 // of the page that initiated it. Specifically, when a load is committed this
1048 // is used to determine if that load originated from a client-side redirect. 1021 // is used to determine if that load originated from a client-side redirect.
1049 // It is empty if there is no top-level client-side redirect. 1022 // It is empty if there is no top-level client-side redirect.
1050 GURL completed_client_redirect_src_; 1023 GURL completed_client_redirect_src_;
1051 1024
1052 // Stores if images, scripts, and plugins have actually been blocked.
1053 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES];
1054
1055 // Holds state pertaining to a navigation that we initiated. This is held by 1025 // Holds state pertaining to a navigation that we initiated. This is held by
1056 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_ 1026 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_
1057 // as a temporary holder for the state until the WebDataSource corresponding 1027 // as a temporary holder for the state until the WebDataSource corresponding
1058 // to the new navigation is created. See DidCreateDataSource. 1028 // to the new navigation is created. See DidCreateDataSource.
1059 scoped_ptr<NavigationState> pending_navigation_state_; 1029 scoped_ptr<NavigationState> pending_navigation_state_;
1060 1030
1061 // Timer used to delay the updating of nav state (see SyncNavigationState). 1031 // Timer used to delay the updating of nav state (see SyncNavigationState).
1062 base::OneShotTimer<RenderView> nav_state_sync_timer_; 1032 base::OneShotTimer<RenderView> nav_state_sync_timer_;
1063 1033
1064 // True if the RenderView is currently prerendering a page. 1034 // True if the RenderView is currently prerendering a page.
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 // bunch of stuff, you should probably create a helper class and put your 1249 // bunch of stuff, you should probably create a helper class and put your
1280 // data and methods on that to avoid bloating RenderView more. You can use 1250 // data and methods on that to avoid bloating RenderView more. You can use
1281 // the Observer interface to filter IPC messages and receive frame change 1251 // the Observer interface to filter IPC messages and receive frame change
1282 // notifications. 1252 // notifications.
1283 // --------------------------------------------------------------------------- 1253 // ---------------------------------------------------------------------------
1284 1254
1285 DISALLOW_COPY_AND_ASSIGN(RenderView); 1255 DISALLOW_COPY_AND_ASSIGN(RenderView);
1286 }; 1256 };
1287 1257
1288 #endif // CONTENT_RENDERER_RENDER_VIEW_H_ 1258 #endif // CONTENT_RENDERER_RENDER_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698