Chromium Code Reviews| 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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 *cross_origin_main_content = false; | 94 *cross_origin_main_content = false; |
| 95 | 95 |
| 96 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 96 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 97 switches::kOverridePluginPowerSaverForTesting) == "always") { | 97 switches::kOverridePluginPowerSaverForTesting) == "always") { |
| 98 return true; | 98 return true; |
| 99 } | 99 } |
| 100 | 100 |
| 101 auto decision = PeripheralContentHeuristic::GetPeripheralStatus( | 101 auto decision = PeripheralContentHeuristic::GetPeripheralStatus( |
| 102 origin_whitelist_, main_frame_origin, content_origin, width, height); | 102 origin_whitelist_, main_frame_origin, content_origin, width, height); |
| 103 | 103 |
| 104 bool plugin_size_unknown = width < 0 || height < 0; | |
| 105 if (plugin_size_unknown) { | |
|
groby-ooo-7-16
2015/12/04 22:06:56
Can you leave a comment why we record these here?
tommycli
2015/12/07 22:06:18
Done. It's very non-obvious.
| |
| 106 if (decision == PeripheralContentHeuristic:: | |
| 107 HEURISTIC_DECISION_ESSENTIAL_SAME_ORIGIN || | |
| 108 decision == PeripheralContentHeuristic:: | |
| 109 HEURISTIC_DECISION_ESSENTIAL_CROSS_ORIGIN_WHITELISTED) { | |
| 110 UMA_HISTOGRAM_ENUMERATION( | |
| 111 kPeripheralHeuristicHistogram, decision, | |
| 112 PeripheralContentHeuristic::HEURISTIC_DECISION_NUM_ITEMS); | |
| 113 return false; | |
| 114 } | |
| 115 | |
| 116 return true; | |
| 117 } | |
| 118 | |
| 104 UMA_HISTOGRAM_ENUMERATION( | 119 UMA_HISTOGRAM_ENUMERATION( |
| 105 kPeripheralHeuristicHistogram, decision, | 120 kPeripheralHeuristicHistogram, decision, |
| 106 PeripheralContentHeuristic::HEURISTIC_DECISION_NUM_ITEMS); | 121 PeripheralContentHeuristic::HEURISTIC_DECISION_NUM_ITEMS); |
| 107 | 122 |
| 108 if (decision == PeripheralContentHeuristic:: | 123 if (decision == PeripheralContentHeuristic:: |
| 109 HEURISTIC_DECISION_ESSENTIAL_CROSS_ORIGIN_BIG && | 124 HEURISTIC_DECISION_ESSENTIAL_CROSS_ORIGIN_BIG && |
| 110 cross_origin_main_content) | 125 cross_origin_main_content) |
| 111 *cross_origin_main_content = true; | 126 *cross_origin_main_content = true; |
| 112 | 127 |
| 113 return decision == PeripheralContentHeuristic::HEURISTIC_DECISION_PERIPHERAL; | 128 return decision == PeripheralContentHeuristic::HEURISTIC_DECISION_PERIPHERAL; |
| 114 } | 129 } |
| 115 | 130 |
| 116 void PluginPowerSaverHelper::WhitelistContentOrigin( | 131 void PluginPowerSaverHelper::WhitelistContentOrigin( |
| 117 const url::Origin& content_origin) { | 132 const url::Origin& content_origin) { |
| 118 if (origin_whitelist_.insert(content_origin).second) { | 133 if (origin_whitelist_.insert(content_origin).second) { |
| 119 Send(new FrameHostMsg_PluginContentOriginAllowed( | 134 Send(new FrameHostMsg_PluginContentOriginAllowed( |
| 120 render_frame()->GetRoutingID(), content_origin)); | 135 render_frame()->GetRoutingID(), content_origin)); |
| 121 } | 136 } |
| 122 } | 137 } |
| 123 | 138 |
| 124 } // namespace content | 139 } // namespace content |
| OLD | NEW |