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

Unified Diff: chrome/browser/extensions/api/cookies/cookies_api.cc

Issue 10915153: Cleanup: Simplify some extension API code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/api/cookies/cookies_api.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,9 +63,9 @@
const content::NotificationSource& source,
const content::NotificationDetails& details) {
Profile* profile = content::Source<Profile>(source).ptr();
- if (!profile_->IsSameProfile(profile)) {
+ if (!profile_->IsSameProfile(profile))
return;
- }
+
switch (type) {
case chrome::NOTIFICATION_COOKIE_CHANGED:
CookieChanged(
@@ -86,10 +87,10 @@
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:
@@ -125,13 +126,15 @@
}
void ExtensionCookiesEventRouter::DispatchEvent(
- Profile* profile, const char* event_name, scoped_ptr<ListValue> event_args,
+ Profile* profile,
+ 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 +146,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 +269,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() ?
« no previous file with comments | « chrome/browser/extensions/api/cookies/cookies_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698