OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/pepper/plugin_power_saver_helper.h" | 5 #include "content/renderer/pepper/plugin_power_saver_helper.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "content/common/frame_messages.h" | 9 #include "content/common/frame_messages.h" |
10 #include "content/public/common/content_constants.h" | 10 #include "content/public/common/content_constants.h" |
11 #include "content/public/renderer/render_frame.h" | 11 #include "content/public/renderer/render_frame.h" |
| 12 #include "ppapi/shared_impl/ppapi_constants.h" |
12 #include "third_party/WebKit/public/web/WebDocument.h" | 13 #include "third_party/WebKit/public/web/WebDocument.h" |
13 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 14 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
14 #include "third_party/WebKit/public/web/WebPluginParams.h" | 15 #include "third_party/WebKit/public/web/WebPluginParams.h" |
15 #include "third_party/WebKit/public/web/WebView.h" | 16 #include "third_party/WebKit/public/web/WebView.h" |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 // Initial decision of the peripheral content decision. | 22 // Initial decision of the peripheral content decision. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 const GURL& content_origin, | 115 const GURL& content_origin, |
115 const std::string& plugin_module_name, | 116 const std::string& plugin_module_name, |
116 int width, | 117 int width, |
117 int height, | 118 int height, |
118 bool* cross_origin_main_content) const { | 119 bool* cross_origin_main_content) const { |
119 DCHECK_EQ(content_origin.GetOrigin(), content_origin); | 120 DCHECK_EQ(content_origin.GetOrigin(), content_origin); |
120 if (cross_origin_main_content) | 121 if (cross_origin_main_content) |
121 *cross_origin_main_content = false; | 122 *cross_origin_main_content = false; |
122 | 123 |
123 // This feature has only been tested throughly with Flash thus far. | 124 // This feature has only been tested throughly with Flash thus far. |
124 if (plugin_module_name != content::kFlashPluginName) | 125 // It is also enabled for the Power Saver test plugin for browser tests. |
| 126 if (plugin_module_name != content::kFlashPluginName && |
| 127 plugin_module_name != ppapi::kPowerSaverTestPluginName) { |
125 return false; | 128 return false; |
| 129 } |
126 | 130 |
127 if (width <= 0 || height <= 0) | 131 if (width <= 0 || height <= 0) |
128 return false; | 132 return false; |
129 | 133 |
130 // TODO(alexmos): Update this to use the origin of the RemoteFrame when 426512 | 134 // TODO(alexmos): Update this to use the origin of the RemoteFrame when 426512 |
131 // is fixed. For now, case 3 in the class level comment doesn't work in | 135 // is fixed. For now, case 3 in the class level comment doesn't work in |
132 // --site-per-process mode. | 136 // --site-per-process mode. |
133 blink::WebFrame* main_frame = | 137 blink::WebFrame* main_frame = |
134 render_frame()->GetWebFrame()->view()->mainFrame(); | 138 render_frame()->GetWebFrame()->view()->mainFrame(); |
135 if (main_frame->isWebRemoteFrame()) { | 139 if (main_frame->isWebRemoteFrame()) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 void PluginPowerSaverHelper::WhitelistContentOrigin( | 177 void PluginPowerSaverHelper::WhitelistContentOrigin( |
174 const GURL& content_origin) { | 178 const GURL& content_origin) { |
175 DCHECK_EQ(content_origin.GetOrigin(), content_origin); | 179 DCHECK_EQ(content_origin.GetOrigin(), content_origin); |
176 if (origin_whitelist_.insert(content_origin).second) { | 180 if (origin_whitelist_.insert(content_origin).second) { |
177 Send(new FrameHostMsg_PluginContentOriginAllowed( | 181 Send(new FrameHostMsg_PluginContentOriginAllowed( |
178 render_frame()->GetRoutingID(), content_origin)); | 182 render_frame()->GetRoutingID(), content_origin)); |
179 } | 183 } |
180 } | 184 } |
181 | 185 |
182 } // namespace content | 186 } // namespace content |
OLD | NEW |