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

Side by Side Diff: content/renderer/browser_plugin/browser_plugin.cc

Issue 11111020: <browser>: Always read <browser>.src attribute from <object>.src. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding comment that empty src would never be shipped to browser process. Created 8 years, 2 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) 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 void BrowserPlugin::Cleanup() { 93 void BrowserPlugin::Cleanup() {
94 if (damage_buffer_) 94 if (damage_buffer_)
95 FreeDamageBuffer(); 95 FreeDamageBuffer();
96 } 96 }
97 97
98 std::string BrowserPlugin::GetSrcAttribute() const { 98 std::string BrowserPlugin::GetSrcAttribute() const {
99 return src_; 99 return src_;
100 } 100 }
101 101
102 void BrowserPlugin::SetSrcAttribute(const std::string& src) { 102 void BrowserPlugin::SetSrcAttribute(const std::string& src) {
103 if (src == src_ && !guest_crashed_) 103 if (src.empty() || (src == src_ && !guest_crashed_))
104 return; 104 return;
105 105
106 // If we haven't created the guest yet, do so now, if |src| is not empty and 106 // If we haven't created the guest yet, do so now, we will navigate it right
Charlie Reis 2012/10/15 18:57:28 nit: Start a new sentence at "we will".
lazyboy 2012/10/15 20:45:57 Done.
107 // we will navigate it right after creation. If |src| is empty, we can delay 107 // after creation. If |src| is empty, we can delay the creation until we
108 // the creation until we acutally need it. 108 // acutally need it.
109 if (!navigate_src_sent_ && !src.empty()) { 109 if (!navigate_src_sent_) {
110 BrowserPluginManager::Get()->Send( 110 BrowserPluginManager::Get()->Send(
111 new BrowserPluginHostMsg_CreateGuest( 111 new BrowserPluginHostMsg_CreateGuest(
112 render_view_->GetRoutingID(), 112 render_view_->GetRoutingID(),
113 instance_id_, 113 instance_id_,
114 storage_partition_id_, 114 storage_partition_id_,
115 persist_storage_)); 115 persist_storage_));
116 } 116 }
117 117
118 if (navigate_src_sent_ || !src.empty()) { 118 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> params(
119 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> params( 119 GetPendingResizeParams());
120 GetPendingResizeParams()); 120 DCHECK(!params->resize_pending);
121 DCHECK(!params->resize_pending);
122 121
123 BrowserPluginManager::Get()->Send( 122 BrowserPluginManager::Get()->Send(
124 new BrowserPluginHostMsg_NavigateGuest( 123 new BrowserPluginHostMsg_NavigateGuest(
125 render_view_->GetRoutingID(), 124 render_view_->GetRoutingID(),
126 instance_id_, 125 instance_id_,
127 src, 126 src,
128 *params)); 127 *params));
129 // Record that we sent a NavigateGuest message to embedder. Once we send 128 // Record that we sent a NavigateGuest message to embedder.
130 // such a message, subsequent SetSrcAttribute() calls must always send 129 // Once this instance has navigated, the storage partition cannot be changed,
131 // NavigateGuest messages to the embedder (even if |src| is empty), so 130 // so this value is used for enforcing this.
132 // resize works correctly for all cases (e.g. The embedder can reset the 131 navigate_src_sent_ = true;
133 // guest's |src| to empty value, resize and then set the |src| to a
134 // non-empty value).
135 // Additionally, once this instance has navigated, the storage partition
136 // cannot be changed, so this value is used for enforcing this.
137 navigate_src_sent_ = true;
138 }
139 src_ = src; 132 src_ = src;
140 guest_crashed_ = false; 133 guest_crashed_ = false;
141 } 134 }
142 135
143 std::string BrowserPlugin::GetPartitionAttribute() const { 136 std::string BrowserPlugin::GetPartitionAttribute() const {
144 std::string value; 137 std::string value;
145 if (persist_storage_) 138 if (persist_storage_)
146 value.append(kPersistPrefix); 139 value.append(kPersistPrefix);
147 140
148 value.append(storage_partition_id_); 141 value.append(storage_partition_id_);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if (LowerCaseEqualsASCII(attributeName, kSrcAttribute)) { 183 if (LowerCaseEqualsASCII(attributeName, kSrcAttribute)) {
191 src = params.attributeValues[i].utf8(); 184 src = params.attributeValues[i].utf8();
192 } else if (LowerCaseEqualsASCII(attributeName, kPartitionAttribute)) { 185 } else if (LowerCaseEqualsASCII(attributeName, kPartitionAttribute)) {
193 std::string error; 186 std::string error;
194 SetPartitionAttribute(params.attributeValues[i].utf8(), error); 187 SetPartitionAttribute(params.attributeValues[i].utf8(), error);
195 } 188 }
196 } 189 }
197 190
198 // Set the 'src' attribute last, as it will set the has_navigated_ flag to 191 // Set the 'src' attribute last, as it will set the has_navigated_ flag to
199 // true, which prevents changing the 'partition' attribute. 192 // true, which prevents changing the 'partition' attribute.
200 if (!src.empty()) 193 SetSrcAttribute(src);
201 SetSrcAttribute(src);
202 } 194 }
203 195
204 float BrowserPlugin::GetDeviceScaleFactor() const { 196 float BrowserPlugin::GetDeviceScaleFactor() const {
205 if (!render_view_) 197 if (!render_view_)
206 return 1.0f; 198 return 1.0f;
207 return render_view_->GetWebView()->deviceScaleFactor(); 199 return render_view_->GetWebView()->deviceScaleFactor();
208 } 200 }
209 201
210 void BrowserPlugin::RemoveEventListeners() { 202 void BrowserPlugin::RemoveEventListeners() {
211 EventListenerMap::iterator event_listener_map_iter = 203 EventListenerMap::iterator event_listener_map_iter =
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 void* notify_data) { 749 void* notify_data) {
758 } 750 }
759 751
760 void BrowserPlugin::didFailLoadingFrameRequest( 752 void BrowserPlugin::didFailLoadingFrameRequest(
761 const WebKit::WebURL& url, 753 const WebKit::WebURL& url,
762 void* notify_data, 754 void* notify_data,
763 const WebKit::WebURLError& error) { 755 const WebKit::WebURLError& error) {
764 } 756 }
765 757
766 } // namespace content 758 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698