| 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_instance_throttler_impl.h" |    5 #include "content/renderer/pepper/plugin_instance_throttler_impl.h" | 
|    6  |    6  | 
|    7 #include "base/memory/ptr_util.h" |    7 #include "base/memory/ptr_util.h" | 
|    8 #include "base/metrics/histogram_macros.h" |    8 #include "base/metrics/histogram_macros.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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  193     EngageThrottle(); |  193     EngageThrottle(); | 
|  194   } |  194   } | 
|  195 } |  195 } | 
|  196  |  196  | 
|  197 bool PluginInstanceThrottlerImpl::ConsumeInputEvent( |  197 bool PluginInstanceThrottlerImpl::ConsumeInputEvent( | 
|  198     const blink::WebInputEvent& event) { |  198     const blink::WebInputEvent& event) { | 
|  199   // Always allow right-clicks through so users may verify it's a plugin. |  199   // Always allow right-clicks through so users may verify it's a plugin. | 
|  200   // TODO(tommycli): We should instead show a custom context menu (probably |  200   // TODO(tommycli): We should instead show a custom context menu (probably | 
|  201   // using PluginPlaceholder) so users aren't confused and try to click the |  201   // using PluginPlaceholder) so users aren't confused and try to click the | 
|  202   // Flash-internal 'Play' menu item. This is a stopgap solution. |  202   // Flash-internal 'Play' menu item. This is a stopgap solution. | 
|  203   if (event.modifiers & blink::WebInputEvent::Modifiers::RightButtonDown) |  203   if (event.modifiers() & blink::WebInputEvent::Modifiers::RightButtonDown) | 
|  204     return false; |  204     return false; | 
|  205  |  205  | 
|  206   if (state_ != THROTTLER_STATE_MARKED_ESSENTIAL && |  206   if (state_ != THROTTLER_STATE_MARKED_ESSENTIAL && | 
|  207       event.type == blink::WebInputEvent::MouseUp && |  207       event.type() == blink::WebInputEvent::MouseUp && | 
|  208       (event.modifiers & blink::WebInputEvent::LeftButtonDown)) { |  208       (event.modifiers() & blink::WebInputEvent::LeftButtonDown)) { | 
|  209     bool was_throttled = IsThrottled(); |  209     bool was_throttled = IsThrottled(); | 
|  210     MarkPluginEssential(UNTHROTTLE_METHOD_BY_CLICK); |  210     MarkPluginEssential(UNTHROTTLE_METHOD_BY_CLICK); | 
|  211     return was_throttled; |  211     return was_throttled; | 
|  212   } |  212   } | 
|  213  |  213  | 
|  214   return IsThrottled(); |  214   return IsThrottled(); | 
|  215 } |  215 } | 
|  216  |  216  | 
|  217 void PluginInstanceThrottlerImpl::EngageThrottle() { |  217 void PluginInstanceThrottlerImpl::EngageThrottle() { | 
|  218   if (state_ != THROTTLER_STATE_AWAITING_KEYFRAME) |  218   if (state_ != THROTTLER_STATE_AWAITING_KEYFRAME) | 
|  219     return; |  219     return; | 
|  220  |  220  | 
|  221   if (!last_received_frame_.empty()) { |  221   if (!last_received_frame_.empty()) { | 
|  222     for (auto& observer : observer_list_) |  222     for (auto& observer : observer_list_) | 
|  223       observer.OnKeyframeExtracted(&last_received_frame_); |  223       observer.OnKeyframeExtracted(&last_received_frame_); | 
|  224  |  224  | 
|  225     // Release our reference to the underlying pixel data. |  225     // Release our reference to the underlying pixel data. | 
|  226     last_received_frame_.reset(); |  226     last_received_frame_.reset(); | 
|  227   } |  227   } | 
|  228  |  228  | 
|  229   state_ = THROTTLER_STATE_PLUGIN_THROTTLED; |  229   state_ = THROTTLER_STATE_PLUGIN_THROTTLED; | 
|  230   for (auto& observer : observer_list_) |  230   for (auto& observer : observer_list_) | 
|  231     observer.OnThrottleStateChange(); |  231     observer.OnThrottleStateChange(); | 
|  232 } |  232 } | 
|  233  |  233  | 
|  234 }  // namespace content |  234 }  // namespace content | 
| OLD | NEW |