Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / base / webui / web_ui_util.h
blob95f1856f34f541cf31db30e59470b0cbd730a274
1 // Copyright 2013 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.
5 #ifndef UI_BASE_WEBUI_WEB_UI_UTIL_H_
6 #define UI_BASE_WEBUI_WEB_UI_UTIL_H_
8 #include <string>
10 #include "base/strings/string_piece.h"
11 #include "base/values.h"
12 #include "ui/base/ui_base_export.h"
13 #include "ui/base/window_open_disposition.h"
15 class GURL;
16 class SkBitmap;
18 namespace webui {
20 // Convenience routine to convert SkBitmap object to data url
21 // so that it can be used in WebUI.
22 UI_BASE_EXPORT std::string GetBitmapDataUrl(const SkBitmap& bitmap);
24 // Extracts a disposition from click event arguments. |args| should contain
25 // an integer button and booleans alt key, ctrl key, meta key, and shift key
26 // (in that order), starting at |start_index|.
27 UI_BASE_EXPORT WindowOpenDisposition
28 GetDispositionFromClick(const base::ListValue* args, int start_index);
30 // Pares a formatted scale factor string into float and sets to |scale_factor|.
31 UI_BASE_EXPORT bool ParseScaleFactor(const base::StringPiece& identifier,
32 float* scale_factor);
34 // Parses a URL containing some path @{scale}x. If it does not contain a scale
35 // factor then the default scale factor is returned.
36 UI_BASE_EXPORT void ParsePathAndScale(const GURL& url,
37 std::string* path,
38 float* scale_factor);
40 // Helper function to set some default values (e.g., font family, size,
41 // language, and text direction) into the given dictionary. Requires an
42 // application locale (i.e. g_browser_process->GetApplicationLocale()).
43 UI_BASE_EXPORT void SetLoadTimeDataDefaults(
44 const std::string& app_locale,
45 base::DictionaryValue* localized_strings);
47 // Get a CSS declaration for common text styles for all of Web UI.
48 UI_BASE_EXPORT std::string GetWebUiCssTextDefaults();
50 // Appends the CSS declaration returned by GetWebUiCssTextDefaults() as an
51 // inline stylesheet.
52 UI_BASE_EXPORT void AppendWebUiCssTextDefaults(std::string* html);
54 // Get some common font styles for all of WebUI.
55 UI_BASE_EXPORT std::string GetFontFamily();
56 UI_BASE_EXPORT std::string GetFontSize();
57 UI_BASE_EXPORT std::string GetTextDirection();
59 } // namespace webui
61 #endif // UI_BASE_WEBUI_WEB_UI_UTIL_H_