OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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 | |
5 #include "components/dom_distiller/content/web_contents_main_frame_observer.h" | |
6 | |
7 #include "content/public/browser/navigation_details.h" | |
8 #include "content/public/browser/render_frame_host.h" | |
9 #include "content/public/browser/web_contents.h" | |
10 #include "content/public/browser/web_contents_observer.h" | |
11 #include "content/public/browser/web_contents_user_data.h" | |
12 | |
13 DEFINE_WEB_CONTENTS_USER_DATA_KEY(dom_distiller::WebContentsMainFrameObserver); | |
14 | |
15 namespace dom_distiller { | |
16 | |
17 WebContentsMainFrameObserver::WebContentsMainFrameObserver( | |
18 content::WebContents* web_contents) | |
19 : is_document_loaded_in_main_frame_(false), | |
20 is_initialized_(false), | |
21 web_contents_(web_contents) { | |
22 content::WebContentsObserver::Observe(web_contents); | |
23 } | |
24 | |
25 WebContentsMainFrameObserver::~WebContentsMainFrameObserver() { | |
26 } | |
Yaron
2014/05/22 18:25:02
Call CleanUp to be safe? (i.e. if you're deleted,
nyquist
2014/05/22 23:00:54
Done.
| |
27 | |
28 void WebContentsMainFrameObserver::DocumentLoadedInFrame( | |
29 int64 frame_id, | |
30 content::RenderViewHost* render_view_host) { | |
31 if (web_contents_ && | |
32 frame_id == web_contents_->GetMainFrame()->GetRoutingID()) { | |
33 is_document_loaded_in_main_frame_ = true; | |
34 } | |
35 } | |
36 | |
37 void WebContentsMainFrameObserver::DidNavigateMainFrame( | |
38 const content::LoadCommittedDetails& details, | |
39 const content::FrameNavigateParams& params) { | |
40 if (details.is_main_frame) { | |
41 is_document_loaded_in_main_frame_ = false; | |
42 is_initialized_ = true; | |
43 } | |
44 } | |
45 | |
46 void WebContentsMainFrameObserver::RenderProcessGone( | |
47 base::TerminationStatus status) { | |
48 CleanUp(); | |
49 } | |
50 | |
51 void WebContentsMainFrameObserver::WebContentsDestroyed() { | |
52 CleanUp(); | |
53 } | |
54 | |
55 void WebContentsMainFrameObserver::CleanUp() { | |
56 content::WebContentsObserver::Observe(NULL); | |
57 web_contents_ = NULL; | |
58 } | |
59 | |
60 } // namespace dom_distiller | |
OLD | NEW |