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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/browsing_data_appcache_helper.h" 11 #include "chrome/browser/browsing_data_appcache_helper.h"
12 #include "chrome/browser/browsing_data_database_helper.h" 12 #include "chrome/browser/browsing_data_database_helper.h"
13 #include "chrome/browser/browsing_data_file_system_helper.h" 13 #include "chrome/browser/browsing_data_file_system_helper.h"
14 #include "chrome/browser/browsing_data_indexed_db_helper.h" 14 #include "chrome/browser/browsing_data_indexed_db_helper.h"
15 #include "chrome/browser/browsing_data_local_storage_helper.h" 15 #include "chrome/browser/browsing_data_local_storage_helper.h"
16 #include "chrome/browser/content_settings/content_settings_details.h" 16 #include "chrome/browser/content_settings/content_settings_details.h"
17 #include "chrome/browser/content_settings/host_content_settings_map.h" 17 #include "chrome/browser/content_settings/host_content_settings_map.h"
18 #include "chrome/browser/cookies_tree_model.h" 18 #include "chrome/browser/cookies_tree_model.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/common/chrome_notification_types.h"
20 #include "chrome/common/render_messages.h" 21 #include "chrome/common/render_messages.h"
21 #include "content/browser/renderer_host/render_process_host.h" 22 #include "content/browser/renderer_host/render_process_host.h"
22 #include "content/browser/renderer_host/render_view_host.h" 23 #include "content/browser/renderer_host/render_view_host.h"
23 #include "content/browser/tab_contents/navigation_details.h" 24 #include "content/browser/tab_contents/navigation_details.h"
24 #include "content/browser/tab_contents/tab_contents.h" 25 #include "content/browser/tab_contents/tab_contents.h"
25 #include "content/browser/tab_contents/tab_contents_delegate.h" 26 #include "content/browser/tab_contents/tab_contents_delegate.h"
26 #include "content/common/notification_service.h" 27 #include "content/common/notification_service.h"
27 #include "content/common/view_messages.h" 28 #include "content/common/view_messages.h"
28 #include "net/base/cookie_monster.h" 29 #include "net/base/cookie_monster.h"
29 #include "webkit/fileapi/file_system_types.h" 30 #include "webkit/fileapi/file_system_types.h"
(...skipping 17 matching lines...) Expand all
47 TabSpecificContentSettings::TabSpecificContentSettings(TabContents* tab) 48 TabSpecificContentSettings::TabSpecificContentSettings(TabContents* tab)
48 : TabContentsObserver(tab), 49 : TabContentsObserver(tab),
49 allowed_local_shared_objects_(tab->profile()), 50 allowed_local_shared_objects_(tab->profile()),
50 blocked_local_shared_objects_(tab->profile()), 51 blocked_local_shared_objects_(tab->profile()),
51 geolocation_settings_state_(tab->profile()), 52 geolocation_settings_state_(tab->profile()),
52 load_plugins_link_enabled_(true) { 53 load_plugins_link_enabled_(true) {
53 ClearBlockedContentSettingsExceptForCookies(); 54 ClearBlockedContentSettingsExceptForCookies();
54 ClearCookieSpecificContentSettings(); 55 ClearCookieSpecificContentSettings();
55 g_tab_specific.Get().push_back(this); 56 g_tab_specific.Get().push_back(this);
56 57
57 registrar_.Add(this, NotificationType::CONTENT_SETTINGS_CHANGED, 58 registrar_.Add(this, chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED,
58 Source<HostContentSettingsMap>( 59 Source<HostContentSettingsMap>(
59 tab->profile()->GetHostContentSettingsMap())); 60 tab->profile()->GetHostContentSettingsMap()));
60 } 61 }
61 62
62 TabSpecificContentSettings::~TabSpecificContentSettings() { 63 TabSpecificContentSettings::~TabSpecificContentSettings() {
63 g_tab_specific.Get().remove(this); 64 g_tab_specific.Get().remove(this);
64 } 65 }
65 66
66 TabSpecificContentSettings* TabSpecificContentSettings::Get( 67 TabSpecificContentSettings* TabSpecificContentSettings::Get(
67 int render_process_id, int render_view_id) { 68 int render_process_id, int render_view_id) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 const std::string& resource_identifier) { 207 const std::string& resource_identifier) {
207 DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION) 208 DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION)
208 << "Geolocation settings handled by OnGeolocationPermissionSet"; 209 << "Geolocation settings handled by OnGeolocationPermissionSet";
209 content_accessed_[type] = true; 210 content_accessed_[type] = true;
210 if (!resource_identifier.empty()) 211 if (!resource_identifier.empty())
211 AddBlockedResource(type, resource_identifier); 212 AddBlockedResource(type, resource_identifier);
212 if (!content_blocked_[type]) { 213 if (!content_blocked_[type]) {
213 content_blocked_[type] = true; 214 content_blocked_[type] = true;
214 // TODO: it would be nice to have a way of mocking this in tests. 215 // TODO: it would be nice to have a way of mocking this in tests.
215 NotificationService::current()->Notify( 216 NotificationService::current()->Notify(
216 NotificationType::TAB_CONTENT_SETTINGS_CHANGED, 217 chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED,
217 Source<TabContents>(tab_contents()), 218 Source<TabContents>(tab_contents()),
218 NotificationService::NoDetails()); 219 NotificationService::NoDetails());
219 } 220 }
220 } 221 }
221 222
222 void TabSpecificContentSettings::OnContentAccessed(ContentSettingsType type) { 223 void TabSpecificContentSettings::OnContentAccessed(ContentSettingsType type) {
223 DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION) 224 DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION)
224 << "Geolocation settings handled by OnGeolocationPermissionSet"; 225 << "Geolocation settings handled by OnGeolocationPermissionSet";
225 if (!content_accessed_[type]) { 226 if (!content_accessed_[type]) {
226 content_accessed_[type] = true; 227 content_accessed_[type] = true;
227 NotificationService::current()->Notify( 228 NotificationService::current()->Notify(
228 NotificationType::TAB_CONTENT_SETTINGS_CHANGED, 229 chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED,
229 Source<TabContents>(tab_contents()), 230 Source<TabContents>(tab_contents()),
230 NotificationService::NoDetails()); 231 NotificationService::NoDetails());
231 } 232 }
232 } 233 }
233 234
234 void TabSpecificContentSettings::OnCookiesRead( 235 void TabSpecificContentSettings::OnCookiesRead(
235 const GURL& url, 236 const GURL& url,
236 const net::CookieList& cookie_list, 237 const net::CookieList& cookie_list,
237 bool blocked_by_policy) { 238 bool blocked_by_policy) {
238 if (cookie_list.empty()) 239 if (cookie_list.empty())
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 fileapi::kFileSystemTypeTemporary, 0); 345 fileapi::kFileSystemTypeTemporary, 0);
345 OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES); 346 OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES);
346 } 347 }
347 } 348 }
348 void TabSpecificContentSettings::OnGeolocationPermissionSet( 349 void TabSpecificContentSettings::OnGeolocationPermissionSet(
349 const GURL& requesting_origin, 350 const GURL& requesting_origin,
350 bool allowed) { 351 bool allowed) {
351 geolocation_settings_state_.OnGeolocationPermissionSet(requesting_origin, 352 geolocation_settings_state_.OnGeolocationPermissionSet(requesting_origin,
352 allowed); 353 allowed);
353 NotificationService::current()->Notify( 354 NotificationService::current()->Notify(
354 NotificationType::TAB_CONTENT_SETTINGS_CHANGED, 355 chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED,
355 Source<TabContents>(tab_contents()), 356 Source<TabContents>(tab_contents()),
356 NotificationService::NoDetails()); 357 NotificationService::NoDetails());
357 } 358 }
358 359
359 void TabSpecificContentSettings::ClearBlockedContentSettingsExceptForCookies() { 360 void TabSpecificContentSettings::ClearBlockedContentSettingsExceptForCookies() {
360 for (size_t i = 0; i < arraysize(content_blocked_); ++i) { 361 for (size_t i = 0; i < arraysize(content_blocked_); ++i) {
361 if (i == CONTENT_SETTINGS_TYPE_COOKIES) 362 if (i == CONTENT_SETTINGS_TYPE_COOKIES)
362 continue; 363 continue;
363 blocked_resources_[i].reset(); 364 blocked_resources_[i].reset();
364 content_blocked_[i] = false; 365 content_blocked_[i] = false;
365 content_accessed_[i] = false; 366 content_accessed_[i] = false;
366 content_blockage_indicated_to_user_[i] = false; 367 content_blockage_indicated_to_user_[i] = false;
367 } 368 }
368 load_plugins_link_enabled_ = true; 369 load_plugins_link_enabled_ = true;
369 NotificationService::current()->Notify( 370 NotificationService::current()->Notify(
370 NotificationType::TAB_CONTENT_SETTINGS_CHANGED, 371 chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED,
371 Source<TabContents>(tab_contents()), 372 Source<TabContents>(tab_contents()),
372 NotificationService::NoDetails()); 373 NotificationService::NoDetails());
373 } 374 }
374 375
375 void TabSpecificContentSettings::ClearCookieSpecificContentSettings() { 376 void TabSpecificContentSettings::ClearCookieSpecificContentSettings() {
376 blocked_local_shared_objects_.Reset(); 377 blocked_local_shared_objects_.Reset();
377 allowed_local_shared_objects_.Reset(); 378 allowed_local_shared_objects_.Reset();
378 content_blocked_[CONTENT_SETTINGS_TYPE_COOKIES] = false; 379 content_blocked_[CONTENT_SETTINGS_TYPE_COOKIES] = false;
379 content_accessed_[CONTENT_SETTINGS_TYPE_COOKIES] = false; 380 content_accessed_[CONTENT_SETTINGS_TYPE_COOKIES] = false;
380 content_blockage_indicated_to_user_[CONTENT_SETTINGS_TYPE_COOKIES] = false; 381 content_blockage_indicated_to_user_[CONTENT_SETTINGS_TYPE_COOKIES] = false;
381 NotificationService::current()->Notify( 382 NotificationService::current()->Notify(
382 NotificationType::TAB_CONTENT_SETTINGS_CHANGED, 383 chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED,
383 Source<TabContents>(tab_contents()), 384 Source<TabContents>(tab_contents()),
384 NotificationService::NoDetails()); 385 NotificationService::NoDetails());
385 } 386 }
386 387
387 void TabSpecificContentSettings::SetPopupsBlocked(bool blocked) { 388 void TabSpecificContentSettings::SetPopupsBlocked(bool blocked) {
388 content_blocked_[CONTENT_SETTINGS_TYPE_POPUPS] = blocked; 389 content_blocked_[CONTENT_SETTINGS_TYPE_POPUPS] = blocked;
389 content_blockage_indicated_to_user_[CONTENT_SETTINGS_TYPE_POPUPS] = false; 390 content_blockage_indicated_to_user_[CONTENT_SETTINGS_TYPE_POPUPS] = false;
390 NotificationService::current()->Notify( 391 NotificationService::current()->Notify(
391 NotificationType::TAB_CONTENT_SETTINGS_CHANGED, 392 chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED,
392 Source<TabContents>(tab_contents()), 393 Source<TabContents>(tab_contents()),
393 NotificationService::NoDetails()); 394 NotificationService::NoDetails());
394 } 395 }
395 396
396 void TabSpecificContentSettings::GeolocationDidNavigate( 397 void TabSpecificContentSettings::GeolocationDidNavigate(
397 const content::LoadCommittedDetails& details) { 398 const content::LoadCommittedDetails& details) {
398 geolocation_settings_state_.DidNavigate(details); 399 geolocation_settings_state_.DidNavigate(details);
399 } 400 }
400 401
401 void TabSpecificContentSettings::ClearGeolocationContentSettings() { 402 void TabSpecificContentSettings::ClearGeolocationContentSettings() {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 return; 450 return;
450 451
451 // If we're displaying a network error page do not reset the content 452 // If we're displaying a network error page do not reset the content
452 // settings delegate's cookies so the user has a chance to modify cookie 453 // settings delegate's cookies so the user has a chance to modify cookie
453 // settings. 454 // settings.
454 if (!is_error_page) 455 if (!is_error_page)
455 ClearCookieSpecificContentSettings(); 456 ClearCookieSpecificContentSettings();
456 ClearGeolocationContentSettings(); 457 ClearGeolocationContentSettings();
457 } 458 }
458 459
459 void TabSpecificContentSettings::Observe(NotificationType type, 460 void TabSpecificContentSettings::Observe(int type,
460 const NotificationSource& source, 461 const NotificationSource& source,
461 const NotificationDetails& details) { 462 const NotificationDetails& details) {
462 DCHECK(type.value == NotificationType::CONTENT_SETTINGS_CHANGED); 463 DCHECK(type == chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED);
463 464
464 Details<const ContentSettingsDetails> settings_details(details); 465 Details<const ContentSettingsDetails> settings_details(details);
465 const NavigationController& controller = tab_contents()->controller(); 466 const NavigationController& controller = tab_contents()->controller();
466 NavigationEntry* entry = controller.GetActiveEntry(); 467 NavigationEntry* entry = controller.GetActiveEntry();
467 GURL entry_url; 468 GURL entry_url;
468 if (entry) 469 if (entry)
469 entry_url = entry->url(); 470 entry_url = entry->url();
470 if (settings_details.ptr()->update_all() || 471 if (settings_details.ptr()->update_all() ||
471 // The active NavigationEntry is the URL in the URL field of a tab. 472 // The active NavigationEntry is the URL in the URL field of a tab.
472 // Currently this should be matched by the |primary_pattern|. 473 // Currently this should be matched by the |primary_pattern|.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 TabSpecificContentSettings::LocalSharedObjectsContainer::GetCookiesTreeModel() { 518 TabSpecificContentSettings::LocalSharedObjectsContainer::GetCookiesTreeModel() {
518 return new CookiesTreeModel(cookies_, 519 return new CookiesTreeModel(cookies_,
519 databases_->Clone(), 520 databases_->Clone(),
520 local_storages_->Clone(), 521 local_storages_->Clone(),
521 session_storages_->Clone(), 522 session_storages_->Clone(),
522 appcaches_->Clone(), 523 appcaches_->Clone(),
523 indexed_dbs_->Clone(), 524 indexed_dbs_->Clone(),
524 file_systems_->Clone(), 525 file_systems_->Clone(),
525 true); 526 true);
526 } 527 }
OLDNEW
« no previous file with comments | « chrome/browser/content_settings/tab_specific_content_settings.h ('k') | chrome/browser/cookies_tree_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698