Allow only one bookmark to be added for multiple fast starring
[chromium-blink-merge.git] / chrome / renderer / chrome_render_view_observer.h
blob06cdd20980ccef5f2aef859f9a81dd1bd3ca19f6
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/geometry/size.h"
19 #include "url/gurl.h"
21 class ContentSettingsObserver;
22 class SkBitmap;
24 namespace blink {
25 class WebView;
26 struct WebWindowFeatures;
29 namespace safe_browsing {
30 class PhishingClassifierDelegate;
33 namespace translate {
34 class TranslateHelper;
37 namespace web_cache {
38 class WebCacheRenderProcessObserver;
41 // This class holds the Chrome specific parts of RenderView, and has the same
42 // lifetime.
43 class ChromeRenderViewObserver : public content::RenderViewObserver {
44 public:
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;
52 private:
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);
63 #endif
64 #if defined(ENABLE_EXTENSIONS)
65 void OnSetVisuallyDeemphasized(bool deemphasized);
66 #endif
67 #if defined(OS_ANDROID)
68 void OnUpdateTopControlsState(content::TopControlsState constraints,
69 content::TopControlsState current,
70 bool animate);
71 void OnRetrieveMetaTagContent(const GURL& expected_url,
72 const std::string tag_name);
73 #endif
74 void OnGetWebApplicationInfo();
75 void OnSetClientSidePhishingDetection(bool enable_phishing_detection);
76 void OnSetWindowFeatures(const blink::WebWindowFeatures& window_features);
78 void CapturePageInfoLater(bool preliminary_capture,
79 base::TimeDelta delay);
81 // Captures the thumbnail and text contents for indexing for the given load
82 // ID. Kicks off analysis of the captured text.
83 void CapturePageInfo(bool preliminary_capture);
85 // Retrieves the text from the given frame contents, the page text up to the
86 // maximum amount kMaxIndexChars will be placed into the given buffer.
87 void CaptureText(blink::WebFrame* frame, base::string16* contents);
89 // Determines if a host is in the strict security host set.
90 bool IsStrictSecurityHost(const std::string& host);
92 // Checks if a page contains <meta http-equiv="refresh" ...> tag.
93 bool HasRefreshMetaTag(blink::WebFrame* frame);
95 // Save the JavaScript to preload if a ViewMsg_WebUIJavaScript is received.
96 std::vector<base::string16> webui_javascript_;
98 // Owned by ChromeContentRendererClient and outlive us.
99 web_cache::WebCacheRenderProcessObserver* web_cache_render_process_observer_;
101 // Have the same lifetime as us.
102 translate::TranslateHelper* translate_helper_;
103 safe_browsing::PhishingClassifierDelegate* phishing_classifier_;
105 // true if webview is overlayed with grey color.
106 bool webview_visually_deemphasized_;
108 // Used to delay calling CapturePageInfo.
109 base::Timer capture_timer_;
111 DISALLOW_COPY_AND_ASSIGN(ChromeRenderViewObserver);
114 #endif // CHROME_RENDERER_CHROME_RENDER_VIEW_OBSERVER_H_