| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_RENDERER_CHROME_RENDER_FRAME_OBSERVER_H_ | 5 #ifndef CHROME_RENDERER_CHROME_RENDER_FRAME_OBSERVER_H_ |
| 6 #define CHROME_RENDERER_CHROME_RENDER_FRAME_OBSERVER_H_ | 6 #define CHROME_RENDERER_CHROME_RENDER_FRAME_OBSERVER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
| 10 #include "chrome/common/image_context_menu_renderer.mojom.h" | 10 #include "chrome/common/image_context_menu_renderer.mojom.h" |
| 11 #include "chrome/common/prerender_types.h" | 11 #include "chrome/common/prerender_types.h" |
| 12 #include "chrome/common/thumbnail_capturer.mojom.h" |
| 12 #include "content/public/renderer/render_frame_observer.h" | 13 #include "content/public/renderer/render_frame_observer.h" |
| 13 #include "mojo/public/cpp/bindings/binding_set.h" | 14 #include "mojo/public/cpp/bindings/binding_set.h" |
| 14 | 15 |
| 15 namespace gfx { | 16 namespace gfx { |
| 16 class Size; | 17 class Size; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace safe_browsing { | 20 namespace safe_browsing { |
| 20 class PhishingClassifierDelegate; | 21 class PhishingClassifierDelegate; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace translate { | 24 namespace translate { |
| 24 class TranslateHelper; | 25 class TranslateHelper; |
| 25 } | 26 } |
| 26 | 27 |
| 27 // This class holds the Chrome specific parts of RenderFrame, and has the same | 28 // This class holds the Chrome specific parts of RenderFrame, and has the same |
| 28 // lifetime. | 29 // lifetime. |
| 29 class ChromeRenderFrameObserver | 30 class ChromeRenderFrameObserver |
| 30 : public content::RenderFrameObserver, | 31 : public content::RenderFrameObserver, |
| 31 public chrome::mojom::ImageContextMenuRenderer { | 32 public chrome::mojom::ImageContextMenuRenderer, |
| 33 public chrome::mojom::ThumbnailCapturer { |
| 32 public: | 34 public: |
| 33 explicit ChromeRenderFrameObserver(content::RenderFrame* render_frame); | 35 explicit ChromeRenderFrameObserver(content::RenderFrame* render_frame); |
| 34 ~ChromeRenderFrameObserver() override; | 36 ~ChromeRenderFrameObserver() override; |
| 35 | 37 |
| 36 private: | 38 private: |
| 37 enum TextCaptureType { PRELIMINARY_CAPTURE, FINAL_CAPTURE }; | 39 enum TextCaptureType { PRELIMINARY_CAPTURE, FINAL_CAPTURE }; |
| 38 | 40 |
| 39 // RenderFrameObserver implementation. | 41 // RenderFrameObserver implementation. |
| 40 bool OnMessageReceived(const IPC::Message& message) override; | 42 bool OnMessageReceived(const IPC::Message& message) override; |
| 41 void DidStartProvisionalLoad(blink::WebDataSource* data_source) override; | 43 void DidStartProvisionalLoad(blink::WebDataSource* data_source) override; |
| 42 void DidFinishLoad() override; | 44 void DidFinishLoad() override; |
| 43 void DidCommitProvisionalLoad(bool is_new_navigation, | 45 void DidCommitProvisionalLoad(bool is_new_navigation, |
| 44 bool is_same_page_navigation) override; | 46 bool is_same_page_navigation) override; |
| 45 void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override; | 47 void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override; |
| 46 void OnDestruct() override; | 48 void OnDestruct() override; |
| 47 | 49 |
| 48 // chrome::mojom::ImageContextMenuRenderer: | 50 // chrome::mojom::ImageContextMenuRenderer: |
| 49 void RequestReloadImageForContextNode() override; | 51 void RequestReloadImageForContextNode() override; |
| 50 | 52 |
| 53 // chrome::mojom::ThumbnailCapturer: |
| 54 void RequestThumbnailForContextNode( |
| 55 int32_t thumbnail_min_area_pixels, |
| 56 const gfx::Size& thumbnail_max_size_pixels, |
| 57 const RequestThumbnailForContextNodeCallback& callback) override; |
| 58 |
| 51 // Mojo handlers. | 59 // Mojo handlers. |
| 52 void OnImageContextMenuRendererRequest( | 60 void OnImageContextMenuRendererRequest( |
| 53 chrome::mojom::ImageContextMenuRendererRequest request); | 61 chrome::mojom::ImageContextMenuRendererRequest request); |
| 62 void OnThumbnailCapturerRequest( |
| 63 chrome::mojom::ThumbnailCapturerRequest request); |
| 54 | 64 |
| 55 // IPC handlers | 65 // IPC handlers |
| 56 void OnSetIsPrerendering(prerender::PrerenderMode mode); | 66 void OnSetIsPrerendering(prerender::PrerenderMode mode); |
| 57 void OnRequestThumbnailForContextNode( | 67 void OnRequestThumbnailForContextNode( |
| 58 int thumbnail_min_area_pixels, | 68 int thumbnail_min_area_pixels, |
| 59 const gfx::Size& thumbnail_max_size_pixels, | 69 const gfx::Size& thumbnail_max_size_pixels, |
| 60 int callback_id); | 70 int callback_id); |
| 61 void OnPrintNodeUnderContextMenu(); | 71 void OnPrintNodeUnderContextMenu(); |
| 62 void OnSetClientSidePhishingDetection(bool enable_phishing_detection); | 72 void OnSetClientSidePhishingDetection(bool enable_phishing_detection); |
| 63 | 73 |
| 64 // Captures page information using the top (main) frame of a frame tree. | 74 // Captures page information using the top (main) frame of a frame tree. |
| 65 // Currently, this page information is just the text content of the all | 75 // Currently, this page information is just the text content of the all |
| 66 // frames, collected and concatenated until a certain limit (kMaxIndexChars) | 76 // frames, collected and concatenated until a certain limit (kMaxIndexChars) |
| 67 // is reached. | 77 // is reached. |
| 68 // TODO(dglazkov): This is incompatible with OOPIF and needs to be updated. | 78 // TODO(dglazkov): This is incompatible with OOPIF and needs to be updated. |
| 69 void CapturePageText(TextCaptureType capture_type); | 79 void CapturePageText(TextCaptureType capture_type); |
| 70 | 80 |
| 71 void CapturePageTextLater(TextCaptureType capture_type, | 81 void CapturePageTextLater(TextCaptureType capture_type, |
| 72 base::TimeDelta delay); | 82 base::TimeDelta delay); |
| 73 | 83 |
| 74 // Have the same lifetime as us. | 84 // Have the same lifetime as us. |
| 75 translate::TranslateHelper* translate_helper_; | 85 translate::TranslateHelper* translate_helper_; |
| 76 safe_browsing::PhishingClassifierDelegate* phishing_classifier_; | 86 safe_browsing::PhishingClassifierDelegate* phishing_classifier_; |
| 77 | 87 |
| 78 mojo::BindingSet<chrome::mojom::ImageContextMenuRenderer> | 88 mojo::BindingSet<chrome::mojom::ImageContextMenuRenderer> |
| 79 image_context_menu_renderer_bindings_; | 89 image_context_menu_renderer_bindings_; |
| 80 | 90 |
| 91 mojo::BindingSet<chrome::mojom::ThumbnailCapturer> |
| 92 thumbnail_capturer_bindings_; |
| 93 |
| 81 DISALLOW_COPY_AND_ASSIGN(ChromeRenderFrameObserver); | 94 DISALLOW_COPY_AND_ASSIGN(ChromeRenderFrameObserver); |
| 82 }; | 95 }; |
| 83 | 96 |
| 84 #endif // CHROME_RENDERER_CHROME_RENDER_FRAME_OBSERVER_H_ | 97 #endif // CHROME_RENDERER_CHROME_RENDER_FRAME_OBSERVER_H_ |
| OLD | NEW |