| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SCOPED_WEB_FRAME_H_ | 5 #ifndef SCOPED_WEB_FRAME_H_ |
| 6 #define SCOPED_WEB_FRAME_H_ | 6 #define SCOPED_WEB_FRAME_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "third_party/WebKit/public/web/WebFrameClient.h" | |
| 10 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 9 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 11 #include "third_party/WebKit/public/web/WebView.h" | 10 #include "third_party/WebKit/public/web/WebView.h" |
| 12 | 11 |
| 13 namespace extensions { | 12 namespace extensions { |
| 14 | 13 |
| 15 // ScopedWebFrame is a class to create a dummy webview and frame for testing. | 14 // 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. | 15 // The dymmy webview and frame will be destructed when the scope exits. |
| 17 class ScopedWebFrame { | 16 class ScopedWebFrame { |
| 18 public: | 17 public: |
| 19 ScopedWebFrame(); | 18 ScopedWebFrame(); |
| 20 ~ScopedWebFrame(); | 19 ~ScopedWebFrame(); |
| 21 | 20 |
| 22 blink::WebLocalFrame* frame() { return frame_; } | 21 blink::WebLocalFrame* frame() { return frame_; } |
| 23 | 22 |
| 24 private: | 23 private: |
| 25 blink::WebFrameClient frame_client_; | 24 // The webview and the frame are kept alive by the ScopedWebFrame |
| 26 | 25 // because they are not destructed unless ~ScopedWebFrame explicitly |
| 27 // The webview and the frame are kept alive by the ScopedWebFrame | 26 // closes the webview and the frame. |
| 28 // because they are not destructed unless ~ScopedWebFrame explicitly | 27 blink::WebView* view_; |
| 29 // closes the WebView. | 28 blink::WebLocalFrame* frame_; |
| 30 blink::WebView* view_; | 29 DISALLOW_COPY_AND_ASSIGN(ScopedWebFrame); |
| 31 blink::WebLocalFrame* frame_; | |
| 32 | |
| 33 DISALLOW_COPY_AND_ASSIGN(ScopedWebFrame); | |
| 34 }; | 30 }; |
| 35 | 31 |
| 36 } // namespace extensions | 32 } // namespace extensions |
| 37 | 33 |
| 38 #endif // SCOPED_WEB_FRAME_H_ | 34 #endif // SCOPED_WEB_FRAME_H_ |
| OLD | NEW |