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" | |
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 Loading... | |
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 Loading... | |
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, const std::string& attribute_value) { | |
sadrul
2012/12/03 21:58:44
each param in own line
Fady Samuel
2012/12/04 00:06:01
Done.
| |
265 if (container()) { | |
266 container()->element().setAttribute( | |
267 WebKit::WebString::fromUTF8(attribute_name), | |
268 WebKit::WebString::fromUTF8(attribute_value)); | |
269 } | |
270 } | |
271 | |
262 void BrowserPlugin::SetMaxHeightAttribute(int max_height) { | 272 void BrowserPlugin::SetMaxHeightAttribute(int max_height) { |
263 if (max_height_ == max_height) | 273 if (max_height_ == max_height) |
264 return; | 274 return; |
265 max_height_ = max_height; | 275 max_height_ = max_height; |
266 if (!auto_size_) | 276 if (!auto_size_) |
267 return; | 277 return; |
268 UpdateGuestAutoSizeState(); | 278 UpdateGuestAutoSizeState(); |
269 } | 279 } |
270 | 280 |
271 void BrowserPlugin::SetMaxWidthAttribute(int max_width) { | 281 void BrowserPlugin::SetMaxWidthAttribute(int max_width) { |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
606 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); | 616 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); |
607 | 617 |
608 TriggerEvent(kEventLoadStart, &props); | 618 TriggerEvent(kEventLoadStart, &props); |
609 } | 619 } |
610 | 620 |
611 void BrowserPlugin::LoadCommit( | 621 void BrowserPlugin::LoadCommit( |
612 const BrowserPluginMsg_LoadCommit_Params& params) { | 622 const BrowserPluginMsg_LoadCommit_Params& params) { |
613 // If the guest has just committed a new navigation then it is no longer | 623 // If the guest has just committed a new navigation then it is no longer |
614 // crashed. | 624 // crashed. |
615 guest_crashed_ = false; | 625 guest_crashed_ = false; |
616 src_ = params.url.spec(); | 626 if (params.is_top_level) { |
627 src_ = params.url.spec(); | |
628 UpdateDOMAttribute(kSrc, src_.c_str()); | |
629 } | |
617 process_id_ = params.process_id; | 630 process_id_ = params.process_id; |
618 current_nav_entry_index_ = params.current_entry_index; | 631 current_nav_entry_index_ = params.current_entry_index; |
619 nav_entry_count_ = params.entry_count; | 632 nav_entry_count_ = params.entry_count; |
620 | 633 |
621 std::map<std::string, base::Value*> props; | 634 std::map<std::string, base::Value*> props; |
622 props[kURL] = base::Value::CreateStringValue(src_); | 635 props[kURL] = base::Value::CreateStringValue(src_); |
623 props[kIsTopLevel] = base::Value::CreateBooleanValue(params.is_top_level); | 636 props[kIsTopLevel] = base::Value::CreateBooleanValue(params.is_top_level); |
624 TriggerEvent(kEventLoadCommit, &props); | 637 TriggerEvent(kEventLoadCommit, &props); |
625 } | 638 } |
626 | 639 |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
977 void* notify_data) { | 990 void* notify_data) { |
978 } | 991 } |
979 | 992 |
980 void BrowserPlugin::didFailLoadingFrameRequest( | 993 void BrowserPlugin::didFailLoadingFrameRequest( |
981 const WebKit::WebURL& url, | 994 const WebKit::WebURL& url, |
982 void* notify_data, | 995 void* notify_data, |
983 const WebKit::WebURLError& error) { | 996 const WebKit::WebURLError& error) { |
984 } | 997 } |
985 | 998 |
986 } // namespace content | 999 } // namespace content |
OLD | NEW |