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_COMMON_WEB_APPLICATION_INFO_H_ 6 #define CHROME_COMMON_WEB_APPLICATION_INFO_H_ 7 8 #include <iosfwd> 9 #include <map> 10 #include <memory> 11 #include <string> 12 #include <vector> 13 14 #include "base/optional.h" 15 #include "base/strings/string16.h" 16 #include "third_party/blink/public/common/manifest/manifest.h" 17 #include "third_party/blink/public/mojom/manifest/display_mode.mojom.h" 18 #include "third_party/skia/include/core/SkBitmap.h" 19 #include "third_party/skia/include/core/SkColor.h" 20 #include "ui/gfx/geometry/size.h" 21 #include "url/gurl.h" 22 23 using SquareSizePx = int; 24 25 struct WebApplicationIconInfo { 26 WebApplicationIconInfo(); 27 WebApplicationIconInfo(const WebApplicationIconInfo&); 28 WebApplicationIconInfo(WebApplicationIconInfo&&); 29 ~WebApplicationIconInfo(); 30 WebApplicationIconInfo& operator=(const WebApplicationIconInfo&); 31 WebApplicationIconInfo& operator=(WebApplicationIconInfo&&); 32 33 GURL url; 34 SquareSizePx square_size_px; 35 }; 36 37 // Structure used when installing a web page as an app. 38 struct WebApplicationInfo { 39 enum MobileCapable { 40 MOBILE_CAPABLE_UNSPECIFIED, 41 MOBILE_CAPABLE, 42 MOBILE_CAPABLE_APPLE 43 }; 44 45 WebApplicationInfo(); 46 WebApplicationInfo(const WebApplicationInfo& other); 47 ~WebApplicationInfo(); 48 49 // Title of the application. 50 base::string16 title; 51 52 // Description of the application. 53 base::string16 description; 54 55 // The launch URL for the app. 56 GURL app_url; 57 58 // Scope for the app. Dictates what URLs will be opened in the app. 59 GURL scope; 60 61 // List of icon URLs with associated square size. 62 std::vector<WebApplicationIconInfo> icon_infos; 63 64 // Icon bitmaps keyed by their square size. 65 std::map<SquareSizePx, SkBitmap> icon_bitmaps; 66 67 // Whether the page is marked as mobile-capable, including apple specific meta 68 // tag. 69 MobileCapable mobile_capable; 70 71 // The color to use if an icon needs to be generated for the web app. 72 SkColor generated_icon_color; 73 74 // The color to use for the web app frame. 75 base::Optional<SkColor> theme_color; 76 77 // App preference regarding whether the app should be opened in a tab, 78 // in a window (with or without minimal-ui buttons), or full screen. Defaults 79 // to browser display mode as specified in 80 // https://w3c.github.io/manifest/#display-modes 81 blink::mojom::DisplayMode display_mode; 82 83 // User preference as to whether the app should be opened in a window. 84 // If false, the app will be opened in a tab. 85 // If true, the app will be opened in a window, with minimal-ui buttons 86 // if display_mode is kBrowser or kMinimalUi. 87 bool open_as_window; 88 89 // The extensions and mime types the app can handle. 90 std::vector<blink::Manifest::FileHandler> file_handlers; 91 92 // Additional search terms that users can use to find the app. 93 std::vector<std::string> additional_search_terms; 94 }; 95 96 std::ostream& operator<<(std::ostream& out, 97 const WebApplicationIconInfo& icon_info); 98 99 bool operator==(const WebApplicationIconInfo& icon_info1, 100 const WebApplicationIconInfo& icon_info2); 101 102 #endif // CHROME_COMMON_WEB_APPLICATION_INFO_H_ 103