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::WebLocalFrame
* frame
,
53 bool is_new_navigation
) OVERRIDE
;
54 virtual void Navigate(const GURL
& url
) OVERRIDE
;
56 #if !defined(OS_ANDROID) && !defined(OS_IOS)
57 void OnWebUIJavaScript(const base::string16
& javascript
);
59 #if defined(ENABLE_EXTENSIONS)
60 void OnSetVisuallyDeemphasized(bool deemphasized
);
62 #if defined(OS_ANDROID)
63 void OnUpdateTopControlsState(content::TopControlsState constraints
,
64 content::TopControlsState current
,
66 void OnRetrieveWebappInformation(const GURL
& expected_url
);
67 void OnRetrieveMetaTagContent(const GURL
& expected_url
,
68 const std::string tag_name
);
70 void OnSetClientSidePhishingDetection(bool enable_phishing_detection
);
71 void OnSetWindowFeatures(const blink::WebWindowFeatures
& window_features
);
73 void CapturePageInfoLater(bool preliminary_capture
,
74 base::TimeDelta delay
);
76 // Captures the thumbnail and text contents for indexing for the given load
77 // ID. Kicks off analysis of the captured text.
78 void CapturePageInfo(bool preliminary_capture
);
80 // Retrieves the text from the given frame contents, the page text up to the
81 // maximum amount kMaxIndexChars will be placed into the given buffer.
82 void CaptureText(blink::WebFrame
* frame
, base::string16
* contents
);
84 // Determines if a host is in the strict security host set.
85 bool IsStrictSecurityHost(const std::string
& host
);
87 // Checks if a page contains <meta http-equiv="refresh" ...> tag.
88 bool HasRefreshMetaTag(blink::WebFrame
* frame
);
90 // Save the JavaScript to preload if a ViewMsg_WebUIJavaScript is received.
91 std::vector
<base::string16
> webui_javascript_
;
93 // Owned by ChromeContentRendererClient and outlive us.
94 ChromeRenderProcessObserver
* chrome_render_process_observer_
;
96 // Have the same lifetime as us.
97 TranslateHelper
* translate_helper_
;
98 safe_browsing::PhishingClassifierDelegate
* phishing_classifier_
;
100 // A color page overlay when visually de-emaphasized.
101 scoped_ptr
<WebViewColorOverlay
> dimmed_color_overlay_
;
103 // Used to delay calling CapturePageInfo.
104 base::Timer capture_timer_
;
106 DISALLOW_COPY_AND_ASSIGN(ChromeRenderViewObserver
);
109 #endif // CHROME_RENDERER_CHROME_RENDER_VIEW_OBSERVER_H_