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

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

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 #ifndef COMPONENTS_DOM_DISTILLER_CONTENT_INJECTION_WEB_CONTENTS_OBSERVER_H_
Yaron 2014/05/16 02:02:49 nit: update
nyquist 2014/05/20 19:58:37 Done.
6 #define COMPONENTS_DOM_DISTILLER_CONTENT_INJECTION_WEB_CONTENTS_OBSERVER_H_
7
8 #include "content/public/browser/web_contents.h"
9 #include "content/public/browser/web_contents_observer.h"
10 #include "content/public/browser/web_contents_user_data.h"
11
12 namespace dom_distiller {
13
14 // Tracks whether DocumentLoadedInFrame has been called for the main frame for
15 // the current main frame for the given WebContents. It removes itself as an
16 // observer if the WebContents is destroyed or the render process is gone.
17 class WebContentsMainFrameObserver
18 : public content::WebContentsObserver,
19 public content::WebContentsUserData<WebContentsMainFrameObserver> {
20 public:
21 virtual ~WebContentsMainFrameObserver();
22
23 bool is_document_loaded_in_main_frame() {
24 return is_document_loaded_in_main_frame_;
25 }
26
27 bool is_initialized() {
28 return is_initialized_;
29 }
30
31 // content::WebContentsObserver implementation.
32 virtual void DocumentLoadedInFrame(
33 int64 frame_id,
34 content::RenderViewHost* render_view_host) OVERRIDE;
35 virtual void DidNavigateMainFrame(
36 const content::LoadCommittedDetails& details,
37 const content::FrameNavigateParams& params) OVERRIDE;
38 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
39 virtual void WebContentsDestroyed() OVERRIDE;
40
41 private:
42 explicit WebContentsMainFrameObserver(content::WebContents* web_contents);
43 friend class content::WebContentsUserData<WebContentsMainFrameObserver>;
44
45 // Removes the observer and clears the WebContents member.
46 void CleanUp();
47
48 // Whether DocumentLoadedInFrame has been called for the tracked WebContents
49 // for the current main frame. This is cleared when the main frame navigates,
50 // and set again when DocumentLoadedInFrame is called for the main frame.
51 bool is_document_loaded_in_main_frame_;
52
53 // Whether this object has been correctly initialized. This is set as soon as
54 // at least one call to DidNavigateMainFrame has happened.
55 bool is_initialized_;
56
57 // The WebContents this class is tracking.
58 content::WebContents* web_contents_;
59
60 DISALLOW_COPY_AND_ASSIGN(WebContentsMainFrameObserver);
61 };
62
63 } // namespace dom_distiller
64
65 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_INJECTION_WEB_CONTENTS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698