Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / components / dom_distiller / content / browser / web_contents_main_frame_observer.cc
blob51fd6906c221b9a860cd5f49b104d06bfaf1729d
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.
5 #include "components/dom_distiller/content/browser/web_contents_main_frame_observer.h"
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"
13 DEFINE_WEB_CONTENTS_USER_DATA_KEY(dom_distiller::WebContentsMainFrameObserver);
15 namespace dom_distiller {
17 WebContentsMainFrameObserver::WebContentsMainFrameObserver(
18 content::WebContents* web_contents)
19 : is_document_loaded_in_main_frame_(false), is_initialized_(false) {
20 content::WebContentsObserver::Observe(web_contents);
23 WebContentsMainFrameObserver::~WebContentsMainFrameObserver() {
24 CleanUp();
27 void WebContentsMainFrameObserver::DocumentLoadedInFrame(
28 content::RenderFrameHost* render_frame_host) {
29 if (!render_frame_host->GetParent()) {
30 is_document_loaded_in_main_frame_ = true;
34 void WebContentsMainFrameObserver::DidNavigateMainFrame(
35 const content::LoadCommittedDetails& details,
36 const content::FrameNavigateParams& params) {
37 if (details.is_navigation_to_different_page()) {
38 is_document_loaded_in_main_frame_ = false;
39 is_initialized_ = true;
43 void WebContentsMainFrameObserver::RenderProcessGone(
44 base::TerminationStatus status) {
45 CleanUp();
48 void WebContentsMainFrameObserver::CleanUp() {
49 content::WebContentsObserver::Observe(NULL);
52 } // namespace dom_distiller