haraken | 1156707 | 2015-06-26 02:03:07 | [diff] [blame] | 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 | |
michaelpg | 0083fc8 | 2017-01-18 22:15:19 | [diff] [blame] | 5 | #ifndef EXTENSIONS_RENDERER_SCOPED_WEB_FRAME_H_ |
| 6 | #define EXTENSIONS_RENDERER_SCOPED_WEB_FRAME_H_ |
haraken | 1156707 | 2015-06-26 02:03:07 | [diff] [blame] | 7 | |
avi | 2d124c0 | 2015-12-23 06:36:42 | [diff] [blame] | 8 | #include "base/macros.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 9 | #include "third_party/blink/public/web/web_local_frame.h" |
Mustaq Ahmed | 55944cb | 2018-05-25 20:44:27 | [diff] [blame] | 10 | #include "third_party/blink/public/web/web_local_frame_client.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 11 | #include "third_party/blink/public/web/web_view.h" |
haraken | 1156707 | 2015-06-26 02:03:07 | [diff] [blame] | 12 | |
| 13 | namespace extensions { |
| 14 | |
| 15 | // ScopedWebFrame is a class to create a dummy webview and frame for testing. |
| 16 | // The dymmy webview and frame will be destructed when the scope exits. |
| 17 | class ScopedWebFrame { |
| 18 | public: |
| 19 | ScopedWebFrame(); |
| 20 | ~ScopedWebFrame(); |
| 21 | |
| 22 | blink::WebLocalFrame* frame() { return frame_; } |
| 23 | |
| 24 | private: |
Mustaq Ahmed | 55944cb | 2018-05-25 20:44:27 | [diff] [blame] | 25 | blink::WebLocalFrameClient frame_client_; |
dcheng | 9f8e2f6 | 2016-09-29 15:54:50 | [diff] [blame] | 26 | |
| 27 | // The webview and the frame are kept alive by the ScopedWebFrame |
| 28 | // because they are not destructed unless ~ScopedWebFrame explicitly |
| 29 | // closes the WebView. |
| 30 | blink::WebView* view_; |
| 31 | blink::WebLocalFrame* frame_; |
| 32 | |
| 33 | DISALLOW_COPY_AND_ASSIGN(ScopedWebFrame); |
haraken | 1156707 | 2015-06-26 02:03:07 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | } // namespace extensions |
| 37 | |
michaelpg | 0083fc8 | 2017-01-18 22:15:19 | [diff] [blame] | 38 | #endif // EXTENSIONS_RENDERER_SCOPED_WEB_FRAME_H_ |