blob: f4f4533a8539db613a761956327108bd86fb45ee [file] [log] [blame]
haraken11567072015-06-26 02:03:071// 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
michaelpg0083fc82017-01-18 22:15:195#ifndef EXTENSIONS_RENDERER_SCOPED_WEB_FRAME_H_
6#define EXTENSIONS_RENDERER_SCOPED_WEB_FRAME_H_
haraken11567072015-06-26 02:03:077
avi2d124c02015-12-23 06:36:428#include "base/macros.h"
Blink Reformata30d4232018-04-07 15:31:069#include "third_party/blink/public/web/web_local_frame.h"
Mustaq Ahmed55944cb2018-05-25 20:44:2710#include "third_party/blink/public/web/web_local_frame_client.h"
Blink Reformata30d4232018-04-07 15:31:0611#include "third_party/blink/public/web/web_view.h"
haraken11567072015-06-26 02:03:0712
13namespace 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.
17class ScopedWebFrame {
18public:
19 ScopedWebFrame();
20 ~ScopedWebFrame();
21
22 blink::WebLocalFrame* frame() { return frame_; }
23
24private:
Mustaq Ahmed55944cb2018-05-25 20:44:2725 blink::WebLocalFrameClient frame_client_;
dcheng9f8e2f62016-09-29 15:54:5026
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);
haraken11567072015-06-26 02:03:0734};
35
36} // namespace extensions
37
michaelpg0083fc82017-01-18 22:15:1938#endif // EXTENSIONS_RENDERER_SCOPED_WEB_FRAME_H_