Add ICU message format support
[chromium-blink-merge.git] / ios / web / webui / crw_web_ui_page_builder.h
blobfb63c259001b75616e3e5518e7457d5b9ff0dc79
1 // Copyright 2015 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 IOS_WEB_WEBUI_CRW_WEB_UI_PAGE_BUILDER_H_
6 #define IOS_WEB_WEBUI_CRW_WEB_UI_PAGE_BUILDER_H_
8 #import <Foundation/Foundation.h>
10 #include "url/gurl.h"
12 namespace web {
13 // Block type for WebUI page build completion callback.
14 typedef void (^WebUIPageCompletion)(NSString*);
15 // Block type for WebUI page builder delegate completion callback.
16 typedef void (^WebUIDelegateCompletion)(NSString*, const GURL&);
17 } // namespace web
19 @class CRWWebUIPageBuilder;
21 // Delegate for CRWWebUIPageBuilder. Handles resource retrieval.
22 @protocol CRWWebUIPageBuilderDelegate<NSObject>
23 // Fetches resource for resourceURL and invokes completionHandler with the
24 // result.
25 - (void)webUIPageBuilder:(CRWWebUIPageBuilder*)webUIPageBuilder
26 fetchResourceWithURL:(const GURL&)resourceURL
27 completionHandler:(web::WebUIDelegateCompletion)completionHandler;
28 @end
30 // Class for requesting and building WebUI HTML pages. Due to limitations on
31 // custom network protocols for WKWebView, it is not possible to directly load
32 // WebUI in WKWebView via the network stack. Instead, WebUI resources are
33 // manually fetched from the network stack and then flattened and loaded into
34 // the web view.
36 // To flatten the WebUI resources, tags for JS and CSS resources are replaced
37 // with retrieved resources. For example, if a WebUI HTML resource looks like:
38 // <html>
39 // <script src='chrome://javascript.js></script>
40 // <link rel="stylesheet" href="chrome://stylesheet.css">
41 // </html>
42 // the flattened version would look like:
43 // <html>
44 // <script>[Content of chrome://javascript.js]</script>
45 // <style>[Content of chrome://stylesheet.css]</style>
46 // </html>
47 @interface CRWWebUIPageBuilder : NSObject
49 // Designated initializer.
50 - (instancetype)initWithDelegate:(id<CRWWebUIPageBuilderDelegate>)delegate;
52 // Builds and flattens page for webUIURL, and invokes completionHandler with the
53 // result.
54 - (void)buildWebUIPageForURL:(const GURL&)webUIURL
55 completionHandler:(web::WebUIPageCompletion)completionHandler;
57 @end
59 #endif // IOS_WEB_WEBUI_CRW_WEB_UI_PAGE_BUILDER_H_