OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_cookies_api.h" | 7 #include "chrome/browser/extensions/extension_cookies_api.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
11 #include "base/task.h" | 11 #include "base/task.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/extensions/extension_cookies_api_constants.h" | 13 #include "chrome/browser/extensions/extension_cookies_api_constants.h" |
14 #include "chrome/browser/extensions/extension_cookies_helpers.h" | 14 #include "chrome/browser/extensions/extension_cookies_helpers.h" |
15 #include "chrome/browser/extensions/extension_event_router.h" | 15 #include "chrome/browser/extensions/extension_event_router.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
18 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
19 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
20 #include "chrome/common/extensions/extension_error_utils.h" | 20 #include "chrome/common/extensions/extension_error_utils.h" |
21 #include "content/browser/browser_thread.h" | 21 #include "content/browser/browser_thread.h" |
22 #include "content/common/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
23 #include "net/base/cookie_monster.h" | 23 #include "net/base/cookie_monster.h" |
24 #include "net/url_request/url_request_context.h" | 24 #include "net/url_request/url_request_context.h" |
25 #include "net/url_request/url_request_context_getter.h" | 25 #include "net/url_request/url_request_context_getter.h" |
26 | 26 |
27 namespace keys = extension_cookies_api_constants; | 27 namespace keys = extension_cookies_api_constants; |
28 | 28 |
29 ExtensionCookiesEventRouter::ExtensionCookiesEventRouter(Profile* profile) | 29 ExtensionCookiesEventRouter::ExtensionCookiesEventRouter(Profile* profile) |
30 : profile_(profile) {} | 30 : profile_(profile) {} |
31 | 31 |
32 ExtensionCookiesEventRouter::~ExtensionCookiesEventRouter() {} | 32 ExtensionCookiesEventRouter::~ExtensionCookiesEventRouter() {} |
33 | 33 |
34 void ExtensionCookiesEventRouter::Init() { | 34 void ExtensionCookiesEventRouter::Init() { |
35 CHECK(registrar_.IsEmpty()); | 35 CHECK(registrar_.IsEmpty()); |
36 registrar_.Add(this, | 36 registrar_.Add(this, |
37 chrome::NOTIFICATION_COOKIE_CHANGED, | 37 chrome::NOTIFICATION_COOKIE_CHANGED, |
38 NotificationService::AllBrowserContextsAndSources()); | 38 content::NotificationService::AllBrowserContextsAndSources()); |
39 } | 39 } |
40 | 40 |
41 void ExtensionCookiesEventRouter::Observe( | 41 void ExtensionCookiesEventRouter::Observe( |
42 int type, | 42 int type, |
43 const content::NotificationSource& source, | 43 const content::NotificationSource& source, |
44 const content::NotificationDetails& details) { | 44 const content::NotificationDetails& details) { |
45 Profile* profile = content::Source<Profile>(source).ptr(); | 45 Profile* profile = content::Source<Profile>(source).ptr(); |
46 if (!profile_->IsSameProfile(profile)) { | 46 if (!profile_->IsSameProfile(profile)) { |
47 return; | 47 return; |
48 } | 48 } |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 extension_cookies_helpers::CreateCookieStoreValue( | 533 extension_cookies_helpers::CreateCookieStoreValue( |
534 incognito_profile, incognito_tab_ids.release())); | 534 incognito_profile, incognito_tab_ids.release())); |
535 } | 535 } |
536 result_.reset(cookie_store_list); | 536 result_.reset(cookie_store_list); |
537 return true; | 537 return true; |
538 } | 538 } |
539 | 539 |
540 void GetAllCookieStoresFunction::Run() { | 540 void GetAllCookieStoresFunction::Run() { |
541 SendResponse(RunImpl()); | 541 SendResponse(RunImpl()); |
542 } | 542 } |
OLD | NEW |