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

Unified Diff: content/renderer/peripheral_content_heuristic.cc

Issue 1497623002: Plugin Power Saver: Improve Poster behavior for essential plugins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/peripheral_content_heuristic.cc
diff --git a/content/renderer/peripheral_content_heuristic.cc b/content/renderer/peripheral_content_heuristic.cc
index b2c59c994a8af6e54f2c883155648d61d3c8dd20..3b36af811c11e192958e4124d67c6c45df9c4f86 100644
--- a/content/renderer/peripheral_content_heuristic.cc
+++ b/content/renderer/peripheral_content_heuristic.cc
@@ -6,6 +6,8 @@
#include <cmath>
+#include "ui/gfx/geometry/size.h"
+
namespace content {
namespace {
@@ -30,33 +32,37 @@ const int kEssentialVideoMinimumArea = 120000;
} // namespace
// static
-PeripheralContentHeuristic::Decision
+RenderFrame::PeripheralContentStatus
PeripheralContentHeuristic::GetPeripheralStatus(
const std::set<url::Origin>& origin_whitelist,
const url::Origin& main_frame_origin,
const url::Origin& content_origin,
- int width,
- int height) {
+ const gfx::Size& unobscured_size) {
if (main_frame_origin.IsSameOriginWith(content_origin))
- return HEURISTIC_DECISION_ESSENTIAL_SAME_ORIGIN;
-
- if (width <= 0 || height <= 0)
- return HEURISTIC_DECISION_ESSENTIAL_UNKNOWN_SIZE;
+ return RenderFrame::CONTENT_STATUS_ESSENTIAL_SAME_ORIGIN;
if (origin_whitelist.count(content_origin))
- return HEURISTIC_DECISION_ESSENTIAL_CROSS_ORIGIN_WHITELISTED;
+ return RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_WHITELISTED;
- if (width <= kTinyContentSize && height <= kTinyContentSize)
- return HEURISTIC_DECISION_ESSENTIAL_CROSS_ORIGIN_TINY;
+ if (unobscured_size.IsEmpty())
+ return RenderFrame::CONTENT_STATUS_ESSENTIAL_UNKNOWN_SIZE;
+
+ if (unobscured_size.width() <= kTinyContentSize &&
+ unobscured_size.height() <= kTinyContentSize) {
+ return RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_TINY;
+ }
- if (IsLargeContent(width, height))
- return HEURISTIC_DECISION_ESSENTIAL_CROSS_ORIGIN_BIG;
+ if (IsLargeContent(unobscured_size))
+ return RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_BIG;
- return HEURISTIC_DECISION_PERIPHERAL;
+ return RenderFrame::CONTENT_STATUS_PERIPHERAL;
}
// static
-bool PeripheralContentHeuristic::IsLargeContent(int width, int height) {
+bool PeripheralContentHeuristic::IsLargeContent(
+ const gfx::Size& unobscured_size) {
+ int width = unobscured_size.width();
+ int height = unobscured_size.height();
if (width >= kLargeContentMinWidth && height >= kLargeContentMinHeight)
return true;
« no previous file with comments | « content/renderer/peripheral_content_heuristic.h ('k') | content/renderer/peripheral_content_heuristic_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698