Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Side by Side Diff: chrome/browser/extensions/extension_cookies_api.cc

Issue 7243012: Change many extension event routers to not be singletons and to be more profile-aware. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bookmark remove observer Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/task.h" 10 #include "base/task.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/extensions/extension_cookies_api_constants.h" 12 #include "chrome/browser/extensions/extension_cookies_api_constants.h"
13 #include "chrome/browser/extensions/extension_cookies_helpers.h" 13 #include "chrome/browser/extensions/extension_cookies_helpers.h"
14 #include "chrome/browser/extensions/extension_event_router.h" 14 #include "chrome/browser/extensions/extension_event_router.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser_list.h" 16 #include "chrome/browser/ui/browser_list.h"
17 #include "chrome/common/extensions/extension.h" 17 #include "chrome/common/extensions/extension.h"
18 #include "chrome/common/extensions/extension_error_utils.h" 18 #include "chrome/common/extensions/extension_error_utils.h"
19 #include "content/browser/browser_thread.h" 19 #include "content/browser/browser_thread.h"
20 #include "content/common/notification_service.h" 20 #include "content/common/notification_service.h"
21 #include "content/common/notification_type.h" 21 #include "content/common/notification_type.h"
22 #include "net/base/cookie_monster.h" 22 #include "net/base/cookie_monster.h"
23 #include "net/url_request/url_request_context.h" 23 #include "net/url_request/url_request_context.h"
24 #include "net/url_request/url_request_context_getter.h" 24 #include "net/url_request/url_request_context_getter.h"
25 25
26 namespace keys = extension_cookies_api_constants; 26 namespace keys = extension_cookies_api_constants;
27 27
28 // static 28 ExtensionCookiesEventRouter::ExtensionCookiesEventRouter() {}
29 ExtensionCookiesEventRouter* ExtensionCookiesEventRouter::GetInstance() {
30 return Singleton<ExtensionCookiesEventRouter>::get();
31 }
32 29
33 void ExtensionCookiesEventRouter::Init() { 30 ExtensionCookiesEventRouter::~ExtensionCookiesEventRouter() {}
31
32 void ExtensionCookiesEventRouter::ObserveProfile(Profile* profile) {
34 if (registrar_.IsEmpty()) { 33 if (registrar_.IsEmpty()) {
35 registrar_.Add(this, 34 registrar_.Add(this,
36 NotificationType::COOKIE_CHANGED, 35 NotificationType::COOKIE_CHANGED,
37 NotificationService::AllSources()); 36 Source<Profile>(profile));
37 registrar_.Add(this,
38 NotificationType::COOKIE_CHANGED,
39 Source<Profile>(profile->GetOffTheRecordProfile()));
38 } 40 }
39 } 41 }
40 42
41 void ExtensionCookiesEventRouter::Observe(NotificationType type, 43 void ExtensionCookiesEventRouter::Observe(NotificationType type,
42 const NotificationSource& source, 44 const NotificationSource& source,
43 const NotificationDetails& details) { 45 const NotificationDetails& details) {
44 switch (type.value) { 46 switch (type.value) {
45 case NotificationType::COOKIE_CHANGED: 47 case NotificationType::COOKIE_CHANGED:
46 CookieChanged( 48 CookieChanged(
47 Source<Profile>(source).ptr(), 49 Source<Profile>(source).ptr(),
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 extension_cookies_helpers::CreateCookieStoreValue( 507 extension_cookies_helpers::CreateCookieStoreValue(
506 incognito_profile, incognito_tab_ids.release())); 508 incognito_profile, incognito_tab_ids.release()));
507 } 509 }
508 result_.reset(cookie_store_list); 510 result_.reset(cookie_store_list);
509 return true; 511 return true;
510 } 512 }
511 513
512 void GetAllCookieStoresFunction::Run() { 514 void GetAllCookieStoresFunction::Run() {
513 SendResponse(RunImpl()); 515 SendResponse(RunImpl());
514 } 516 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_cookies_api.h ('k') | chrome/browser/extensions/extension_history_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698