OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ios/web/net/cookie_notification_bridge.h" |
| 6 |
| 7 #import <Foundation/Foundation.h> |
| 8 |
| 9 #include "base/bind.h" |
| 10 #include "base/location.h" |
| 11 #include "ios/net/cookies/cookie_store_ios.h" |
| 12 #include "ios/web/public/web_thread.h" |
| 13 |
| 14 namespace web { |
| 15 |
| 16 CookieNotificationBridge::CookieNotificationBridge() { |
| 17 observer_.reset([[NSNotificationCenter defaultCenter] |
| 18 addObserverForName:NSHTTPCookieManagerCookiesChangedNotification |
| 19 object:[NSHTTPCookieStorage sharedHTTPCookieStorage] |
| 20 queue:nil |
| 21 usingBlock:^(NSNotification* notification) { |
| 22 OnNotificationReceived(notification); |
| 23 }]); |
| 24 } |
| 25 |
| 26 CookieNotificationBridge::~CookieNotificationBridge() { |
| 27 [[NSNotificationCenter defaultCenter] removeObserver:observer_]; |
| 28 } |
| 29 |
| 30 void CookieNotificationBridge::OnNotificationReceived( |
| 31 NSNotification* notification) { |
| 32 DCHECK(thread_checker_.CalledOnValidThread()); |
| 33 DCHECK([[notification name] |
| 34 isEqualToString:NSHTTPCookieManagerCookiesChangedNotification]); |
| 35 web::WebThread::PostTask( |
| 36 web::WebThread::IO, FROM_HERE, |
| 37 base::Bind(&net::CookieStoreIOS::NotifySystemCookiesChanged)); |
| 38 } |
| 39 |
| 40 } // namespace web |
OLD | NEW |