//content/public
is the API exposed to embedders of the content module.
In general, we follow the design of the Blink Public API. This makes it easier for people who're already familiar with it, and also keeps things consistent.
//content/public
should contain only interfaces, enums, structs and (rarely) static functions.//content/public/test
. We allow concrete classes that chrome test classes derive from or use in here.//content/public
should be inside implementation directories, e.g. //content/browser
, //content/renderer
etc..._messages.h
files in //content/public
, we do allow .mojom
files (see discussion). If a mojom is only used inside content, it should be in //content/common
. If it’s an interface that is implemented or called by content's embedder, then it belongs in //content/public/common
.//content
should be in the "content"
namespace.PAGE_TRANSITION_LINK
in the content::PageTransition
enum.//content/renderer
should use RenderViewImpl
instead of content::RenderView
).RenderViewObserver
) this might cover things like automatic registration/unregistration. Normally we would put this small code in headers, but because of the clang checks against putting code in headers, we’re forced to put it in .cc files (we don't want to make a clang exception for the content/public
directory since that would lead to confusion).ChromeContentBrowserClient
derives from content::ContentBrowserClient
).foo_impl.h
and not foo.h
.//content/public
but instead some module that's higher level.const
identifier can be added to simple getter APIs implemented by content. Don‘t add const
to interfaces implemented by the embedder, where we can’t make assumptions about what the embedder needs to implement it.WebContentsObserver
, RenderFrameObserver
, RenderViewObserver
) should only have void methods. This is because otherwise the order that observers are registered would matter, and we don‘t want that. The only exception is OnMessageReceived()
, which is fine since only one observer class handles each particular IPC, so ordering doesn’t make a difference.