OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_UI_WEBUI_WEB_UI_UTIL_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_WEB_UI_UTIL_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_WEB_UI_UTIL_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_WEB_UI_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 class GURL; | 11 class GURL; |
12 class SkBitmap; | 12 class SkBitmap; |
13 | 13 |
14 namespace web_ui_util { | 14 namespace web_ui_util { |
15 | 15 |
16 // Convenience routine to convert SkBitmap object to data url | 16 // Convenience routine to convert SkBitmap object to data url |
17 // so that it can be used in WebUI. | 17 // so that it can be used in WebUI. |
18 std::string GetImageDataUrl(const SkBitmap& bitmap); | 18 std::string GetImageDataUrl(const SkBitmap& bitmap); |
19 | 19 |
20 // Convenience routine to get data url that corresponds to given | 20 // Convenience routine to get data url that corresponds to given |
21 // resource_id as an image. This function does not check if the | 21 // resource_id as an image. This function does not check if the |
22 // resource for the |resource_id| is an image, therefore it is the | 22 // resource for the |resource_id| is an image, therefore it is the |
23 // caller's responsibility to make sure the resource is indeed an | 23 // caller's responsibility to make sure the resource is indeed an |
24 // image. Returns empty string if a resource does not exist for given | 24 // image. Returns empty string if a resource does not exist for given |
25 // |resource_id|. | 25 // |resource_id|. |
26 std::string GetImageDataUrlFromResource(int resource_id); | 26 std::string GetImageDataUrlFromResource(int resource_id); |
27 | 27 |
28 // Returns true if |url| has a chrome: or about: scheme. | |
29 bool IsChromeURL(const GURL& url); | |
30 | |
31 // GURL typically parses "scheme://host/path?query#ref" correctly, however: | |
32 // If chrome: omits scheme separator slashes, e.g. "chrome:host/path?query#ref", | |
33 // then GURL reports that the URL has no host and path "host/path?qry#ref". | |
34 // If about: has scheme separator slashes, e.g. "about://host/path?query#ref", | |
35 // then GURL reports that the URL has no host and path "//host/path?qry#ref". | |
36 // These functions parse common about and chrome URL formats as intended. | |
37 std::string GetChromeURLHost(const GURL& url); | |
38 std::string GetChromeURLPath(const GURL& url); | |
abarth-chromium
2011/05/27 17:19:25
Should we fix GURL to get these cases right instea
msw
2011/05/31 13:34:29
I rewrote this as URLFixerUpper::FixupChromeURL. I
| |
39 | |
40 // Returns true if |url|'s host matches |host|. | |
41 bool HostEquals(const GURL& url, const char* host); | |
42 | |
28 // Returns true if |url| has a chrome: or about: scheme and matching |host|. | 43 // Returns true if |url| has a chrome: or about: scheme and matching |host|. |
29 // The url may contain a path under the host. | 44 // The url may contain a path under the host. |
30 bool ChromeURLHostEquals(const GURL& url, const char* host); | 45 bool ChromeURLHostEquals(const GURL& url, const char* host); |
31 | 46 |
32 } // namespace web_ui_util | 47 } // namespace web_ui_util |
33 | 48 |
34 #endif // CHROME_BROWSER_UI_WEBUI_WEB_UI_UTIL_H_ | 49 #endif // CHROME_BROWSER_UI_WEBUI_WEB_UI_UTIL_H_ |
OLD | NEW |