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 #include "content/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 3778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3789 | 3789 |
3790 int remote_id; | 3790 int remote_id; |
3791 if (frame_tree->GetInteger(content::kFrameTreeNodeIdKey, &remote_id)) | 3791 if (frame_tree->GetInteger(content::kFrameTreeNodeIdKey, &remote_id)) |
3792 active_frame_id_map_.insert(std::pair<int, int>(frame->identifier(), | 3792 active_frame_id_map_.insert(std::pair<int, int>(frame->identifier(), |
3793 remote_id)); | 3793 remote_id)); |
3794 | 3794 |
3795 ListValue* children; | 3795 ListValue* children; |
3796 if (!frame_tree->GetList(content::kFrameTreeNodeSubtreeKey, &children)) | 3796 if (!frame_tree->GetList(content::kFrameTreeNodeSubtreeKey, &children)) |
3797 return; | 3797 return; |
3798 | 3798 |
| 3799 // Create an invisible iframe tree in the swapped out page. |
3799 base::DictionaryValue* child; | 3800 base::DictionaryValue* child; |
3800 for (size_t i = 0; i < children->GetSize(); ++i) { | 3801 for (size_t i = 0; i < children->GetSize(); ++i) { |
3801 if (!children->GetDictionary(i, &child)) | 3802 if (!children->GetDictionary(i, &child)) |
3802 continue; | 3803 continue; |
3803 WebElement element = frame->document().createElement("iframe"); | 3804 WebElement element = frame->document().createElement("iframe"); |
| 3805 element.setAttribute("width", "0"); |
| 3806 element.setAttribute("height", "0"); |
| 3807 element.setAttribute("frameBorder", "0"); |
3804 if (frame->document().body().appendChild(element)) { | 3808 if (frame->document().body().appendChild(element)) { |
3805 WebFrame* subframe = WebFrame::fromFrameOwnerElement(element); | 3809 WebFrame* subframe = WebFrame::fromFrameOwnerElement(element); |
3806 if (subframe) | 3810 if (subframe) |
3807 CreateFrameTree(subframe, child); | 3811 CreateFrameTree(subframe, child); |
3808 } else { | 3812 } else { |
3809 LOG(ERROR) << "Failed to append created iframe element."; | 3813 LOG(ERROR) << "Failed to append created iframe element."; |
3810 } | 3814 } |
3811 } | 3815 } |
3812 } | 3816 } |
3813 | 3817 |
(...skipping 2321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6135 DCHECK(!java_bridge_dispatcher_); | 6139 DCHECK(!java_bridge_dispatcher_); |
6136 #if defined(ENABLE_JAVA_BRIDGE) | 6140 #if defined(ENABLE_JAVA_BRIDGE) |
6137 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); | 6141 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); |
6138 #endif | 6142 #endif |
6139 } | 6143 } |
6140 | 6144 |
6141 void RenderViewImpl::OnUpdatedFrameTree( | 6145 void RenderViewImpl::OnUpdatedFrameTree( |
6142 int process_id, | 6146 int process_id, |
6143 int route_id, | 6147 int route_id, |
6144 const std::string& frame_tree) { | 6148 const std::string& frame_tree) { |
| 6149 // We should only act on this message if we are swapped out. It's possible |
| 6150 // for this to happen due to races. |
| 6151 if (!is_swapped_out_) |
| 6152 return; |
| 6153 |
6145 base::DictionaryValue* frames = NULL; | 6154 base::DictionaryValue* frames = NULL; |
6146 scoped_ptr<base::Value> tree(base::JSONReader::Read(frame_tree)); | 6155 scoped_ptr<base::Value> tree(base::JSONReader::Read(frame_tree)); |
6147 if (tree.get() && tree->IsType(base::Value::TYPE_DICTIONARY)) | 6156 if (tree.get() && tree->IsType(base::Value::TYPE_DICTIONARY)) |
6148 tree->GetAsDictionary(&frames); | 6157 tree->GetAsDictionary(&frames); |
6149 | 6158 |
6150 updating_frame_tree_ = true; | 6159 updating_frame_tree_ = true; |
6151 active_frame_id_map_.clear(); | 6160 active_frame_id_map_.clear(); |
6152 | 6161 |
6153 target_process_id_ = process_id; | 6162 target_process_id_ = process_id; |
6154 target_routing_id_ = route_id; | 6163 target_routing_id_ = route_id; |
6155 CreateFrameTree(webview()->mainFrame(), frames); | 6164 CreateFrameTree(webview()->mainFrame(), frames); |
6156 | 6165 |
6157 updating_frame_tree_ = false; | 6166 updating_frame_tree_ = false; |
6158 } | 6167 } |
OLD | NEW |