| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 // This file defines utility functions for working with html. | 5 // This file defines utility functions for working with html. |
| 6 | 6 |
| 7 #ifndef CHROME_FRAME_HTML_UTILS_H_ | 7 #ifndef CHROME_FRAME_HTML_UTILS_H_ |
| 8 #define CHROME_FRAME_HTML_UTILS_H_ | 8 #define CHROME_FRAME_HTML_UTILS_H_ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 const std::wstring html_string_; | 120 const std::wstring html_string_; |
| 121 | 121 |
| 122 // Store the string of quote characters to avoid repeated construction. | 122 // Store the string of quote characters to avoid repeated construction. |
| 123 const std::wstring quotes_; | 123 const std::wstring quotes_; |
| 124 | 124 |
| 125 DISALLOW_COPY_AND_ASSIGN(HTMLScanner); | 125 DISALLOW_COPY_AND_ASSIGN(HTMLScanner); |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 namespace http_utils { | 128 namespace http_utils { |
| 129 | 129 |
| 130 // Adds "chromeframe/x.y" to the end of the User-Agent string (x.y is the | 130 // Adds "chromeframe/a.b.c.d" to the User-Agent string (a.b.c.d is the version). |
| 131 // version). If the cf tag has already been added to the string, | 131 // If the cf tag has already been added to the string, the original string is |
| 132 // the original string is returned. | 132 // returned. |
| 133 std::string AddChromeFrameToUserAgentValue(const std::string& value); | 133 std::string AddChromeFrameToUserAgentValue(const std::string& value); |
| 134 | 134 |
| 135 // Removes "chromeframe/a.b.c.d" from the User-Agent string (a.b.c.d is the |
| 136 // version). If the cf tag is not present in the string, the original string is |
| 137 // returned. |
| 138 std::string RemoveChromeFrameFromUserAgentValue(const std::string& value); |
| 139 |
| 135 // Fetches the user agent from urlmon and adds chrome frame to the | 140 // Fetches the user agent from urlmon and adds chrome frame to the |
| 136 // comment section. | 141 // comment section. |
| 137 // NOTE: The returned string includes the "User-Agent: " header name. | 142 // NOTE: The returned string includes the "User-Agent: " header name. |
| 138 std::string GetDefaultUserAgentHeaderWithCFTag(); | 143 std::string GetDefaultUserAgentHeaderWithCFTag(); |
| 139 | 144 |
| 140 // Returns the User-Agent header as would be used by Chrome itself. | 145 // Returns the User-Agent header as would be used by Chrome itself. |
| 141 const char* GetChromeUserAgent(); | 146 const char* GetChromeUserAgent(); |
| 142 | 147 |
| 143 // Fetches the default user agent string from urlmon. | 148 // Fetches the default user agent string from urlmon. |
| 144 // This value does not include the "User-Agent:" header name. | 149 // This value does not include the "User-Agent:" header name. |
| 145 std::string GetDefaultUserAgent(); | 150 std::string GetDefaultUserAgent(); |
| 146 | 151 |
| 147 // Returns the Chrome Frame user agent. E.g. "chromeframe/1.0". | 152 // Returns the Chrome Frame user agent. E.g. "chromeframe/1.0". |
| 148 // Note that in unit tests this will be "chromeframe/0.0" due to the version | 153 // Note that in unit tests this will be "chromeframe/0.0" due to the version |
| 149 // table not being present in the unit test executable. | 154 // table not being present in the unit test executable. |
| 150 const char* GetChromeFrameUserAgent(); | 155 const char* GetChromeFrameUserAgent(); |
| 151 | 156 |
| 152 // Returns true if there is a frame busting header (other than the do-nothing | 157 // Returns true if there is a frame busting header (other than the do-nothing |
| 153 // "X-Frame-Options: ALLOWALL") in the provided header block. Note that there | 158 // "X-Frame-Options: ALLOWALL") in the provided header block. Note that there |
| 154 // may be multiple X-Frame-Options values specified; if there is one anywhere in | 159 // may be multiple X-Frame-Options values specified; if there is one anywhere in |
| 155 // the list with a value other than ALLOWALL, this returns true. | 160 // the list with a value other than ALLOWALL, this returns true. |
| 156 bool HasFrameBustingHeader(const std::string& http_headers); | 161 bool HasFrameBustingHeader(const std::string& http_headers); |
| 157 | 162 |
| 158 // Returns the header passed in from the headers list. | 163 // Returns the header passed in from the headers list. |
| 159 std::string GetHttpHeaderFromHeaderList(const std::string& header_name, | 164 std::string GetHttpHeaderFromHeaderList(const std::string& header_name, |
| 160 const std::string& headers); | 165 const std::string& headers); |
| 161 } // namespace http_utils | 166 } // namespace http_utils |
| 162 | 167 |
| 163 #endif // CHROME_FRAME_HTML_UTILS_H_ | 168 #endif // CHROME_FRAME_HTML_UTILS_H_ |
| OLD | NEW |