Chromium Code Reviews| 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 <memory> | |
| 9 | |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/timer/timer.h" | 11 #include "base/timer/timer.h" |
| 10 #include "chrome/common/prerender_types.h" | 12 #include "chrome/common/prerender_types.h" |
| 11 #include "content/public/renderer/render_frame_observer.h" | 13 #include "content/public/renderer/render_frame_observer.h" |
| 14 #include "mojo/public/cpp/bindings/binding.h" | |
| 15 #include "third_party/WebKit/public/platform/modules/app_banner/app_banner.mojom .h" | |
| 12 | 16 |
| 13 class GURL; | 17 class GURL; |
| 14 | 18 |
| 15 namespace gfx { | 19 namespace gfx { |
| 16 class Size; | 20 class Size; |
| 17 } | 21 } |
| 18 | 22 |
| 19 namespace safe_browsing { | 23 namespace safe_browsing { |
| 20 class PhishingClassifierDelegate; | 24 class PhishingClassifierDelegate; |
| 21 } | 25 } |
| 22 | 26 |
| 23 namespace translate { | 27 namespace translate { |
| 24 class TranslateHelper; | 28 class TranslateHelper; |
| 25 } | 29 } |
| 26 | 30 |
| 27 // This class holds the Chrome specific parts of RenderFrame, and has the same | 31 // This class holds the Chrome specific parts of RenderFrame, and has the same |
| 28 // lifetime. | 32 // lifetime. |
| 29 class ChromeRenderFrameObserver : public content::RenderFrameObserver { | 33 class ChromeRenderFrameObserver : public content::RenderFrameObserver, |
| 34 public blink::mojom::AppBannerClient { | |
| 30 public: | 35 public: |
| 36 static void BindBannerClient( | |
|
dcheng
2016/10/07 07:03:16
Nit: any reason this needs to be static?
dominickn
2016/10/13 00:18:15
Nope! Done.
| |
| 37 ChromeRenderFrameObserver* observer, | |
| 38 mojo::InterfaceRequest<blink::mojom::AppBannerClient> request); | |
| 31 explicit ChromeRenderFrameObserver(content::RenderFrame* render_frame); | 39 explicit ChromeRenderFrameObserver(content::RenderFrame* render_frame); |
| 32 ~ChromeRenderFrameObserver() override; | 40 ~ChromeRenderFrameObserver() override; |
| 33 | 41 |
| 34 private: | 42 private: |
| 35 enum TextCaptureType { PRELIMINARY_CAPTURE, FINAL_CAPTURE }; | 43 enum TextCaptureType { PRELIMINARY_CAPTURE, FINAL_CAPTURE }; |
| 36 | 44 |
| 37 // RenderFrameObserver implementation. | 45 // RenderFrameObserver implementation. |
| 38 bool OnMessageReceived(const IPC::Message& message) override; | 46 bool OnMessageReceived(const IPC::Message& message) override; |
| 39 void DidStartProvisionalLoad() override; | 47 void DidStartProvisionalLoad() override; |
| 40 void DidFinishLoad() override; | 48 void DidFinishLoad() override; |
| 41 void DidCommitProvisionalLoad(bool is_new_navigation, | 49 void DidCommitProvisionalLoad(bool is_new_navigation, |
| 42 bool is_same_page_navigation) override; | 50 bool is_same_page_navigation) override; |
| 43 void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override; | 51 void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override; |
| 44 void OnDestruct() override; | 52 void OnDestruct() override; |
| 45 | 53 |
| 46 // IPC handlers | 54 // IPC handlers |
| 47 void OnSetIsPrerendering(prerender::PrerenderMode mode); | 55 void OnSetIsPrerendering(prerender::PrerenderMode mode); |
| 48 void OnRequestReloadImageForContextNode(); | 56 void OnRequestReloadImageForContextNode(); |
| 49 void OnRequestThumbnailForContextNode( | 57 void OnRequestThumbnailForContextNode( |
| 50 int thumbnail_min_area_pixels, | 58 int thumbnail_min_area_pixels, |
| 51 const gfx::Size& thumbnail_max_size_pixels, | 59 const gfx::Size& thumbnail_max_size_pixels, |
| 52 int callback_id); | 60 int callback_id); |
| 53 void OnPrintNodeUnderContextMenu(); | 61 void OnPrintNodeUnderContextMenu(); |
| 54 void OnSetClientSidePhishingDetection(bool enable_phishing_detection); | 62 void OnSetClientSidePhishingDetection(bool enable_phishing_detection); |
| 55 void OnAppBannerPromptRequest(int request_id, | 63 |
| 56 const std::string& platform); | 64 // blink::mojom::AppBannerClient implementation. |
| 65 void BannerPromptRequest( | |
| 66 blink::mojom::AppBannerServicePtr banner_service, | |
| 67 blink::mojom::AppBannerEventRequest event_request, | |
| 68 const std::string& platform, | |
| 69 const BannerPromptRequestCallback& callback) override; | |
| 57 | 70 |
| 58 // Captures page information using the top (main) frame of a frame tree. | 71 // Captures page information using the top (main) frame of a frame tree. |
| 59 // Currently, this page information is just the text content of the all | 72 // Currently, this page information is just the text content of the all |
| 60 // frames, collected and concatenated until a certain limit (kMaxIndexChars) | 73 // frames, collected and concatenated until a certain limit (kMaxIndexChars) |
| 61 // is reached. | 74 // is reached. |
| 62 // TODO(dglazkov): This is incompatible with OOPIF and needs to be updated. | 75 // TODO(dglazkov): This is incompatible with OOPIF and needs to be updated. |
| 63 void CapturePageText(TextCaptureType capture_type); | 76 void CapturePageText(TextCaptureType capture_type); |
| 64 | 77 |
| 65 void CapturePageTextLater(TextCaptureType capture_type, | 78 void CapturePageTextLater(TextCaptureType capture_type, |
| 66 base::TimeDelta delay); | 79 base::TimeDelta delay); |
| 67 | 80 |
| 81 std::unique_ptr<mojo::Binding<blink::mojom::AppBannerClient>> banner_binding_; | |
| 82 | |
| 68 // Have the same lifetime as us. | 83 // Have the same lifetime as us. |
| 69 translate::TranslateHelper* translate_helper_; | 84 translate::TranslateHelper* translate_helper_; |
| 70 safe_browsing::PhishingClassifierDelegate* phishing_classifier_; | 85 safe_browsing::PhishingClassifierDelegate* phishing_classifier_; |
| 71 | 86 |
| 72 DISALLOW_COPY_AND_ASSIGN(ChromeRenderFrameObserver); | 87 DISALLOW_COPY_AND_ASSIGN(ChromeRenderFrameObserver); |
| 73 }; | 88 }; |
| 74 | 89 |
| 75 #endif // CHROME_RENDERER_CHROME_RENDER_FRAME_OBSERVER_H_ | 90 #endif // CHROME_RENDERER_CHROME_RENDER_FRAME_OBSERVER_H_ |
| OLD | NEW |