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

Side by Side Diff: chrome/browser/extensions/api/cookies/cookies_api.cc

Issue 2058233002: Rewrite simple uses of base::ListValue::Append() taking a raw pointer var. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: less comments more ownership Created 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/api/cookies/cookies_api.h" 7 #include "chrome/browser/extensions/api/cookies/cookies_api.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 default: 134 default:
135 NOTREACHED(); 135 NOTREACHED();
136 } 136 }
137 } 137 }
138 138
139 void CookiesEventRouter::CookieChanged( 139 void CookiesEventRouter::CookieChanged(
140 Profile* profile, 140 Profile* profile,
141 ChromeCookieDetails* details) { 141 ChromeCookieDetails* details) {
142 std::unique_ptr<base::ListValue> args(new base::ListValue()); 142 std::unique_ptr<base::ListValue> args(new base::ListValue());
143 base::DictionaryValue* dict = new base::DictionaryValue(); 143 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
144 dict->SetBoolean(keys::kRemovedKey, details->removed); 144 dict->SetBoolean(keys::kRemovedKey, details->removed);
145 145
146 cookies::Cookie cookie = cookies_helpers::CreateCookie( 146 cookies::Cookie cookie = cookies_helpers::CreateCookie(
147 *details->cookie, cookies_helpers::GetStoreIdFromProfile(profile)); 147 *details->cookie, cookies_helpers::GetStoreIdFromProfile(profile));
148 dict->Set(keys::kCookieKey, cookie.ToValue()); 148 dict->Set(keys::kCookieKey, cookie.ToValue());
149 149
150 // Map the internal cause to an external string. 150 // Map the internal cause to an external string.
151 std::string cause; 151 std::string cause;
152 switch (details->cause) { 152 switch (details->cause) {
153 case net::CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT: 153 case net::CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT:
(...skipping 14 matching lines...) Expand all
168 168
169 case net::CookieMonsterDelegate::CHANGE_COOKIE_EXPIRED_OVERWRITE: 169 case net::CookieMonsterDelegate::CHANGE_COOKIE_EXPIRED_OVERWRITE:
170 cause = keys::kExpiredOverwriteChangeCause; 170 cause = keys::kExpiredOverwriteChangeCause;
171 break; 171 break;
172 172
173 default: 173 default:
174 NOTREACHED(); 174 NOTREACHED();
175 } 175 }
176 dict->SetString(keys::kCauseKey, cause); 176 dict->SetString(keys::kCauseKey, cause);
177 177
178 args->Append(dict); 178 args->Append(std::move(dict));
179 179
180 GURL cookie_domain = 180 GURL cookie_domain =
181 cookies_helpers::GetURLFromCanonicalCookie(*details->cookie); 181 cookies_helpers::GetURLFromCanonicalCookie(*details->cookie);
182 DispatchEvent(profile, events::COOKIES_ON_CHANGED, 182 DispatchEvent(profile, events::COOKIES_ON_CHANGED,
183 cookies::OnChanged::kEventName, std::move(args), cookie_domain); 183 cookies::OnChanged::kEventName, std::move(args), cookie_domain);
184 } 184 }
185 185
186 void CookiesEventRouter::DispatchEvent( 186 void CookiesEventRouter::DispatchEvent(
187 content::BrowserContext* context, 187 content::BrowserContext* context,
188 events::HistogramValue histogram_value, 188 events::HistogramValue histogram_value,
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 BrowserContextKeyedAPIFactory<CookiesAPI>* CookiesAPI::GetFactoryInstance() { 592 BrowserContextKeyedAPIFactory<CookiesAPI>* CookiesAPI::GetFactoryInstance() {
593 return g_factory.Pointer(); 593 return g_factory.Pointer();
594 } 594 }
595 595
596 void CookiesAPI::OnListenerAdded(const EventListenerInfo& details) { 596 void CookiesAPI::OnListenerAdded(const EventListenerInfo& details) {
597 cookies_event_router_.reset(new CookiesEventRouter(browser_context_)); 597 cookies_event_router_.reset(new CookiesEventRouter(browser_context_));
598 EventRouter::Get(browser_context_)->UnregisterObserver(this); 598 EventRouter::Get(browser_context_)->UnregisterObserver(this);
599 } 599 }
600 600
601 } // namespace extensions 601 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698