Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Side by Side Diff: net/cookies/cookie_monster.cc

Issue 976553002: Remove the '--enable-file-cookies' flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Whole method. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« net/cookies/cookie_monster.h ('K') | « net/cookies/cookie_monster.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Portions of this code based on Mozilla: 5 // Portions of this code based on Mozilla:
6 // (netwerk/cookie/src/nsCookieService.cpp) 6 // (netwerk/cookie/src/nsCookieService.cpp)
7 /* ***** BEGIN LICENSE BLOCK ***** 7 /* ***** BEGIN LICENSE BLOCK *****
8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
9 * 9 *
10 * The contents of this file are subject to the Mozilla Public License Version 10 * The contents of this file are subject to the Mozilla Public License Version
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 base::AutoLock autolock(lock_); 1333 base::AutoLock autolock(lock_);
1334 1334
1335 // Cookieable Schemes must be set before first use of function. 1335 // Cookieable Schemes must be set before first use of function.
1336 DCHECK(!initialized_); 1336 DCHECK(!initialized_);
1337 1337
1338 cookieable_schemes_.clear(); 1338 cookieable_schemes_.clear();
1339 cookieable_schemes_.insert(cookieable_schemes_.end(), schemes, 1339 cookieable_schemes_.insert(cookieable_schemes_.end(), schemes,
1340 schemes + num_schemes); 1340 schemes + num_schemes);
1341 } 1341 }
1342 1342
1343 void CookieMonster::SetEnableFileScheme(bool accept) {
1344 // This assumes "file" is always at the end of the array. See the comment
1345 // above kDefaultCookieableSchemes.
1346 int num_schemes = accept ? kDefaultCookieableSchemesCount
1347 : kDefaultCookieableSchemesCount - 1;
1348 SetCookieableSchemes(kDefaultCookieableSchemes, num_schemes);
1349 }
1350
1351 void CookieMonster::SetKeepExpiredCookies() { 1343 void CookieMonster::SetKeepExpiredCookies() {
1352 keep_expired_cookies_ = true; 1344 keep_expired_cookies_ = true;
1353 } 1345 }
1354 1346
1355 void CookieMonster::FlushStore(const base::Closure& callback) { 1347 void CookieMonster::FlushStore(const base::Closure& callback) {
1356 base::AutoLock autolock(lock_); 1348 base::AutoLock autolock(lock_);
1357 if (initialized_ && store_.get()) 1349 if (initialized_ && store_.get())
1358 store_->Flush(callback); 1350 store_->Flush(callback);
1359 else if (!callback.is_null()) 1351 else if (!callback.is_null())
1360 base::MessageLoop::current()->PostTask(FROM_HERE, callback); 1352 base::MessageLoop::current()->PostTask(FROM_HERE, callback);
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after
2343 const std::string& name, 2335 const std::string& name,
2344 const CookieChangedCallback& callback) { 2336 const CookieChangedCallback& callback) {
2345 base::AutoLock autolock(lock_); 2337 base::AutoLock autolock(lock_);
2346 std::pair<GURL, std::string> key(gurl, name); 2338 std::pair<GURL, std::string> key(gurl, name);
2347 if (hook_map_.count(key) == 0) 2339 if (hook_map_.count(key) == 0)
2348 hook_map_[key] = make_linked_ptr(new CookieChangedCallbackList()); 2340 hook_map_[key] = make_linked_ptr(new CookieChangedCallbackList());
2349 return hook_map_[key]->Add( 2341 return hook_map_[key]->Add(
2350 base::Bind(&RunAsync, base::MessageLoopProxy::current(), callback)); 2342 base::Bind(&RunAsync, base::MessageLoopProxy::current(), callback));
2351 } 2343 }
2352 2344
2345 #if defined(OS_ANDROID)
2346 void CookieMonster::SetEnableFileScheme(bool accept) {
2347 // This assumes "file" is always at the end of the array. See the comment
2348 // above kDefaultCookieableSchemes.
2349 //
2350 // TODO(mkwst): We're keeping this method around to support the
2351 // 'CookieManager::setAcceptFileSchemeCookies' method on Android's WebView;
2352 // if/when we can deprecate and remove that method, we can remove this one
2353 // as well. Until then, we'll just ensure that the method has no effect on
2354 // non-android systems.
2355 int num_schemes = accept ? kDefaultCookieableSchemesCount
2356 : kDefaultCookieableSchemesCount - 1;
2357
2358 SetCookieableSchemes(kDefaultCookieableSchemes, num_schemes);
2359 }
2360 #endif
2361
2353 void CookieMonster::RunCallbacks(const CanonicalCookie& cookie, bool removed) { 2362 void CookieMonster::RunCallbacks(const CanonicalCookie& cookie, bool removed) {
2354 lock_.AssertAcquired(); 2363 lock_.AssertAcquired();
2355 CookieOptions opts; 2364 CookieOptions opts;
2356 opts.set_include_httponly(); 2365 opts.set_include_httponly();
2357 opts.set_include_first_party_only(); 2366 opts.set_include_first_party_only();
2358 // Note that the callbacks in hook_map_ are wrapped with MakeAsync(), so they 2367 // Note that the callbacks in hook_map_ are wrapped with MakeAsync(), so they
2359 // are guaranteed to not take long - they just post a RunAsync task back to 2368 // are guaranteed to not take long - they just post a RunAsync task back to
2360 // the appropriate thread's message loop and return. It is important that this 2369 // the appropriate thread's message loop and return. It is important that this
2361 // method not run user-supplied callbacks directly, since the CookieMonster 2370 // method not run user-supplied callbacks directly, since the CookieMonster
2362 // lock is held and it is easy to accidentally introduce deadlocks. 2371 // lock is held and it is easy to accidentally introduce deadlocks.
2363 for (CookieChangedHookMap::iterator it = hook_map_.begin(); 2372 for (CookieChangedHookMap::iterator it = hook_map_.begin();
2364 it != hook_map_.end(); ++it) { 2373 it != hook_map_.end(); ++it) {
2365 std::pair<GURL, std::string> key = it->first; 2374 std::pair<GURL, std::string> key = it->first;
2366 if (cookie.IncludeForRequestURL(key.first, opts) && 2375 if (cookie.IncludeForRequestURL(key.first, opts) &&
2367 cookie.Name() == key.second) { 2376 cookie.Name() == key.second) {
2368 it->second->Notify(cookie, removed); 2377 it->second->Notify(cookie, removed);
2369 } 2378 }
2370 } 2379 }
2371 } 2380 }
2372 2381
2373 } // namespace net 2382 } // namespace net
OLDNEW
« net/cookies/cookie_monster.h ('K') | « net/cookies/cookie_monster.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698