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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/extensions/api/cookies/cookies_api_constants.h" | 17 #include "chrome/browser/extensions/api/cookies/cookies_api_constants.h" |
18 #include "chrome/browser/extensions/api/cookies/cookies_helpers.h" | 18 #include "chrome/browser/extensions/api/cookies/cookies_helpers.h" |
19 #include "chrome/browser/extensions/event_router.h" | 19 #include "chrome/browser/extensions/event_router.h" |
| 20 #include "chrome/browser/extensions/extension_system.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
23 #include "chrome/common/chrome_notification_types.h" | 24 #include "chrome/common/chrome_notification_types.h" |
24 #include "chrome/common/extensions/api/cookies.h" | 25 #include "chrome/common/extensions/api/cookies.h" |
25 #include "chrome/common/extensions/extension.h" | 26 #include "chrome/common/extensions/extension.h" |
26 #include "chrome/common/extensions/extension_error_utils.h" | 27 #include "chrome/common/extensions/extension_error_utils.h" |
27 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
28 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
29 #include "net/cookies/canonical_cookie.h" | 30 #include "net/cookies/canonical_cookie.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 GURL cookie_domain = | 124 GURL cookie_domain = |
124 cookies_helpers::GetURLFromCanonicalCookie(*details->cookie); | 125 cookies_helpers::GetURLFromCanonicalCookie(*details->cookie); |
125 DispatchEvent(profile, keys::kOnChanged, args.Pass(), cookie_domain); | 126 DispatchEvent(profile, keys::kOnChanged, args.Pass(), cookie_domain); |
126 } | 127 } |
127 | 128 |
128 void ExtensionCookiesEventRouter::DispatchEvent( | 129 void ExtensionCookiesEventRouter::DispatchEvent( |
129 Profile* profile, | 130 Profile* profile, |
130 const std::string& event_name, | 131 const std::string& event_name, |
131 scoped_ptr<ListValue> event_args, | 132 scoped_ptr<ListValue> event_args, |
132 GURL& cookie_domain) { | 133 GURL& cookie_domain) { |
133 EventRouter* router = profile ? profile->GetExtensionEventRouter() : NULL; | 134 EventRouter* router = profile ? |
| 135 extensions::ExtensionSystem::Get(profile)->event_router() : NULL; |
134 if (!router) | 136 if (!router) |
135 return; | 137 return; |
136 router->DispatchEventToRenderers(event_name, event_args.Pass(), profile, | 138 router->DispatchEventToRenderers(event_name, event_args.Pass(), profile, |
137 cookie_domain); | 139 cookie_domain); |
138 } | 140 } |
139 | 141 |
140 bool CookiesFunction::ParseUrl(const std::string& url_string, GURL* url, | 142 bool CookiesFunction::ParseUrl(const std::string& url_string, GURL* url, |
141 bool check_host_permissions) { | 143 bool check_host_permissions) { |
142 *url = GURL(url_string); | 144 *url = GURL(url_string); |
143 if (!url->is_valid()) { | 145 if (!url->is_valid()) { |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 } | 537 } |
536 results_ = GetAllCookieStores::Results::Create(cookie_stores); | 538 results_ = GetAllCookieStores::Results::Create(cookie_stores); |
537 return true; | 539 return true; |
538 } | 540 } |
539 | 541 |
540 void GetAllCookieStoresFunction::Run() { | 542 void GetAllCookieStoresFunction::Run() { |
541 SendResponse(RunImpl()); | 543 SendResponse(RunImpl()); |
542 } | 544 } |
543 | 545 |
544 } // namespace extensions | 546 } // namespace extensions |
OLD | NEW |