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