Add ICU message format support
[chromium-blink-merge.git] / ios / web / web_state / ui / wk_web_view_configuration_provider.h
blobcd243cd49f62872e055d5464ef903e856b71ee67
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_WEB_STATE_UI_WK_WEB_VIEW_CONFIGURATION_PROVIDER_H_
6 #define IOS_WEB_WEB_STATE_UI_WK_WEB_VIEW_CONFIGURATION_PROVIDER_H_
8 #include "base/mac/scoped_nsobject.h"
9 #include "base/macros.h"
10 #include "base/supports_user_data.h"
12 @class WKWebViewConfiguration;
14 namespace web {
16 class BrowserState;
18 // A provider class associated with a single web::BrowserState object. Manages
19 // the lifetime and performs setup of WKWebViewConfiguration instance.
20 // Not threadsafe. Must be used only on the main thread.
21 class WKWebViewConfigurationProvider : public base::SupportsUserData::Data {
22 public:
23 // Returns a provider for the given |browser_state|. Lazily attaches one if it
24 // does not exist. |browser_state| can not be null.
25 static web::WKWebViewConfigurationProvider& FromBrowserState(
26 web::BrowserState* browser_state);
28 // Returns an autoreleased copy of WKWebViewConfiguration associated with
29 // browser state. Lazily creates the config. Configuration's |preferences|
30 // will have scriptCanOpenWindowsAutomatically property set to YES.
31 // Must be used instead of [[WKWebViewConfiguration alloc] init].
32 // Callers must not retain the returned object.
33 WKWebViewConfiguration* GetWebViewConfiguration();
35 // Returns true if this object holds a valid config. false if
36 // |GetWebViewConfiguration| was never called or configuration was purged by
37 // calling |Purge|.
38 bool HasWebViewConfiguration() const;
40 // Purges config object if it exists. When this method is called config and
41 // config's process pool must not be retained by anyone (this will be enforced
42 // in debug builds). |HasWebViewConfiguration| will return false after config
43 // is purged.
44 void Purge();
46 private:
47 WKWebViewConfigurationProvider();
48 ~WKWebViewConfigurationProvider() override;
50 base::scoped_nsobject<WKWebViewConfiguration> configuration_;
52 DISALLOW_COPY_AND_ASSIGN(WKWebViewConfigurationProvider);
55 } // namespace web
57 #endif // IOS_WEB_WEB_STATE_UI_WK_WEB_VIEW_CONFIGURATION_PROVIDER_H_