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

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

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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 <utility> 10 #include <utility>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/bind.h" 13 #include "base/bind.h"
13 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
14 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
15 #include "base/memory/linked_ptr.h" 16 #include "base/memory/linked_ptr.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/browser/chrome_notification_types.h" 19 #include "chrome/browser/chrome_notification_types.h"
20 #include "chrome/browser/extensions/api/cookies/cookies_api_constants.h" 20 #include "chrome/browser/extensions/api/cookies/cookies_api_constants.h"
21 #include "chrome/browser/extensions/api/cookies/cookies_helpers.h" 21 #include "chrome/browser/extensions/api/cookies/cookies_helpers.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/ui/browser.h" 23 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_list.h" 24 #include "chrome/browser/ui/browser_list.h"
25 #include "chrome/common/extensions/api/cookies.h" 25 #include "chrome/common/extensions/api/cookies.h"
26 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 break; 132 break;
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 scoped_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 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) {
(...skipping 23 matching lines...) Expand all
176 dict->SetString(keys::kCauseKey, cause); 176 dict->SetString(keys::kCauseKey, cause);
177 177
178 args->Append(dict); 178 args->Append(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(content::BrowserContext* context, 186 void CookiesEventRouter::DispatchEvent(
187 events::HistogramValue histogram_value, 187 content::BrowserContext* context,
188 const std::string& event_name, 188 events::HistogramValue histogram_value,
189 scoped_ptr<base::ListValue> event_args, 189 const std::string& event_name,
190 GURL& cookie_domain) { 190 std::unique_ptr<base::ListValue> event_args,
191 GURL& cookie_domain) {
191 EventRouter* router = context ? EventRouter::Get(context) : NULL; 192 EventRouter* router = context ? EventRouter::Get(context) : NULL;
192 if (!router) 193 if (!router)
193 return; 194 return;
194 scoped_ptr<Event> event( 195 std::unique_ptr<Event> event(
195 new Event(histogram_value, event_name, std::move(event_args))); 196 new Event(histogram_value, event_name, std::move(event_args)));
196 event->restrict_to_browser_context = context; 197 event->restrict_to_browser_context = context;
197 event->event_url = cookie_domain; 198 event->event_url = cookie_domain;
198 router->BroadcastEvent(std::move(event)); 199 router->BroadcastEvent(std::move(event));
199 } 200 }
200 201
201 CookiesGetFunction::CookiesGetFunction() { 202 CookiesGetFunction::CookiesGetFunction() {
202 } 203 }
203 204
204 CookiesGetFunction::~CookiesGetFunction() { 205 CookiesGetFunction::~CookiesGetFunction() {
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 } 529 }
529 530
530 void CookiesRemoveFunction::RespondOnUIThread() { 531 void CookiesRemoveFunction::RespondOnUIThread() {
531 DCHECK_CURRENTLY_ON(BrowserThread::UI); 532 DCHECK_CURRENTLY_ON(BrowserThread::UI);
532 SendResponse(true); 533 SendResponse(true);
533 } 534 }
534 535
535 bool CookiesGetAllCookieStoresFunction::RunSync() { 536 bool CookiesGetAllCookieStoresFunction::RunSync() {
536 Profile* original_profile = GetProfile(); 537 Profile* original_profile = GetProfile();
537 DCHECK(original_profile); 538 DCHECK(original_profile);
538 scoped_ptr<base::ListValue> original_tab_ids(new base::ListValue()); 539 std::unique_ptr<base::ListValue> original_tab_ids(new base::ListValue());
539 Profile* incognito_profile = NULL; 540 Profile* incognito_profile = NULL;
540 scoped_ptr<base::ListValue> incognito_tab_ids; 541 std::unique_ptr<base::ListValue> incognito_tab_ids;
541 if (include_incognito() && GetProfile()->HasOffTheRecordProfile()) { 542 if (include_incognito() && GetProfile()->HasOffTheRecordProfile()) {
542 incognito_profile = GetProfile()->GetOffTheRecordProfile(); 543 incognito_profile = GetProfile()->GetOffTheRecordProfile();
543 if (incognito_profile) 544 if (incognito_profile)
544 incognito_tab_ids.reset(new base::ListValue()); 545 incognito_tab_ids.reset(new base::ListValue());
545 } 546 }
546 DCHECK(original_profile != incognito_profile); 547 DCHECK(original_profile != incognito_profile);
547 548
548 // Iterate through all browser instances, and for each browser, 549 // Iterate through all browser instances, and for each browser,
549 // add its tab IDs to either the regular or incognito tab ID list depending 550 // add its tab IDs to either the regular or incognito tab ID list depending
550 // whether the browser is regular or incognito. 551 // whether the browser is regular or incognito.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 BrowserContextKeyedAPIFactory<CookiesAPI>* CookiesAPI::GetFactoryInstance() { 592 BrowserContextKeyedAPIFactory<CookiesAPI>* CookiesAPI::GetFactoryInstance() {
592 return g_factory.Pointer(); 593 return g_factory.Pointer();
593 } 594 }
594 595
595 void CookiesAPI::OnListenerAdded(const EventListenerInfo& details) { 596 void CookiesAPI::OnListenerAdded(const EventListenerInfo& details) {
596 cookies_event_router_.reset(new CookiesEventRouter(browser_context_)); 597 cookies_event_router_.reset(new CookiesEventRouter(browser_context_));
597 EventRouter::Get(browser_context_)->UnregisterObserver(this); 598 EventRouter::Get(browser_context_)->UnregisterObserver(this);
598 } 599 }
599 600
600 } // namespace extensions 601 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/cookies/cookies_api.h ('k') | chrome/browser/extensions/api/cookies/cookies_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698