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