OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_RENDER_VIEW_IMPL_H_ |
6 #define CONTENT_RENDERER_RENDER_VIEW_IMPL_H_ | 6 #define CONTENT_RENDERER_RENDER_VIEW_IMPL_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
16 #include "base/id_map.h" | 16 #include "base/id_map.h" |
17 #include "base/memory/linked_ptr.h" | 17 #include "base/memory/linked_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
20 #include "base/timer.h" | 20 #include "base/timer.h" |
| 21 #include "base/values.h" |
21 #include "build/build_config.h" | 22 #include "build/build_config.h" |
22 #include "content/common/content_export.h" | 23 #include "content/common/content_export.h" |
23 #include "content/common/edit_command.h" | 24 #include "content/common/edit_command.h" |
24 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 25 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
25 #include "content/common/navigation_gesture.h" | 26 #include "content/common/navigation_gesture.h" |
26 #include "content/common/view_message_enums.h" | 27 #include "content/common/view_message_enums.h" |
27 #include "content/public/common/javascript_message_type.h" | 28 #include "content/public/common/javascript_message_type.h" |
28 #include "content/public/common/page_zoom.h" | 29 #include "content/public/common/page_zoom.h" |
29 #include "content/public/common/referrer.h" | 30 #include "content/public/common/referrer.h" |
30 #include "content/public/common/renderer_preferences.h" | 31 #include "content/public/common/renderer_preferences.h" |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 WebKit::WebFrame* frame, | 536 WebKit::WebFrame* frame, |
536 WebKit::WebMediaPlayerClient* client); | 537 WebKit::WebMediaPlayerClient* client); |
537 virtual WebKit::WebMediaPlayer* createMediaPlayer( | 538 virtual WebKit::WebMediaPlayer* createMediaPlayer( |
538 WebKit::WebFrame* frame, | 539 WebKit::WebFrame* frame, |
539 const WebKit::WebURL& url, | 540 const WebKit::WebURL& url, |
540 WebKit::WebMediaPlayerClient* client); | 541 WebKit::WebMediaPlayerClient* client); |
541 virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost( | 542 virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost( |
542 WebKit::WebFrame* frame, | 543 WebKit::WebFrame* frame, |
543 WebKit::WebApplicationCacheHostClient* client); | 544 WebKit::WebApplicationCacheHostClient* client); |
544 virtual WebKit::WebCookieJar* cookieJar(WebKit::WebFrame* frame); | 545 virtual WebKit::WebCookieJar* cookieJar(WebKit::WebFrame* frame); |
| 546 virtual void didCreateFrame(WebKit::WebFrame* parent, |
| 547 WebKit::WebFrame* child); |
545 virtual void frameDetached(WebKit::WebFrame* frame); | 548 virtual void frameDetached(WebKit::WebFrame* frame); |
546 virtual void willClose(WebKit::WebFrame* frame); | 549 virtual void willClose(WebKit::WebFrame* frame); |
547 virtual void loadURLExternally(WebKit::WebFrame* frame, | 550 virtual void loadURLExternally(WebKit::WebFrame* frame, |
548 const WebKit::WebURLRequest& request, | 551 const WebKit::WebURLRequest& request, |
549 WebKit::WebNavigationPolicy policy); | 552 WebKit::WebNavigationPolicy policy); |
550 virtual void loadURLExternally(WebKit::WebFrame* frame, | 553 virtual void loadURLExternally(WebKit::WebFrame* frame, |
551 const WebKit::WebURLRequest& request, | 554 const WebKit::WebURLRequest& request, |
552 WebKit::WebNavigationPolicy policy, | 555 WebKit::WebNavigationPolicy policy, |
553 const WebKit::WebString& suggested_name); | 556 const WebKit::WebString& suggested_name); |
554 virtual WebKit::WebNavigationPolicy decidePolicyForNavigation( | 557 virtual WebKit::WebNavigationPolicy decidePolicyForNavigation( |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 unsigned long long requested_size, | 676 unsigned long long requested_size, |
674 WebKit::WebStorageQuotaCallbacks* callbacks); | 677 WebKit::WebStorageQuotaCallbacks* callbacks); |
675 virtual void registerIntentService( | 678 virtual void registerIntentService( |
676 WebKit::WebFrame* frame, | 679 WebKit::WebFrame* frame, |
677 const WebKit::WebIntentServiceInfo& service); | 680 const WebKit::WebIntentServiceInfo& service); |
678 virtual void dispatchIntent(WebKit::WebFrame* frame, | 681 virtual void dispatchIntent(WebKit::WebFrame* frame, |
679 const WebKit::WebIntentRequest& intentRequest); | 682 const WebKit::WebIntentRequest& intentRequest); |
680 virtual void willOpenSocketStream( | 683 virtual void willOpenSocketStream( |
681 WebKit::WebSocketStreamHandle* handle); | 684 WebKit::WebSocketStreamHandle* handle); |
682 virtual bool willCheckAndDispatchMessageEvent( | 685 virtual bool willCheckAndDispatchMessageEvent( |
683 WebKit::WebFrame* source, | 686 WebKit::WebFrame* sourceFrame, |
| 687 WebKit::WebFrame* targetFrame, |
684 WebKit::WebSecurityOrigin targetOrigin, | 688 WebKit::WebSecurityOrigin targetOrigin, |
685 WebKit::WebDOMMessageEvent event) OVERRIDE; | 689 WebKit::WebDOMMessageEvent event) OVERRIDE; |
686 virtual WebKit::WebString userAgentOverride( | 690 virtual WebKit::WebString userAgentOverride( |
687 WebKit::WebFrame* frame, | 691 WebKit::WebFrame* frame, |
688 const WebKit::WebURL& url) OVERRIDE; | 692 const WebKit::WebURL& url) OVERRIDE; |
689 | 693 |
690 // WebKit::WebPageSerializerClient implementation ---------------------------- | 694 // WebKit::WebPageSerializerClient implementation ---------------------------- |
691 | 695 |
692 virtual void didSerializeDataForFrame( | 696 virtual void didSerializeDataForFrame( |
693 const WebKit::WebURL& frame_url, | 697 const WebKit::WebURL& frame_url, |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 #endif | 1040 #endif |
1037 | 1041 |
1038 void OnZoom(content::PageZoom zoom); | 1042 void OnZoom(content::PageZoom zoom); |
1039 void OnZoomFactor(content::PageZoom zoom, int zoom_center_x, | 1043 void OnZoomFactor(content::PageZoom zoom, int zoom_center_x, |
1040 int zoom_center_y); | 1044 int zoom_center_y); |
1041 | 1045 |
1042 void OnEnableViewSourceMode(); | 1046 void OnEnableViewSourceMode(); |
1043 | 1047 |
1044 void OnJavaBridgeInit(); | 1048 void OnJavaBridgeInit(); |
1045 | 1049 |
| 1050 void OnUpdatedFrameTree(int process_id, |
| 1051 int route_id, |
| 1052 const std::string& frame_tree); |
| 1053 |
1046 // Adding a new message handler? Please add it in alphabetical order above | 1054 // Adding a new message handler? Please add it in alphabetical order above |
1047 // and put it in the same position in the .cc file. | 1055 // and put it in the same position in the .cc file. |
1048 | 1056 |
1049 // Misc private functions ---------------------------------------------------- | 1057 // Misc private functions ---------------------------------------------------- |
1050 void ZoomFactorHelper(content::PageZoom zoom, int zoom_center_x, | 1058 void ZoomFactorHelper(content::PageZoom zoom, int zoom_center_x, |
1051 int zoom_center_y, float scaling_increment); | 1059 int zoom_center_y, float scaling_increment); |
1052 | 1060 |
1053 void AltErrorPageFinished(WebKit::WebFrame* frame, | 1061 void AltErrorPageFinished(WebKit::WebFrame* frame, |
1054 const WebKit::WebURLError& original_error, | 1062 const WebKit::WebURLError& original_error, |
1055 const std::string& html); | 1063 const std::string& html); |
1056 | 1064 |
1057 // Check whether the preferred size has changed. | 1065 // Check whether the preferred size has changed. |
1058 void CheckPreferredSize(); | 1066 void CheckPreferredSize(); |
1059 | 1067 |
1060 WebKit::WebGraphicsContext3D* CreateGraphicsContext3D( | 1068 WebKit::WebGraphicsContext3D* CreateGraphicsContext3D( |
1061 const WebKit::WebGraphicsContext3D::Attributes& attributes); | 1069 const WebKit::WebGraphicsContext3D::Attributes& attributes); |
1062 | 1070 |
| 1071 // This method walks the entire frame tree for this RenderView and sends an |
| 1072 // update to the browser process as described in the |
| 1073 // ViewHostMsg_FrameTreeUpdated comments. If |exclude_frame_subtree| |
| 1074 // frame is non-NULL, the subtree starting at that frame not included in the |
| 1075 // serialized form. |
| 1076 // This is used when a frame is going to be removed from the tree. |
| 1077 void SendUpdatedFrameTree(WebKit::WebFrame* exclude_frame_subtree); |
| 1078 |
| 1079 // Recursively creates a DOM frame tree starting with |frame|, based on |
| 1080 // |frame_tree|. For each node, the frame is navigated to the swapped out URL, |
| 1081 // the name (if present) is set on it, and all the subframes are created |
| 1082 // and added to the DOM. |
| 1083 void CreateFrameTree(WebKit::WebFrame* frame, DictionaryValue* frame_tree); |
| 1084 |
| 1085 // If this is a swapped out RenderView, which maintains a copy of the frame |
| 1086 // tree of an active RenderView, we keep a map from frame ids in this view to |
| 1087 // the frame ids of the active view for each corresponding frame. |
| 1088 // This method uses the map to find the frame in this RenderView that |
| 1089 // corresponds to the frame in the active RenderView specified by |frame_id|. |
| 1090 WebKit::WebFrame* GetFrameByMappedID(int frame_id); |
| 1091 |
1063 void EnsureMediaStreamImpl(); | 1092 void EnsureMediaStreamImpl(); |
1064 | 1093 |
1065 // This callback is triggered when DownloadFavicon completes, either | 1094 // This callback is triggered when DownloadFavicon completes, either |
1066 // succesfully or with a failure. See DownloadFavicon for more | 1095 // succesfully or with a failure. See DownloadFavicon for more |
1067 // details. | 1096 // details. |
1068 void DidDownloadFavicon(webkit_glue::ImageResourceFetcher* fetcher, | 1097 void DidDownloadFavicon(webkit_glue::ImageResourceFetcher* fetcher, |
1069 const SkBitmap& image); | 1098 const SkBitmap& image); |
1070 | 1099 |
1071 // Requests to download a favicon image. When done, the RenderView is notified | 1100 // Requests to download a favicon image. When done, the RenderView is notified |
1072 // by way of DidDownloadFavicon. Returns true if the request was successfully | 1101 // by way of DidDownloadFavicon. Returns true if the request was successfully |
(...skipping 28 matching lines...) Expand all Loading... |
1101 #if defined(OS_ANDROID) | 1130 #if defined(OS_ANDROID) |
1102 // Launch an Android content intent with the given URL. | 1131 // Launch an Android content intent with the given URL. |
1103 void LaunchAndroidContentIntent(const GURL& intent_url, size_t request_id); | 1132 void LaunchAndroidContentIntent(const GURL& intent_url, size_t request_id); |
1104 #endif | 1133 #endif |
1105 | 1134 |
1106 bool MaybeLoadAlternateErrorPage(WebKit::WebFrame* frame, | 1135 bool MaybeLoadAlternateErrorPage(WebKit::WebFrame* frame, |
1107 const WebKit::WebURLError& error, | 1136 const WebKit::WebURLError& error, |
1108 bool replace); | 1137 bool replace); |
1109 | 1138 |
1110 // Make this RenderView show an empty, unscriptable page. | 1139 // Make this RenderView show an empty, unscriptable page. |
1111 void NavigateToSwappedOutURL(); | 1140 void NavigateToSwappedOutURL(WebKit::WebFrame* frame); |
1112 | 1141 |
1113 // If we initiated a navigation, this function will populate |document_state| | 1142 // If we initiated a navigation, this function will populate |document_state| |
1114 // with the navigation information saved in OnNavigate(). | 1143 // with the navigation information saved in OnNavigate(). |
1115 void PopulateDocumentStateFromPending(content::DocumentState* document_state); | 1144 void PopulateDocumentStateFromPending(content::DocumentState* document_state); |
1116 | 1145 |
1117 // Returns a new NavigationState populated with the navigation information | 1146 // Returns a new NavigationState populated with the navigation information |
1118 // saved in OnNavigate(). | 1147 // saved in OnNavigate(). |
1119 content::NavigationState* CreateNavigationStateFromPending(); | 1148 content::NavigationState* CreateNavigationStateFromPending(); |
1120 | 1149 |
1121 // Processes the command-line flags --enable-viewport and | 1150 // Processes the command-line flags --enable-viewport and |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1465 // guest RenderView. | 1494 // guest RenderView. |
1466 ppapi::HostResource guest_graphics_resource_; | 1495 ppapi::HostResource guest_graphics_resource_; |
1467 | 1496 |
1468 // This graphics context is initialized once GuestReady() is called. | 1497 // This graphics context is initialized once GuestReady() is called. |
1469 WebGraphicsContext3DCommandBufferImpl* guest_uninitialized_context_; | 1498 WebGraphicsContext3DCommandBufferImpl* guest_uninitialized_context_; |
1470 | 1499 |
1471 // These are the attributes originally passed into createOutputSurface | 1500 // These are the attributes originally passed into createOutputSurface |
1472 // before the guest_to_embedder_channel was ready. | 1501 // before the guest_to_embedder_channel was ready. |
1473 WebKit::WebGraphicsContext3D::Attributes guest_attributes_; | 1502 WebKit::WebGraphicsContext3D::Attributes guest_attributes_; |
1474 | 1503 |
| 1504 // Boolean indicating whether we are in the process of creating the frame |
| 1505 // tree for this renderer in response to ViewMsg_UpdateFrameTree. If true, |
| 1506 // we won't be sending ViewHostMsg_FrameTreeUpdated messages back to the |
| 1507 // browser, as those will be redundant. |
| 1508 bool updating_frame_tree_; |
| 1509 |
| 1510 // Boolean indicating that the frame tree has changed, but a message has not |
| 1511 // been sent to the browser because a page has been loading. This helps |
| 1512 // avoid extra messages being sent to the browser when navigating away from a |
| 1513 // page with subframes, which will be destroyed. Instead, a single message |
| 1514 // is sent when the load is stopped with the final state of the frame tree. |
| 1515 // |
| 1516 // TODO(nasko): Relying on the is_loading_ means that frame tree updates will |
| 1517 // not be sent until *all* subframes have completed loading. This can cause |
| 1518 // JavaScript calls to fail, if they occur prior to the first update message |
| 1519 // being sent. This will be fixed by bug http://crbug.com/145014. |
| 1520 bool pending_frame_tree_update_; |
| 1521 |
| 1522 // If this render view is a swapped out "mirror" of an active render view in a |
| 1523 // different process, we record the process id and route id for the active RV. |
| 1524 // For further details, see the comments on ViewHostMsg_FrameTreeUpdated. |
| 1525 int target_process_id_; |
| 1526 int target_routing_id_; |
| 1527 |
| 1528 // A map of the current process's frame ids to ids in the remote active render |
| 1529 // view, if this is a swapped out render view. |
| 1530 std::map<int, int> active_frame_id_map_; |
| 1531 |
1475 // NOTE: pepper_delegate_ should be last member because its constructor calls | 1532 // NOTE: pepper_delegate_ should be last member because its constructor calls |
1476 // AddObservers method of RenderViewImpl from c-tor. | 1533 // AddObservers method of RenderViewImpl from c-tor. |
1477 content::PepperPluginDelegateImpl pepper_delegate_; | 1534 content::PepperPluginDelegateImpl pepper_delegate_; |
1478 | 1535 |
1479 // --------------------------------------------------------------------------- | 1536 // --------------------------------------------------------------------------- |
1480 // ADDING NEW DATA? Please see if it fits appropriately in one of the above | 1537 // ADDING NEW DATA? Please see if it fits appropriately in one of the above |
1481 // sections rather than throwing it randomly at the end. If you're adding a | 1538 // sections rather than throwing it randomly at the end. If you're adding a |
1482 // bunch of stuff, you should probably create a helper class and put your | 1539 // bunch of stuff, you should probably create a helper class and put your |
1483 // data and methods on that to avoid bloating RenderView more. You can | 1540 // data and methods on that to avoid bloating RenderView more. You can |
1484 // use the Observer interface to filter IPC messages and receive frame change | 1541 // use the Observer interface to filter IPC messages and receive frame change |
1485 // notifications. | 1542 // notifications. |
1486 // --------------------------------------------------------------------------- | 1543 // --------------------------------------------------------------------------- |
1487 | 1544 |
1488 DISALLOW_COPY_AND_ASSIGN(RenderViewImpl); | 1545 DISALLOW_COPY_AND_ASSIGN(RenderViewImpl); |
1489 }; | 1546 }; |
1490 | 1547 |
1491 #endif // CONTENT_RENDERER_RENDER_VIEW_IMPL_H_ | 1548 #endif // CONTENT_RENDERER_RENDER_VIEW_IMPL_H_ |
OLD | NEW |