| 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 #ifndef CONTENT_RENDERER_PERIPHERAL_CONTENT_HEURISTIC_H_ | 5 #ifndef CONTENT_RENDERER_PERIPHERAL_CONTENT_HEURISTIC_H_ |
| 6 #define CONTENT_RENDERER_PERIPHERAL_CONTENT_HEURISTIC_H_ | 6 #define CONTENT_RENDERER_PERIPHERAL_CONTENT_HEURISTIC_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 11 #include "content/public/renderer/render_frame.h" | |
| 12 #include "url/origin.h" | 11 #include "url/origin.h" |
| 13 | 12 |
| 14 namespace gfx { | |
| 15 class Size; | |
| 16 } | |
| 17 | |
| 18 namespace content { | 13 namespace content { |
| 19 | 14 |
| 20 class CONTENT_EXPORT PeripheralContentHeuristic { | 15 class CONTENT_EXPORT PeripheralContentHeuristic { |
| 21 public: | 16 public: |
| 17 // Initial decision of the peripheral content decision. |
| 18 // These numeric values are used in UMA logs; do not change them. |
| 19 enum Decision { |
| 20 HEURISTIC_DECISION_PERIPHERAL = 0, |
| 21 HEURISTIC_DECISION_ESSENTIAL_SAME_ORIGIN = 1, |
| 22 HEURISTIC_DECISION_ESSENTIAL_CROSS_ORIGIN_BIG = 2, |
| 23 HEURISTIC_DECISION_ESSENTIAL_CROSS_ORIGIN_WHITELISTED = 3, |
| 24 HEURISTIC_DECISION_ESSENTIAL_CROSS_ORIGIN_TINY = 4, |
| 25 HEURISTIC_DECISION_ESSENTIAL_UNKNOWN_SIZE = 5, |
| 26 HEURISTIC_DECISION_NUM_ITEMS |
| 27 }; |
| 28 |
| 22 // Returns true if this content should have power saver enabled. | 29 // Returns true if this content should have power saver enabled. |
| 23 // | 30 // |
| 24 // Power Saver is enabled for content that are cross-origin and | 31 // Power Saver is enabled for content that are cross-origin and |
| 25 // heuristically determined to be not essential to the web page content. | 32 // heuristically determined to be not essential to the web page content. |
| 26 // | 33 // |
| 27 // Content is defined to be cross-origin when the source's origin differs | 34 // Content is defined to be cross-origin when the source's origin differs |
| 28 // from the top level frame's origin. For example: | 35 // from the top level frame's origin. For example: |
| 29 // - Cross-origin: a.com -> b.com/plugin.swf | 36 // - Cross-origin: a.com -> b.com/plugin.swf |
| 30 // - Cross-origin: a.com -> b.com/iframe.html -> b.com/plugin.swf | 37 // - Cross-origin: a.com -> b.com/iframe.html -> b.com/plugin.swf |
| 31 // - Same-origin: a.com -> b.com/iframe-to-a.html -> a.com/plugin.swf | 38 // - Same-origin: a.com -> b.com/iframe-to-a.html -> a.com/plugin.swf |
| 32 // | 39 // |
| 33 // |origin_whitelist| is the whitelist of content origins. | 40 // |origin_whitelist| is the whitelist of content origins. |
| 34 // | 41 // |
| 35 // |main_frame_origin| is the origin of the main frame. | 42 // |main_frame_origin| is the origin of the main frame. |
| 36 // | 43 // |
| 37 // |content_origin| is the origin of the content e.g. plugin or video source. | 44 // |content_origin| is the origin of the content e.g. plugin or video source. |
| 38 // | 45 // |
| 39 // |unobscured_size| is in zoom and device scale independent logical pixels. | 46 // |width| and |height| are zoom and device scale independent logical pixels. |
| 40 static RenderFrame::PeripheralContentStatus GetPeripheralStatus( | 47 static Decision GetPeripheralStatus( |
| 41 const std::set<url::Origin>& origin_whitelist, | 48 const std::set<url::Origin>& origin_whitelist, |
| 42 const url::Origin& main_frame_origin, | 49 const url::Origin& main_frame_origin, |
| 43 const url::Origin& content_origin, | 50 const url::Origin& content_origin, |
| 44 const gfx::Size& unobscured_size); | 51 int width, |
| 52 int height); |
| 45 | 53 |
| 46 // Returns true if content is considered "large", and thus essential. | 54 // Returns true if content is considered "large", and thus essential. |
| 47 // |unobscured_size| is in zoom and device scale independent logical pixels. | 55 // |width| and |height| are zoom and device scale independent logical pixels. |
| 48 static bool IsLargeContent(const gfx::Size& unobscured_size); | 56 static bool IsLargeContent(int width, int height); |
| 49 }; | 57 }; |
| 50 | 58 |
| 51 } // namespace content | 59 } // namespace content |
| 52 | 60 |
| 53 #endif // CONTENT_RENDERER_PERIPHERAL_CONTENT_HEURISTIC_H_ | 61 #endif // CONTENT_RENDERER_PERIPHERAL_CONTENT_HEURISTIC_H_ |
| OLD | NEW |