Chromium Code Reviews| Index: ios/web_view/internal/web_view_early_page_script_provider.h |
| diff --git a/ios/web_view/internal/web_view_early_page_script_provider.h b/ios/web_view/internal/web_view_early_page_script_provider.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..97d34e64f926fc56e535587ffed34cfb6e14628c |
| --- /dev/null |
| +++ b/ios/web_view/internal/web_view_early_page_script_provider.h |
| @@ -0,0 +1,48 @@ |
| +// Copyright 2017 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_VIEW_INTERNAL_WEB_VIEW_EARLY_PAGE_SCRIPT_PROVIDER_H_ |
| +#define IOS_WEB_VIEW_INTERNAL_WEB_VIEW_EARLY_PAGE_SCRIPT_PROVIDER_H_ |
| + |
| +#include <Foundation/Foundation.h> |
| + |
| +#include "base/macros.h" |
| +#include "base/supports_user_data.h" |
| + |
| +namespace web { |
| +class BrowserState; |
| +} |
| + |
| +namespace ios_web_view { |
| + |
| +// A provider class associated with a single web::BrowserState object. Keeps |
| +// an early page script, a JavaScript injected into all pages as early as |
| +// possible. |
| +// |
| +// Not threadsafe. Must be used only on the main thread. |
| +class WebViewEarlyPageScriptProvider : public base::SupportsUserData::Data { |
| + public: |
| + ~WebViewEarlyPageScriptProvider() override; |
| + |
| + // Returns a provider for the given |browser_state|. Lazily attaches one if it |
| + // does not exist. |browser_state| can not be null. |
| + static WebViewEarlyPageScriptProvider& FromBrowserState( |
| + web::BrowserState* browser_state); |
| + |
| + // Getter and Setter for the JavaScript source code. |
| + NSString* GetScript() { return script_; } |
| + void SetScript(NSString* script) { script_ = script; } |
|
michaeldo
2017/03/21 16:12:34
Please document setter as script must be nonnull.
Eugene But (OOO till 7-30)
2017/03/21 16:47:55
script_ = [script copy];
Hiroshi Ichikawa
2017/03/22 04:52:52
Done.
Hiroshi Ichikawa
2017/03/22 04:52:52
I *documented* the requirement by adding _Nonnull
michaeldo
2017/03/22 23:03:32
I found at least one other reference to _Nonnull s
Hiroshi Ichikawa
2017/03/23 02:48:05
Acknowledged.
|
| + |
| + private: |
| + WebViewEarlyPageScriptProvider(); |
|
michaeldo
2017/03/21 16:12:34
please move to immediately after public: above
Hiroshi Ichikawa
2017/03/22 04:52:52
Shouldn't the constructor be private so that it ca
Eugene But (OOO till 7-30)
2017/03/22 15:08:50
Private constructor seems like a better choice
michaeldo
2017/03/22 23:03:32
Sorry, you're right. I didn't see why it was priva
|
| + |
| + // The JavaScript source code. |
| + NSString* script_; |
|
michaeldo
2017/03/21 16:12:34
Please use:
base::scoped_nsobject<NSString> scrip
Hiroshi Ichikawa
2017/03/22 04:52:52
Done. What is the benefit using scoped_nsobject co
michaeldo
2017/03/22 23:03:32
I mostly suggested based on style and consistency.
Hiroshi Ichikawa
2017/03/23 02:48:05
Acknowledged.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(WebViewEarlyPageScriptProvider); |
| +}; |
| + |
| +} // namespace ios_web_view |
| + |
| +#endif // IOS_WEB_VIEW_INTERNAL_WEB_VIEW_EARLY_PAGE_SCRIPT_PROVIDER_H_ |