Remove anchor tags from WebUI docs.
They are already automatically generated by Markdown. Change-Id: I22b53b8a33de21bdcf314d4b5c95329750e2ac15 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3413792 Reviewed-by: Rebekah Potter <rbpotter@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org> Cr-Commit-Position: refs/heads/main@{#962885}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
47d3c5d57d
commit
fded90de75
@ -14,7 +14,6 @@
|
||||
|
||||
[TOC]
|
||||
|
||||
<a name="What_is_webui"></a>
|
||||
## What is "WebUI"?
|
||||
|
||||
"WebUI" is a term used to loosely describe **parts of Chrome's UI
|
||||
@ -32,7 +31,6 @@ Not all web-based UIs in Chrome have chrome:// URLs.
|
||||
|
||||
This document explains how WebUI works.
|
||||
|
||||
<a name="bindings"></a>
|
||||
## What's different from a web page?
|
||||
|
||||
WebUIs are granted super powers so that they can manage Chrome itself. For
|
||||
@ -52,7 +50,6 @@ Specifically, these bindings:
|
||||
[`chrome.send()`](#chrome_send) and friends
|
||||
* ignore content settings regarding showing images or executing JavaScript
|
||||
|
||||
<a name="chrome_urls"></a>
|
||||
## How `chrome:` URLs work
|
||||
|
||||
<div class="note">
|
||||
@ -192,7 +189,6 @@ Because they run in a separate process and can exist before a corresponding
|
||||
renderer process has been created, special care is required to communicate with
|
||||
the renderer if reliable message passing is required.
|
||||
|
||||
<a name="WebUIController"></a>
|
||||
### WebUIController
|
||||
|
||||
A `WebUIController` is the brains of the operation, and is responsible for
|
||||
@ -207,7 +203,6 @@ an existing [`WebUI`](#WebUI) when the correct one is determined via URL
|
||||
inspection (i.e. chrome://settings creates a generic [`WebUI`](#WebUI) with a
|
||||
settings-specific `WebUIController`).
|
||||
|
||||
<a name="WebUIDataSource"></a>
|
||||
### WebUIDataSource
|
||||
|
||||
The `WebUIDataSource` class provides a place for data to live for WebUI pages.
|
||||
@ -247,7 +242,6 @@ For more about each of the methods called on `WebUIDataSource` and the utility
|
||||
method that performs additional configuration, see [DataSources](#DataSources)
|
||||
and [WebUIDataSourceUtils](#WebUIDataSourceUtils)
|
||||
|
||||
<a name="WebUIMessageHandler"></a>
|
||||
### WebUIMessageHandler
|
||||
|
||||
Because some pages have many messages or share code that sends messages, message
|
||||
@ -283,17 +277,14 @@ $('bakeDonutsButton').onclick = function() {
|
||||
};
|
||||
```
|
||||
|
||||
<a name="DataSources">
|
||||
## Data Sources
|
||||
|
||||
<a name="Create"></a>
|
||||
### WebUIDataSource::Create()
|
||||
|
||||
This is a factory method required to create a WebUIDataSource instance. The
|
||||
argument to `Create()` is typically the host name of the page. Caller owns the
|
||||
result.
|
||||
|
||||
<a name="Add"></a>
|
||||
### WebUIDataSource::Add()
|
||||
|
||||
Once you've created and added some things to a data source, it'll need to be
|
||||
@ -307,7 +298,6 @@ It's unsafe to keep references to a <code>WebUIDataSource</code> after calling
|
||||
<code>Add()</code>. Don't do this.
|
||||
</div>
|
||||
|
||||
<a name="AddLocalizedString"></a>
|
||||
### WebUIDataSource::AddLocalizedString()
|
||||
|
||||
Using an int reference to a grit string (starts with "IDS" and lives in a .grd
|
||||
@ -315,7 +305,6 @@ or .grdp file), adding a string with a key name will be possible to reference
|
||||
via the `$i18n{}` syntax (and will be replaced when requested) or later
|
||||
dynamically in JavaScript via `loadTimeData.getString()` (or `getStringF`).
|
||||
|
||||
<a name="AddResourcePath"></a>
|
||||
### WebUIDataSource::AddResourcePath()
|
||||
|
||||
Using an int reference to a grit resource (starts with "IDR" and lives in a .grd
|
||||
@ -332,7 +321,6 @@ they will be redirected to the main history page, instead of seeing an error,
|
||||
but incorrect imports in the source code will fail, so that they can be more
|
||||
easily found and corrected.
|
||||
|
||||
<a name="AddBoolean"></a>
|
||||
### WebUIDataSource::AddBoolean()
|
||||
|
||||
Often a page needs to know whether a feature is enabled. This is a good use case
|
||||
@ -355,13 +343,11 @@ If you really want or need to use <code>AddBoolean()</code> for a dynamic value,
|
||||
make sure to call <code>WebUIDataSource::Update()</code> when the value changes.
|
||||
</div>
|
||||
|
||||
<a name="WebUIDataSourceUtils"></a>
|
||||
## WebUI utils for working with data sources
|
||||
|
||||
chrome/browser/ui/webui/webui\_util.\* contains a number of methods to simplify
|
||||
common configuration tasks.
|
||||
|
||||
<a name="AddLocalizedStringsBulk"></a>
|
||||
### WebUIDataSource::AddLocalizedStrings()
|
||||
|
||||
Many Web UI data sources need to be set up with a large number of localized
|
||||
@ -378,7 +364,6 @@ an array of all the strings and use <code>AddLocalizedStrings()</code>:
|
||||
source->AddLocalizedStrings(kStrings);
|
||||
```
|
||||
|
||||
<a name="AddResourcePaths"></a>
|
||||
### WebUIDataSource::AddResourcePaths()
|
||||
|
||||
Similar to the localized strings, many Web UIs need to add a large number of
|
||||
@ -406,7 +391,6 @@ resource map can be added as follows:
|
||||
base::make_span(kPrintPreviewResources, kPrintPreviewResourcesSize));
|
||||
```
|
||||
|
||||
<a name="SetupWebUIDataSource"></a>
|
||||
### webui::SetupWebUIDataSource()
|
||||
|
||||
This method performs common configuration tasks on a data source for a Web UI
|
||||
@ -426,7 +410,6 @@ Specific setup steps include:
|
||||
|
||||
## Browser (C++) → Renderer (JS)
|
||||
|
||||
<a name="AllowJavascript"></a>
|
||||
### WebUIMessageHandler::AllowJavascript()
|
||||
|
||||
A tab that has been used for settings UI may be reloaded, or may navigate to an
|
||||
@ -491,7 +474,6 @@ detect page readiness omits <i>application-specific</i> initialization, and a
|
||||
custom <code>'initialized'</code> message is often necessary.
|
||||
</div>
|
||||
|
||||
<a name="CallJavascriptFunction"></a>
|
||||
### WebUIMessageHandler::CallJavascriptFunction()
|
||||
|
||||
When the browser process needs to tell the renderer/JS of an event or otherwise
|
||||
@ -537,7 +519,6 @@ alternatives:
|
||||
when Javascript requires a response to an inquiry about C++-canonical state
|
||||
(i.e. "Is Autofill enabled?", "Is the user incognito?")
|
||||
|
||||
<a name="FireWebUIListener"></a>
|
||||
### WebUIMessageHandler::FireWebUIListener()
|
||||
|
||||
`FireWebUIListener()` is used to notify a registered set of listeners that an
|
||||
@ -566,7 +547,6 @@ If you simply need to get a response in Javascript from C++, consider using
|
||||
[`cr.sendWithPromise()`](#cr_sendWithPromise) and
|
||||
[`ResolveJavascriptCallback`](#ResolveJavascriptCallback).
|
||||
|
||||
<a name="OnJavascriptAllowed"></a>
|
||||
### WebUIMessageHandler::OnJavascriptAllowed()
|
||||
|
||||
`OnJavascriptDisallowed()` is a lifecycle method called in response to
|
||||
@ -609,7 +589,6 @@ when a renderer has been created and the
|
||||
document has loaded enough to signal to the C++ that it's ready to respond to
|
||||
messages.
|
||||
|
||||
<a name="OnJavascriptDisallowed"></a>
|
||||
### WebUIMessageHandler::OnJavascriptDisallowed()
|
||||
|
||||
`OnJavascriptDisallowed` is a lifecycle method called when it's unclear whether
|
||||
@ -644,7 +623,6 @@ Because `OnJavascriptDisallowed()` is not guaranteed to be called before a
|
||||
scoped observer that automatically unsubscribes on destruction but can also
|
||||
imperatively unsubscribe in `OnJavascriptDisallowed()`.
|
||||
|
||||
<a name="RejectJavascriptCallback"></a>
|
||||
### WebUIMessageHandler::RejectJavascriptCallback()
|
||||
|
||||
This method is called in response to
|
||||
@ -676,7 +654,6 @@ CallJavascriptFunction("cr.webUIResponse", callback_id, base::Value(false),
|
||||
|
||||
See also: [`ResolveJavascriptCallback`](#ResolveJavascriptCallback)
|
||||
|
||||
<a name="ResolveJavascriptCallback"></a>
|
||||
### WebUIMessageHandler::ResolveJavascriptCallback()
|
||||
|
||||
This method is called in response to
|
||||
@ -706,7 +683,6 @@ void OvenHandler::HandleBakeDonuts(const base::ListValue* args) {
|
||||
|
||||
## Renderer (JS) → Browser (C++)
|
||||
|
||||
<a name="chrome_send"></a>
|
||||
### chrome.send()
|
||||
|
||||
When the JavaScript `window` object is created, a renderer is checked for [WebUI
|
||||
@ -758,7 +734,6 @@ callback with the deserialized arguments:
|
||||
message_callbacks_.find(message)->second.Run(&args);
|
||||
```
|
||||
|
||||
<a name="cr_addWebUIListener">
|
||||
### cr.addWebUIListener()
|
||||
|
||||
WebUI listeners are a convenient way for C++ to inform JavaScript of events.
|
||||
@ -808,7 +783,6 @@ cr.addWebUIListener('donuts-baked', function(numFreshlyBakedDonuts) {
|
||||
});
|
||||
```
|
||||
|
||||
<a name="cr_sendWithPromise"></a>
|
||||
### cr.sendWithPromise()
|
||||
|
||||
`cr.sendWithPromise()` is a wrapper around `chrome.send()`. It's used when
|
||||
|
@ -15,7 +15,6 @@ This guide is based on [Creating WebUI Interfaces in components](webui_in_compon
|
||||
|
||||
[TOC]
|
||||
|
||||
<a name="creating_web_ui_page"></a>
|
||||
WebUI pages live in `chrome/browser/resources`. You should create a folder for your project `chrome/browser/resources/hello_world`.
|
||||
When creating WebUI resources, follow the [Web Development Style Guide](https://chromium.googlesource.com/chromium/src/+/main/styleguide/web/web.md). For a sample WebUI page you could start with the following files:
|
||||
|
||||
|
@ -16,7 +16,6 @@ To create a WebUI interface in `components/` you need to follow different steps
|
||||
|
||||
[TOC]
|
||||
|
||||
<a name="creating_webui_page"></a>
|
||||
## Creating the WebUI page
|
||||
|
||||
WebUI resources in `components/` will be added in your specific project folder. Create a project folder `src/components/hello_world/`. When creating WebUI resources, follow the [Web Development Style Guide](https://chromium.googlesource.com/chromium/src/+/main/styleguide/web/web.md). For a sample WebUI page you could start with the following files:
|
||||
|
Reference in New Issue
Block a user