Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Unified Diff: ios/web/web_state/ui/wk_web_view_configuration_provider.h

Issue 1048613002: Upstream ios/web/web_state/ui support classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/web/web_state/ui/wk_web_view_configuration_provider.h
diff --git a/ios/web/web_state/ui/wk_web_view_configuration_provider.h b/ios/web/web_state/ui/wk_web_view_configuration_provider.h
new file mode 100644
index 0000000000000000000000000000000000000000..e65523f6edbaed0edd7316165603095d0ea3b383
--- /dev/null
+++ b/ios/web/web_state/ui/wk_web_view_configuration_provider.h
@@ -0,0 +1,65 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_WEB_WEB_STATE_UI_WK_WEB_VIEW_CONFIGURATION_PROVIDER_H_
+#define IOS_WEB_WEB_STATE_UI_WK_WEB_VIEW_CONFIGURATION_PROVIDER_H_
+
+#include "base/mac/scoped_nsobject.h"
+#include "base/macros.h"
+#include "base/supports_user_data.h"
+
+@class CRWWKScriptMessageRouter;
+@class WKWebViewConfiguration;
+
+namespace web {
+
+class BrowserState;
+
+// A provider class associated with a single web::BrowserState object. Manages
+// the lifetime and performs setup of WKWebViewConfiguration and
+// CRWWKScriptMessageRouter instances. Not threadsafe. Must be used only on the
+// main thread.
+class WKWebViewConfigurationProvider : public base::SupportsUserData::Data {
+ public:
+ // Returns a provider for the given |browser_state|. Lazily attaches one if it
+ // does not exist. |browser_state| can not be null.
+ static web::WKWebViewConfigurationProvider& FromBrowserState(
+ web::BrowserState* browser_state);
+
+ // Returns an autoreleased copy of WKWebViewConfiguration associated with
+ // browser state. Lazily creates the config. Configuration's |preferences|
+ // will have scriptCanOpenWindowsAutomatically property set to YES.
+ // Must be used instead of [[WKWebViewConfiguration alloc] init].
+ // Callers must not retain the returned object.
+ WKWebViewConfiguration* GetWebViewConfiguration();
+
+ // Returns CRWWKScriptMessafeRouter associated with WKWebViewConfiguration.
+ // Lazily creates the router. Callers must not retain the returned object
+ // (this will be enforced in debug builds).
+ CRWWKScriptMessageRouter* GetScriptMessageRouter();
Eugene But (OOO till 7-30) 2015/03/30 05:03:58 Optional: Could you please exclude this file from
stuartmorgan 2015/03/30 14:17:57 Done.
+
+ // Returns true if this object holds a valid config. false if
+ // |GetWebViewConfiguration| was never called or configuration was purged by
+ // calling |Purge|.
+ bool HasWebViewConfiguration() const;
+
+ // Purges config and router objects if they exist. When this method is called
+ // config, config's process pool and router must not be retained by anyone
+ // (this will be enforced in debug builds). |HasWebViewConfiguration| will
+ // return false after config is purged.
+ void Purge();
+
+ private:
+ WKWebViewConfigurationProvider();
+ ~WKWebViewConfigurationProvider() override;
+
+ base::scoped_nsobject<WKWebViewConfiguration> configuration_;
+ base::scoped_nsobject<CRWWKScriptMessageRouter> router_;
+
+ DISALLOW_COPY_AND_ASSIGN(WKWebViewConfigurationProvider);
+};
+
+} // namespace web
+
+#endif // IOS_WEB_WEB_STATE_UI_WK_WEB_VIEW_CONFIGURATION_PROVIDER_H_

Powered by Google App Engine
This is Rietveld 408576698