| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/plugins/renderer/webview_plugin.h" | 5 #include "components/plugins/renderer/webview_plugin.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
| 10 #include "content/public/common/web_preferences.h" | 10 #include "content/public/common/web_preferences.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 void WebViewPlugin::RestoreTitleText() { | 105 void WebViewPlugin::RestoreTitleText() { |
| 106 if (container_) | 106 if (container_) |
| 107 container_->element().setAttribute("title", old_title_); | 107 container_->element().setAttribute("title", old_title_); |
| 108 } | 108 } |
| 109 | 109 |
| 110 WebPluginContainer* WebViewPlugin::container() const { return container_; } | 110 WebPluginContainer* WebViewPlugin::container() const { return container_; } |
| 111 | 111 |
| 112 bool WebViewPlugin::initialize(WebPluginContainer* container) { | 112 bool WebViewPlugin::initialize(WebPluginContainer* container) { |
| 113 container_ = container; | 113 container_ = container; |
| 114 if (container_) { | 114 if (container_) { |
| 115 // We must call layout again here to ensure that the container is laid |
| 116 // out before we next try to paint it, which is a requirement of the |
| 117 // document life cycle in Blink. In most cases, needsLayout is set by |
| 118 // scheduleAnimation, but due to timers controlling widget update, |
| 119 // scheduleAnimation may be invoked before this initialize call (which |
| 120 // comes through the widget update process). It doesn't hurt to mark |
| 121 // for layout again, and it does help us in the race-condition situation. |
| 122 container_->setNeedsLayout(); |
| 123 |
| 115 old_title_ = container_->element().getAttribute("title"); | 124 old_title_ = container_->element().getAttribute("title"); |
| 116 | 125 |
| 117 // Propagate device scale to inner webview to load the correct resource | 126 // Propagate device scale to inner webview to load the correct resource |
| 118 // when images have a "srcset" attribute. | 127 // when images have a "srcset" attribute. |
| 119 web_view_->setDeviceScaleFactor(container_->deviceScaleFactor()); | 128 web_view_->setDeviceScaleFactor(container_->deviceScaleFactor()); |
| 120 } | 129 } |
| 121 return true; | 130 return true; |
| 122 } | 131 } |
| 123 | 132 |
| 124 void WebViewPlugin::destroy() { | 133 void WebViewPlugin::destroy() { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 288 |
| 280 global->Set(gin::StringToV8(isolate, "plugin"), | 289 global->Set(gin::StringToV8(isolate, "plugin"), |
| 281 delegate_->GetV8Handle(isolate)); | 290 delegate_->GetV8Handle(isolate)); |
| 282 } | 291 } |
| 283 | 292 |
| 284 void WebViewPlugin::didReceiveResponse(WebLocalFrame* frame, | 293 void WebViewPlugin::didReceiveResponse(WebLocalFrame* frame, |
| 285 unsigned identifier, | 294 unsigned identifier, |
| 286 const WebURLResponse& response) { | 295 const WebURLResponse& response) { |
| 287 WebFrameClient::didReceiveResponse(frame, identifier, response); | 296 WebFrameClient::didReceiveResponse(frame, identifier, response); |
| 288 } | 297 } |
| OLD | NEW |