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
;
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
{
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 // Purges config object if it exists. When this method is called config and
36 // config's process pool must not be retained by anyone (this will be enforced
41 explicit WKWebViewConfigurationProvider(bool is_off_the_record
);
42 WKWebViewConfigurationProvider() = delete;
43 ~WKWebViewConfigurationProvider() override
;
45 base::scoped_nsobject
<WKWebViewConfiguration
> configuration_
;
46 // Result of |web::BrowserState::IsOffTheRecord| call.
47 bool is_off_the_record_
;
49 DISALLOW_COPY_AND_ASSIGN(WKWebViewConfigurationProvider
);
54 #endif // IOS_WEB_WEB_STATE_UI_WK_WEB_VIEW_CONFIGURATION_PROVIDER_H_