diff options
Diffstat (limited to 'chromium/weblayer/public/tab.h')
-rw-r--r-- | chromium/weblayer/public/tab.h | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/chromium/weblayer/public/tab.h b/chromium/weblayer/public/tab.h index eeec5ff218a..ccf25ff7fd6 100644 --- a/chromium/weblayer/public/tab.h +++ b/chromium/weblayer/public/tab.h @@ -6,7 +6,9 @@ #define WEBLAYER_PUBLIC_TAB_H_ #include <algorithm> +#include <map> #include <string> +#include <vector> #include "base/callback_forward.h" #include "base/strings/string16.h" @@ -27,19 +29,13 @@ class ErrorPageDelegate; class FullscreenDelegate; class NavigationController; class NewTabDelegate; -class Profile; class TabObserver; +class WebMessageHostFactory; // Represents a tab that is navigable. class Tab { public: - static std::unique_ptr<Tab> Create(Profile* profile); - -#if defined(OS_ANDROID) - static Tab* GetLastTabForTesting(); -#endif - - virtual ~Tab() {} + virtual ~Tab() = default; // Sets the ErrorPageDelegate. If none is set, a default action will be taken // for any given interaction with an error page. @@ -75,6 +71,40 @@ class Tab { // Returns the tab's guid. virtual const std::string& GetGuid() = 0; + // Allows the embedder to get and set arbitrary data on the tab. This will be + // saved and restored with the browser, so it is important to keep this data + // as small as possible. + virtual void SetData(const std::map<std::string, std::string>& data) = 0; + virtual const std::map<std::string, std::string>& GetData() = 0; + + // Adds a new WebMessageHostFactory. For any urls that match + // |allowed_origin_rules| a JS object is registered using the name + // |js_object_name| (in the global namespace). Script may use the object to + // send and receive messages and is available at page load time. + // + // The page is responsible for initiating the connection. That is, + // WebMessageHostFactory::CreateHost() is called once the page posts a + // message to the JS object. + // + // |allowed_origin_rules| is a set of rules used to determine which pages + // this applies to. '*' may be used to match anything. If not '*' the format + // is 'scheme://host:port': + // . scheme: The scheme, which can not be empty or contain '*'. + // . host: The host to match against. Can not contain '/' and may start with + // '*.' to match against a specific subdomain. + // . port (optional): matches a specific port. + // + // Returns an empty string on success. On failure, the return string gives + // an error message. + virtual base::string16 AddWebMessageHostFactory( + std::unique_ptr<WebMessageHostFactory> factory, + const base::string16& js_object_name, + const std::vector<std::string>& allowed_origin_rules) = 0; + + // Removes the WebMessageHostFactory registered under |js_object_name|. + virtual void RemoveWebMessageHostFactory( + const base::string16& js_object_name) = 0; + #if !defined(OS_ANDROID) // TODO: this isn't a stable API, so use it now for expediency in the C++ API, // but if we ever want to have backward or forward compatibility in C++ this |