Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: chrome/renderer/content_settings_observer.h

Issue 6873040: Move the content settings code out of RenderView, since it belongs in the Chrome layer. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 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.
4
5 #ifndef CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_
6 #define CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_
7 #pragma once
8
9 #include <map>
10
11 #include "chrome/common/content_settings.h"
12 #include "content/renderer/render_view_observer.h"
13 #include "content/renderer/render_view_observer_tracker.h"
14
15 class GURL;
16
17 // Handles blocking content per content settings for each RenderView.
18 class ContentSettingsObserver
19 : public RenderViewObserver,
20 public RenderViewObserverTracker<ContentSettingsObserver> {
21 public:
22 explicit ContentSettingsObserver(RenderView* render_view);
23 virtual ~ContentSettingsObserver();
24
25 // Sets the content settings that back allowScripts(), allowImages(), and
26 // allowPlugins().
27 void SetContentSettings(const ContentSettings& settings);
28
29 // Returns the setting for the given type.
30 ContentSetting GetContentSetting(ContentSettingsType type);
31
32 // Sends an IPC notification that the specified content type was blocked.
33 // If the content type requires it, |resource_identifier| names the specific
34 // resource that was blocked (the plugin path in the case of plugins),
35 // otherwise it's the empty string.
36 void DidBlockContentType(ContentSettingsType settings_type,
37 const std::string& resource_identifier);
38
39 private:
40 // RenderViewObserver implementation.
41 virtual bool OnMessageReceived(const IPC::Message& message);
42 virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame,
43 bool is_new_navigation);
44 virtual bool AllowImages(WebKit::WebFrame* frame, bool enabled_per_settings);
45 virtual bool AllowPlugins(WebKit::WebFrame* frame, bool enabled_per_settings);
46 virtual bool AllowScript(WebKit::WebFrame* frame, bool enabled_per_settings);
47 virtual void DidNotAllowPlugins(WebKit::WebFrame* frame);
48 virtual void DidNotAllowScript(WebKit::WebFrame* frame);
49
50 // Message handlers.
51 void OnSetContentSettingsForLoadingURL(
52 const GURL& url,
53 const ContentSettings& content_settings);
54
55 // Helper method that returns if the user wants to block content of type
pastarmovj 2011/04/18 16:09:23 nit: Indentation
jam 2011/04/18 16:50:10 Done.
56 // |content_type|.
57 bool AllowContentType(ContentSettingsType settings_type);
58
59 // Resets the |content_blocked_| array.
60 void ClearBlockedContentSettings();
61
62 typedef std::map<GURL, ContentSettings> HostContentSettings;
63 HostContentSettings host_content_settings_;
64
65 // Stores if loading of images, scripts, and plugins is allowed.
66 ContentSettings current_content_settings_;
67
68 // Stores if images, scripts, and plugins have actually been blocked.
69 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES];
70
71 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver);
72 };
73
74 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698