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

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

Issue 11821028: Browser Plugin: Make sure name attribute is propagated to guest if it's set prior to initializing p… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed breakage on certain compilers Created 7 years, 11 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/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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 static std::string TerminationStatusToString(base::TerminationStatus status) { 83 static std::string TerminationStatusToString(base::TerminationStatus status) {
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 case base::TERMINATION_STATUS_STILL_RUNNING:
94 // This should never happen. 94 case base::TERMINATION_STATUS_MAX_ENUM:
95 DCHECK(false); 95 break;
96 return "unknown";
97 } 96 }
97 NOTREACHED() << "Unknown Termination Status.";
98 return "unknown";
99 }
100
101 static std::string GetInternalEventName(const char* event_name) {
102 return base::StringPrintf("-internal-%s", event_name);
98 } 103 }
99 } 104 }
100 105
101 BrowserPlugin::BrowserPlugin( 106 BrowserPlugin::BrowserPlugin(
102 int instance_id, 107 int instance_id,
103 RenderViewImpl* render_view, 108 RenderViewImpl* render_view,
104 WebKit::WebFrame* frame, 109 WebKit::WebFrame* frame,
105 const WebPluginParams& params) 110 const WebPluginParams& params)
106 : instance_id_(instance_id), 111 : instance_id_(instance_id),
107 render_view_(render_view->AsWeakPtr()), 112 render_view_(render_view->AsWeakPtr()),
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 std::string src; 647 std::string src;
643 648
644 // Get the src attribute from the attributes vector 649 // Get the src attribute from the attributes vector
645 for (unsigned i = 0; i < params.attributeNames.size(); ++i) { 650 for (unsigned i = 0; i < params.attributeNames.size(); ++i) {
646 std::string attributeName = params.attributeNames[i].utf8(); 651 std::string attributeName = params.attributeNames[i].utf8();
647 if (LowerCaseEqualsASCII(attributeName, kSrc)) { 652 if (LowerCaseEqualsASCII(attributeName, kSrc)) {
648 src = params.attributeValues[i].utf8(); 653 src = params.attributeValues[i].utf8();
649 } else if (LowerCaseEqualsASCII(attributeName, kPartition)) { 654 } else if (LowerCaseEqualsASCII(attributeName, kPartition)) {
650 std::string error; 655 std::string error;
651 SetPartitionAttribute(params.attributeValues[i].utf8(), &error); 656 SetPartitionAttribute(params.attributeValues[i].utf8(), &error);
657 } else if (LowerCaseEqualsASCII(attributeName, kName)) {
658 SetNameAttribute(params.attributeValues[i].utf8());
652 } 659 }
653 } 660 }
654 661
655 // Set the 'src' attribute last, as it will set the has_navigated_ flag to 662 // Set the 'src' attribute last, as it will set the has_navigated_ flag to
656 // true, which prevents changing the 'partition' attribute. 663 // true, which prevents changing the 'partition' attribute.
657 std::string error; 664 std::string error;
658 SetSrcAttribute(src, &error); 665 SetSrcAttribute(src, &error);
659 } 666 }
660 667
661 float BrowserPlugin::GetDeviceScaleFactor() const { 668 float BrowserPlugin::GetDeviceScaleFactor() const {
(...skipping 21 matching lines...) Expand all
683 } 690 }
684 691
685 WebKit::WebFrame* frame = container()->element().document().frame(); 692 WebKit::WebFrame* frame = container()->element().document().frame();
686 WebKit::WebDOMEvent dom_event = frame->document().createEvent("CustomEvent"); 693 WebKit::WebDOMEvent dom_event = frame->document().createEvent("CustomEvent");
687 WebKit::WebDOMCustomEvent event = dom_event.to<WebKit::WebDOMCustomEvent>(); 694 WebKit::WebDOMCustomEvent event = dom_event.to<WebKit::WebDOMCustomEvent>();
688 695
689 // The events triggered directly from the plugin <object> are internal events 696 // The events triggered directly from the plugin <object> are internal events
690 // whose implementation details can (and likely will) change over time. The 697 // 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 698 // 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. 699 // 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( 700 event.initCustomEvent(
696 WebKit::WebString::fromUTF8(internal_name.c_str()), 701 WebKit::WebString::fromUTF8(GetInternalEventName(event_name.c_str())),
697 false, false, 702 false, false,
698 WebKit::WebSerializedScriptValue::serialize( 703 WebKit::WebSerializedScriptValue::serialize(
699 v8::String::New(json_string.c_str(), json_string.size()))); 704 v8::String::New(json_string.c_str(), json_string.size())));
700 container()->element().dispatchEvent(event); 705 container()->element().dispatchEvent(event);
701 } 706 }
702 707
703 void BrowserPlugin::Back() { 708 void BrowserPlugin::Back() {
704 if (!navigate_src_sent_) 709 if (!navigate_src_sent_)
705 return; 710 return;
706 browser_plugin_manager()->Send( 711 browser_plugin_manager()->Send(
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 const WebVector<WebRect>& cut_outs_rects, 882 const WebVector<WebRect>& cut_outs_rects,
878 bool is_visible) { 883 bool is_visible) {
879 int old_width = width(); 884 int old_width = width();
880 int old_height = height(); 885 int old_height = height();
881 plugin_rect_ = window_rect; 886 plugin_rect_ = window_rect;
882 // In AutoSize mode, guests don't care when the BrowserPlugin container is 887 // 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 888 // 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 889 // previous resize to be ACK'ed and so we don't issue additional resizes
885 // until the previous one is ACK'ed. 890 // until the previous one is ACK'ed.
886 if (!navigate_src_sent_ || auto_size_ || !resize_ack_received_ || 891 if (!navigate_src_sent_ || auto_size_ || !resize_ack_received_ ||
887 (old_width == window_rect.width && 892 (old_width == window_rect.width && old_height == window_rect.height)) {
888 old_height == window_rect.height)) {
889 return; 893 return;
890 } 894 }
891 895
892 BrowserPluginHostMsg_ResizeGuest_Params params; 896 BrowserPluginHostMsg_ResizeGuest_Params params;
893 PopulateResizeGuestParameters(&params, gfx::Size(width(), height())); 897 PopulateResizeGuestParameters(&params, gfx::Size(width(), height()));
894 resize_ack_received_ = false; 898 resize_ack_received_ = false;
895 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( 899 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest(
896 render_view_routing_id_, 900 render_view_routing_id_,
897 instance_id_, 901 instance_id_,
898 params)); 902 params));
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 void* notify_data) { 1066 void* notify_data) {
1063 } 1067 }
1064 1068
1065 void BrowserPlugin::didFailLoadingFrameRequest( 1069 void BrowserPlugin::didFailLoadingFrameRequest(
1066 const WebKit::WebURL& url, 1070 const WebKit::WebURL& url,
1067 void* notify_data, 1071 void* notify_data,
1068 const WebKit::WebURLError& error) { 1072 const WebKit::WebURLError& error) {
1069 } 1073 }
1070 1074
1071 } // namespace content 1075 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698