Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(606)

Side by Side Diff: components/dom_distiller/content/web_contents_main_frame_observer.cc

Issue 266073003: Add support for distilling current WebContents (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added comment Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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), web_contents_(web_contents) {
20 content::WebContentsObserver::Observe(web_contents);
21 }
22
23 WebContentsMainFrameObserver::~WebContentsMainFrameObserver() {
24 }
25
26 void WebContentsMainFrameObserver::DocumentLoadedInFrame(
27 int64 frame_id,
28 content::RenderViewHost* render_view_host) {
29 if (web_contents_ &&
30 frame_id == web_contents_->GetMainFrame()->GetRoutingID()) {
31 is_document_loaded_in_main_frame_ = true;
32 }
33 }
34
35 void WebContentsMainFrameObserver::DidNavigateMainFrame(
36 const content::LoadCommittedDetails& details,
37 const content::FrameNavigateParams& params) {
38 if (details.is_main_frame) {
39 is_document_loaded_in_main_frame_ = false;
40 is_initialized_ = true;
41 }
42 }
43
44 void WebContentsMainFrameObserver::RenderProcessGone(
45 base::TerminationStatus status) {
46 CleanUp();
47 }
48
49 void WebContentsMainFrameObserver::WebContentsDestroyed() {
50 CleanUp();
51 }
52
53 void WebContentsMainFrameObserver::CleanUp() {
54 content::WebContentsObserver::Observe(NULL);
55 web_contents_ = NULL;
56 }
57
58 } // namespace dom_distiller
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698