| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 // Report an inserted cookie as an "explicit" change cause. All other causes | 146 // Report an inserted cookie as an "explicit" change cause. All other causes |
| 147 // only make sense for deletions. | 147 // only make sense for deletions. |
| 148 case net::CookieStore::ChangeCause::INSERTED: | 148 case net::CookieStore::ChangeCause::INSERTED: |
| 149 case net::CookieStore::ChangeCause::EXPLICIT: | 149 case net::CookieStore::ChangeCause::EXPLICIT_DELETE: |
| 150 case net::CookieStore::ChangeCause::EXPLICIT_DUPLICATE_IN_BACKING_STORE: |
| 151 case net::CookieStore::ChangeCause::EXPLICIT_DONT_RECORD: |
| 152 case net::CookieStore::ChangeCause::EXPLICIT_LAST_ENTRY: |
| 150 cause = keys::kExplicitChangeCause; | 153 cause = keys::kExplicitChangeCause; |
| 151 break; | 154 break; |
| 152 | 155 |
| 153 case net::CookieStore::ChangeCause::OVERWRITE: | 156 case net::CookieStore::ChangeCause::OVERWRITE: |
| 154 cause = keys::kOverwriteChangeCause; | 157 cause = keys::kOverwriteChangeCause; |
| 155 break; | 158 break; |
| 156 | 159 |
| 157 case net::CookieStore::ChangeCause::EXPIRED: | 160 case net::CookieStore::ChangeCause::EXPIRED: |
| 158 cause = keys::kExpiredChangeCause; | 161 cause = keys::kExpiredChangeCause; |
| 159 break; | 162 break; |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 BrowserContextKeyedAPIFactory<CookiesAPI>* CookiesAPI::GetFactoryInstance() { | 591 BrowserContextKeyedAPIFactory<CookiesAPI>* CookiesAPI::GetFactoryInstance() { |
| 589 return g_factory.Pointer(); | 592 return g_factory.Pointer(); |
| 590 } | 593 } |
| 591 | 594 |
| 592 void CookiesAPI::OnListenerAdded(const EventListenerInfo& details) { | 595 void CookiesAPI::OnListenerAdded(const EventListenerInfo& details) { |
| 593 cookies_event_router_.reset(new CookiesEventRouter(browser_context_)); | 596 cookies_event_router_.reset(new CookiesEventRouter(browser_context_)); |
| 594 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 597 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
| 595 } | 598 } |
| 596 | 599 |
| 597 } // namespace extensions | 600 } // namespace extensions |
| OLD | NEW |