diff options
author | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-17 21:35:08 +0000 |
---|---|---|
committer | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-17 21:35:08 +0000 |
commit | 37e050cf1d493e210ac6035c1ff45ccb1784c69b (patch) | |
tree | 4f4fc7766e17084d44eff9ca637a78f950c43ddb /chrome/browser/net | |
parent | f2e5f9dbec4e957fbf709afefd49813b5515b846 (diff) | |
download | chromium_src-37e050cf1d493e210ac6035c1ff45ccb1784c69b.zip chromium_src-37e050cf1d493e210ac6035c1ff45ccb1784c69b.tar.gz chromium_src-37e050cf1d493e210ac6035c1ff45ccb1784c69b.tar.bz2 |
When we're initializing the modal dialog box which asks whether the page has permission to access a "cookie", double check that the value has not since been set. If it has, close the window before it's even shown.
This is a stop-gap solution. We should probably come up with something more elegent long term.
TEST=Go to a page that starts a database transaction and immediately sets a local storage value. You should get one prompt instead of 2.
BUG=36006
Review URL: http://codereview.chromium.org/619009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39270 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r-- | chrome/browser/net/chrome_cookie_policy.cc | 44 | ||||
-rw-r--r-- | chrome/browser/net/chrome_cookie_policy.h | 18 |
2 files changed, 14 insertions, 48 deletions
diff --git a/chrome/browser/net/chrome_cookie_policy.cc b/chrome/browser/net/chrome_cookie_policy.cc index 6646af3..b825257 100644 --- a/chrome/browser/net/chrome_cookie_policy.cc +++ b/chrome/browser/net/chrome_cookie_policy.cc @@ -140,16 +140,21 @@ int ChromeCookiePolicy::CheckPolicy(const GURL& url) const { return net::ERR_IO_PENDING; // Need to prompt. } -void ChromeCookiePolicy::ShowNextPrompt() { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); - - if (prompt_queue_.empty()) +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, url, + cookie_line)); 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.url); + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + const std::string& host = url.host(); + + // The policy may have changed (due to the "remember" option) + int policy = CheckPolicy(url); if (policy != net::ERR_IO_PENDING) { DidPromptForSetCookie(host, policy, false); return; @@ -163,7 +168,7 @@ void ChromeCookiePolicy::ShowNextPrompt() { } #if defined(OS_WIN) - RunCookiePrompt(browser->GetSelectedTabContents(), data.url, data.cookie_line, + RunCookiePrompt(browser->GetSelectedTabContents(), url, cookie_line, new PromptDelegate(this, host)); #else // TODO(darin): Enable prompting for other ports. @@ -171,24 +176,6 @@ void ChromeCookiePolicy::ShowNextPrompt() { #endif } -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, url, - cookie_line)); - return; - } - - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); - - bool show_now = prompt_queue_.empty(); - prompt_queue_.push(PromptData(url, cookie_line)); - if (show_now) - ShowNextPrompt(); -} - void ChromeCookiePolicy::DidPromptForSetCookie(const std::string& host, int policy, bool remember) { if (!ChromeThread::CurrentlyOn(ChromeThread::IO)) { @@ -205,9 +192,6 @@ void ChromeCookiePolicy::DidPromptForSetCookie(const std::string& host, ChromeThread::IO, FROM_HERE, NewRunnableMethod(this, &ChromeCookiePolicy::DidPromptForSetCookie, host, policy, remember)); - - prompt_queue_.pop(); - ShowNextPrompt(); return; } diff --git a/chrome/browser/net/chrome_cookie_policy.h b/chrome/browser/net/chrome_cookie_policy.h index 40138a2..ae60764 100644 --- a/chrome/browser/net/chrome_cookie_policy.h +++ b/chrome/browser/net/chrome_cookie_policy.h @@ -66,19 +66,7 @@ class ChromeCookiePolicy typedef std::vector<Completion> Completions; typedef std::map<std::string, Completions> HostCompletionsMap; - struct PromptData { - GURL url; - std::string cookie_line; - - PromptData(const GURL& url, const std::string& cookie_line) - : url(url), - cookie_line(cookie_line) { - } - }; - typedef std::queue<PromptData> PromptQueue; - int CheckPolicy(const GURL& url) const; - void ShowNextPrompt(); void PromptForSetCookie(const GURL& url, const std::string& cookie_line); void DidPromptForSetCookie(const std::string& host, int result, bool remember); @@ -87,12 +75,6 @@ class ChromeCookiePolicy // This map is only accessed on the IO thread. HostCompletionsMap host_completions_map_; - // A queue of pending prompts. We queue these up here so that before showing - // the next prompt we can reconsult the HostContentSettingsMap in case - // settings have changed since the prompt request was placed in the queue. - // This queue is only accessed on the UI thread. - PromptQueue prompt_queue_; - scoped_refptr<HostContentSettingsMap> host_content_settings_map_; }; |