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

Unified Diff: chrome/browser/extensions/api/tabs/tabs_api.cc

Issue 2067033002: Discarded property on chrome.tabs.Tab and chrome.tabs.query() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/tabs/tabs_api.cc
diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc
index 3179defec81ce864d026d376c237b789e42c7f34..6b17af5957fbb3c068fa25cd757cb850f3f76e67 100644
--- a/chrome/browser/extensions/api/tabs/tabs_api.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_api.cc
@@ -26,6 +26,7 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/api/tabs/tabs_constants.h"
#include "chrome/browser/extensions/api/tabs/windows_util.h"
@@ -34,6 +35,7 @@
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/extensions/window_controller.h"
#include "chrome/browser/extensions/window_controller_list.h"
+#include "chrome/browser/memory/tab_manager.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sessions/session_tab_helper.h"
@@ -966,6 +968,8 @@ bool TabsQueryFunction::RunSync() {
TabStripModel* tab_strip = browser->tab_strip_model();
for (int i = 0; i < tab_strip->count(); ++i) {
WebContents* web_contents = tab_strip->GetWebContentsAt(i);
+ memory::TabManager* tab_manager =
+ g_browser_process ? g_browser_process->GetTabManager() : nullptr;
if (index > -1 && i != index)
continue;
@@ -995,6 +999,19 @@ bool TabsQueryFunction::RunSync() {
continue;
}
+ // If tab_manager is not present, none tabs are discarded and therefore
chrisha 2016/06/15 15:56:12 ... no* tabs...
Anderson Silva 2016/06/16 14:04:51 Acknowledged.
+ // the tab is returned only if query_info.discarded is false. Otherwise
+ // check the matching of the parameter and the status on tab_manager.
chrisha 2016/06/15 15:56:12 Maybe slightly clearer as follows, less lines, and
Anderson Silva 2016/06/16 14:04:51 Acknowledged.
+ if (!tab_manager &&
+ !MatchesBool(params->query_info.discarded.get(), false)) {
+ continue;
+ }
+ if (tab_manager &&
+ !MatchesBool(params->query_info.discarded.get(),
+ tab_manager->IsTabDiscarded(web_contents))) {
+ continue;
+ }
+
if (!title.empty() || !url_patterns.is_empty()) {
// "title" and "url" properties are considered privileged data and can
// only be checked if the extension has the "tabs" permission or it has
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_tab_util.cc » ('j') | chrome/browser/extensions/extension_tab_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698