| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/renderer/plugins/power_saver_info.h" | 10 #include "chrome/renderer/plugins/power_saver_info.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 info.power_saver_enabled = | 95 info.power_saver_enabled = |
| 96 override_for_testing == "always" || | 96 override_for_testing == "always" || |
| 97 (power_saver_setting_on && can_throttle_plugin_type); | 97 (power_saver_setting_on && can_throttle_plugin_type); |
| 98 | 98 |
| 99 if (info.power_saver_enabled) { | 99 if (info.power_saver_enabled) { |
| 100 // Even if we disable PPS in the next block because content is same-origin, | 100 // Even if we disable PPS in the next block because content is same-origin, |
| 101 // it should still be eligible for background tab deferral if PPS is on. | 101 // it should still be eligible for background tab deferral if PPS is on. |
| 102 info.blocked_for_background_tab = render_frame->IsHidden(); | 102 info.blocked_for_background_tab = render_frame->IsHidden(); |
| 103 | 103 |
| 104 auto status = render_frame->GetPeripheralContentStatus( | 104 auto status = render_frame->GetPeripheralContentStatus( |
| 105 render_frame->GetWebFrame()->top()->securityOrigin(), | 105 render_frame->GetWebFrame()->top()->getSecurityOrigin(), |
| 106 url::Origin(params.url), gfx::Size()); | 106 url::Origin(params.url), gfx::Size()); |
| 107 | 107 |
| 108 // Early-exit from the whole Power Saver system if the content is | 108 // Early-exit from the whole Power Saver system if the content is |
| 109 // same-origin or whitelisted-origin. We ignore the other possibilities, | 109 // same-origin or whitelisted-origin. We ignore the other possibilities, |
| 110 // because we don't know the unobscured size of the plugin content yet. | 110 // because we don't know the unobscured size of the plugin content yet. |
| 111 // | 111 // |
| 112 // Once the plugin is loaded, the peripheral content status is re-tested | 112 // Once the plugin is loaded, the peripheral content status is re-tested |
| 113 // with the actual unobscured plugin size. | 113 // with the actual unobscured plugin size. |
| 114 if (status == content::RenderFrame::CONTENT_STATUS_ESSENTIAL_SAME_ORIGIN || | 114 if (status == content::RenderFrame::CONTENT_STATUS_ESSENTIAL_SAME_ORIGIN || |
| 115 status == content::RenderFrame:: | 115 status == content::RenderFrame:: |
| 116 CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_WHITELISTED) { | 116 CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_WHITELISTED) { |
| 117 info.power_saver_enabled = false; | 117 info.power_saver_enabled = false; |
| 118 } else { | 118 } else { |
| 119 info.poster_attribute = GetPluginInstancePosterAttribute(params); | 119 info.poster_attribute = GetPluginInstancePosterAttribute(params); |
| 120 info.base_url = document_url; | 120 info.base_url = document_url; |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 if (is_flash) | 124 if (is_flash) |
| 125 TrackPosterParamPresence(params, info.power_saver_enabled); | 125 TrackPosterParamPresence(params, info.power_saver_enabled); |
| 126 | 126 |
| 127 return info; | 127 return info; |
| 128 } | 128 } |
| OLD | NEW |