NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / renderer / chrome_render_view_observer.h
bloba2e7f689f89ebfe9d575981ddff643b2d1cfc56c
1 // Copyright (c) 2012 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.
5 #ifndef CHROME_RENDERER_CHROME_RENDER_VIEW_OBSERVER_H_
6 #define CHROME_RENDERER_CHROME_RENDER_VIEW_OBSERVER_H_
8 #include <set>
9 #include <string>
10 #include <vector>
12 #include "base/basictypes.h"
13 #include "base/memory/linked_ptr.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/timer/timer.h"
16 #include "content/public/common/top_controls_state.h"
17 #include "content/public/renderer/render_view_observer.h"
18 #include "ui/gfx/size.h"
19 #include "url/gurl.h"
21 class ChromeRenderProcessObserver;
22 class ContentSettingsObserver;
23 class SkBitmap;
24 class TranslateHelper;
25 class WebViewColorOverlay;
26 class WebViewAnimatingOverlay;
28 namespace blink {
29 class WebView;
30 struct WebWindowFeatures;
33 namespace safe_browsing {
34 class PhishingClassifierDelegate;
37 // This class holds the Chrome specific parts of RenderView, and has the same
38 // lifetime.
39 class ChromeRenderViewObserver : public content::RenderViewObserver {
40 public:
41 // translate_helper can be NULL.
42 ChromeRenderViewObserver(
43 content::RenderView* render_view,
44 ChromeRenderProcessObserver* chrome_render_process_observer);
45 virtual ~ChromeRenderViewObserver();
47 private:
48 // Holds the information received in OnWebUIJavaScript for later use
49 // to call EvaluateScript() to preload javascript for WebUI tests.
50 struct WebUIJavaScript {
51 base::string16 frame_xpath;
52 base::string16 jscript;
53 int id;
54 bool notify_result;
57 // RenderViewObserver implementation.
58 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
59 virtual void DidStartLoading() OVERRIDE;
60 virtual void DidStopLoading() OVERRIDE;
61 virtual void DidCommitProvisionalLoad(blink::WebFrame* frame,
62 bool is_new_navigation) OVERRIDE;
63 virtual void DetailedConsoleMessageAdded(const base::string16& message,
64 const base::string16& source,
65 const base::string16& stack_trace,
66 int32 line_number,
67 int32 severity_level) OVERRIDE;
68 virtual void Navigate(const GURL& url) OVERRIDE;
70 void OnWebUIJavaScript(const base::string16& frame_xpath,
71 const base::string16& jscript,
72 int id,
73 bool notify_result);
74 void OnJavaScriptStressTestControl(int cmd, int param);
75 void OnSetClientSidePhishingDetection(bool enable_phishing_detection);
76 void OnSetVisuallyDeemphasized(bool deemphasized);
77 void OnRequestThumbnailForContextNode(int thumbnail_min_area_pixels,
78 gfx::Size thumbnail_max_size_pixels);
79 void OnGetFPS();
80 #if defined(OS_ANDROID)
81 void OnUpdateTopControlsState(content::TopControlsState constraints,
82 content::TopControlsState current,
83 bool animate);
84 void OnRetrieveWebappInformation(const GURL& expected_url);
85 void OnRetrieveMetaTagContent(const GURL& expected_url,
86 const std::string tag_name);
87 #endif
88 void OnSetWindowFeatures(const blink::WebWindowFeatures& window_features);
90 void CapturePageInfoLater(int page_id,
91 bool preliminary_capture,
92 base::TimeDelta delay);
94 // Captures the thumbnail and text contents for indexing for the given load
95 // ID. Kicks off analysis of the captured text.
96 void CapturePageInfo(int page_id, bool preliminary_capture);
98 // Retrieves the text from the given frame contents, the page text up to the
99 // maximum amount kMaxIndexChars will be placed into the given buffer.
100 void CaptureText(blink::WebFrame* frame, base::string16* contents);
102 // Determines if a host is in the strict security host set.
103 bool IsStrictSecurityHost(const std::string& host);
105 // Checks if a page contains <meta http-equiv="refresh" ...> tag.
106 bool HasRefreshMetaTag(blink::WebFrame* frame);
108 // Save the JavaScript to preload if a ViewMsg_WebUIJavaScript is received.
109 scoped_ptr<WebUIJavaScript> webui_javascript_;
111 // Owned by ChromeContentRendererClient and outlive us.
112 ChromeRenderProcessObserver* chrome_render_process_observer_;
114 // Have the same lifetime as us.
115 TranslateHelper* translate_helper_;
116 safe_browsing::PhishingClassifierDelegate* phishing_classifier_;
118 // Page_id from the last page we indexed. This prevents us from indexing the
119 // same page twice in a row.
120 int32 last_indexed_page_id_;
121 // The toplevel URL that was last indexed. This is used together with the
122 // page id to decide whether to reindex in certain cases like history
123 // replacement.
124 GURL last_indexed_url_;
126 // A color page overlay when visually de-emaphasized.
127 scoped_ptr<WebViewColorOverlay> dimmed_color_overlay_;
129 // Used to delay calling CapturePageInfo.
130 base::Timer capture_timer_;
132 DISALLOW_COPY_AND_ASSIGN(ChromeRenderViewObserver);
135 #endif // CHROME_RENDERER_CHROME_RENDER_VIEW_OBSERVER_H_