| 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 #include "chrome/browser/extensions/api/tabs/tabs_api.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 if (!MatchesBool(params->query_info.pinned.get(), | 986 if (!MatchesBool(params->query_info.pinned.get(), |
| 987 tab_strip->IsTabPinned(i))) { | 987 tab_strip->IsTabPinned(i))) { |
| 988 continue; | 988 continue; |
| 989 } | 989 } |
| 990 | 990 |
| 991 if (!MatchesBool(params->query_info.audible.get(), | 991 if (!MatchesBool(params->query_info.audible.get(), |
| 992 web_contents->WasRecentlyAudible())) { | 992 web_contents->WasRecentlyAudible())) { |
| 993 continue; | 993 continue; |
| 994 } | 994 } |
| 995 | 995 |
| 996 // If tab_manager isn't present, then no tabs are discarded. | 996 if (!MatchesBool(params->query_info.discarded.get(), |
| 997 bool discarded = tab_manager && tab_manager->IsTabDiscarded(web_contents); | 997 tab_manager->IsTabDiscarded(web_contents))) { |
| 998 if (!MatchesBool(params->query_info.discarded.get(), discarded)) | |
| 999 continue; | 998 continue; |
| 999 } |
| 1000 |
| 1001 if (!MatchesBool(params->query_info.auto_discardable.get(), |
| 1002 tab_manager->IsTabAutoDiscardable(web_contents))) { |
| 1003 continue; |
| 1004 } |
| 1000 | 1005 |
| 1001 if (!MatchesBool(params->query_info.muted.get(), | 1006 if (!MatchesBool(params->query_info.muted.get(), |
| 1002 web_contents->IsAudioMuted())) { | 1007 web_contents->IsAudioMuted())) { |
| 1003 continue; | 1008 continue; |
| 1004 } | 1009 } |
| 1005 | 1010 |
| 1006 if (!title.empty() || !url_patterns.is_empty()) { | 1011 if (!title.empty() || !url_patterns.is_empty()) { |
| 1007 // "title" and "url" properties are considered privileged data and can | 1012 // "title" and "url" properties are considered privileged data and can |
| 1008 // only be checked if the extension has the "tabs" permission or it has | 1013 // only be checked if the extension has the "tabs" permission or it has |
| 1009 // access to the WebContents's origin. Otherwise, this tab is considered | 1014 // access to the WebContents's origin. Otherwise, this tab is considered |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 include_incognito(), | 1334 include_incognito(), |
| 1330 NULL, | 1335 NULL, |
| 1331 NULL, | 1336 NULL, |
| 1332 &opener_contents, | 1337 &opener_contents, |
| 1333 NULL)) | 1338 NULL)) |
| 1334 return false; | 1339 return false; |
| 1335 | 1340 |
| 1336 tab_strip->SetOpenerOfWebContentsAt(tab_index, opener_contents); | 1341 tab_strip->SetOpenerOfWebContentsAt(tab_index, opener_contents); |
| 1337 } | 1342 } |
| 1338 | 1343 |
| 1344 if (params->update_properties.auto_discardable.get()) { |
| 1345 bool state = *params->update_properties.auto_discardable; |
| 1346 g_browser_process->GetTabManager()->SetTabAutoDiscardableState(contents, |
| 1347 state); |
| 1348 } |
| 1349 |
| 1339 if (!is_async) { | 1350 if (!is_async) { |
| 1340 PopulateResult(); | 1351 PopulateResult(); |
| 1341 SendResponse(true); | 1352 SendResponse(true); |
| 1342 } | 1353 } |
| 1343 return true; | 1354 return true; |
| 1344 } | 1355 } |
| 1345 | 1356 |
| 1346 bool TabsUpdateFunction::UpdateURL(const std::string &url_string, | 1357 bool TabsUpdateFunction::UpdateURL(const std::string &url_string, |
| 1347 int tab_id, | 1358 int tab_id, |
| 1348 bool* is_async) { | 1359 bool* is_async) { |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2200 params->tab_id | 2211 params->tab_id |
| 2201 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, | 2212 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, |
| 2202 base::IntToString(*params->tab_id)) | 2213 base::IntToString(*params->tab_id)) |
| 2203 : keys::kCannotFindTabToDiscard)); | 2214 : keys::kCannotFindTabToDiscard)); |
| 2204 } | 2215 } |
| 2205 | 2216 |
| 2206 TabsDiscardFunction::TabsDiscardFunction() {} | 2217 TabsDiscardFunction::TabsDiscardFunction() {} |
| 2207 TabsDiscardFunction::~TabsDiscardFunction() {} | 2218 TabsDiscardFunction::~TabsDiscardFunction() {} |
| 2208 | 2219 |
| 2209 } // namespace extensions | 2220 } // namespace extensions |
| OLD | NEW |