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

Side by Side 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, 8 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 unified diff | Download patch
OLDNEW
(Empty)
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.
4
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_
7
8 #include "base/mac/scoped_nsobject.h"
9 #include "base/macros.h"
10 #include "base/supports_user_data.h"
11
12 @class CRWWKScriptMessageRouter;
13 @class WKWebViewConfiguration;
14
15 namespace web {
16
17 class BrowserState;
18
19 // A provider class associated with a single web::BrowserState object. Manages
20 // the lifetime and performs setup of WKWebViewConfiguration and
21 // CRWWKScriptMessageRouter instances. Not threadsafe. Must be used only on the
22 // main thread.
23 class WKWebViewConfigurationProvider : public base::SupportsUserData::Data {
24 public:
25 // Returns a provider for the given |browser_state|. Lazily attaches one if it
26 // does not exist. |browser_state| can not be null.
27 static web::WKWebViewConfigurationProvider& FromBrowserState(
28 web::BrowserState* browser_state);
29
30 // Returns an autoreleased copy of WKWebViewConfiguration associated with
31 // browser state. Lazily creates the config. Configuration's |preferences|
32 // will have scriptCanOpenWindowsAutomatically property set to YES.
33 // Must be used instead of [[WKWebViewConfiguration alloc] init].
34 // Callers must not retain the returned object.
35 WKWebViewConfiguration* GetWebViewConfiguration();
36
37 // Returns CRWWKScriptMessafeRouter associated with WKWebViewConfiguration.
38 // Lazily creates the router. Callers must not retain the returned object
39 // (this will be enforced in debug builds).
40 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.
41
42 // Returns true if this object holds a valid config. false if
43 // |GetWebViewConfiguration| was never called or configuration was purged by
44 // calling |Purge|.
45 bool HasWebViewConfiguration() const;
46
47 // Purges config and router objects if they exist. When this method is called
48 // config, config's process pool and router must not be retained by anyone
49 // (this will be enforced in debug builds). |HasWebViewConfiguration| will
50 // return false after config is purged.
51 void Purge();
52
53 private:
54 WKWebViewConfigurationProvider();
55 ~WKWebViewConfigurationProvider() override;
56
57 base::scoped_nsobject<WKWebViewConfiguration> configuration_;
58 base::scoped_nsobject<CRWWKScriptMessageRouter> router_;
59
60 DISALLOW_COPY_AND_ASSIGN(WKWebViewConfigurationProvider);
61 };
62
63 } // namespace web
64
65 #endif // IOS_WEB_WEB_STATE_UI_WK_WEB_VIEW_CONFIGURATION_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698