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_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 switch (status) { | 84 switch (status) { |
85 case base::TERMINATION_STATUS_NORMAL_TERMINATION: | 85 case base::TERMINATION_STATUS_NORMAL_TERMINATION: |
86 return "normal"; | 86 return "normal"; |
87 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: | 87 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: |
88 return "abnormal"; | 88 return "abnormal"; |
89 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: | 89 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: |
90 return "killed"; | 90 return "killed"; |
91 case base::TERMINATION_STATUS_PROCESS_CRASHED: | 91 case base::TERMINATION_STATUS_PROCESS_CRASHED: |
92 return "crashed"; | 92 return "crashed"; |
93 default: | 93 default: |
94 // This should never happen. | 94 NOTREACHED() << "Unknown Termination Status."; |
95 DCHECK(false); | |
96 return "unknown"; | 95 return "unknown"; |
97 } | 96 } |
98 } | 97 } |
98 | |
99 static std::string GetInternalEventName(const char* event_name) { | |
100 return base::StringPrintf("-internal-%s", event_name); | |
101 } | |
99 } | 102 } |
100 | 103 |
101 BrowserPlugin::BrowserPlugin( | 104 BrowserPlugin::BrowserPlugin( |
102 int instance_id, | 105 int instance_id, |
103 RenderViewImpl* render_view, | 106 RenderViewImpl* render_view, |
104 WebKit::WebFrame* frame, | 107 WebKit::WebFrame* frame, |
105 const WebPluginParams& params) | 108 const WebPluginParams& params) |
106 : instance_id_(instance_id), | 109 : instance_id_(instance_id), |
107 render_view_(render_view->AsWeakPtr()), | 110 render_view_(render_view->AsWeakPtr()), |
108 render_view_routing_id_(render_view->GetRoutingID()), | 111 render_view_routing_id_(render_view->GetRoutingID()), |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
642 std::string src; | 645 std::string src; |
643 | 646 |
644 // Get the src attribute from the attributes vector | 647 // Get the src attribute from the attributes vector |
645 for (unsigned i = 0; i < params.attributeNames.size(); ++i) { | 648 for (unsigned i = 0; i < params.attributeNames.size(); ++i) { |
646 std::string attributeName = params.attributeNames[i].utf8(); | 649 std::string attributeName = params.attributeNames[i].utf8(); |
647 if (LowerCaseEqualsASCII(attributeName, kSrc)) { | 650 if (LowerCaseEqualsASCII(attributeName, kSrc)) { |
648 src = params.attributeValues[i].utf8(); | 651 src = params.attributeValues[i].utf8(); |
649 } else if (LowerCaseEqualsASCII(attributeName, kPartition)) { | 652 } else if (LowerCaseEqualsASCII(attributeName, kPartition)) { |
650 std::string error; | 653 std::string error; |
651 SetPartitionAttribute(params.attributeValues[i].utf8(), &error); | 654 SetPartitionAttribute(params.attributeValues[i].utf8(), &error); |
655 } else if (LowerCaseEqualsASCII(attributeName, kName)) { | |
656 SetNameAttribute(params.attributeValues[i].utf8()); | |
sadrul
2013/01/09 18:04:29
Can this be tested?
Fady Samuel
2013/01/09 18:19:37
Done.
| |
652 } | 657 } |
653 } | 658 } |
654 | 659 |
655 // Set the 'src' attribute last, as it will set the has_navigated_ flag to | 660 // Set the 'src' attribute last, as it will set the has_navigated_ flag to |
656 // true, which prevents changing the 'partition' attribute. | 661 // true, which prevents changing the 'partition' attribute. |
657 std::string error; | 662 std::string error; |
658 SetSrcAttribute(src, &error); | 663 SetSrcAttribute(src, &error); |
659 } | 664 } |
660 | 665 |
661 float BrowserPlugin::GetDeviceScaleFactor() const { | 666 float BrowserPlugin::GetDeviceScaleFactor() const { |
(...skipping 21 matching lines...) Expand all Loading... | |
683 } | 688 } |
684 | 689 |
685 WebKit::WebFrame* frame = container()->element().document().frame(); | 690 WebKit::WebFrame* frame = container()->element().document().frame(); |
686 WebKit::WebDOMEvent dom_event = frame->document().createEvent("CustomEvent"); | 691 WebKit::WebDOMEvent dom_event = frame->document().createEvent("CustomEvent"); |
687 WebKit::WebDOMCustomEvent event = dom_event.to<WebKit::WebDOMCustomEvent>(); | 692 WebKit::WebDOMCustomEvent event = dom_event.to<WebKit::WebDOMCustomEvent>(); |
688 | 693 |
689 // The events triggered directly from the plugin <object> are internal events | 694 // The events triggered directly from the plugin <object> are internal events |
690 // whose implementation details can (and likely will) change over time. The | 695 // whose implementation details can (and likely will) change over time. The |
691 // wrapper/shim (e.g. <webview> tag) should receive these events, and expose a | 696 // wrapper/shim (e.g. <webview> tag) should receive these events, and expose a |
692 // more appropriate (and stable) event to the consumers as part of the API. | 697 // more appropriate (and stable) event to the consumers as part of the API. |
693 std::string internal_name = base::StringPrintf("-internal-%s", | |
694 event_name.c_str()); | |
695 event.initCustomEvent( | 698 event.initCustomEvent( |
696 WebKit::WebString::fromUTF8(internal_name.c_str()), | 699 WebKit::WebString::fromUTF8(GetInternalEventName(event_name.c_str())), |
697 false, false, | 700 false, false, |
698 WebKit::WebSerializedScriptValue::serialize( | 701 WebKit::WebSerializedScriptValue::serialize( |
699 v8::String::New(json_string.c_str(), json_string.size()))); | 702 v8::String::New(json_string.c_str(), json_string.size()))); |
700 container()->element().dispatchEvent(event); | 703 container()->element().dispatchEvent(event); |
701 } | 704 } |
702 | 705 |
703 void BrowserPlugin::Back() { | 706 void BrowserPlugin::Back() { |
704 if (!navigate_src_sent_) | 707 if (!navigate_src_sent_) |
705 return; | 708 return; |
706 browser_plugin_manager()->Send( | 709 browser_plugin_manager()->Send( |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
877 const WebVector<WebRect>& cut_outs_rects, | 880 const WebVector<WebRect>& cut_outs_rects, |
878 bool is_visible) { | 881 bool is_visible) { |
879 int old_width = width(); | 882 int old_width = width(); |
880 int old_height = height(); | 883 int old_height = height(); |
881 plugin_rect_ = window_rect; | 884 plugin_rect_ = window_rect; |
882 // In AutoSize mode, guests don't care when the BrowserPlugin container is | 885 // In AutoSize mode, guests don't care when the BrowserPlugin container is |
883 // resized. If |!resize_ack_received_|, then we are still waiting on a | 886 // resized. If |!resize_ack_received_|, then we are still waiting on a |
884 // previous resize to be ACK'ed and so we don't issue additional resizes | 887 // previous resize to be ACK'ed and so we don't issue additional resizes |
885 // until the previous one is ACK'ed. | 888 // until the previous one is ACK'ed. |
886 if (!navigate_src_sent_ || auto_size_ || !resize_ack_received_ || | 889 if (!navigate_src_sent_ || auto_size_ || !resize_ack_received_ || |
887 (old_width == window_rect.width && | 890 (old_width == window_rect.width && old_height == window_rect.height)) { |
888 old_height == window_rect.height)) { | |
889 return; | 891 return; |
890 } | 892 } |
891 | 893 |
892 BrowserPluginHostMsg_ResizeGuest_Params params; | 894 BrowserPluginHostMsg_ResizeGuest_Params params; |
893 PopulateResizeGuestParameters(¶ms, gfx::Size(width(), height())); | 895 PopulateResizeGuestParameters(¶ms, gfx::Size(width(), height())); |
894 resize_ack_received_ = false; | 896 resize_ack_received_ = false; |
895 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( | 897 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( |
896 render_view_routing_id_, | 898 render_view_routing_id_, |
897 instance_id_, | 899 instance_id_, |
898 params)); | 900 params)); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1062 void* notify_data) { | 1064 void* notify_data) { |
1063 } | 1065 } |
1064 | 1066 |
1065 void BrowserPlugin::didFailLoadingFrameRequest( | 1067 void BrowserPlugin::didFailLoadingFrameRequest( |
1066 const WebKit::WebURL& url, | 1068 const WebKit::WebURL& url, |
1067 void* notify_data, | 1069 void* notify_data, |
1068 const WebKit::WebURLError& error) { | 1070 const WebKit::WebURLError& error) { |
1069 } | 1071 } |
1070 | 1072 |
1071 } // namespace content | 1073 } // namespace content |
OLD | NEW |