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/geometry/size.h"
21 class ContentSettingsObserver
;
26 struct WebWindowFeatures
;
29 namespace safe_browsing
{
30 class PhishingClassifierDelegate
;
34 class TranslateHelper
;
38 class WebCacheRenderProcessObserver
;
41 // This class holds the Chrome specific parts of RenderView, and has the same
43 class ChromeRenderViewObserver
: public content::RenderViewObserver
{
45 // translate_helper can be NULL.
46 ChromeRenderViewObserver(
47 content::RenderView
* render_view
,
48 web_cache::WebCacheRenderProcessObserver
*
49 web_cache_render_process_observer
);
50 ~ChromeRenderViewObserver() override
;
53 // RenderViewObserver implementation.
54 bool OnMessageReceived(const IPC::Message
& message
) override
;
55 void DidStartLoading() override
;
56 void DidStopLoading() override
;
57 void DidCommitProvisionalLoad(blink::WebLocalFrame
* frame
,
58 bool is_new_navigation
) override
;
59 void Navigate(const GURL
& url
) override
;
61 #if !defined(OS_ANDROID) && !defined(OS_IOS)
62 void OnWebUIJavaScript(const base::string16
& javascript
);
64 #if defined(ENABLE_EXTENSIONS)
65 void OnSetVisuallyDeemphasized(bool deemphasized
);
67 #if defined(OS_ANDROID)
68 void OnUpdateTopControlsState(content::TopControlsState constraints
,
69 content::TopControlsState current
,
72 void OnGetWebApplicationInfo();
73 void OnSetClientSidePhishingDetection(bool enable_phishing_detection
);
74 void OnSetWindowFeatures(const blink::WebWindowFeatures
& window_features
);
76 void CapturePageInfoLater(bool preliminary_capture
,
77 base::TimeDelta delay
);
79 // Captures the thumbnail and text contents for indexing for the given load
80 // ID. Kicks off analysis of the captured text.
81 void CapturePageInfo(bool preliminary_capture
);
83 // Retrieves the text from the given frame contents, the page text up to the
84 // maximum amount kMaxIndexChars will be placed into the given buffer.
85 void CaptureText(blink::WebFrame
* frame
, base::string16
* contents
);
87 // Determines if a host is in the strict security host set.
88 bool IsStrictSecurityHost(const std::string
& host
);
90 // Checks if a page contains <meta http-equiv="refresh" ...> tag.
91 bool HasRefreshMetaTag(blink::WebFrame
* frame
);
93 // Save the JavaScript to preload if a ViewMsg_WebUIJavaScript is received.
94 std::vector
<base::string16
> webui_javascript_
;
96 // Owned by ChromeContentRendererClient and outlive us.
97 web_cache::WebCacheRenderProcessObserver
* web_cache_render_process_observer_
;
99 // Have the same lifetime as us.
100 translate::TranslateHelper
* translate_helper_
;
101 safe_browsing::PhishingClassifierDelegate
* phishing_classifier_
;
103 // true if webview is overlayed with grey color.
104 bool webview_visually_deemphasized_
;
106 // Used to delay calling CapturePageInfo.
107 base::Timer capture_timer_
;
109 DISALLOW_COPY_AND_ASSIGN(ChromeRenderViewObserver
);
112 #endif // CHROME_RENDERER_CHROME_RENDER_VIEW_OBSERVER_H_