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