 434a6e3561
			
		
	
	
	434a6e3561
	
	
	
		
			
			* [ci skip] refactor: create request context from network context * [ci skip] refactor: subscribe to mojo cookiemanager for cookie changes * [ci skip] refactor: manage the lifetime of custom URLRequestJobFactory * refactor: use OOP mojo proxy resolver * revert: add support for kIgnoreCertificateErrorsSPKIList * build: provide service manifest overlays for content services * chore: gn format * fix: log-net-log switch not working as expected * spec: verify proxy settings are respected from pac script with session.setProxy * chore: use chrome constants where possible * fix: initialize request context for global cert fetcher * refactor: fix destruction of request context getters * spec: use custom session for proxy tests * fix: queue up additional stop callbacks while net log is being stopped * fix: Add CHECK for cookie manager retrieval * chore: add helper to retrieve logging state for net log module * fix: ui::ResourceBundle::GetRawDataResourceForScale => GetRawDataResource * style: comment unused parameters * build: move //components/certificate_transparency deps from //brightray * chore: update gritsettings_resource_ids patch * chore: update api for chromium 68 * fix: net log instance is now a property of session
		
			
				
	
	
		
			72 lines
		
	
	
	
		
			2.3 KiB
			
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			72 lines
		
	
	
	
		
			2.3 KiB
			
		
	
	
	
		
			C++
		
	
	
	
	
	
| // Copyright (c) 2018 GitHub, Inc.
 | |
| // Use of this source code is governed by the MIT license that can be
 | |
| // found in the LICENSE file.
 | |
| 
 | |
| #include "atom/browser/cookie_change_notifier.h"
 | |
| 
 | |
| #include <utility>
 | |
| 
 | |
| #include "atom/browser/atom_browser_context.h"
 | |
| #include "atom/browser/net/cookie_details.h"
 | |
| #include "base/bind.h"
 | |
| #include "content/public/browser/browser_thread.h"
 | |
| #include "content/public/browser/storage_partition.h"
 | |
| #include "net/cookies/canonical_cookie.h"
 | |
| 
 | |
| using content::BrowserThread;
 | |
| 
 | |
| namespace atom {
 | |
| 
 | |
| CookieChangeNotifier::CookieChangeNotifier(AtomBrowserContext* browser_context)
 | |
|     : browser_context_(browser_context), binding_(this) {
 | |
|   StartListening();
 | |
| }
 | |
| 
 | |
| CookieChangeNotifier::~CookieChangeNotifier() = default;
 | |
| 
 | |
| std::unique_ptr<base::CallbackList<void(const CookieDetails*)>::Subscription>
 | |
| CookieChangeNotifier::RegisterCookieChangeCallback(
 | |
|     const base::Callback<void(const CookieDetails*)>& cb) {
 | |
|   DCHECK_CURRENTLY_ON(BrowserThread::UI);
 | |
| 
 | |
|   return cookie_change_sub_list_.Add(cb);
 | |
| }
 | |
| 
 | |
| void CookieChangeNotifier::StartListening() {
 | |
|   DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
 | |
|   DCHECK(!binding_.is_bound());
 | |
| 
 | |
|   network::mojom::CookieManager* cookie_manager =
 | |
|       content::BrowserContext::GetDefaultStoragePartition(browser_context_)
 | |
|           ->GetCookieManagerForBrowserProcess();
 | |
|   // Cookie manager should be created whenever network context is created,
 | |
|   // if this fails then there is something wrong with our context creation
 | |
|   // cycle.
 | |
|   CHECK(cookie_manager);
 | |
| 
 | |
|   network::mojom::CookieChangeListenerPtr listener_ptr;
 | |
|   binding_.Bind(mojo::MakeRequest(&listener_ptr));
 | |
|   binding_.set_connection_error_handler(base::BindOnce(
 | |
|       &CookieChangeNotifier::OnConnectionError, base::Unretained(this)));
 | |
| 
 | |
|   cookie_manager->AddGlobalChangeListener(std::move(listener_ptr));
 | |
| }
 | |
| 
 | |
| void CookieChangeNotifier::OnConnectionError() {
 | |
|   DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
 | |
| 
 | |
|   binding_.Close();
 | |
|   StartListening();
 | |
| }
 | |
| 
 | |
| void CookieChangeNotifier::OnCookieChange(
 | |
|     const net::CanonicalCookie& cookie,
 | |
|     network::mojom::CookieChangeCause cause) {
 | |
|   DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
 | |
| 
 | |
|   CookieDetails cookie_details(
 | |
|       &cookie, cause != network::mojom::CookieChangeCause::INSERTED, cause);
 | |
|   cookie_change_sub_list_.Notify(&cookie_details);
 | |
| }
 | |
| 
 | |
| }  // namespace atom
 |