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

Side by Side Diff: chrome/renderer/chrome_render_frame_observer.h

Issue 1398823004: Switch the page-capturing machinery to use the new hooks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
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/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/timer/timer.h" 9 #include "base/timer/timer.h"
10 #include "content/public/renderer/render_frame_observer.h" 10 #include "content/public/renderer/render_frame_observer.h"
(...skipping 28 matching lines...) Expand all
39 // Currently, this page information is just the text content of the all frames, 39 // Currently, this page information is just the text content of the all frames,
40 // collected and concatenated until a certain limit (kMaxIndexChars) is reached. 40 // collected and concatenated until a certain limit (kMaxIndexChars) is reached.
41 // TODO(dglazkov): This is incompatible with OOPIF and needs to be updated. 41 // TODO(dglazkov): This is incompatible with OOPIF and needs to be updated.
42 class PageInfo { 42 class PageInfo {
43 public: 43 public:
44 using CaptureType = PageInfoReceiver::CaptureType; 44 using CaptureType = PageInfoReceiver::CaptureType;
45 45
46 explicit PageInfo(PageInfoReceiver* context); 46 explicit PageInfo(PageInfoReceiver* context);
47 ~PageInfo() {} 47 ~PageInfo() {}
48 48
49 void CapturePageInfoLater(CaptureType capture_type, 49 // void CapturePageInfoLater(CaptureType capture_type,
50 content::RenderFrame* render_frame, 50 // content::RenderFrame* render_frame,
51 base::TimeDelta delay); 51 // base::TimeDelta delay);
52
53 private:
54 // Checks if the current frame is an error page.
55 bool IsErrorPage(blink::WebLocalFrame* frame);
56 52
57 // Captures the thumbnail and text contents for indexing for the given load 53 // Captures the thumbnail and text contents for indexing for the given load
58 // ID. Kicks off analysis of the captured text. 54 // ID. Kicks off analysis of the captured text.
59 void CapturePageInfo(content::RenderFrame* render_frame, 55 void CapturePageInfo(content::RenderFrame* render_frame,
60 CaptureType capture_type); 56 CaptureType capture_type);
61 57
58 private:
59 // Checks if the current frame is an error page.
60 bool IsErrorPage(blink::WebLocalFrame* frame);
61
62
62 // Retrieves the text from the given frame contents, the page text up to the 63 // Retrieves the text from the given frame contents, the page text up to the
63 // maximum amount kMaxIndexChars will be placed into the given buffer. 64 // maximum amount kMaxIndexChars will be placed into the given buffer.
64 void CaptureText(blink::WebLocalFrame* frame, base::string16* contents); 65 void CaptureText(blink::WebLocalFrame* frame, base::string16* contents);
65 66
66 PageInfoReceiver* context_; 67 PageInfoReceiver* context_;
67 68
68 // Used to delay calling CapturePageInfo. 69 // Used to delay calling CapturePageInfo.
69 base::Timer capture_timer_; 70 base::Timer capture_timer_;
70 71
71 DISALLOW_COPY_AND_ASSIGN(PageInfo); 72 DISALLOW_COPY_AND_ASSIGN(PageInfo);
72 }; 73 };
73 74
74 // This class holds the Chrome specific parts of RenderFrame, and has the same 75 // This class holds the Chrome specific parts of RenderFrame, and has the same
75 // lifetime. 76 // lifetime.
76 class ChromeRenderFrameObserver : public content::RenderFrameObserver, 77 class ChromeRenderFrameObserver : public content::RenderFrameObserver,
77 public PageInfoReceiver { 78 public PageInfoReceiver {
78 public: 79 public:
79 explicit ChromeRenderFrameObserver(content::RenderFrame* render_frame); 80 explicit ChromeRenderFrameObserver(content::RenderFrame* render_frame);
80 ~ChromeRenderFrameObserver() override; 81 ~ChromeRenderFrameObserver() override;
81 82
82 private: 83 private:
83 // RenderFrameObserver implementation. 84 // RenderFrameObserver implementation.
84 bool OnMessageReceived(const IPC::Message& message) override; 85 bool OnMessageReceived(const IPC::Message& message) override;
85 void DidFinishDocumentLoad() override; 86 void DidFinishDocumentLoad() override;
86 void DidStartProvisionalLoad() override; 87 void DidStartProvisionalLoad() override;
87 void DidFinishLoad() override; 88 void DidFinishLoad() override;
88 void DidCommitProvisionalLoad(bool is_new_navigation, 89 void DidCommitProvisionalLoad(bool is_new_navigation,
89 bool is_same_page_navigation) override; 90 bool is_same_page_navigation) override;
91 void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;
90 92
91 // IPC handlers 93 // IPC handlers
92 void OnSetIsPrerendering(bool is_prerendering); 94 void OnSetIsPrerendering(bool is_prerendering);
93 void OnRequestReloadImageForContextNode(); 95 void OnRequestReloadImageForContextNode();
94 void OnRequestThumbnailForContextNode( 96 void OnRequestThumbnailForContextNode(
95 int thumbnail_min_area_pixels, 97 int thumbnail_min_area_pixels,
96 const gfx::Size& thumbnail_max_size_pixels); 98 const gfx::Size& thumbnail_max_size_pixels);
97 void OnPrintNodeUnderContextMenu(); 99 void OnPrintNodeUnderContextMenu();
98 void OnSetClientSidePhishingDetection(bool enable_phishing_detection); 100 void OnSetClientSidePhishingDetection(bool enable_phishing_detection);
99 void OnAppBannerPromptRequest(int request_id, 101 void OnAppBannerPromptRequest(int request_id,
100 const std::string& platform); 102 const std::string& platform);
101 void OnAppBannerDebugMessageRequest(const std::string& message); 103 void OnAppBannerDebugMessageRequest(const std::string& message);
102 104
103 // PageInfoReceiver implementation. 105 // PageInfoReceiver implementation.
104 void PageCaptured(base::string16* content, CaptureType capture_type) override; 106 void PageCaptured(base::string16* content, CaptureType capture_type) override;
105 107
106 // Have the same lifetime as us. 108 // Have the same lifetime as us.
107 translate::TranslateHelper* translate_helper_; 109 translate::TranslateHelper* translate_helper_;
108 safe_browsing::PhishingClassifierDelegate* phishing_classifier_; 110 safe_browsing::PhishingClassifierDelegate* phishing_classifier_;
109 111
110 PageInfo page_info_; 112 PageInfo page_info_;
111 113
112 DISALLOW_COPY_AND_ASSIGN(ChromeRenderFrameObserver); 114 DISALLOW_COPY_AND_ASSIGN(ChromeRenderFrameObserver);
113 }; 115 };
114 116
115 #endif // CHROME_RENDERER_CHROME_RENDER_FRAME_OBSERVER_H_ 117 #endif // CHROME_RENDERER_CHROME_RENDER_FRAME_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698