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

Side by Side Diff: chrome/browser/content_settings/tab_specific_content_settings.cc

Issue 104833006: Switch ContentSettingsObserver to be a RenderFrameObserver instead of a RenderViewObserver (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 7 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 5 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/content_settings/content_settings_utils.h" 21 #include "chrome/browser/content_settings/content_settings_utils.h"
22 #include "chrome/browser/content_settings/host_content_settings_map.h" 22 #include "chrome/browser/content_settings/host_content_settings_map.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/render_messages.h" 25 #include "chrome/common/render_messages.h"
26 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/navigation_controller.h" 27 #include "content/public/browser/navigation_controller.h"
28 #include "content/public/browser/navigation_details.h" 28 #include "content/public/browser/navigation_details.h"
29 #include "content/public/browser/navigation_entry.h" 29 #include "content/public/browser/navigation_entry.h"
30 #include "content/public/browser/notification_service.h" 30 #include "content/public/browser/notification_service.h"
31 #include "content/public/browser/render_frame_host.h"
31 #include "content/public/browser/render_view_host.h" 32 #include "content/public/browser/render_view_host.h"
32 #include "content/public/browser/web_contents.h" 33 #include "content/public/browser/web_contents.h"
33 #include "content/public/browser/web_contents_delegate.h" 34 #include "content/public/browser/web_contents_delegate.h"
34 #include "net/cookies/canonical_cookie.h" 35 #include "net/cookies/canonical_cookie.h"
35 #include "webkit/common/fileapi/file_system_types.h" 36 #include "webkit/common/fileapi/file_system_types.h"
36 37
37 using content::BrowserThread; 38 using content::BrowserThread;
38 using content::NavigationController; 39 using content::NavigationController;
39 using content::NavigationEntry; 40 using content::NavigationEntry;
40 using content::RenderViewHost; 41 using content::RenderViewHost;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 if (!view) 91 if (!view)
91 return NULL; 92 return NULL;
92 93
93 WebContents* web_contents = WebContents::FromRenderViewHost(view); 94 WebContents* web_contents = WebContents::FromRenderViewHost(view);
94 if (!web_contents) 95 if (!web_contents)
95 return NULL; 96 return NULL;
96 97
97 return TabSpecificContentSettings::FromWebContents(web_contents); 98 return TabSpecificContentSettings::FromWebContents(web_contents);
98 } 99 }
99 100
101 TabSpecificContentSettings* TabSpecificContentSettings::GetForFrame(
102 int render_process_id, int render_frame_id) {
103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
104
105 content::RenderFrameHost* frame = content::RenderFrameHost::FromID(
106 render_process_id, render_frame_id);
107 if (!frame)
108 return NULL;
109
110 WebContents* web_contents = WebContents::FromRenderFrameHost(frame);
111 if (!web_contents)
112 return NULL;
113
114 return TabSpecificContentSettings::FromWebContents(web_contents);
115 }
116
100 // static 117 // static
101 void TabSpecificContentSettings::CookiesRead(int render_process_id, 118 void TabSpecificContentSettings::CookiesRead(int render_process_id,
102 int render_view_id, 119 int render_view_id,
103 const GURL& url, 120 const GURL& url,
104 const GURL& frame_url, 121 const GURL& frame_url,
105 const net::CookieList& cookie_list, 122 const net::CookieList& cookie_list,
106 bool blocked_by_policy) { 123 bool blocked_by_policy) {
107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
108 TabSpecificContentSettings* settings = Get(render_process_id, render_view_id); 125 TabSpecificContentSettings* settings = Get(render_process_id, render_view_id);
109 if (settings) { 126 if (settings) {
(...skipping 14 matching lines...) Expand all
124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 141 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
125 TabSpecificContentSettings* settings = Get(render_process_id, render_view_id); 142 TabSpecificContentSettings* settings = Get(render_process_id, render_view_id);
126 if (settings) 143 if (settings)
127 settings->OnCookieChanged(url, frame_url, cookie_line, options, 144 settings->OnCookieChanged(url, frame_url, cookie_line, options,
128 blocked_by_policy); 145 blocked_by_policy);
129 } 146 }
130 147
131 // static 148 // static
132 void TabSpecificContentSettings::WebDatabaseAccessed( 149 void TabSpecificContentSettings::WebDatabaseAccessed(
133 int render_process_id, 150 int render_process_id,
134 int render_view_id, 151 int render_frame_id,
135 const GURL& url, 152 const GURL& url,
136 const base::string16& name, 153 const base::string16& name,
137 const base::string16& display_name, 154 const base::string16& display_name,
138 bool blocked_by_policy) { 155 bool blocked_by_policy) {
139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
140 TabSpecificContentSettings* settings = Get(render_process_id, render_view_id); 157 TabSpecificContentSettings* settings = GetForFrame(
158 render_process_id, render_frame_id);
159
160 // TODO(jam): remove this once WorkerProcessHost knows the RenderFrame IDs for
161 // a shared worker, which needs SharedWorkerRepository to be per frame.
162 if (!settings)
163 settings = Get(render_process_id, render_frame_id);
164
141 if (settings) 165 if (settings)
142 settings->OnWebDatabaseAccessed(url, name, display_name, blocked_by_policy); 166 settings->OnWebDatabaseAccessed(url, name, display_name, blocked_by_policy);
143 } 167 }
144 168
145 // static 169 // static
146 void TabSpecificContentSettings::DOMStorageAccessed(int render_process_id, 170 void TabSpecificContentSettings::DOMStorageAccessed(int render_process_id,
147 int render_view_id, 171 int render_frame_id,
148 const GURL& url, 172 const GURL& url,
149 bool local, 173 bool local,
150 bool blocked_by_policy) { 174 bool blocked_by_policy) {
151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
152 TabSpecificContentSettings* settings = Get(render_process_id, render_view_id); 176 TabSpecificContentSettings* settings = GetForFrame(
177 render_process_id, render_frame_id);
153 if (settings) 178 if (settings)
154 settings->OnLocalStorageAccessed(url, local, blocked_by_policy); 179 settings->OnLocalStorageAccessed(url, local, blocked_by_policy);
155 } 180 }
156 181
157 // static 182 // static
158 void TabSpecificContentSettings::IndexedDBAccessed(int render_process_id, 183 void TabSpecificContentSettings::IndexedDBAccessed(
159 int render_view_id, 184 int render_process_id,
160 const GURL& url, 185 int render_frame_id,
161 const base::string16& descrip tion, 186 const GURL& url,
162 bool blocked_by_policy) { 187 const base::string16& description,
188 bool blocked_by_policy) {
163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 189 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
164 TabSpecificContentSettings* settings = Get(render_process_id, render_view_id); 190 TabSpecificContentSettings* settings = GetForFrame(
191 render_process_id, render_frame_id);
192
193 // TODO(jam): remove this once WorkerProcessHost knows the RenderFrame IDs for
194 // a shared worker, which needs SharedWorkerRepository to be per frame.
195 if (!settings)
196 settings = Get(render_process_id, render_frame_id);
197
165 if (settings) 198 if (settings)
166 settings->OnIndexedDBAccessed(url, description, blocked_by_policy); 199 settings->OnIndexedDBAccessed(url, description, blocked_by_policy);
167 } 200 }
168 201
169 // static 202 // static
170 void TabSpecificContentSettings::FileSystemAccessed(int render_process_id, 203 void TabSpecificContentSettings::FileSystemAccessed(int render_process_id,
171 int render_view_id, 204 int render_frame_id,
172 const GURL& url, 205 const GURL& url,
173 bool blocked_by_policy) { 206 bool blocked_by_policy) {
174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
175 TabSpecificContentSettings* settings = Get(render_process_id, render_view_id); 208 TabSpecificContentSettings* settings = GetForFrame(
209 render_process_id, render_frame_id);
210
211 // TODO(jam): remove this once WorkerProcessHost knows the RenderFrame IDs for
212 // a shared worker, which needs SharedWorkerRepository to be per frame.
213 if (!settings)
214 settings = Get(render_process_id, render_frame_id);
215
176 if (settings) 216 if (settings)
177 settings->OnFileSystemAccessed(url, blocked_by_policy); 217 settings->OnFileSystemAccessed(url, blocked_by_policy);
178 } 218 }
179 219
180 bool TabSpecificContentSettings::IsContentBlocked( 220 bool TabSpecificContentSettings::IsContentBlocked(
181 ContentSettingsType content_type) const { 221 ContentSettingsType content_type) const {
182 DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION) 222 DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION)
183 << "Geolocation settings handled by ContentSettingGeolocationImageModel"; 223 << "Geolocation settings handled by ContentSettingGeolocationImageModel";
184 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS) 224 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
185 << "Notifications settings handled by " 225 << "Notifications settings handled by "
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 } 624 }
585 625
586 void TabSpecificContentSettings::SetPepperBrokerAllowed(bool allowed) { 626 void TabSpecificContentSettings::SetPepperBrokerAllowed(bool allowed) {
587 if (allowed) { 627 if (allowed) {
588 OnContentAllowed(CONTENT_SETTINGS_TYPE_PPAPI_BROKER); 628 OnContentAllowed(CONTENT_SETTINGS_TYPE_PPAPI_BROKER);
589 } else { 629 } else {
590 OnContentBlocked(CONTENT_SETTINGS_TYPE_PPAPI_BROKER); 630 OnContentBlocked(CONTENT_SETTINGS_TYPE_PPAPI_BROKER);
591 } 631 }
592 } 632 }
593 633
594 void TabSpecificContentSettings::RenderViewForInterstitialPageCreated( 634 void TabSpecificContentSettings::RenderFrameForInterstitialPageCreated(
595 RenderViewHost* render_view_host) { 635 content::RenderFrameHost* render_frame_host) {
596 // We want to tell the renderer-side code to ignore content settings for this 636 // We want to tell the renderer-side code to ignore content settings for this
597 // page. 637 // page.
598 render_view_host->Send(new ChromeViewMsg_SetAsInterstitial( 638 render_frame_host->Send(new ChromeViewMsg_SetAsInterstitial(
599 render_view_host->GetRoutingID())); 639 render_frame_host->GetRoutingID()));
600 } 640 }
601 641
602 bool TabSpecificContentSettings::OnMessageReceived( 642 bool TabSpecificContentSettings::OnMessageReceived(
603 const IPC::Message& message) { 643 const IPC::Message& message) {
604 bool handled = true; 644 bool handled = true;
605 IPC_BEGIN_MESSAGE_MAP(TabSpecificContentSettings, message) 645 IPC_BEGIN_MESSAGE_MAP(TabSpecificContentSettings, message)
606 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ContentBlocked, OnContentBlocked) 646 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ContentBlocked, OnContentBlocked)
607 IPC_MESSAGE_UNHANDLED(handled = false) 647 IPC_MESSAGE_UNHANDLED(handled = false)
608 IPC_END_MESSAGE_MAP() 648 IPC_END_MESSAGE_MAP()
609 return handled; 649 return handled;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 } 723 }
684 724
685 void TabSpecificContentSettings::RemoveSiteDataObserver( 725 void TabSpecificContentSettings::RemoveSiteDataObserver(
686 SiteDataObserver* observer) { 726 SiteDataObserver* observer) {
687 observer_list_.RemoveObserver(observer); 727 observer_list_.RemoveObserver(observer);
688 } 728 }
689 729
690 void TabSpecificContentSettings::NotifySiteDataObservers() { 730 void TabSpecificContentSettings::NotifySiteDataObservers() {
691 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); 731 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed());
692 } 732 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698