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 "chrome/renderer/chrome_content_renderer_client.h" | 5 #include "chrome/renderer/chrome_content_renderer_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/crash_logging.h" | 8 #include "base/debug/crash_logging.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 void IsGuestViewApiAvailableToScriptContext( | 262 void IsGuestViewApiAvailableToScriptContext( |
263 bool* api_is_available, | 263 bool* api_is_available, |
264 extensions::ScriptContext* context) { | 264 extensions::ScriptContext* context) { |
265 if (context->GetAvailability("guestViewInternal").is_available()) { | 265 if (context->GetAvailability("guestViewInternal").is_available()) { |
266 *api_is_available = true; | 266 *api_is_available = true; |
267 } | 267 } |
268 } | 268 } |
269 #endif | 269 #endif |
270 | 270 |
271 #if defined(ENABLE_PLUGINS) | 271 #if defined(ENABLE_PLUGINS) |
| 272 // Presence of the poster param within plugin object tags. |
| 273 // These numeric values are used in UMA logs; do not change them. |
| 274 enum PosterParamPresence { |
| 275 POSTER_PRESENCE_NO_PARAM_PPS_DISABLED = 0, |
| 276 POSTER_PRESENCE_NO_PARAM_PPS_ENABLED = 1, |
| 277 POSTER_PRESENCE_PARAM_EXISTS_PPS_DISABLED = 2, |
| 278 POSTER_PRESENCE_PARAM_EXISTS_PPS_ENABLED = 3, |
| 279 POSTER_PRESENCE_NUM_ITEMS |
| 280 }; |
| 281 |
| 282 const char kPluginPowerSaverPosterParamPresenceHistogram[] = |
| 283 "Plugin.PowerSaver.PosterParamPresence"; |
| 284 |
| 285 void RecordPosterParamPresence(PosterParamPresence presence) { |
| 286 UMA_HISTOGRAM_ENUMERATION(kPluginPowerSaverPosterParamPresenceHistogram, |
| 287 presence, POSTER_PRESENCE_NUM_ITEMS); |
| 288 } |
| 289 |
| 290 void TrackPosterParamPresence(const blink::WebPluginParams& params, |
| 291 bool power_saver_enabled) { |
| 292 DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size()); |
| 293 |
| 294 for (size_t i = 0; i < params.attributeNames.size(); ++i) { |
| 295 if (params.attributeNames[i].utf8() == "poster") { |
| 296 if (power_saver_enabled) |
| 297 RecordPosterParamPresence(POSTER_PRESENCE_PARAM_EXISTS_PPS_ENABLED); |
| 298 else |
| 299 RecordPosterParamPresence(POSTER_PRESENCE_PARAM_EXISTS_PPS_DISABLED); |
| 300 |
| 301 return; |
| 302 } |
| 303 } |
| 304 |
| 305 if (power_saver_enabled) |
| 306 RecordPosterParamPresence(POSTER_PRESENCE_NO_PARAM_PPS_ENABLED); |
| 307 else |
| 308 RecordPosterParamPresence(POSTER_PRESENCE_NO_PARAM_PPS_DISABLED); |
| 309 } |
| 310 |
272 GURL GetPluginInstancePosterImage(const blink::WebPluginParams& params, | 311 GURL GetPluginInstancePosterImage(const blink::WebPluginParams& params, |
273 const GURL& page_base_url) { | 312 const GURL& page_base_url) { |
274 DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size()); | 313 DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size()); |
275 | 314 |
276 for (size_t i = 0; i < params.attributeNames.size(); ++i) { | 315 for (size_t i = 0; i < params.attributeNames.size(); ++i) { |
277 if (params.attributeNames[i].utf8() == "poster" && | 316 if (params.attributeNames[i].utf8() == "poster" && |
278 !params.attributeValues[i].isEmpty()) { | 317 !params.attributeValues[i].isEmpty()) { |
279 return page_base_url.Resolve(params.attributeValues[i].utf8()); | 318 return page_base_url.Resolve(params.attributeValues[i].utf8()); |
280 } | 319 } |
281 } | 320 } |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 } | 839 } |
801 #endif // !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) | 840 #endif // !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) |
802 | 841 |
803 #if defined(ENABLE_PLUGINS) | 842 #if defined(ENABLE_PLUGINS) |
804 bool power_saver_enabled = | 843 bool power_saver_enabled = |
805 status_value == | 844 status_value == |
806 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; | 845 ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent; |
807 bool blocked_for_background_tab = | 846 bool blocked_for_background_tab = |
808 render_frame->IsHidden() && power_saver_enabled; | 847 render_frame->IsHidden() && power_saver_enabled; |
809 | 848 |
| 849 if (info.name == ASCIIToUTF16(content::kFlashPluginName)) |
| 850 TrackPosterParamPresence(params, power_saver_enabled); |
| 851 |
810 GURL poster_url; | 852 GURL poster_url; |
811 if (power_saver_enabled) { | 853 if (power_saver_enabled) { |
812 poster_url = | 854 poster_url = |
813 GetPluginInstancePosterImage(params, frame->document().url()); | 855 GetPluginInstancePosterImage(params, frame->document().url()); |
814 } | 856 } |
815 | 857 |
816 // Delay loading plugins if prerendering. | 858 // Delay loading plugins if prerendering. |
817 // TODO(mmenke): In the case of prerendering, feed into | 859 // TODO(mmenke): In the case of prerendering, feed into |
818 // ChromeContentRendererClient::CreatePlugin instead, to | 860 // ChromeContentRendererClient::CreatePlugin instead, to |
819 // reduce the chance of future regressions. | 861 // reduce the chance of future regressions. |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1578 if (mime_type == content::kBrowserPluginMimeType) { | 1620 if (mime_type == content::kBrowserPluginMimeType) { |
1579 return new extensions::ExtensionsGuestViewContainer(render_frame); | 1621 return new extensions::ExtensionsGuestViewContainer(render_frame); |
1580 } else { | 1622 } else { |
1581 return new extensions::MimeHandlerViewContainer( | 1623 return new extensions::MimeHandlerViewContainer( |
1582 render_frame, mime_type, original_url); | 1624 render_frame, mime_type, original_url); |
1583 } | 1625 } |
1584 #else | 1626 #else |
1585 return NULL; | 1627 return NULL; |
1586 #endif | 1628 #endif |
1587 } | 1629 } |
OLD | NEW |