OLD | NEW |
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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 cookies_helpers::AppendToTabIdList(browser, original_tab_ids.get()); | 548 cookies_helpers::AppendToTabIdList(browser, original_tab_ids.get()); |
549 } else if (incognito_tab_ids.get() && | 549 } else if (incognito_tab_ids.get() && |
550 browser->profile() == incognito_profile) { | 550 browser->profile() == incognito_profile) { |
551 cookies_helpers::AppendToTabIdList(browser, incognito_tab_ids.get()); | 551 cookies_helpers::AppendToTabIdList(browser, incognito_tab_ids.get()); |
552 } | 552 } |
553 } | 553 } |
554 // Return a list of all cookie stores with at least one open tab. | 554 // Return a list of all cookie stores with at least one open tab. |
555 std::vector<cookies::CookieStore> cookie_stores; | 555 std::vector<cookies::CookieStore> cookie_stores; |
556 if (original_tab_ids->GetSize() > 0) { | 556 if (original_tab_ids->GetSize() > 0) { |
557 cookie_stores.push_back(cookies_helpers::CreateCookieStore( | 557 cookie_stores.push_back(cookies_helpers::CreateCookieStore( |
558 original_profile, original_tab_ids.release())); | 558 original_profile, std::move(original_tab_ids))); |
559 } | 559 } |
560 if (incognito_tab_ids.get() && incognito_tab_ids->GetSize() > 0 && | 560 if (incognito_tab_ids.get() && incognito_tab_ids->GetSize() > 0 && |
561 incognito_profile) { | 561 incognito_profile) { |
562 cookie_stores.push_back(cookies_helpers::CreateCookieStore( | 562 cookie_stores.push_back(cookies_helpers::CreateCookieStore( |
563 incognito_profile, incognito_tab_ids.release())); | 563 incognito_profile, std::move(incognito_tab_ids))); |
564 } | 564 } |
565 return RespondNow( | 565 return RespondNow( |
566 ArgumentList(GetAllCookieStores::Results::Create(cookie_stores))); | 566 ArgumentList(GetAllCookieStores::Results::Create(cookie_stores))); |
567 } | 567 } |
568 | 568 |
569 CookiesAPI::CookiesAPI(content::BrowserContext* context) | 569 CookiesAPI::CookiesAPI(content::BrowserContext* context) |
570 : browser_context_(context) { | 570 : browser_context_(context) { |
571 EventRouter::Get(browser_context_) | 571 EventRouter::Get(browser_context_) |
572 ->RegisterObserver(this, cookies::OnChanged::kEventName); | 572 ->RegisterObserver(this, cookies::OnChanged::kEventName); |
573 } | 573 } |
(...skipping 13 matching lines...) Expand all Loading... |
587 BrowserContextKeyedAPIFactory<CookiesAPI>* CookiesAPI::GetFactoryInstance() { | 587 BrowserContextKeyedAPIFactory<CookiesAPI>* CookiesAPI::GetFactoryInstance() { |
588 return g_factory.Pointer(); | 588 return g_factory.Pointer(); |
589 } | 589 } |
590 | 590 |
591 void CookiesAPI::OnListenerAdded(const EventListenerInfo& details) { | 591 void CookiesAPI::OnListenerAdded(const EventListenerInfo& details) { |
592 cookies_event_router_.reset(new CookiesEventRouter(browser_context_)); | 592 cookies_event_router_.reset(new CookiesEventRouter(browser_context_)); |
593 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 593 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
594 } | 594 } |
595 | 595 |
596 } // namespace extensions | 596 } // namespace extensions |
OLD | NEW |