| 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/pepper_plugin_instance_throttler.h" | 5 #include "content/renderer/pepper/pepper_plugin_instance_throttler.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "content/public/common/content_constants.h" | 10 #include "content/public/common/content_constants.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 ++consecutive_interesting_frames_; | 156 ++consecutive_interesting_frames_; |
| 157 else | 157 else |
| 158 consecutive_interesting_frames_ = 0; | 158 consecutive_interesting_frames_ = 0; |
| 159 | 159 |
| 160 if (consecutive_interesting_frames_ >= kMinimumConsecutiveInterestingFrames) | 160 if (consecutive_interesting_frames_ >= kMinimumConsecutiveInterestingFrames) |
| 161 SetPluginThrottled(true); | 161 SetPluginThrottled(true); |
| 162 } | 162 } |
| 163 | 163 |
| 164 bool PepperPluginInstanceThrottler::ConsumeInputEvent( | 164 bool PepperPluginInstanceThrottler::ConsumeInputEvent( |
| 165 const blink::WebInputEvent& event) { | 165 const blink::WebInputEvent& event) { |
| 166 // Always allow right-clicks through so users may verify it's a plug-in. |
| 167 // TODO(tommycli): We should instead show a custom context menu (probably |
| 168 // using PluginPlaceholder) so users aren't confused and try to click the |
| 169 // Flash-internal 'Play' menu item. This is a stopgap solution. |
| 170 if (event.modifiers & blink::WebInputEvent::Modifiers::RightButtonDown) |
| 171 return false; |
| 172 |
| 166 if (!has_been_clicked_ && is_flash_plugin_ && | 173 if (!has_been_clicked_ && is_flash_plugin_ && |
| 167 event.type == blink::WebInputEvent::MouseDown) { | 174 event.type == blink::WebInputEvent::MouseDown && |
| 175 (event.modifiers & blink::WebInputEvent::LeftButtonDown)) { |
| 168 has_been_clicked_ = true; | 176 has_been_clicked_ = true; |
| 169 RecordFlashClickSizeMetric(bounds_.width, bounds_.height); | 177 RecordFlashClickSizeMetric(bounds_.width, bounds_.height); |
| 170 } | 178 } |
| 171 | 179 |
| 172 if (event.type == blink::WebInputEvent::MouseUp && is_peripheral_content_) { | 180 if (is_peripheral_content_ && event.type == blink::WebInputEvent::MouseUp && |
| 181 (event.modifiers & blink::WebInputEvent::LeftButtonDown)) { |
| 173 is_peripheral_content_ = false; | 182 is_peripheral_content_ = false; |
| 174 power_saver_enabled_ = false; | 183 power_saver_enabled_ = false; |
| 175 needs_representative_keyframe_ = false; | 184 needs_representative_keyframe_ = false; |
| 176 | 185 |
| 177 RecordUnthrottleMethodMetric(UNTHROTTLE_METHOD_BY_CLICK); | 186 RecordUnthrottleMethodMetric(UNTHROTTLE_METHOD_BY_CLICK); |
| 178 | 187 |
| 179 if (plugin_throttled_) { | 188 if (plugin_throttled_) { |
| 180 SetPluginThrottled(false /* throttled */); | 189 SetPluginThrottled(false /* throttled */); |
| 181 return true; | 190 return true; |
| 182 } | 191 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 203 return; | 212 return; |
| 204 | 213 |
| 205 // Once we change the throttle state, we will never need the snapshot again. | 214 // Once we change the throttle state, we will never need the snapshot again. |
| 206 needs_representative_keyframe_ = false; | 215 needs_representative_keyframe_ = false; |
| 207 | 216 |
| 208 plugin_throttled_ = throttled; | 217 plugin_throttled_ = throttled; |
| 209 throttle_change_callback_.Run(); | 218 throttle_change_callback_.Run(); |
| 210 } | 219 } |
| 211 | 220 |
| 212 } // namespace content | 221 } // namespace content |
| OLD | NEW |