OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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_COMMON_WEB_APPS_H_ |
| 6 #define CHROME_COMMON_WEB_APPS_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/string16.h" |
| 13 #include "googleurl/src/gurl.h" |
| 14 #include "gfx/size.h" |
| 15 #include "third_party/skia/include/core/SkBitmap.h" |
| 16 |
| 17 namespace WebKit { |
| 18 class WebDocument; |
| 19 class WebFrame; |
| 20 } |
| 21 |
| 22 class DictionaryValue; |
| 23 |
| 24 // Structure used when installing a web page as an app. |
| 25 struct WebApplicationInfo { |
| 26 struct IconInfo { |
| 27 GURL url; |
| 28 int width; |
| 29 int height; |
| 30 SkBitmap data; |
| 31 }; |
| 32 |
| 33 static const char kInvalidDefinitionURL[]; |
| 34 static const char kInvalidLaunchURL[]; |
| 35 static const char kInvalidURL[]; |
| 36 static const char kInvalidIconSize[]; |
| 37 static const char kInvalidIconURL[]; |
| 38 |
| 39 WebApplicationInfo(); |
| 40 ~WebApplicationInfo(); |
| 41 |
| 42 // URL to a manifest that defines the application. If specified, all other |
| 43 // attributes are derived from this manifest, and the manifest is the unique |
| 44 // ID of the application. |
| 45 GURL manifest_url; |
| 46 |
| 47 // Title of the application. |
| 48 string16 title; |
| 49 |
| 50 // Description of the application. |
| 51 string16 description; |
| 52 |
| 53 // The launch URL for the app. |
| 54 GURL app_url; |
| 55 |
| 56 // Set of available icons. |
| 57 std::vector<IconInfo> icons; |
| 58 |
| 59 // The permissions the app requests. Only supported with manifest-based apps. |
| 60 std::vector<std::string> permissions; |
| 61 |
| 62 // Set of URLs that comprise the app. Only supported with manifest-based apps. |
| 63 // All these must be of the same origin as manifest_url. |
| 64 std::vector<GURL> urls; |
| 65 |
| 66 // The type of launch container to use with the app. Currently supported |
| 67 // values are 'tab' and 'panel'. Only supported with manifest-based apps. |
| 68 std::string launch_container; |
| 69 }; |
| 70 |
| 71 |
| 72 // Parses an icon size. An icon size must match the following regex: |
| 73 // [1-9][0-9]*x[1-9][0-9]*. |
| 74 // If the input couldn't be parsed, a size with a width/height < 0 is returned. |
| 75 gfx::Size ParseIconSize(const string16& text); |
| 76 |
| 77 // Parses the icon's size attribute as defined in the HTML 5 spec. Returns true |
| 78 // on success, false on errors. On success either all the sizes specified in |
| 79 // the attribute are added to sizes, or is_any is set to true. |
| 80 // |
| 81 // You shouldn't have a need to invoke this directly, it's public for testing. |
| 82 bool ParseIconSizes(const string16& text, std::vector<gfx::Size>* sizes, |
| 83 bool* is_any); |
| 84 |
| 85 // Parses |web_app| information out of the document in frame. Returns true on |
| 86 // success, or false and |error| on failure. Note that the document may contain |
| 87 // no web application information, in which case |web_app| is unchanged and the |
| 88 // function returns true. |
| 89 // |
| 90 // Documents can also contain a link to a application 'definition'. In this case |
| 91 // web_app will have manifest_url set and nothing else. The caller must fetch |
| 92 // this URL and pass the result to ParseWebAppFromDefinitionFile() for further |
| 93 // processing. |
| 94 bool ParseWebAppFromWebDocument(WebKit::WebFrame* frame, |
| 95 WebApplicationInfo* web_app, |
| 96 string16* error); |
| 97 |
| 98 // Parses |web_app| information out of |definition|. Returns true on success, or |
| 99 // false and |error| on failure. This function assumes that |web_app| has a |
| 100 // valid manifest_url. |
| 101 bool ParseWebAppFromDefinitionFile(const DictionaryValue& definition, |
| 102 WebApplicationInfo* web_app, |
| 103 string16* error); |
| 104 |
| 105 #endif // CHROME_COMMON_WEB_APPS_H_ |
OLD | NEW |