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 #include "headless/lib/browser/headless_web_contents_impl.h" | 5 #include "headless/lib/browser/headless_web_contents_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "content/public/browser/navigation_handle.h" |
10 #include "content/public/browser/render_frame_host.h" | 11 #include "content/public/browser/render_frame_host.h" |
11 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
12 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
13 #include "content/public/browser/render_widget_host_view.h" | 14 #include "content/public/browser/render_widget_host_view.h" |
14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
15 #include "content/public/browser/web_contents_delegate.h" | 16 #include "content/public/browser/web_contents_delegate.h" |
16 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
17 #include "content/public/common/bindings_policy.h" | 18 #include "content/public/common/bindings_policy.h" |
18 #include "content/public/common/service_registry.h" | 19 #include "content/public/common/service_registry.h" |
19 #include "content/public/renderer/render_frame.h" | 20 #include "content/public/renderer/render_frame.h" |
20 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
21 | 22 |
22 namespace headless { | 23 namespace headless { |
23 | 24 |
24 class WebContentsObserverAdapter : public content::WebContentsObserver { | 25 class WebContentsObserverAdapter : public content::WebContentsObserver { |
25 public: | 26 public: |
26 WebContentsObserverAdapter(content::WebContents* web_contents, | 27 WebContentsObserverAdapter(content::WebContents* web_contents, |
27 HeadlessWebContents::Observer* observer) | 28 HeadlessWebContents::Observer* observer) |
28 : content::WebContentsObserver(web_contents), observer_(observer) {} | 29 : content::WebContentsObserver(web_contents), observer_(observer) {} |
29 | 30 |
30 ~WebContentsObserverAdapter() override {} | 31 ~WebContentsObserverAdapter() override {} |
31 | 32 |
32 void DocumentOnLoadCompletedInMainFrame() override { | 33 void DocumentOnLoadCompletedInMainFrame() override { |
33 observer_->DocumentOnLoadCompletedInMainFrame(); | 34 observer_->DocumentOnLoadCompletedInMainFrame(); |
34 } | 35 } |
35 | 36 |
| 37 void DidFinishNavigation( |
| 38 content::NavigationHandle* navigation_handle) override { |
| 39 observer_->DidFinishNavigation(navigation_handle->HasCommitted() && |
| 40 !navigation_handle->IsErrorPage()); |
| 41 } |
| 42 |
36 private: | 43 private: |
37 HeadlessWebContents::Observer* observer_; // Not owned. | 44 HeadlessWebContents::Observer* observer_; // Not owned. |
38 | 45 |
39 DISALLOW_COPY_AND_ASSIGN(WebContentsObserverAdapter); | 46 DISALLOW_COPY_AND_ASSIGN(WebContentsObserverAdapter); |
40 }; | 47 }; |
41 | 48 |
42 class HeadlessWebContentsImpl::Delegate : public content::WebContentsDelegate { | 49 class HeadlessWebContentsImpl::Delegate : public content::WebContentsDelegate { |
43 public: | 50 public: |
44 Delegate() {} | 51 Delegate() {} |
45 | 52 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 ObserverMap::iterator it = observer_map_.find(observer); | 102 ObserverMap::iterator it = observer_map_.find(observer); |
96 DCHECK(it != observer_map_.end()); | 103 DCHECK(it != observer_map_.end()); |
97 observer_map_.erase(it); | 104 observer_map_.erase(it); |
98 } | 105 } |
99 | 106 |
100 content::WebContents* HeadlessWebContentsImpl::web_contents() const { | 107 content::WebContents* HeadlessWebContentsImpl::web_contents() const { |
101 return web_contents_.get(); | 108 return web_contents_.get(); |
102 } | 109 } |
103 | 110 |
104 } // namespace headless | 111 } // namespace headless |
OLD | NEW |