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/browser_plugin/browser_plugin.h" | 5 #include "content/renderer/browser_plugin/browser_plugin.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #if defined (OS_WIN) | 9 #if defined (OS_WIN) |
10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 void BrowserPlugin::Cleanup() { | 95 void BrowserPlugin::Cleanup() { |
96 if (damage_buffer_) | 96 if (damage_buffer_) |
97 FreeDamageBuffer(); | 97 FreeDamageBuffer(); |
98 } | 98 } |
99 | 99 |
100 std::string BrowserPlugin::GetSrcAttribute() const { | 100 std::string BrowserPlugin::GetSrcAttribute() const { |
101 return src_; | 101 return src_; |
102 } | 102 } |
103 | 103 |
104 void BrowserPlugin::SetSrcAttribute(const std::string& src) { | 104 void BrowserPlugin::SetSrcAttribute(const std::string& src) { |
105 if (src == src_ && !guest_crashed_) | 105 if (src.empty() || (src == src_ && !guest_crashed_)) |
106 return; | 106 return; |
107 | 107 |
108 // If we haven't created the guest yet, do so now, if |src| is not empty and | 108 // If we haven't created the guest yet, do so now. We will navigate it right |
109 // we will navigate it right after creation. If |src| is empty, we can delay | 109 // after creation. If |src| is empty, we can delay the creation until we |
110 // the creation until we acutally need it. | 110 // acutally need it. |
111 if (!navigate_src_sent_ && !src.empty()) { | 111 if (!navigate_src_sent_) { |
112 BrowserPluginManager::Get()->Send( | 112 BrowserPluginManager::Get()->Send( |
113 new BrowserPluginHostMsg_CreateGuest( | 113 new BrowserPluginHostMsg_CreateGuest( |
114 render_view_->GetRoutingID(), | 114 render_view_->GetRoutingID(), |
115 instance_id_, | 115 instance_id_, |
116 storage_partition_id_, | 116 storage_partition_id_, |
117 persist_storage_)); | 117 persist_storage_)); |
118 } | 118 } |
119 | 119 |
120 if (navigate_src_sent_ || !src.empty()) { | 120 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> params( |
121 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> params( | 121 GetPendingResizeParams()); |
122 GetPendingResizeParams()); | 122 DCHECK(!params->resize_pending); |
123 DCHECK(!params->resize_pending); | |
124 | 123 |
125 BrowserPluginManager::Get()->Send( | 124 BrowserPluginManager::Get()->Send( |
126 new BrowserPluginHostMsg_NavigateGuest( | 125 new BrowserPluginHostMsg_NavigateGuest( |
127 render_view_->GetRoutingID(), | 126 render_view_->GetRoutingID(), |
128 instance_id_, | 127 instance_id_, |
129 src, | 128 src, |
130 *params)); | 129 *params)); |
131 // Record that we sent a NavigateGuest message to embedder. Once we send | 130 // Record that we sent a NavigateGuest message to embedder. |
132 // such a message, subsequent SetSrcAttribute() calls must always send | 131 // Once this instance has navigated, the storage partition cannot be changed, |
133 // NavigateGuest messages to the embedder (even if |src| is empty), so | 132 // so this value is used for enforcing this. |
134 // resize works correctly for all cases (e.g. The embedder can reset the | 133 navigate_src_sent_ = true; |
135 // guest's |src| to empty value, resize and then set the |src| to a | |
136 // non-empty value). | |
137 // Additionally, once this instance has navigated, the storage partition | |
138 // cannot be changed, so this value is used for enforcing this. | |
139 navigate_src_sent_ = true; | |
140 } | |
141 src_ = src; | 134 src_ = src; |
142 guest_crashed_ = false; | 135 guest_crashed_ = false; |
143 } | 136 } |
144 | 137 |
145 std::string BrowserPlugin::GetPartitionAttribute() const { | 138 std::string BrowserPlugin::GetPartitionAttribute() const { |
146 std::string value; | 139 std::string value; |
147 if (persist_storage_) | 140 if (persist_storage_) |
148 value.append(kPersistPrefix); | 141 value.append(kPersistPrefix); |
149 | 142 |
150 value.append(storage_partition_id_); | 143 value.append(storage_partition_id_); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 if (LowerCaseEqualsASCII(attributeName, kSrcAttribute)) { | 194 if (LowerCaseEqualsASCII(attributeName, kSrcAttribute)) { |
202 src = params.attributeValues[i].utf8(); | 195 src = params.attributeValues[i].utf8(); |
203 } else if (LowerCaseEqualsASCII(attributeName, kPartitionAttribute)) { | 196 } else if (LowerCaseEqualsASCII(attributeName, kPartitionAttribute)) { |
204 std::string error; | 197 std::string error; |
205 SetPartitionAttribute(params.attributeValues[i].utf8(), error); | 198 SetPartitionAttribute(params.attributeValues[i].utf8(), error); |
206 } | 199 } |
207 } | 200 } |
208 | 201 |
209 // Set the 'src' attribute last, as it will set the has_navigated_ flag to | 202 // Set the 'src' attribute last, as it will set the has_navigated_ flag to |
210 // true, which prevents changing the 'partition' attribute. | 203 // true, which prevents changing the 'partition' attribute. |
211 if (!src.empty()) | 204 SetSrcAttribute(src); |
212 SetSrcAttribute(src); | |
213 } | 205 } |
214 | 206 |
215 float BrowserPlugin::GetDeviceScaleFactor() const { | 207 float BrowserPlugin::GetDeviceScaleFactor() const { |
216 if (!render_view_) | 208 if (!render_view_) |
217 return 1.0f; | 209 return 1.0f; |
218 return render_view_->GetWebView()->deviceScaleFactor(); | 210 return render_view_->GetWebView()->deviceScaleFactor(); |
219 } | 211 } |
220 | 212 |
221 void BrowserPlugin::RemoveEventListeners() { | 213 void BrowserPlugin::RemoveEventListeners() { |
222 EventListenerMap::iterator event_listener_map_iter = | 214 EventListenerMap::iterator event_listener_map_iter = |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 void* notify_data) { | 788 void* notify_data) { |
797 } | 789 } |
798 | 790 |
799 void BrowserPlugin::didFailLoadingFrameRequest( | 791 void BrowserPlugin::didFailLoadingFrameRequest( |
800 const WebKit::WebURL& url, | 792 const WebKit::WebURL& url, |
801 void* notify_data, | 793 void* notify_data, |
802 const WebKit::WebURLError& error) { | 794 const WebKit::WebURLError& error) { |
803 } | 795 } |
804 | 796 |
805 } // namespace content | 797 } // namespace content |
OLD | NEW |