Chromium Code Reviews| Index: chrome/browser/net/chrome_cookie_policy.cc |
| =================================================================== |
| --- chrome/browser/net/chrome_cookie_policy.cc (revision 59533) |
| +++ chrome/browser/net/chrome_cookie_policy.cc (working copy) |
| @@ -7,9 +7,7 @@ |
| #include "base/string_util.h" |
| #include "chrome/browser/browser_list.h" |
| #include "chrome/browser/chrome_thread.h" |
| -#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 "net/base/net_errors.h" |
| #include "net/base/static_cookie_policy.h" |
| @@ -20,45 +18,6 @@ |
| // ---------------------------------------------------------------------------- |
| -// ChromeCookiePolicy cannot just subclass the delegate interface because we |
| -// may have several prompts pending. |
| -class ChromeCookiePolicy::PromptDelegate |
| - : public CookiePromptModalDialogDelegate { |
| - public: |
| - PromptDelegate(ChromeCookiePolicy* cookie_policy, const std::string& host) |
| - : cookie_policy_(cookie_policy), |
| - host_(host) { |
| - } |
| - |
| - // CookiesPromptViewDelegate methods: |
| - virtual void AllowSiteData(bool session_expire); |
| - virtual void BlockSiteData(); |
| - |
| - private: |
| - void NotifyDone(int policy); |
| - |
| - scoped_refptr<ChromeCookiePolicy> cookie_policy_; |
| - std::string host_; |
| -}; |
| - |
| -void ChromeCookiePolicy::PromptDelegate::AllowSiteData(bool session_expire) { |
| - int policy = net::OK; |
| - if (session_expire) |
| - policy = net::OK_FOR_SESSION_ONLY; |
| - NotifyDone(policy); |
| -} |
| - |
| -void ChromeCookiePolicy::PromptDelegate::BlockSiteData() { |
| - NotifyDone(net::ERR_ACCESS_DENIED); |
| -} |
| - |
| -void ChromeCookiePolicy::PromptDelegate::NotifyDone(int policy) { |
| - cookie_policy_->DidPromptForSetCookie(host_, policy); |
| - delete this; |
| -} |
| - |
| -// ---------------------------------------------------------------------------- |
| - |
| ChromeCookiePolicy::ChromeCookiePolicy(HostContentSettingsMap* map) |
| : host_content_settings_map_(map) { |
| } |
| @@ -121,10 +80,7 @@ |
| DCHECK(callback); |
|
willchan no longer on Chromium
2011/03/23 15:44:53
Is the following code ever supposed to be hit? Or
|
| - // Else, ask the user... |
| - |
| Completions& completions = host_completions_map_[url.host()]; |
| - |
| if (completions.size() >= kMaxCompletionsPerHost) { |
| LOG(ERROR) << "Would exceed kMaxCompletionsPerHost"; |
| policy = net::ERR_ACCESS_DENIED; |
| @@ -133,7 +89,6 @@ |
| policy = net::ERR_IO_PENDING; |
| } |
| - PromptForSetCookie(url, cookie_line); |
| return policy; |
| } |
| @@ -149,75 +104,3 @@ |
| return net::ERR_IO_PENDING; // Need to prompt. |
|
willchan no longer on Chromium
2011/03/23 15:44:53
What's supposed to happen in this case? Is this ca
|
| } |
| -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)); |
| - 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); |
| - return; |
| - } |
| - |
| - // Show the prompt on top of the current tab. |
| - Browser* browser = BrowserList::GetLastActive(); |
| - if (!browser || !browser->GetSelectedTabContents()) { |
| - DidPromptForSetCookie(host, net::ERR_ACCESS_DENIED); |
| - return; |
| - } |
| - |
| - RunCookiePrompt(browser->GetSelectedTabContents(), |
| - host_content_settings_map_, url, cookie_line, |
| - new PromptDelegate(this, host)); |
| -} |
| - |
| -void ChromeCookiePolicy::DidPromptForSetCookie(const std::string& host, |
| - int policy) { |
| - if (!ChromeThread::CurrentlyOn(ChromeThread::IO)) { |
| - ChromeThread::PostTask( |
| - ChromeThread::IO, FROM_HERE, |
| - NewRunnableMethod(this, &ChromeCookiePolicy::DidPromptForSetCookie, |
| - host, policy)); |
| - return; |
| - } |
| - |
| - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| - |
| - // Notify all callbacks, starting with the first until we hit another that |
| - // is for a 'set-cookie'. |
| - HostCompletionsMap::iterator it = host_completions_map_.find(host); |
| - CHECK(it != host_completions_map_.end()); |
| - |
| - Completions& completions = it->second; |
| - CHECK(!completions.empty() && completions[0].is_set_cookie_request()); |
| - |
| - // Gather the list of callbacks to notify, and remove them from the |
| - // completions list before handing control to the callbacks (in case |
| - // they should call back into us to modify host_completions_map_). |
| - |
| - std::vector<net::CompletionCallback*> callbacks; |
| - callbacks.push_back(completions[0].callback()); |
| - size_t i = 1; |
| - for (; i < completions.size(); ++i) { |
| - if (completions[i].is_set_cookie_request()) |
| - break; |
| - callbacks.push_back(completions[i].callback()); |
| - } |
| - completions.erase(completions.begin(), completions.begin() + i); |
| - |
| - if (completions.empty()) |
| - host_completions_map_.erase(it); |
| - |
| - for (size_t j = 0; j < callbacks.size(); ++j) |
| - callbacks[j]->Run(policy); |
| -} |