Chromium Code Reviews| Index: chrome/browser/extensions/api/cookies/cookies_api.cc |
| =================================================================== |
| --- chrome/browser/extensions/api/cookies/cookies_api.cc (revision 155424) |
| +++ chrome/browser/extensions/api/cookies/cookies_api.cc (working copy) |
| @@ -12,6 +12,7 @@ |
| #include "base/json/json_writer.h" |
| #include "base/memory/linked_ptr.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/time.h" |
| #include "base/values.h" |
| #include "chrome/browser/extensions/api/cookies/cookies_api_constants.h" |
| #include "chrome/browser/extensions/api/cookies/cookies_helpers.h" |
| @@ -62,14 +63,12 @@ |
| const content::NotificationSource& source, |
| const content::NotificationDetails& details) { |
| Profile* profile = content::Source<Profile>(source).ptr(); |
| - if (!profile_->IsSameProfile(profile)) { |
| + if (!profile_->IsSameProfile(profile)) |
|
jochen (gone - plz use gerrit)
2012/09/10 08:31:27
The incognito profile and the regular profile are
Lei Zhang
2012/09/10 17:55:12
Done.
|
| return; |
| - } |
| + |
| switch (type) { |
| case chrome::NOTIFICATION_COOKIE_CHANGED: |
| - CookieChanged( |
| - profile, |
| - content::Details<ChromeCookieDetails>(details).ptr()); |
| + CookieChanged(content::Details<ChromeCookieDetails>(details).ptr()); |
| break; |
| default: |
| @@ -77,19 +76,17 @@ |
| } |
| } |
| -void ExtensionCookiesEventRouter::CookieChanged( |
| - Profile* profile, |
| - ChromeCookieDetails* details) { |
| +void ExtensionCookiesEventRouter::CookieChanged(ChromeCookieDetails* details) { |
| scoped_ptr<ListValue> args(new ListValue()); |
| DictionaryValue* dict = new DictionaryValue(); |
| dict->SetBoolean(keys::kRemovedKey, details->removed); |
| scoped_ptr<Cookie> cookie( |
| cookies_helpers::CreateCookie(*details->cookie, |
| - cookies_helpers::GetStoreIdFromProfile(profile))); |
| + cookies_helpers::GetStoreIdFromProfile(profile_))); |
| dict->Set(keys::kCookieKey, cookie->ToValue().release()); |
| - // Map the interal cause to an external string. |
| + // Map the internal cause to an external string. |
| std::string cause; |
| switch (details->cause) { |
| case net::CookieMonster::Delegate::CHANGE_COOKIE_EXPLICIT: |
| @@ -121,17 +118,18 @@ |
| GURL cookie_domain = |
| cookies_helpers::GetURLFromCanonicalCookie(*details->cookie); |
| - DispatchEvent(profile, keys::kOnChanged, args.Pass(), cookie_domain); |
| + DispatchEvent(keys::kOnChanged, args.Pass(), cookie_domain); |
| } |
| void ExtensionCookiesEventRouter::DispatchEvent( |
| - Profile* profile, const char* event_name, scoped_ptr<ListValue> event_args, |
| + const std::string& event_name, |
| + scoped_ptr<ListValue> event_args, |
| GURL& cookie_domain) { |
| - if (profile && profile->GetExtensionEventRouter()) { |
| - profile->GetExtensionEventRouter()->DispatchEventToRenderers( |
| - event_name, event_args.Pass(), profile, cookie_domain, |
| - EventFilteringInfo()); |
| - } |
| + EventRouter* router = profile_ ? profile_->GetExtensionEventRouter() : NULL; |
| + if (!router) |
| + return; |
| + router->DispatchEventToRenderers(event_name, event_args.Pass(), profile_, |
| + cookie_domain); |
| } |
| bool CookiesFunction::ParseUrl(const std::string& url_string, GURL* url, |
| @@ -143,8 +141,7 @@ |
| return false; |
| } |
| // Check against host permissions if needed. |
| - if (check_host_permissions && |
| - !GetExtension()->HasHostPermission(*url)) { |
| + if (check_host_permissions && !GetExtension()->HasHostPermission(*url)) { |
| error_ = ExtensionErrorUtils::FormatErrorMessage( |
| keys::kNoHostPermissionsError, url->spec()); |
| return false; |
| @@ -267,9 +264,9 @@ |
| parsed_args_ = GetAll::Params::Create(*args_); |
| EXTENSION_FUNCTION_VALIDATE(parsed_args_.get()); |
| - if (parsed_args_->details.url.get()) { |
| - if (!ParseUrl(*parsed_args_->details.url, &url_, false)) |
| - return false; |
| + if (parsed_args_->details.url.get() && |
| + !ParseUrl(*parsed_args_->details.url, &url_, false)) { |
| + return false; |
| } |
| std::string store_id = parsed_args_->details.store_id.get() ? |