Chromium Code Reviews| Index: headless/public/headless_web_contents.h |
| diff --git a/headless/public/headless_web_contents.h b/headless/public/headless_web_contents.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f5b3615983988e586f31275e38480279e32bd05a |
| --- /dev/null |
| +++ b/headless/public/headless_web_contents.h |
| @@ -0,0 +1,59 @@ |
| +// Copyright 2015 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 HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ |
| +#define HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ |
| + |
| +#include "base/callback.h" |
| +#include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "headless/public/headless_export.h" |
| +#include "url/gurl.h" |
| + |
| +namespace headless { |
| + |
| +// Class representing contents of a browser tab. Should be accessed from browser |
| +// main thread. |
| +class HEADLESS_EXPORT HeadlessWebContents { |
| + public: |
| + virtual ~HeadlessWebContents() {} |
| + |
| + // TODO(skyostil): Replace this with an equivalent client API. |
| + class Observer { |
| + public: |
| + // Will be called on browser thread. |
| + virtual void DocumentOnLoadCompletedInMainFrame() = 0; |
| + |
| + protected: |
| + // Use this constructor when the observer's lifetime matches that of the |
| + // HeadlessWebContents. |
| + explicit Observer(HeadlessWebContents* web_contents); |
|
Ryan Sleevi
2016/02/22 22:01:22
This seems like it violates the SingleResponsibili
Sami
2016/02/23 20:19:08
This was modeled after WebContentsObserver which h
|
| + |
| + // This constructor creates a detached observer. Use Observe() to attach it |
| + // to a HeadlessWebContents instance. |
| + Observer(); |
| + virtual ~Observer(); |
| + |
| + void Observe(HeadlessWebContents* web_contents); |
| + |
| + private: |
| + class ObserverImpl; |
| + scoped_ptr<ObserverImpl> observer_impl_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(Observer); |
| + }; |
| + |
| + // TODO(skyostil): Replace this with an equivalent client API. |
| + virtual void OpenURL(const GURL& url) = 0; |
| + |
| + private: |
| + friend class HeadlessWebContentsImpl; |
| + HeadlessWebContents() {} |
| + |
| + DISALLOW_COPY_AND_ASSIGN(HeadlessWebContents); |
| +}; |
| + |
| +} // namespace headless |
| + |
| +#endif // HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ |