Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(650)

Side by Side Diff: content/renderer/pepper/pepper_plugin_instance_throttler.cc

Issue 802453004: Plugin Power Saver: Improve right-click and middle-click behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0208-plugin-power-saver-fix-black-video-on-resume-problem
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/renderer/pepper/pepper_plugin_instance_throttler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | content/renderer/pepper/pepper_plugin_instance_throttler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698