| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 const gfx::Size& unobscured_size, | 105 const gfx::Size& unobscured_size, |
| 106 RenderFrame::RecordPeripheralDecision record_decision) const { | 106 RenderFrame::RecordPeripheralDecision record_decision) const { |
| 107 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 107 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 108 switches::kOverridePluginPowerSaverForTesting) == "always") { | 108 switches::kOverridePluginPowerSaverForTesting) == "always") { |
| 109 return RenderFrame::CONTENT_STATUS_PERIPHERAL; | 109 return RenderFrame::CONTENT_STATUS_PERIPHERAL; |
| 110 } | 110 } |
| 111 | 111 |
| 112 auto status = PeripheralContentHeuristic::GetPeripheralStatus( | 112 auto status = PeripheralContentHeuristic::GetPeripheralStatus( |
| 113 origin_whitelist_, main_frame_origin, content_origin, unobscured_size); | 113 origin_whitelist_, main_frame_origin, content_origin, unobscured_size); |
| 114 | 114 |
| 115 // Never record UNKNOWN_SIZE. Wait for retest after size is known. | 115 if (record_decision == RenderFrame::RECORD_DECISION) { |
| 116 if (record_decision == RenderFrame::RECORD_DECISION && | |
| 117 status != RenderFrame::CONTENT_STATUS_UNKNOWN_SIZE) { | |
| 118 UMA_HISTOGRAM_ENUMERATION(kPeripheralHeuristicHistogram, status, | 116 UMA_HISTOGRAM_ENUMERATION(kPeripheralHeuristicHistogram, status, |
| 119 RenderFrame::CONTENT_STATUS_NUM_ITEMS); | 117 RenderFrame::CONTENT_STATUS_NUM_ITEMS); |
| 120 } | 118 } |
| 121 | 119 |
| 122 return status; | 120 return status; |
| 123 } | 121 } |
| 124 | 122 |
| 125 void PluginPowerSaverHelper::WhitelistContentOrigin( | 123 void PluginPowerSaverHelper::WhitelistContentOrigin( |
| 126 const url::Origin& content_origin) { | 124 const url::Origin& content_origin) { |
| 127 if (origin_whitelist_.insert(content_origin).second) { | 125 if (origin_whitelist_.insert(content_origin).second) { |
| 128 Send(new FrameHostMsg_PluginContentOriginAllowed( | 126 Send(new FrameHostMsg_PluginContentOriginAllowed( |
| 129 render_frame()->GetRoutingID(), content_origin)); | 127 render_frame()->GetRoutingID(), content_origin)); |
| 130 } | 128 } |
| 131 } | 129 } |
| 132 | 130 |
| 133 } // namespace content | 131 } // namespace content |
| OLD | NEW |