| 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/plugin_placeholder.h" | 5 #include "components/plugins/renderer/plugin_placeholder.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "content/public/renderer/render_frame.h" | 8 #include "content/public/renderer/render_frame.h" |
| 9 #include "content/public/renderer/render_thread.h" | 9 #include "content/public/renderer/render_thread.h" |
| 10 #include "content/public/common/web_preferences.h" |
| 10 #include "gin/object_template_builder.h" | 11 #include "gin/object_template_builder.h" |
| 11 #include "third_party/WebKit/public/web/WebElement.h" | 12 #include "third_party/WebKit/public/web/WebElement.h" |
| 12 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 13 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 13 #include "third_party/re2/re2/re2.h" | 14 #include "third_party/re2/re2/re2.h" |
| 14 | 15 |
| 15 namespace plugins { | 16 namespace plugins { |
| 16 | 17 |
| 17 // The placeholder is loaded in normal web renderer processes, so it should not | 18 // The placeholder is loaded in normal web renderer processes, so it should not |
| 18 // have a chrome:// scheme that might let it be confused with a WebUI page. | 19 // have a chrome:// scheme that might let it be confused with a WebUI page. |
| 19 const char kPluginPlaceholderDataURL[] = "data:text/html,pluginplaceholderdata"; | 20 const char kPluginPlaceholderDataURL[] = "data:text/html,pluginplaceholderdata"; |
| 20 | 21 |
| 21 gin::WrapperInfo PluginPlaceholder::kWrapperInfo = {gin::kEmbedderNativeGin}; | 22 gin::WrapperInfo PluginPlaceholder::kWrapperInfo = {gin::kEmbedderNativeGin}; |
| 22 | 23 |
| 23 PluginPlaceholder::PluginPlaceholder(content::RenderFrame* render_frame, | 24 PluginPlaceholder::PluginPlaceholder(content::RenderFrame* render_frame, |
| 24 blink::WebLocalFrame* frame, | 25 blink::WebLocalFrame* frame, |
| 25 const blink::WebPluginParams& params, | 26 const blink::WebPluginParams& params, |
| 26 const std::string& html_data) | 27 const std::string& html_data) |
| 27 : content::RenderFrameObserver(render_frame), | 28 : content::RenderFrameObserver(render_frame), |
| 28 frame_(frame), | 29 frame_(frame), |
| 29 plugin_params_(params), | 30 plugin_params_(params), |
| 30 plugin_(WebViewPlugin::Create(this, | 31 plugin_(WebViewPlugin::Create(this, |
| 31 render_frame->GetWebkitPreferences(), | 32 render_frame ? render_frame->GetWebkitPrefer
ences() |
| 33 : content::WebPreferences(), |
| 32 html_data, | 34 html_data, |
| 33 GURL(kPluginPlaceholderDataURL))), | 35 GURL(kPluginPlaceholderDataURL))), |
| 34 hidden_(false) { | 36 hidden_(false) { |
| 35 } | 37 } |
| 36 | 38 |
| 37 PluginPlaceholder::~PluginPlaceholder() {} | 39 PluginPlaceholder::~PluginPlaceholder() {} |
| 38 | 40 |
| 39 const blink::WebPluginParams& PluginPlaceholder::GetPluginParams() const { | 41 const blink::WebPluginParams& PluginPlaceholder::GetPluginParams() const { |
| 40 return plugin_params_; | 42 return plugin_params_; |
| 41 } | 43 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 129 |
| 128 void PluginPlaceholder::HideCallback() { | 130 void PluginPlaceholder::HideCallback() { |
| 129 content::RenderThread::Get()->RecordAction( | 131 content::RenderThread::Get()->RecordAction( |
| 130 base::UserMetricsAction("Plugin_Hide_Click")); | 132 base::UserMetricsAction("Plugin_Hide_Click")); |
| 131 HidePlugin(); | 133 HidePlugin(); |
| 132 } | 134 } |
| 133 | 135 |
| 134 blink::WebLocalFrame* PluginPlaceholder::GetFrame() { return frame_; } | 136 blink::WebLocalFrame* PluginPlaceholder::GetFrame() { return frame_; } |
| 135 | 137 |
| 136 } // namespace plugins | 138 } // namespace plugins |
| OLD | NEW |