summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/chrome_render_view_observer.h
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-16 02:08:42 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-16 02:08:42 +0000
commit38b592904f582daacd833b767b3cce3d1c211068 (patch)
treea91ae9b6694153f8f017778e56f67797fc2a136d /chrome/renderer/chrome_render_view_observer.h
parent4766a6019405334b45222b48560aeda994a0e8e8 (diff)
downloadchromium_src-38b592904f582daacd833b767b3cce3d1c211068.zip
chromium_src-38b592904f582daacd833b767b3cce3d1c211068.tar.gz
chromium_src-38b592904f582daacd833b767b3cce3d1c211068.tar.bz2
Clear RenderThread of any Chrome specific code, and move a bunch of stuff out of RenderView.
Took out CookieMessageFilter since it's not used anymore. Removed RenderProcessTest and RendererMainTest since they really weren't testing much. Review URL: http://codereview.chromium.org/6873014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81851 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/chrome_render_view_observer.h')
-rw-r--r--chrome/renderer/chrome_render_view_observer.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/chrome/renderer/chrome_render_view_observer.h b/chrome/renderer/chrome_render_view_observer.h
new file mode 100644
index 0000000..038753b
--- /dev/null
+++ b/chrome/renderer/chrome_render_view_observer.h
@@ -0,0 +1,82 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_RENDERER_CHROME_RENDER_VIEW_OBSERVER_H_
+#define CHROME_RENDERER_CHROME_RENDER_VIEW_OBSERVER_H_
+#pragma once
+
+#include "base/task.h"
+#include "content/renderer/render_view_observer.h"
+
+class SkBitmap;
+class TranslateHelper;
+struct ThumbnailScore;
+struct ViewMsg_Navigate_Params;
+
+namespace WebKit {
+class WebView;
+}
+
+namespace safe_browsing {
+class PhishingClassifierDelegate;
+}
+
+// This class holds the Chrome specific parts of RenderView, and has the same
+// lifetime.
+class ChromeRenderViewObserver : public RenderViewObserver {
+ public:
+ // translate_helper and/or phishing_classifier can be NULL.
+ ChromeRenderViewObserver(
+ RenderView* render_view,
+ TranslateHelper* translate_helper,
+ safe_browsing::PhishingClassifierDelegate* phishing_classifier);
+ virtual ~ChromeRenderViewObserver();
+
+ private:
+ // RenderViewObserver implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+ virtual void DidStopLoading() OVERRIDE;
+ virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame,
+ bool is_new_navigation) OVERRIDE;
+
+ void OnCaptureSnapshot();
+ void OnNavigate(const ViewMsg_Navigate_Params& params);
+
+ // Captures the thumbnail and text contents for indexing for the given load
+ // ID. If the view's load ID is different than the parameter, this call is
+ // a NOP. Typically called on a timer, so the load ID may have changed in the
+ // meantime.
+ void CapturePageInfo(int load_id, bool preliminary_capture);
+
+ // Retrieves the text from the given frame contents, the page text up to the
+ // maximum amount kMaxIndexChars will be placed into the given buffer.
+ void CaptureText(WebKit::WebFrame* frame, string16* contents);
+
+ void CaptureThumbnail();
+
+ // Creates a thumbnail of |frame|'s contents resized to (|w|, |h|)
+ // and puts that in |thumbnail|. Thumbnail metadata goes in |score|.
+ bool CaptureFrameThumbnail(WebKit::WebView* view, int w, int h,
+ SkBitmap* thumbnail,
+ ThumbnailScore* score);
+
+ // Capture a snapshot of a view. This is used to allow an extension
+ // to get a snapshot of a tab using chrome.tabs.captureVisibleTab().
+ bool CaptureSnapshot(WebKit::WebView* view, SkBitmap* snapshot);
+
+ // Has the same lifetime as us.
+ TranslateHelper* translate_helper_;
+ safe_browsing::PhishingClassifierDelegate* phishing_classifier_;
+
+ // Page_id from the last page we indexed. This prevents us from indexing the
+ // same page twice in a row.
+ int32 last_indexed_page_id_;
+
+ ScopedRunnableMethodFactory<ChromeRenderViewObserver>
+ page_info_method_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeRenderViewObserver);
+};
+
+#endif // CHROME_RENDERER_CHROME_RENDER_VIEW_OBSERVER_H_