OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/net/cookie_store_util.h" | 5 #include "chrome/browser/net/cookie_store_util.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
13 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 13 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
14 #include "chrome/browser/net/evicted_domain_cookie_counter.h" | 14 #include "chrome/browser/net/evicted_domain_cookie_counter.h" |
| 15 #include "chrome/browser/prerender/prerender_manager.h" |
| 16 #include "chrome/browser/prerender/prerender_manager_factory.h" |
15 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/common/chrome_constants.h" | 19 #include "chrome/common/chrome_constants.h" |
18 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
19 #include "components/os_crypt/os_crypt.h" | 21 #include "components/os_crypt/os_crypt.h" |
20 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/browser/cookie_crypto_delegate.h" | 23 #include "content/public/browser/cookie_crypto_delegate.h" |
22 #include "content/public/browser/cookie_store_factory.h" | 24 #include "content/public/browser/cookie_store_factory.h" |
23 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
24 #include "content/public/common/content_constants.h" | 26 #include "content/public/common/content_constants.h" |
(...skipping 17 matching lines...) Expand all Loading... |
42 virtual void OnCookieChanged( | 44 virtual void OnCookieChanged( |
43 const net::CanonicalCookie& cookie, | 45 const net::CanonicalCookie& cookie, |
44 bool removed, | 46 bool removed, |
45 net::CookieMonster::Delegate::ChangeCause cause) OVERRIDE { | 47 net::CookieMonster::Delegate::ChangeCause cause) OVERRIDE { |
46 BrowserThread::PostTask( | 48 BrowserThread::PostTask( |
47 BrowserThread::UI, FROM_HERE, | 49 BrowserThread::UI, FROM_HERE, |
48 base::Bind(&ChromeCookieMonsterDelegate::OnCookieChangedAsyncHelper, | 50 base::Bind(&ChromeCookieMonsterDelegate::OnCookieChangedAsyncHelper, |
49 this, cookie, removed, cause)); | 51 this, cookie, removed, cause)); |
50 } | 52 } |
51 | 53 |
| 54 virtual void OnLoaded() OVERRIDE { |
| 55 BrowserThread::PostTask( |
| 56 BrowserThread::UI, FROM_HERE, |
| 57 base::Bind(&ChromeCookieMonsterDelegate::OnLoadedAsyncHelper, |
| 58 this)); |
| 59 } |
| 60 |
52 private: | 61 private: |
53 virtual ~ChromeCookieMonsterDelegate() {} | 62 virtual ~ChromeCookieMonsterDelegate() {} |
54 | 63 |
55 static Profile* GetProfileOnUI(ProfileManager* profile_manager, | 64 static Profile* GetProfileOnUI(ProfileManager* profile_manager, |
56 Profile* profile) { | 65 Profile* profile) { |
57 if (profile_manager->IsValidProfile(profile)) | 66 if (profile_manager->IsValidProfile(profile)) |
58 return profile; | 67 return profile; |
59 return NULL; | 68 return NULL; |
60 } | 69 } |
61 | 70 |
62 void OnCookieChangedAsyncHelper( | 71 void OnCookieChangedAsyncHelper( |
63 const net::CanonicalCookie& cookie, | 72 const net::CanonicalCookie& cookie, |
64 bool removed, | 73 bool removed, |
65 net::CookieMonster::Delegate::ChangeCause cause) { | 74 net::CookieMonster::Delegate::ChangeCause cause) { |
66 Profile* profile = profile_getter_.Run(); | 75 Profile* profile = profile_getter_.Run(); |
67 if (profile) { | 76 if (profile) { |
68 ChromeCookieDetails cookie_details(&cookie, removed, cause); | 77 ChromeCookieDetails cookie_details(&cookie, removed, cause); |
69 content::NotificationService::current()->Notify( | 78 content::NotificationService::current()->Notify( |
70 chrome::NOTIFICATION_COOKIE_CHANGED, | 79 chrome::NOTIFICATION_COOKIE_CHANGED, |
71 content::Source<Profile>(profile), | 80 content::Source<Profile>(profile), |
72 content::Details<ChromeCookieDetails>(&cookie_details)); | 81 content::Details<ChromeCookieDetails>(&cookie_details)); |
73 } | 82 } |
74 } | 83 } |
75 | 84 |
| 85 void OnLoadedAsyncHelper() { |
| 86 Profile* profile = profile_getter_.Run(); |
| 87 if (profile) { |
| 88 prerender::PrerenderManager* prerender_manager = |
| 89 prerender::PrerenderManagerFactory::GetForProfile(profile); |
| 90 if (prerender_manager) |
| 91 prerender_manager->OnCookieStoreLoaded(); |
| 92 } |
| 93 } |
| 94 |
76 const base::Callback<Profile*(void)> profile_getter_; | 95 const base::Callback<Profile*(void)> profile_getter_; |
77 }; | 96 }; |
78 | 97 |
79 } // namespace | 98 } // namespace |
80 | 99 |
81 namespace chrome_browser_net { | 100 namespace chrome_browser_net { |
82 | 101 |
83 bool IsCookieRecordMode() { | 102 bool IsCookieRecordMode() { |
84 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 103 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
85 // Only allow Record Mode if we are in a Debug build or where we are running | 104 // Only allow Record Mode if we are in a Debug build or where we are running |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 content::CookieCryptoDelegate* GetCookieCryptoDelegate() { | 155 content::CookieCryptoDelegate* GetCookieCryptoDelegate() { |
137 return g_cookie_crypto_delegate.Pointer(); | 156 return g_cookie_crypto_delegate.Pointer(); |
138 } | 157 } |
139 #else // defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) | 158 #else // defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) |
140 content::CookieCryptoDelegate* GetCookieCryptoDelegate() { | 159 content::CookieCryptoDelegate* GetCookieCryptoDelegate() { |
141 return NULL; | 160 return NULL; |
142 } | 161 } |
143 #endif // defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) | 162 #endif // defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) |
144 | 163 |
145 } // namespace chrome_browser_net | 164 } // namespace chrome_browser_net |
OLD | NEW |