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

Side by Side Diff: components/dom_distiller/content/browser/distillability_driver.h

Issue 1883023004: Reader Mode triggers after tab crash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@distillability-mojo
Patch Set: different lifecycle Created 4 years, 8 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
« no previous file with comments | « no previous file | components/dom_distiller/content/browser/distillability_driver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_ 5 #ifndef COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_
6 #define COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_ 6 #define COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "components/dom_distiller/content/common/distillability_service.mojom.h " 10 #include "components/dom_distiller/content/common/distillability_service.mojom.h "
11 #include "content/public/browser/web_contents_observer.h" 11 #include "content/public/browser/web_contents_observer.h"
12 #include "content/public/browser/web_contents_user_data.h" 12 #include "content/public/browser/web_contents_user_data.h"
13 #include "mojo/public/cpp/bindings/strong_binding.h" 13 #include "mojo/public/cpp/bindings/strong_binding.h"
14 14
15 namespace dom_distiller { 15 namespace dom_distiller {
16 16
17 // This is an IPC helper for determining whether a page should be distilled. 17 // This is an IPC helper for determining whether a page should be distilled.
18 class DistillabilityDriver 18 class DistillabilityDriver
19 : public content::WebContentsObserver, 19 : public content::WebContentsObserver,
20 public content::WebContentsUserData<DistillabilityDriver> { 20 public content::WebContentsUserData<DistillabilityDriver> {
21 public: 21 public:
22 ~DistillabilityDriver() override; 22 ~DistillabilityDriver() override;
23 void CreateDistillabilityService( 23 void CreateDistillabilityService(
24 mojo::InterfaceRequest<DistillabilityService> request); 24 mojo::InterfaceRequest<DistillabilityService> request);
25 25
26 void SetDelegate(const base::Callback<void(bool, bool)>& delegate); 26 void SetDelegate(const base::Callback<void(bool, bool)>& delegate);
27 27
28 // content::WebContentsObserver implementation. 28 // content::WebContentsObserver implementation.
29 void RenderProcessGone(base::TerminationStatus status) override; 29 void DidStartProvisionalLoadForFrame(
30 content::RenderFrameHost* render_frame_host,
31 const GURL& validated_url,
32 bool is_error_page,
33 bool is_iframe_srcdoc) override;
30 34
31 private: 35 private:
32 explicit DistillabilityDriver(content::WebContents* web_contents); 36 explicit DistillabilityDriver(content::WebContents* web_contents);
33 friend class content::WebContentsUserData<DistillabilityDriver>; 37 friend class content::WebContentsUserData<DistillabilityDriver>;
34 friend class DistillabilityServiceImpl; 38 friend class DistillabilityServiceImpl;
35 39
40 void SetupMojoService();
36 void OnDistillability(bool distillable, bool is_last); 41 void OnDistillability(bool distillable, bool is_last);
37 42
38 // Removes the observer, clears the WebContents member, and removed mojo
39 // service from registry.
40 void CleanUp();
41
42 base::Callback<void(bool, bool)> m_delegate_; 43 base::Callback<void(bool, bool)> m_delegate_;
43 44
44 base::WeakPtrFactory<DistillabilityDriver> weak_factory_; 45 base::WeakPtrFactory<DistillabilityDriver> weak_factory_;
45 46
46 DISALLOW_COPY_AND_ASSIGN(DistillabilityDriver); 47 DISALLOW_COPY_AND_ASSIGN(DistillabilityDriver);
47 }; 48 };
48 49
49 } // namespace dom_distiller 50 } // namespace dom_distiller
50 51
51 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_ 52 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLIBILITY_DRIVER_H_
OLDNEW
« no previous file with comments | « no previous file | components/dom_distiller/content/browser/distillability_driver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698