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

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

Issue 11418261: Browser Plugin: Update DOM Node attributes when properties are updated (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed nits Created 8 years 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/json/json_string_value_serializer.h" 7 #include "base/json/json_string_value_serializer.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/string_number_conversions.h"
9 #include "base/string_util.h" 10 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
11 #include "content/common/browser_plugin_messages.h" 12 #include "content/common/browser_plugin_messages.h"
12 #include "content/common/view_messages.h" 13 #include "content/common/view_messages.h"
13 #include "content/public/common/content_client.h" 14 #include "content/public/common/content_client.h"
14 #include "content/public/renderer/content_renderer_client.h" 15 #include "content/public/renderer/content_renderer_client.h"
15 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" 16 #include "content/renderer/browser_plugin/browser_plugin_bindings.h"
16 #include "content/renderer/browser_plugin/browser_plugin_manager.h" 17 #include "content/renderer/browser_plugin/browser_plugin_manager.h"
17 #include "content/renderer/render_process_impl.h" 18 #include "content/renderer/render_process_impl.h"
18 #include "content/renderer/render_thread_impl.h" 19 #include "content/renderer/render_thread_impl.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 const char kIsTopLevel[] = "isTopLevel"; 60 const char kIsTopLevel[] = "isTopLevel";
60 const char kNewURL[] = "newUrl"; 61 const char kNewURL[] = "newUrl";
61 const char kNewHeight[] = "newHeight"; 62 const char kNewHeight[] = "newHeight";
62 const char kNewWidth[] = "newWidth"; 63 const char kNewWidth[] = "newWidth";
63 const char kOldURL[] = "oldUrl"; 64 const char kOldURL[] = "oldUrl";
64 const char kOldHeight[] = "oldHeight"; 65 const char kOldHeight[] = "oldHeight";
65 const char kOldWidth[] = "oldWidth"; 66 const char kOldWidth[] = "oldWidth";
66 const char kPartition[] = "partition"; 67 const char kPartition[] = "partition";
67 const char kPersistPrefix[] = "persist:"; 68 const char kPersistPrefix[] = "persist:";
68 const char kProcessId[] = "processId"; 69 const char kProcessId[] = "processId";
70 const char kReason[] = "reason";
69 const char kSrc[] = "src"; 71 const char kSrc[] = "src";
70 const char kReason[] = "reason";
71 const char kURL[] = "url"; 72 const char kURL[] = "url";
72 73
73 // Error messages. 74 // Error messages.
74 const char kErrorAlreadyNavigated[] = 75 const char kErrorAlreadyNavigated[] =
75 "The object has already navigated, so its partition cannot be changed."; 76 "The object has already navigated, so its partition cannot be changed.";
76 const char kErrorInvalidPartition[] = 77 const char kErrorInvalidPartition[] =
77 "Invalid partition attribute."; 78 "Invalid partition attribute.";
78 79
79 static std::string TerminationStatusToString(base::TerminationStatus status) { 80 static std::string TerminationStatusToString(base::TerminationStatus status) {
80 switch (status) { 81 switch (status) {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 #else 253 #else
253 bool BrowserPlugin::DamageBufferMatches( 254 bool BrowserPlugin::DamageBufferMatches(
254 const TransportDIB* damage_buffer, 255 const TransportDIB* damage_buffer,
255 const TransportDIB::Handle& other_damage_buffer_handle) { 256 const TransportDIB::Handle& other_damage_buffer_handle) {
256 if (!damage_buffer) 257 if (!damage_buffer)
257 return false; 258 return false;
258 return damage_buffer->handle() == other_damage_buffer_handle; 259 return damage_buffer->handle() == other_damage_buffer_handle;
259 } 260 }
260 #endif 261 #endif
261 262
263 void BrowserPlugin::UpdateDOMAttribute(
264 const std::string& attribute_name,
265 const std::string& attribute_value) {
266 if (!container())
267 return;
268
269 WebKit::WebElement element = container()->element();
270 WebKit::WebString web_attribute_name =
271 WebKit::WebString::fromUTF8(attribute_name);
272 std::string current_value(element.getAttribute(web_attribute_name).utf8());
273 if (current_value == attribute_value)
274 return;
275
276 if (attribute_value.empty()) {
277 element.removeAttribute(web_attribute_name);
278 } else {
279 element.setAttribute(web_attribute_name,
280 WebKit::WebString::fromUTF8(attribute_value));
281 }
282 }
283
262 void BrowserPlugin::SetMaxHeightAttribute(int max_height) { 284 void BrowserPlugin::SetMaxHeightAttribute(int max_height) {
263 if (max_height_ == max_height) 285 if (max_height_ == max_height)
264 return; 286 return;
265 max_height_ = max_height; 287 max_height_ = max_height;
266 if (!auto_size_) 288 if (!auto_size_)
267 return; 289 return;
268 UpdateGuestAutoSizeState(); 290 UpdateGuestAutoSizeState();
269 } 291 }
270 292
271 void BrowserPlugin::SetMaxWidthAttribute(int max_width) { 293 void BrowserPlugin::SetMaxWidthAttribute(int max_width) {
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); 628 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level);
607 629
608 TriggerEvent(kEventLoadStart, &props); 630 TriggerEvent(kEventLoadStart, &props);
609 } 631 }
610 632
611 void BrowserPlugin::LoadCommit( 633 void BrowserPlugin::LoadCommit(
612 const BrowserPluginMsg_LoadCommit_Params& params) { 634 const BrowserPluginMsg_LoadCommit_Params& params) {
613 // If the guest has just committed a new navigation then it is no longer 635 // If the guest has just committed a new navigation then it is no longer
614 // crashed. 636 // crashed.
615 guest_crashed_ = false; 637 guest_crashed_ = false;
616 if (params.is_top_level) 638 if (params.is_top_level) {
617 src_ = params.url.spec(); 639 src_ = params.url.spec();
640 UpdateDOMAttribute(kSrc, src_.c_str());
641 }
618 process_id_ = params.process_id; 642 process_id_ = params.process_id;
619 current_nav_entry_index_ = params.current_entry_index; 643 current_nav_entry_index_ = params.current_entry_index;
620 nav_entry_count_ = params.entry_count; 644 nav_entry_count_ = params.entry_count;
621 645
622 std::map<std::string, base::Value*> props; 646 std::map<std::string, base::Value*> props;
623 props[kURL] = base::Value::CreateStringValue(params.url.spec()); 647 props[kURL] = base::Value::CreateStringValue(params.url.spec());
624 props[kIsTopLevel] = base::Value::CreateBooleanValue(params.is_top_level); 648 props[kIsTopLevel] = base::Value::CreateBooleanValue(params.is_top_level);
625 TriggerEvent(kEventLoadCommit, &props); 649 TriggerEvent(kEventLoadCommit, &props);
626 } 650 }
627 651
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 void* notify_data) { 1002 void* notify_data) {
979 } 1003 }
980 1004
981 void BrowserPlugin::didFailLoadingFrameRequest( 1005 void BrowserPlugin::didFailLoadingFrameRequest(
982 const WebKit::WebURL& url, 1006 const WebKit::WebURL& url,
983 void* notify_data, 1007 void* notify_data,
984 const WebKit::WebURLError& error) { 1008 const WebKit::WebURLError& error) {
985 } 1009 }
986 1010
987 } // namespace content 1011 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.h ('k') | content/renderer/browser_plugin/browser_plugin_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698