OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_NET_CLIENT_HINTS_H_ |
| 6 #define CHROME_BROWSER_NET_CLIENT_HINTS_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/memory/weak_ptr.h" |
| 11 |
| 12 // ClientHints is a repository in Chrome for information used |
| 13 // to create the Client-Hints request header. For more information, see: |
| 14 // https://github.com/igrigorik/http-client-hints/blob/master/ |
| 15 // draft-grigorik-http-client-hints-00.txt |
| 16 class ClientHints { |
| 17 public: |
| 18 // Contains information about the client device. |
| 19 struct ScreenInfo { |
| 20 int width; |
| 21 int height; |
| 22 float pixel_ratio; |
| 23 }; |
| 24 |
| 25 ClientHints(); |
| 26 ~ClientHints(); |
| 27 |
| 28 void Init(); |
| 29 |
| 30 // Retrieves screen information for use on the IO thread. |
| 31 bool RetrieveScreenInfo(); |
| 32 |
| 33 // Returns client hints pertaining to screen information. The format is: |
| 34 // "dh=x, dw=y, dpr=z", where x, y, and z are the device screen height, |
| 35 // screen width, and pixel ratio, respectively. These values are the |
| 36 // same as the values returned by the JavaScript commands: |
| 37 // screen.height, screen.width, and window.devicePixelRatio. |
| 38 const std::string& GetScreenInfoHints(); |
| 39 |
| 40 private: |
| 41 friend class ClientHintsTest; |
| 42 |
| 43 void UpdateScreenInfo(ScreenInfo* info); |
| 44 |
| 45 std::string screen_hints_; |
| 46 |
| 47 base::WeakPtrFactory<ClientHints> weak_ptr_factory_; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(ClientHints); |
| 50 }; |
| 51 |
| 52 #endif // CHROME_BROWSER_NET_CLIENT_HINTS_H_ |
OLD | NEW |