Add ICU message format support
[chromium-blink-merge.git] / chrome / browser / extensions / extension_cookie_monster_delegate.cc
blobe07efbd71a12da5ee84cb03574646f92f322c248
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/extension_cookie_monster_delegate.h"
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/net/chrome_cookie_notification_details.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/notification_service.h"
17 namespace {
18 Profile* GetProfileOnUI(ProfileManager* profile_manager, Profile* profile) {
19 if (profile_manager->IsValidProfile(profile))
20 return profile;
21 return NULL;
23 } // namespace
25 ExtensionCookieMonsterDelegate::ExtensionCookieMonsterDelegate(Profile* profile)
26 : profile_getter_(base::Bind(&GetProfileOnUI,
27 g_browser_process->profile_manager(),
28 profile)) {
29 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
30 DCHECK(profile);
33 // net::CookieMonster::Delegate implementation.
34 void ExtensionCookieMonsterDelegate::OnCookieChanged(
35 const net::CanonicalCookie& cookie,
36 bool removed,
37 net::CookieMonster::Delegate::ChangeCause cause) {
38 content::BrowserThread::PostTask(
39 content::BrowserThread::UI, FROM_HERE,
40 base::Bind(&ExtensionCookieMonsterDelegate::OnCookieChangedAsyncHelper,
41 this, cookie, removed, cause));
44 ExtensionCookieMonsterDelegate::~ExtensionCookieMonsterDelegate() {}
46 void ExtensionCookieMonsterDelegate::OnCookieChangedAsyncHelper(
47 const net::CanonicalCookie& cookie,
48 bool removed,
49 net::CookieMonster::Delegate::ChangeCause cause) {
50 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
51 Profile* profile = profile_getter_.Run();
52 if (profile) {
53 ChromeCookieDetails cookie_details(&cookie, removed, cause);
54 content::NotificationService::current()->Notify(
55 chrome::NOTIFICATION_COOKIE_CHANGED_FOR_EXTENSIONS,
56 content::Source<Profile>(profile),
57 content::Details<ChromeCookieDetails>(&cookie_details));