diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-09 23:25:49 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-09 23:25:49 +0000 |
commit | da0c8e9e4c51699ef08ee449fe83fc1fb24b773d (patch) | |
tree | 671475593d2a739ed91dae72e631173ddd6219eb | |
parent | 42da24d2930b8c2257f3560366a8eff766d8fb9b (diff) | |
download | chromium_src-da0c8e9e4c51699ef08ee449fe83fc1fb24b773d.zip chromium_src-da0c8e9e4c51699ef08ee449fe83fc1fb24b773d.tar.gz chromium_src-da0c8e9e4c51699ef08ee449fe83fc1fb24b773d.tar.bz2 |
Whitelist all content for various internal schemes.
BUG=34805
TEST=New Tab page should still work if you disable script + images
Review URL: http://codereview.chromium.org/588011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38536 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/host_content_settings_map.cc | 23 | ||||
-rw-r--r-- | chrome/browser/host_content_settings_map.h | 17 | ||||
-rw-r--r-- | chrome/browser/host_content_settings_map_unittest.cc | 12 | ||||
-rw-r--r-- | chrome/browser/in_process_webkit/dom_storage_area.cc | 9 | ||||
-rw-r--r-- | chrome/browser/in_process_webkit/dom_storage_area.h | 11 | ||||
-rw-r--r-- | chrome/browser/in_process_webkit/dom_storage_permission_request.cc | 15 | ||||
-rw-r--r-- | chrome/browser/in_process_webkit/dom_storage_permission_request.h | 11 | ||||
-rw-r--r-- | chrome/browser/net/chrome_cookie_policy.cc | 42 | ||||
-rw-r--r-- | chrome/browser/net/chrome_cookie_policy.h | 12 | ||||
-rw-r--r-- | chrome/browser/renderer_host/async_resource_handler.cc | 8 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 13 | ||||
-rw-r--r-- | chrome/common/content_settings.h | 5 |
12 files changed, 111 insertions, 67 deletions
diff --git a/chrome/browser/host_content_settings_map.cc b/chrome/browser/host_content_settings_map.cc index 0546ece..3603215 100644 --- a/chrome/browser/host_content_settings_map.cc +++ b/chrome/browser/host_content_settings_map.cc @@ -11,6 +11,7 @@ #include "chrome/common/notification_type.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" +#include "chrome/common/url_constants.h" #include "net/base/static_cookie_policy.h" // static @@ -130,6 +131,13 @@ ContentSetting HostContentSettingsMap::GetContentSetting( i->second.settings[content_type]; } +ContentSetting HostContentSettingsMap::GetContentSetting( + const GURL& url, + ContentSettingsType content_type) const { + return ShouldAllowAllContent(url) ? + CONTENT_SETTING_ALLOW : GetContentSetting(url.host(), content_type); +} + ContentSettings HostContentSettingsMap::GetContentSettings( const std::string& host) const { AutoLock auto_lock(lock_); @@ -145,6 +153,12 @@ ContentSettings HostContentSettingsMap::GetContentSettings( return output; } +ContentSettings HostContentSettingsMap::GetContentSettings( + const GURL& url) const { + return ShouldAllowAllContent(url) ? + ContentSettings(CONTENT_SETTING_ALLOW) : GetContentSettings(url.host()); +} + void HostContentSettingsMap::GetSettingsForOneType( ContentSettingsType content_type, SettingsForOneType* settings) const { @@ -304,6 +318,15 @@ void HostContentSettingsMap::ResetToDefaults() { HostContentSettingsMap::~HostContentSettingsMap() { } +// static +bool HostContentSettingsMap::ShouldAllowAllContent(const GURL& url) { + return url.SchemeIs(chrome::kChromeInternalScheme) || + url.SchemeIs(chrome::kChromeUIScheme) || + url.SchemeIs(chrome::kExtensionScheme) || + url.SchemeIs(chrome::kGearsScheme) || + url.SchemeIs(chrome::kUserScriptScheme); +} + void HostContentSettingsMap::GetSettingsFromDictionary( const DictionaryValue* dictionary, ContentSettings* settings) { diff --git a/chrome/browser/host_content_settings_map.h b/chrome/browser/host_content_settings_map.h index 509fa9d..4b4e141 100644 --- a/chrome/browser/host_content_settings_map.h +++ b/chrome/browser/host_content_settings_map.h @@ -17,6 +17,7 @@ #include "base/lock.h" #include "base/ref_counted.h" #include "chrome/common/content_settings.h" +#include "googleurl/src/gurl.h" class DictionaryValue; class PrefService; @@ -32,7 +33,7 @@ class HostContentSettingsMap // each host. class ContentSettingsDetails { public: - ContentSettingsDetails(const std::string& host) : host_(host) {} + explicit ContentSettingsDetails(const std::string& host) : host_(host) {} // The host whose settings have changed. Empty if many hosts are affected // (e.g. if the default settings have changed). const std::string& host() { return host_; } @@ -60,11 +61,20 @@ class HostContentSettingsMap ContentSetting GetContentSetting(const std::string& host, ContentSettingsType content_type) const; + // Same as above, but for a URL instead of a host. The difference is that + // URLs with particular internal schemes are whitelisted. + ContentSetting GetContentSetting(const GURL& url, + ContentSettingsType content_type) const; + // Returns all ContentSettings which apply to a given host. // // This may be called on any thread. ContentSettings GetContentSettings(const std::string& host) const; + // Same as above, but for a URL instead of a host. The difference is that + // URLs with particular internal schemes are whitelisted. + ContentSettings GetContentSettings(const GURL& url) const; + // For a given content type, returns all hosts with a non-default setting, // mapped to their actual settings, in lexicographical order. |settings| must // be a non-NULL outparam. @@ -119,6 +129,11 @@ class HostContentSettingsMap ~HostContentSettingsMap(); + // Returns true if we should allow all content types for this URL. This is + // true for various internal objects like chrome:// URLs, so UI and other + // things users think of as "not webpages" don't break. + static bool ShouldAllowAllContent(const GURL& url); + // Sets the fields of |settings| based on the values in |dictionary|. void GetSettingsFromDictionary(const DictionaryValue* dictionary, ContentSettings* settings); diff --git a/chrome/browser/host_content_settings_map_unittest.cc b/chrome/browser/host_content_settings_map_unittest.cc index dade37c..45a03a4 100644 --- a/chrome/browser/host_content_settings_map_unittest.cc +++ b/chrome/browser/host_content_settings_map_unittest.cc @@ -6,6 +6,7 @@ #include "chrome/common/notification_registrar.h" #include "chrome/common/notification_service.h" +#include "chrome/common/url_constants.h" #include "chrome/test/testing_profile.h" #include "testing/gtest/include/gtest/gtest.h" @@ -23,10 +24,9 @@ bool SettingsEqual(const ContentSettings& settings1, class StubSettingsObserver : public NotificationObserver { public: - StubSettingsObserver() - : last_notifier(NULL), counter(0) { + StubSettingsObserver() : last_notifier(NULL), counter(0) { registrar_.Add(this, NotificationType::CONTENT_SETTINGS_CHANGED, - NotificationService::AllSources()); + NotificationService::AllSources()); } virtual void Observe(NotificationType type, @@ -53,8 +53,7 @@ class StubSettingsObserver : public NotificationObserver { class HostContentSettingsMapTest : public testing::Test { public: - HostContentSettingsMapTest() - : ui_thread_(ChromeThread::UI, &message_loop_) {} + HostContentSettingsMapTest() : ui_thread_(ChromeThread::UI, &message_loop_) {} protected: MessageLoop message_loop_; @@ -75,6 +74,9 @@ TEST_F(HostContentSettingsMapTest, DefaultValues) { EXPECT_EQ(CONTENT_SETTING_BLOCK, host_content_settings_map->GetDefaultContentSetting( CONTENT_SETTINGS_TYPE_IMAGES)); + EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( + GURL(chrome::kChromeUINewTabURL), + CONTENT_SETTINGS_TYPE_IMAGES)); host_content_settings_map->SetDefaultContentSetting( CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_ASK); EXPECT_EQ(CONTENT_SETTING_ASK, diff --git a/chrome/browser/in_process_webkit/dom_storage_area.cc b/chrome/browser/in_process_webkit/dom_storage_area.cc index e2a4549..fc9bf80 100644 --- a/chrome/browser/in_process_webkit/dom_storage_area.cc +++ b/chrome/browser/in_process_webkit/dom_storage_area.cc @@ -13,7 +13,6 @@ #include "chrome/browser/in_process_webkit/dom_storage_namespace.h" #include "chrome/browser/in_process_webkit/dom_storage_permission_request.h" #include "chrome/browser/host_content_settings_map.h" -#include "googleurl/src/gurl.h" #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" #include "third_party/WebKit/WebKit/chromium/public/WebStorageArea.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h" @@ -31,10 +30,10 @@ DOMStorageArea::DOMStorageArea( DOMStorageNamespace* owner, HostContentSettingsMap* host_content_settings_map) : origin_(origin), + origin_url_(origin), id_(id), owner_(owner), - host_content_settings_map_(host_content_settings_map), - host_(GURL(origin).host()) { + host_content_settings_map_(host_content_settings_map) { DCHECK(owner_); DCHECK(host_content_settings_map_); } @@ -111,7 +110,7 @@ void DOMStorageArea::CreateWebStorageAreaIfNecessary() { bool DOMStorageArea::CheckContentSetting() { ContentSetting content_setting = host_content_settings_map_->GetContentSetting( - host_, CONTENT_SETTINGS_TYPE_COOKIES); + origin_url_, CONTENT_SETTINGS_TYPE_COOKIES); if (content_setting == CONTENT_SETTING_ASK) { WebSecurityOrigin security_origin( @@ -131,7 +130,7 @@ bool DOMStorageArea::CheckContentSetting() { size = file_info.size; last_modified = file_info.last_modified; } - DOMStoragePermissionRequest request(host_, file_exists, size, + DOMStoragePermissionRequest request(origin_url_, file_exists, size, last_modified, host_content_settings_map_); ChromeThread::PostTask( diff --git a/chrome/browser/in_process_webkit/dom_storage_area.h b/chrome/browser/in_process_webkit/dom_storage_area.h index 36191db..4afc731 100644 --- a/chrome/browser/in_process_webkit/dom_storage_area.h +++ b/chrome/browser/in_process_webkit/dom_storage_area.h @@ -1,6 +1,6 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this -// source code is governed by a BSD-style license that can be found in the -// LICENSE file. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #ifndef CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_ #define CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_ @@ -11,6 +11,7 @@ #include "base/nullable_string16.h" #include "base/ref_counted.h" #include "base/scoped_ptr.h" +#include "googleurl/src/gurl.h" class DOMStorageNamespace; class HostContentSettingsMap; @@ -47,6 +48,7 @@ class DOMStorageArea { // The origin this storage area represents. string16 origin_; + GURL origin_url_; // The storage area we wrap. scoped_ptr<WebKit::WebStorageArea> storage_area_; @@ -59,9 +61,6 @@ class DOMStorageArea { scoped_refptr<HostContentSettingsMap> host_content_settings_map_; - // The host portion of the origin_. - const std::string host_; - DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageArea); }; diff --git a/chrome/browser/in_process_webkit/dom_storage_permission_request.cc b/chrome/browser/in_process_webkit/dom_storage_permission_request.cc index 3fd0045..4fb3293 100644 --- a/chrome/browser/in_process_webkit/dom_storage_permission_request.cc +++ b/chrome/browser/in_process_webkit/dom_storage_permission_request.cc @@ -8,12 +8,12 @@ #include "chrome/browser/message_box_handler.h" DOMStoragePermissionRequest::DOMStoragePermissionRequest( - const std::string& host, + const GURL& url, bool file_exists, int64 size, base::Time last_modified, HostContentSettingsMap* settings) - : host_(host), + : url_(url), file_exists_(file_exists), size_(size), last_modified_(last_modified), @@ -31,20 +31,20 @@ void DOMStoragePermissionRequest::SendResponse(ContentSetting content_setting, response_content_setting_ = content_setting; if (remember) { host_content_settings_map_->SetContentSetting( - host_, CONTENT_SETTINGS_TYPE_COOKIES, content_setting); + url_.host(), CONTENT_SETTINGS_TYPE_COOKIES, content_setting); } event_.Signal(); } // static void DOMStoragePermissionRequest::PromptUser( - DOMStoragePermissionRequest *dom_storage_permission_request) { + DOMStoragePermissionRequest* dom_storage_permission_request) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); // Cookie settings may have changed. ContentSetting setting = dom_storage_permission_request->host_content_settings_map_-> - GetContentSetting(dom_storage_permission_request->host(), + GetContentSetting(dom_storage_permission_request->url(), CONTENT_SETTINGS_TYPE_COOKIES); if (setting != CONTENT_SETTING_ASK) { dom_storage_permission_request->SendResponse(setting, false); @@ -60,13 +60,14 @@ void DOMStoragePermissionRequest::PromptUser( #if defined(OS_WIN) // TODO(darin): It seems like it would be interesting if the dialog actually // showed the name and value being stored (as is done for cookies). + const std::string& host = dom_storage_permission_request->url().host(); RunLocalStoragePrompt(browser->GetSelectedTabContents(), BrowsingDataLocalStorageHelper::LocalStorageInfo( std::string(), - dom_storage_permission_request->host(), + host, -1, std::string(), - dom_storage_permission_request->host(), + host, FilePath(), dom_storage_permission_request->size(), dom_storage_permission_request->last_modified()), diff --git a/chrome/browser/in_process_webkit/dom_storage_permission_request.h b/chrome/browser/in_process_webkit/dom_storage_permission_request.h index d84ed09..3b94177 100644 --- a/chrome/browser/in_process_webkit/dom_storage_permission_request.h +++ b/chrome/browser/in_process_webkit/dom_storage_permission_request.h @@ -13,12 +13,13 @@ #include "chrome/browser/host_content_settings_map.h" #include "chrome/browser/cookie_prompt_modal_dialog_delegate.h" #include "chrome/common/content_settings.h" +#include "googleurl/src/gurl.h" // This class is used to request content setting related permission for local // storage. It should only be used for one such event and then discarded. class DOMStoragePermissionRequest : public CookiePromptModalDialogDelegate { public: - DOMStoragePermissionRequest(const std::string& host, + DOMStoragePermissionRequest(const GURL& url, bool file_exists, int64 size, base::Time last_modified, @@ -28,21 +29,21 @@ class DOMStoragePermissionRequest : public CookiePromptModalDialogDelegate { ContentSetting WaitOnResponse(); void SendResponse(ContentSetting content_setting, bool remember); - const std::string& host() const { return host_; } + const GURL& url() const { return url_; } bool file_exists() const { return file_exists_; } int64 size() const { return size_; } const base::Time last_modified() const { return last_modified_; } // Called on the UI thread. - static void PromptUser(DOMStoragePermissionRequest *request); + static void PromptUser(DOMStoragePermissionRequest* request); // CookiesPromptViewDelegate methods: virtual void AllowSiteData(bool remember, bool session_expire); virtual void BlockSiteData(bool remember); private: - // The host we need to get permission for. - const std::string host_; + // The URL we need to get permission for. + const GURL url_; // Is there any information on disk currently? bool file_exists_; diff --git a/chrome/browser/net/chrome_cookie_policy.cc b/chrome/browser/net/chrome_cookie_policy.cc index a72d916..848ce28 100644 --- a/chrome/browser/net/chrome_cookie_policy.cc +++ b/chrome/browser/net/chrome_cookie_policy.cc @@ -10,7 +10,6 @@ #include "chrome/browser/cookie_prompt_modal_dialog_delegate.h" #include "chrome/browser/host_content_settings_map.h" #include "chrome/browser/message_box_handler.h" -#include "googleurl/src/gurl.h" #include "net/base/net_errors.h" #include "net/base/static_cookie_policy.h" @@ -74,9 +73,7 @@ int ChromeCookiePolicy::CanGetCookies(const GURL& url, return rv; } - const std::string& host = url.host(); - - int policy = CheckPolicy(host); + int policy = CheckPolicy(url); if (policy != net::ERR_IO_PENDING) return policy; @@ -84,7 +81,7 @@ int ChromeCookiePolicy::CanGetCookies(const GURL& url, // If we are currently prompting the user for a 'set-cookie' matching this // host, then we need to defer reading cookies. - HostCompletionsMap::iterator it = host_completions_map_.find(host); + HostCompletionsMap::iterator it = host_completions_map_.find(url.host()); if (it == host_completions_map_.end()) { policy = net::OK; } else if (it->second.size() >= kMaxCompletionsPerHost) { @@ -111,9 +108,7 @@ int ChromeCookiePolicy::CanSetCookie(const GURL& url, return rv; } - const std::string& host = url.host(); - - int policy = CheckPolicy(host); + int policy = CheckPolicy(url); if (policy != net::ERR_IO_PENDING) return policy; @@ -121,7 +116,7 @@ int ChromeCookiePolicy::CanSetCookie(const GURL& url, // Else, ask the user... - Completions& completions = host_completions_map_[host]; + Completions& completions = host_completions_map_[url.host()]; if (completions.size() >= kMaxCompletionsPerHost) { LOG(ERROR) << "Would exceed kMaxCompletionsPerHost"; @@ -131,13 +126,13 @@ int ChromeCookiePolicy::CanSetCookie(const GURL& url, policy = net::ERR_IO_PENDING; } - PromptForSetCookie(host, cookie_line); + PromptForSetCookie(url, cookie_line); return policy; } -int ChromeCookiePolicy::CheckPolicy(const std::string& host) const { +int ChromeCookiePolicy::CheckPolicy(const GURL& url) const { ContentSetting setting = host_content_settings_map_->GetContentSetting( - host, CONTENT_SETTINGS_TYPE_COOKIES); + url, CONTENT_SETTINGS_TYPE_COOKIES); if (setting == CONTENT_SETTING_BLOCK) return net::ERR_ACCESS_DENIED; if (setting == CONTENT_SETTING_ALLOW) @@ -151,38 +146,37 @@ void ChromeCookiePolicy::ShowNextPrompt() { if (prompt_queue_.empty()) return; PromptData data = prompt_queue_.front(); + const std::string& host = data.url.host(); // The policy may have changed (due to the "remember" option). - int policy = CheckPolicy(data.host); + int policy = CheckPolicy(data.url); if (policy != net::ERR_IO_PENDING) { - DidPromptForSetCookie(data.host, policy, false); + DidPromptForSetCookie(host, policy, false); return; } // Show the prompt on top of the current tab. Browser* browser = BrowserList::GetLastActive(); if (!browser || !browser->GetSelectedTabContents()) { - DidPromptForSetCookie(data.host, net::ERR_ACCESS_DENIED, false); + DidPromptForSetCookie(host, net::ERR_ACCESS_DENIED, false); return; } #if defined(OS_WIN) - RunCookiePrompt(browser->GetSelectedTabContents(), - data.host, - data.cookie_line, - new PromptDelegate(this, data.host)); + RunCookiePrompt(browser->GetSelectedTabContents(), host, data.cookie_line, + new PromptDelegate(this, host)); #else // TODO(darin): Enable prompting for other ports. - DidPromptForSetCookie(data.host, net::ERR_ACCESS_DENIED, false); + DidPromptForSetCookie(host, net::ERR_ACCESS_DENIED, false); #endif } -void ChromeCookiePolicy::PromptForSetCookie(const std::string &host, +void ChromeCookiePolicy::PromptForSetCookie(const GURL& url, const std::string& cookie_line) { if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) { ChromeThread::PostTask( ChromeThread::UI, FROM_HERE, - NewRunnableMethod(this, &ChromeCookiePolicy::PromptForSetCookie, host, + NewRunnableMethod(this, &ChromeCookiePolicy::PromptForSetCookie, url, cookie_line)); return; } @@ -190,12 +184,12 @@ void ChromeCookiePolicy::PromptForSetCookie(const std::string &host, DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); bool show_now = prompt_queue_.empty(); - prompt_queue_.push(PromptData(host, cookie_line)); + prompt_queue_.push(PromptData(url, cookie_line)); if (show_now) ShowNextPrompt(); } -void ChromeCookiePolicy::DidPromptForSetCookie(const std::string &host, +void ChromeCookiePolicy::DidPromptForSetCookie(const std::string& host, int policy, bool remember) { if (!ChromeThread::CurrentlyOn(ChromeThread::IO)) { // Process the remember flag immediately. diff --git a/chrome/browser/net/chrome_cookie_policy.h b/chrome/browser/net/chrome_cookie_policy.h index 6b4d675..40138a2 100644 --- a/chrome/browser/net/chrome_cookie_policy.h +++ b/chrome/browser/net/chrome_cookie_policy.h @@ -11,6 +11,7 @@ #include <vector> #include "base/ref_counted.h" +#include "googleurl/src/gurl.h" #include "net/base/cookie_policy.h" class HostContentSettingsMap; @@ -66,20 +67,19 @@ class ChromeCookiePolicy typedef std::map<std::string, Completions> HostCompletionsMap; struct PromptData { - std::string host; + GURL url; std::string cookie_line; - PromptData(const std::string& host, const std::string& cookie_line) - : host(host), + PromptData(const GURL& url, const std::string& cookie_line) + : url(url), cookie_line(cookie_line) { } }; typedef std::queue<PromptData> PromptQueue; - int CheckPolicy(const std::string& host) const; + int CheckPolicy(const GURL& url) const; void ShowNextPrompt(); - void PromptForSetCookie(const std::string& host, - const std::string& cookie_line); + void PromptForSetCookie(const GURL& url, const std::string& cookie_line); void DidPromptForSetCookie(const std::string& host, int result, bool remember); diff --git a/chrome/browser/renderer_host/async_resource_handler.cc b/chrome/browser/renderer_host/async_resource_handler.cc index 6cba3f4..da1a74e 100644 --- a/chrome/browser/renderer_host/async_resource_handler.cc +++ b/chrome/browser/renderer_host/async_resource_handler.cc @@ -109,13 +109,15 @@ bool AsyncResourceHandler::OnResponseStarted(int request_id, GlobalRequestID(process_id_, request_id)); ResourceDispatcherHostRequestInfo* info = rdh_->InfoForRequest(request); if (info->resource_type() == ResourceType::MAIN_FRAME) { - std::string host(request->url().host()); + GURL request_url(request->url()); + std::string host(request_url.host()); ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>(request->context()); if (!host.empty() && context) { receiver_->Send(new ViewMsg_SetContentSettingsForLoadingHost( - info->route_id(), host, - context->host_content_settings_map()->GetContentSettings(host))); + info->route_id(), host, + context->host_content_settings_map()->GetContentSettings( + request_url))); receiver_->Send(new ViewMsg_SetZoomLevelForLoadingHost(info->route_id(), host, context->host_zoom_map()->GetZoomLevel(host))); } diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 9c334dc..58eb083 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -1321,7 +1321,7 @@ void TabContents::AddPopup(TabContents* new_contents, GURL url(GetURL()); if (url.is_valid() && profile()->GetHostContentSettingsMap()->GetContentSetting( - url.host(), CONTENT_SETTINGS_TYPE_POPUPS) == CONTENT_SETTING_ALLOW) { + url, CONTENT_SETTINGS_TYPE_POPUPS) == CONTENT_SETTING_ALLOW) { AddNewContents(new_contents, NEW_POPUP, initial_pos, true); } else { if (!blocked_popups_) @@ -2763,15 +2763,18 @@ void TabContents::Observe(NotificationType type, case NotificationType::CONTENT_SETTINGS_CHANGED: { Details<HostContentSettingsMap::ContentSettingsDetails> settings_details(details); - std::string host; NavigationEntry* entry = controller_.GetActiveEntry(); - if (entry) - host = entry->url().host(); + GURL entry_url; + std::string host; + if (entry) { + entry_url = entry->url(); + host = entry_url.host(); + } Source<HostContentSettingsMap> content_settings(source); if (settings_details.ptr()->host().empty() || settings_details.ptr()->host() == host) { render_view_host()->SendContentSettings(host, - content_settings.ptr()->GetContentSettings(host)); + content_settings.ptr()->GetContentSettings(entry_url)); } break; } diff --git a/chrome/common/content_settings.h b/chrome/common/content_settings.h index 3e798b3..63af52e 100644 --- a/chrome/common/content_settings.h +++ b/chrome/common/content_settings.h @@ -24,6 +24,11 @@ struct ContentSettings { settings[i] = CONTENT_SETTING_DEFAULT; } + explicit ContentSettings(ContentSetting default_setting) { + for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) + settings[i] = default_setting; + } + ContentSetting settings[CONTENT_SETTINGS_NUM_TYPES]; }; |