OLD | NEW |
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" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" | 12 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
13 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 13 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
14 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" | 14 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
15 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" | 15 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
16 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
17 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 17 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
18 #include "chrome/browser/browsing_data/cookies_tree_model.h" | 18 #include "chrome/browser/browsing_data/cookies_tree_model.h" |
19 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
20 #include "chrome/browser/content_settings/content_settings_details.h" | 20 #include "chrome/browser/content_settings/content_settings_details.h" |
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/password_manager/password_form_manager.h" | |
24 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/render_messages.h" | 25 #include "chrome/common/render_messages.h" |
27 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
28 #include "content/public/browser/navigation_controller.h" | 27 #include "content/public/browser/navigation_controller.h" |
29 #include "content/public/browser/navigation_details.h" | 28 #include "content/public/browser/navigation_details.h" |
30 #include "content/public/browser/navigation_entry.h" | 29 #include "content/public/browser/navigation_entry.h" |
31 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
32 #include "content/public/browser/render_view_host.h" | 31 #include "content/public/browser/render_view_host.h" |
33 #include "content/public/browser/render_view_host_observer.h" | 32 #include "content/public/browser/render_view_host_observer.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 registrar_.Add(this, chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED, | 91 registrar_.Add(this, chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED, |
93 content::Source<HostContentSettingsMap>( | 92 content::Source<HostContentSettingsMap>( |
94 profile_->GetHostContentSettingsMap())); | 93 profile_->GetHostContentSettingsMap())); |
95 } | 94 } |
96 | 95 |
97 TabSpecificContentSettings::~TabSpecificContentSettings() { | 96 TabSpecificContentSettings::~TabSpecificContentSettings() { |
98 FOR_EACH_OBSERVER( | 97 FOR_EACH_OBSERVER( |
99 SiteDataObserver, observer_list_, ContentSettingsDestroyed()); | 98 SiteDataObserver, observer_list_, ContentSettingsDestroyed()); |
100 } | 99 } |
101 | 100 |
102 bool TabSpecificContentSettings::PasswordAccepted() { | |
103 DCHECK(form_to_save_.get()); | |
104 form_to_save_->SavePassword(); | |
105 return true; | |
106 } | |
107 | |
108 bool TabSpecificContentSettings::PasswordFormBlacklisted() { | |
109 DCHECK(form_to_save_.get()); | |
110 form_to_save_->BlacklistPassword(); | |
111 return true; | |
112 } | |
113 | |
114 TabSpecificContentSettings* TabSpecificContentSettings::Get( | 101 TabSpecificContentSettings* TabSpecificContentSettings::Get( |
115 int render_process_id, int render_view_id) { | 102 int render_process_id, int render_view_id) { |
116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
117 | 104 |
118 RenderViewHost* view = RenderViewHost::FromID(render_process_id, | 105 RenderViewHost* view = RenderViewHost::FromID(render_process_id, |
119 render_view_id); | 106 render_view_id); |
120 if (!view) | 107 if (!view) |
121 return NULL; | 108 return NULL; |
122 | 109 |
123 WebContents* web_contents = WebContents::FromRenderViewHost(view); | 110 WebContents* web_contents = WebContents::FromRenderViewHost(view); |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 const GURL& requesting_origin, | 456 const GURL& requesting_origin, |
470 bool allowed) { | 457 bool allowed) { |
471 geolocation_usages_state_.OnPermissionSet(requesting_origin, allowed); | 458 geolocation_usages_state_.OnPermissionSet(requesting_origin, allowed); |
472 content::NotificationService::current()->Notify( | 459 content::NotificationService::current()->Notify( |
473 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 460 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
474 content::Source<WebContents>(web_contents()), | 461 content::Source<WebContents>(web_contents()), |
475 content::NotificationService::NoDetails()); | 462 content::NotificationService::NoDetails()); |
476 } | 463 } |
477 | 464 |
478 void TabSpecificContentSettings::OnPasswordSubmitted( | 465 void TabSpecificContentSettings::OnPasswordSubmitted( |
479 PasswordFormManager* form_to_save) { | 466 PasswordFormManager* form_manager) { |
480 form_to_save_.reset(form_to_save); | 467 form_manager_.reset(form_manager); |
481 OnContentAllowed(CONTENT_SETTINGS_TYPE_SAVE_PASSWORD); | 468 OnContentAllowed(CONTENT_SETTINGS_TYPE_SAVE_PASSWORD); |
482 NotifySiteDataObservers(); | 469 NotifySiteDataObservers(); |
483 } | 470 } |
484 | 471 |
485 TabSpecificContentSettings::PasswordSavingState | 472 TabSpecificContentSettings::PasswordSavingState |
486 TabSpecificContentSettings::GetPasswordSavingState() const { | 473 TabSpecificContentSettings::GetPasswordSavingState() const { |
487 if (IsContentAllowed(CONTENT_SETTINGS_TYPE_SAVE_PASSWORD)) | 474 if (IsContentAllowed(CONTENT_SETTINGS_TYPE_SAVE_PASSWORD)) |
488 return PASSWORD_TO_BE_SAVED; | 475 return PASSWORD_TO_BE_SAVED; |
489 else | 476 else |
490 return NO_PASSWORD_TO_BE_SAVED; | 477 return NO_PASSWORD_TO_BE_SAVED; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 IPC_BEGIN_MESSAGE_MAP(TabSpecificContentSettings, message) | 639 IPC_BEGIN_MESSAGE_MAP(TabSpecificContentSettings, message) |
653 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ContentBlocked, OnContentBlocked) | 640 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ContentBlocked, OnContentBlocked) |
654 IPC_MESSAGE_UNHANDLED(handled = false) | 641 IPC_MESSAGE_UNHANDLED(handled = false) |
655 IPC_END_MESSAGE_MAP() | 642 IPC_END_MESSAGE_MAP() |
656 return handled; | 643 return handled; |
657 } | 644 } |
658 | 645 |
659 void TabSpecificContentSettings::DidNavigateMainFrame( | 646 void TabSpecificContentSettings::DidNavigateMainFrame( |
660 const content::LoadCommittedDetails& details, | 647 const content::LoadCommittedDetails& details, |
661 const content::FrameNavigateParams& params) { | 648 const content::FrameNavigateParams& params) { |
662 if (form_to_save_) | 649 if (form_manager_) |
663 form_to_save_->ApplyChange(); | 650 form_manager_->ApplyChange(); |
664 if (!details.is_in_page) { | 651 if (!details.is_in_page) { |
665 // Clear "blocked" flags. | 652 // Clear "blocked" flags. |
666 ClearBlockedContentSettingsExceptForCookies(); | 653 ClearBlockedContentSettingsExceptForCookies(); |
667 GeolocationDidNavigate(details); | 654 GeolocationDidNavigate(details); |
668 MIDIDidNavigate(details); | 655 MIDIDidNavigate(details); |
669 } | 656 } |
670 } | 657 } |
671 | 658 |
672 void TabSpecificContentSettings::DidStartProvisionalLoadForFrame( | 659 void TabSpecificContentSettings::DidStartProvisionalLoadForFrame( |
673 int64 frame_id, | 660 int64 frame_id, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 } | 718 } |
732 | 719 |
733 void TabSpecificContentSettings::RemoveSiteDataObserver( | 720 void TabSpecificContentSettings::RemoveSiteDataObserver( |
734 SiteDataObserver* observer) { | 721 SiteDataObserver* observer) { |
735 observer_list_.RemoveObserver(observer); | 722 observer_list_.RemoveObserver(observer); |
736 } | 723 } |
737 | 724 |
738 void TabSpecificContentSettings::NotifySiteDataObservers() { | 725 void TabSpecificContentSettings::NotifySiteDataObservers() { |
739 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); | 726 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); |
740 } | 727 } |
OLD | NEW |