| 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" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "content/public/browser/render_view_host.h" | 42 #include "content/public/browser/render_view_host.h" |
| 43 #include "content/public/browser/web_contents.h" | 43 #include "content/public/browser/web_contents.h" |
| 44 #include "content/public/browser/web_contents_delegate.h" | 44 #include "content/public/browser/web_contents_delegate.h" |
| 45 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 45 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 46 #include "net/cookies/canonical_cookie.h" | 46 #include "net/cookies/canonical_cookie.h" |
| 47 #include "storage/common/fileapi/file_system_types.h" | 47 #include "storage/common/fileapi/file_system_types.h" |
| 48 | 48 |
| 49 using content::BrowserThread; | 49 using content::BrowserThread; |
| 50 using content::NavigationController; | 50 using content::NavigationController; |
| 51 using content::NavigationEntry; | 51 using content::NavigationEntry; |
| 52 using content::RenderViewHost; | |
| 53 using content::WebContents; | 52 using content::WebContents; |
| 54 | 53 |
| 55 DEFINE_WEB_CONTENTS_USER_DATA_KEY(TabSpecificContentSettings); | 54 DEFINE_WEB_CONTENTS_USER_DATA_KEY(TabSpecificContentSettings); |
| 56 | 55 |
| 57 namespace { | 56 namespace { |
| 58 | 57 |
| 59 // Returns the object given a render frame's id. | 58 // Returns the object given a render frame's id. |
| 60 TabSpecificContentSettings* GetForFrame(int render_process_id, | 59 TabSpecificContentSettings* GetForFrame(int render_process_id, |
| 61 int render_frame_id) { | 60 int render_frame_id) { |
| 62 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 61 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 ->GetHostContentSettingsMap()); | 127 ->GetHostContentSettingsMap()); |
| 129 } | 128 } |
| 130 | 129 |
| 131 TabSpecificContentSettings::~TabSpecificContentSettings() { | 130 TabSpecificContentSettings::~TabSpecificContentSettings() { |
| 132 FOR_EACH_OBSERVER( | 131 FOR_EACH_OBSERVER( |
| 133 SiteDataObserver, observer_list_, ContentSettingsDestroyed()); | 132 SiteDataObserver, observer_list_, ContentSettingsDestroyed()); |
| 134 } | 133 } |
| 135 | 134 |
| 136 // static | 135 // static |
| 137 TabSpecificContentSettings* TabSpecificContentSettings::Get( | 136 TabSpecificContentSettings* TabSpecificContentSettings::Get( |
| 138 int render_process_id, int render_view_id) { | 137 content::RenderFrameHost* render_frame_host) { |
| 139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 138 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 140 | 139 |
| 141 RenderViewHost* view = RenderViewHost::FromID(render_process_id, | 140 WebContents* web_contents = |
| 142 render_view_id); | 141 WebContents::FromRenderFrameHost(render_frame_host); |
| 143 if (!view) | |
| 144 return NULL; | |
| 145 | |
| 146 WebContents* web_contents = WebContents::FromRenderViewHost(view); | |
| 147 if (!web_contents) | 142 if (!web_contents) |
| 148 return NULL; | 143 return nullptr; |
| 149 | 144 |
| 150 return TabSpecificContentSettings::FromWebContents(web_contents); | 145 return TabSpecificContentSettings::FromWebContents(web_contents); |
| 151 } | 146 } |
| 152 | 147 |
| 153 // static | 148 // static |
| 154 void TabSpecificContentSettings::CookiesRead(int render_process_id, | 149 void TabSpecificContentSettings::CookiesRead(int render_process_id, |
| 155 int render_frame_id, | 150 int render_frame_id, |
| 156 const GURL& url, | 151 const GURL& url, |
| 157 const GURL& frame_url, | 152 const GURL& frame_url, |
| 158 const net::CookieList& cookie_list, | 153 const net::CookieList& cookie_list, |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 | 817 |
| 823 void TabSpecificContentSettings::GeolocationDidNavigate( | 818 void TabSpecificContentSettings::GeolocationDidNavigate( |
| 824 const content::LoadCommittedDetails& details) { | 819 const content::LoadCommittedDetails& details) { |
| 825 geolocation_usages_state_.DidNavigate(GetCommittedDetails(details)); | 820 geolocation_usages_state_.DidNavigate(GetCommittedDetails(details)); |
| 826 } | 821 } |
| 827 | 822 |
| 828 void TabSpecificContentSettings::MidiDidNavigate( | 823 void TabSpecificContentSettings::MidiDidNavigate( |
| 829 const content::LoadCommittedDetails& details) { | 824 const content::LoadCommittedDetails& details) { |
| 830 midi_usages_state_.DidNavigate(GetCommittedDetails(details)); | 825 midi_usages_state_.DidNavigate(GetCommittedDetails(details)); |
| 831 } | 826 } |
| OLD | NEW |