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_
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"
21 class ChromeRenderProcessObserver
;
22 class ContentSettingsObserver
;
24 class TranslateHelper
;
25 class WebViewColorOverlay
;
26 class WebViewAnimatingOverlay
;
30 struct WebWindowFeatures
;
33 namespace safe_browsing
{
34 class PhishingClassifierDelegate
;
37 // This class holds the Chrome specific parts of RenderView, and has the same
39 class ChromeRenderViewObserver
: public content::RenderViewObserver
{
41 // translate_helper can be NULL.
42 ChromeRenderViewObserver(
43 content::RenderView
* render_view
,
44 ChromeRenderProcessObserver
* chrome_render_process_observer
);
45 virtual ~ChromeRenderViewObserver();
48 // RenderViewObserver implementation.
49 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
50 virtual void DidStartLoading() OVERRIDE
;
51 virtual void DidStopLoading() OVERRIDE
;
52 virtual void DidCommitProvisionalLoad(blink::WebFrame
* frame
,
53 bool is_new_navigation
) OVERRIDE
;
54 virtual void DetailedConsoleMessageAdded(const base::string16
& message
,
55 const base::string16
& source
,
56 const base::string16
& stack_trace
,
58 int32 severity_level
) OVERRIDE
;
59 virtual void Navigate(const GURL
& url
) OVERRIDE
;
61 void OnWebUIJavaScript(const base::string16
& javascript
);
62 void OnJavaScriptStressTestControl(int cmd
, int param
);
63 void OnSetClientSidePhishingDetection(bool enable_phishing_detection
);
64 void OnSetVisuallyDeemphasized(bool deemphasized
);
66 #if defined(OS_ANDROID)
67 void OnUpdateTopControlsState(content::TopControlsState constraints
,
68 content::TopControlsState current
,
70 void OnRetrieveWebappInformation(const GURL
& expected_url
);
71 void OnRetrieveMetaTagContent(const GURL
& expected_url
,
72 const std::string tag_name
);
74 void OnSetWindowFeatures(const blink::WebWindowFeatures
& window_features
);
76 void CapturePageInfoLater(int page_id
,
77 bool preliminary_capture
,
78 base::TimeDelta delay
);
80 // Captures the thumbnail and text contents for indexing for the given load
81 // ID. Kicks off analysis of the captured text.
82 void CapturePageInfo(int page_id
, bool preliminary_capture
);
84 // Retrieves the text from the given frame contents, the page text up to the
85 // maximum amount kMaxIndexChars will be placed into the given buffer.
86 void CaptureText(blink::WebFrame
* frame
, base::string16
* contents
);
88 // Determines if a host is in the strict security host set.
89 bool IsStrictSecurityHost(const std::string
& host
);
91 // Checks if a page contains <meta http-equiv="refresh" ...> tag.
92 bool HasRefreshMetaTag(blink::WebFrame
* frame
);
94 // Save the JavaScript to preload if a ViewMsg_WebUIJavaScript is received.
95 base::string16 webui_javascript_
;
97 // Owned by ChromeContentRendererClient and outlive us.
98 ChromeRenderProcessObserver
* chrome_render_process_observer_
;
100 // Have the same lifetime as us.
101 TranslateHelper
* translate_helper_
;
102 safe_browsing::PhishingClassifierDelegate
* phishing_classifier_
;
104 // Page_id from the last page we indexed. This prevents us from indexing the
105 // same page twice in a row.
106 int32 last_indexed_page_id_
;
107 // The toplevel URL that was last indexed. This is used together with the
108 // page id to decide whether to reindex in certain cases like history
110 GURL last_indexed_url_
;
112 // A color page overlay when visually de-emaphasized.
113 scoped_ptr
<WebViewColorOverlay
> dimmed_color_overlay_
;
115 // Used to delay calling CapturePageInfo.
116 base::Timer capture_timer_
;
118 DISALLOW_COPY_AND_ASSIGN(ChromeRenderViewObserver
);
121 #endif // CHROME_RENDERER_CHROME_RENDER_VIEW_OBSERVER_H_