OLD | NEW |
---|---|
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 // Implements the Chrome Extensions Cookies API. | 5 // Implements the Chrome Extensions Cookies API. |
6 | 6 |
7 #include "chrome/browser/extensions/api/cookies/cookies_api.h" | 7 #include "chrome/browser/extensions/api/cookies/cookies_api.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 136 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
137 dict->SetBoolean(keys::kRemovedKey, details->removed); | 137 dict->SetBoolean(keys::kRemovedKey, details->removed); |
138 | 138 |
139 cookies::Cookie cookie = cookies_helpers::CreateCookie( | 139 cookies::Cookie cookie = cookies_helpers::CreateCookie( |
140 *details->cookie, cookies_helpers::GetStoreIdFromProfile(profile)); | 140 *details->cookie, cookies_helpers::GetStoreIdFromProfile(profile)); |
141 dict->Set(keys::kCookieKey, cookie.ToValue()); | 141 dict->Set(keys::kCookieKey, cookie.ToValue()); |
142 | 142 |
143 // Map the internal cause to an external string. | 143 // Map the internal cause to an external string. |
144 std::string cause; | 144 std::string cause; |
145 switch (details->cause) { | 145 switch (details->cause) { |
146 case net::CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT: | 146 case net::CookieStore::ChangeCause::INSERTED: |
147 case net::CookieStore::ChangeCause::EXPLICIT: | |
147 cause = keys::kExplicitChangeCause; | 148 cause = keys::kExplicitChangeCause; |
148 break; | 149 break; |
149 | 150 |
150 case net::CookieMonsterDelegate::CHANGE_COOKIE_OVERWRITE: | 151 case net::CookieStore::ChangeCause::OVERWRITE: |
151 cause = keys::kOverwriteChangeCause; | 152 cause = keys::kOverwriteChangeCause; |
152 break; | 153 break; |
153 | 154 |
154 case net::CookieMonsterDelegate::CHANGE_COOKIE_EXPIRED: | 155 case net::CookieStore::ChangeCause::EXPIRED: |
155 cause = keys::kExpiredChangeCause; | 156 cause = keys::kExpiredChangeCause; |
156 break; | 157 break; |
157 | 158 |
158 case net::CookieMonsterDelegate::CHANGE_COOKIE_EVICTED: | 159 case net::CookieStore::ChangeCause::EVICTED: |
159 cause = keys::kEvictedChangeCause; | 160 cause = keys::kEvictedChangeCause; |
160 break; | 161 break; |
161 | 162 |
162 case net::CookieMonsterDelegate::CHANGE_COOKIE_EXPIRED_OVERWRITE: | 163 case net::CookieStore::ChangeCause::EXPIRED_OVERWRITE: |
163 cause = keys::kExpiredOverwriteChangeCause; | 164 cause = keys::kExpiredOverwriteChangeCause; |
164 break; | 165 break; |
165 | 166 |
167 case net::CookieStore::ChangeCause::UNKNOWN_DELETION: | |
166 default: | 168 default: |
Devlin
2016/09/27 15:48:05
Can we remove the default: case here?
nharper
2016/09/27 17:43:48
Done.
| |
167 NOTREACHED(); | 169 NOTREACHED(); |
168 } | 170 } |
169 dict->SetString(keys::kCauseKey, cause); | 171 dict->SetString(keys::kCauseKey, cause); |
170 | 172 |
171 args->Append(std::move(dict)); | 173 args->Append(std::move(dict)); |
172 | 174 |
173 GURL cookie_domain = | 175 GURL cookie_domain = |
174 cookies_helpers::GetURLFromCanonicalCookie(*details->cookie); | 176 cookies_helpers::GetURLFromCanonicalCookie(*details->cookie); |
175 DispatchEvent(profile, events::COOKIES_ON_CHANGED, | 177 DispatchEvent(profile, events::COOKIES_ON_CHANGED, |
176 cookies::OnChanged::kEventName, std::move(args), cookie_domain); | 178 cookies::OnChanged::kEventName, std::move(args), cookie_domain); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
585 BrowserContextKeyedAPIFactory<CookiesAPI>* CookiesAPI::GetFactoryInstance() { | 587 BrowserContextKeyedAPIFactory<CookiesAPI>* CookiesAPI::GetFactoryInstance() { |
586 return g_factory.Pointer(); | 588 return g_factory.Pointer(); |
587 } | 589 } |
588 | 590 |
589 void CookiesAPI::OnListenerAdded(const EventListenerInfo& details) { | 591 void CookiesAPI::OnListenerAdded(const EventListenerInfo& details) { |
590 cookies_event_router_.reset(new CookiesEventRouter(browser_context_)); | 592 cookies_event_router_.reset(new CookiesEventRouter(browser_context_)); |
591 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 593 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
592 } | 594 } |
593 | 595 |
594 } // namespace extensions | 596 } // namespace extensions |
OLD | NEW |