| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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 CHROME_RENDERER_CHROME_RENDER_OBSERVER_H_ | |
| 6 #define CHROME_RENDERER_CHROME_RENDER_OBSERVER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/task.h" | |
| 10 #include "content/renderer/render_view_observer.h" | |
| 11 | |
| 12 class SkBitmap; | |
| 13 class TranslateHelper; | |
| 14 struct ThumbnailScore; | |
| 15 | |
| 16 namespace WebKit { | |
| 17 class WebView; | |
| 18 } | |
| 19 | |
| 20 namespace safe_browsing { | |
| 21 class PhishingClassifierDelegate; | |
| 22 } | |
| 23 | |
| 24 // This class holds the Chrome specific parts of RenderView, and has the same | |
| 25 // lifetime. | |
| 26 class ChromeRenderObserver : public RenderViewObserver { | |
| 27 public: | |
| 28 // translate_helper and/or phishing_classifier can be NULL. | |
| 29 ChromeRenderObserver( | |
| 30 RenderView* render_view, | |
| 31 TranslateHelper* translate_helper, | |
| 32 safe_browsing::PhishingClassifierDelegate* phishing_classifier); | |
| 33 virtual ~ChromeRenderObserver(); | |
| 34 | |
| 35 private: | |
| 36 // RenderViewObserver implementation. | |
| 37 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
| 38 virtual void DidStopLoading() OVERRIDE; | |
| 39 virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame, | |
| 40 bool is_new_navigation) OVERRIDE; | |
| 41 | |
| 42 void OnCaptureSnapshot(); | |
| 43 | |
| 44 // Captures the thumbnail and text contents for indexing for the given load | |
| 45 // ID. If the view's load ID is different than the parameter, this call is | |
| 46 // a NOP. Typically called on a timer, so the load ID may have changed in the | |
| 47 // meantime. | |
| 48 void CapturePageInfo(int load_id, bool preliminary_capture); | |
| 49 | |
| 50 // Retrieves the text from the given frame contents, the page text up to the | |
| 51 // maximum amount kMaxIndexChars will be placed into the given buffer. | |
| 52 void CaptureText(WebKit::WebFrame* frame, string16* contents); | |
| 53 | |
| 54 void CaptureThumbnail(); | |
| 55 | |
| 56 // Creates a thumbnail of |frame|'s contents resized to (|w|, |h|) | |
| 57 // and puts that in |thumbnail|. Thumbnail metadata goes in |score|. | |
| 58 bool CaptureFrameThumbnail(WebKit::WebView* view, int w, int h, | |
| 59 SkBitmap* thumbnail, | |
| 60 ThumbnailScore* score); | |
| 61 | |
| 62 // Capture a snapshot of a view. This is used to allow an extension | |
| 63 // to get a snapshot of a tab using chrome.tabs.captureVisibleTab(). | |
| 64 bool CaptureSnapshot(WebKit::WebView* view, SkBitmap* snapshot); | |
| 65 | |
| 66 // Has the same lifetime as us. | |
| 67 TranslateHelper* translate_helper_; | |
| 68 safe_browsing::PhishingClassifierDelegate* phishing_classifier_; | |
| 69 | |
| 70 // Page_id from the last page we indexed. This prevents us from indexing the | |
| 71 // same page twice in a row. | |
| 72 int32 last_indexed_page_id_; | |
| 73 | |
| 74 ScopedRunnableMethodFactory<ChromeRenderObserver> page_info_method_factory_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(ChromeRenderObserver); | |
| 77 }; | |
| 78 | |
| 79 #endif // CHROME_RENDERER_CHROME_OBSERVER_H_ | |
| OLD | NEW |