| 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 <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 namespace GetAll = extensions::api::cookies::GetAll; | 40 namespace GetAll = extensions::api::cookies::GetAll; |
| 41 namespace GetAllCookieStores = extensions::api::cookies::GetAllCookieStores; | 41 namespace GetAllCookieStores = extensions::api::cookies::GetAllCookieStores; |
| 42 namespace Remove = extensions::api::cookies::Remove; | 42 namespace Remove = extensions::api::cookies::Remove; |
| 43 namespace Set = extensions::api::cookies::Set; | 43 namespace Set = extensions::api::cookies::Set; |
| 44 | 44 |
| 45 namespace extensions { | 45 namespace extensions { |
| 46 namespace keys = cookies_api_constants; | 46 namespace keys = cookies_api_constants; |
| 47 | 47 |
| 48 ExtensionCookiesEventRouter::ExtensionCookiesEventRouter(Profile* profile) | 48 ExtensionCookiesEventRouter::ExtensionCookiesEventRouter(Profile* profile) |
| 49 : profile_(profile) { | 49 : profile_(profile) { |
| 50 } | |
| 51 | |
| 52 ExtensionCookiesEventRouter::~ExtensionCookiesEventRouter() { | |
| 53 } | |
| 54 | |
| 55 void ExtensionCookiesEventRouter::Init() { | |
| 56 CHECK(registrar_.IsEmpty()); | 50 CHECK(registrar_.IsEmpty()); |
| 57 registrar_.Add(this, | 51 registrar_.Add(this, |
| 58 chrome::NOTIFICATION_COOKIE_CHANGED, | 52 chrome::NOTIFICATION_COOKIE_CHANGED, |
| 59 content::NotificationService::AllBrowserContextsAndSources()); | 53 content::NotificationService::AllBrowserContextsAndSources()); |
| 60 } | 54 } |
| 61 | 55 |
| 56 ExtensionCookiesEventRouter::~ExtensionCookiesEventRouter() { |
| 57 } |
| 58 |
| 62 void ExtensionCookiesEventRouter::Observe( | 59 void ExtensionCookiesEventRouter::Observe( |
| 63 int type, | 60 int type, |
| 64 const content::NotificationSource& source, | 61 const content::NotificationSource& source, |
| 65 const content::NotificationDetails& details) { | 62 const content::NotificationDetails& details) { |
| 66 Profile* profile = content::Source<Profile>(source).ptr(); | 63 Profile* profile = content::Source<Profile>(source).ptr(); |
| 67 if (!profile_->IsSameProfile(profile)) | 64 if (!profile_->IsSameProfile(profile)) |
| 68 return; | 65 return; |
| 69 | 66 |
| 70 switch (type) { | 67 switch (type) { |
| 71 case chrome::NOTIFICATION_COOKIE_CHANGED: | 68 case chrome::NOTIFICATION_COOKIE_CHANGED: |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 } | 534 } |
| 538 results_ = GetAllCookieStores::Results::Create(cookie_stores); | 535 results_ = GetAllCookieStores::Results::Create(cookie_stores); |
| 539 return true; | 536 return true; |
| 540 } | 537 } |
| 541 | 538 |
| 542 void GetAllCookieStoresFunction::Run() { | 539 void GetAllCookieStoresFunction::Run() { |
| 543 SendResponse(RunImpl()); | 540 SendResponse(RunImpl()); |
| 544 } | 541 } |
| 545 | 542 |
| 546 } // namespace extensions | 543 } // namespace extensions |
| OLD | NEW |