summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-28 03:32:30 +0000
committerjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-28 03:32:30 +0000
commit8c3495cdfbc29b4d903103bf3f0cea7e5bfc24de (patch)
tree025f57b645272c61fe681d1418acfc4523309381 /chrome
parent98af60b92b1828945dca0c8cf384645a62682f6d (diff)
downloadchromium_src-8c3495cdfbc29b4d903103bf3f0cea7e5bfc24de.zip
chromium_src-8c3495cdfbc29b4d903103bf3f0cea7e5bfc24de.tar.gz
chromium_src-8c3495cdfbc29b4d903103bf3f0cea7e5bfc24de.tar.bz2
Extend chrome.tabs* API to support multiple tabs.
This adds support for handling multiple tabs, including selecting, removing and moving many tabs at once. (Selecting is now called highlighting for backwards compatibility). The changes are outlined below. Adds: - 'highlighted' property to Tab, chrome.tabs.update - chrome.tabs.query for searching across tabs - chrome.tabs.highlight for selecting multiple tabs - chrome.tabs.onHighlightChanged for listening to multi-select events Modifies: - renames 'selected' to 'active' on Tab, chrome.tabs.create, chrome.tabs.update - renames onSelectionChanged to onActiveChanged - chrome.tabs.move to accept an array of tabs or a single tab - chrome.tabs.remove to accept an array of tabs or a single tab - deprecates chrome.tabs.getSelected in favor of chrome.tabs.query - deprecates chrome.tabs.getAllInWindow in favor of chrome.tabs.query BUG=81411 TEST=ExtensionApiTest.*Tab* Review URL: http://codereview.chromium.org/7731004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103084 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/extension_browser_event_router.cc33
-rw-r--r--chrome/browser/extensions/extension_browser_event_router.h3
-rw-r--r--chrome/browser/extensions/extension_event_names.cc2
-rw-r--r--chrome/browser/extensions/extension_event_names.h2
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.cc6
-rw-r--r--chrome/browser/extensions/extension_tab_util.cc36
-rw-r--r--chrome/browser/extensions/extension_tab_util.h2
-rw-r--r--chrome/browser/extensions/extension_tabs_apitest.cc10
-rw-r--r--chrome/browser/extensions/extension_tabs_module.cc440
-rw-r--r--chrome/browser/extensions/extension_tabs_module.h18
-rw-r--r--chrome/browser/extensions/extension_tabs_module_constants.cc6
-rw-r--r--chrome/browser/extensions/extension_tabs_module_constants.h6
-rw-r--r--chrome/browser/tabs/tab_strip_model.cc4
-rw-r--r--chrome/browser/tabs/tab_strip_model_observer.cc1
-rw-r--r--chrome/browser/tabs/tab_strip_model_observer.h10
-rw-r--r--chrome/browser/tabs/tab_strip_model_unittest.cc3
-rw-r--r--chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc3
-rw-r--r--chrome/browser/ui/gtk/tabs/tab_strip_gtk.h3
-rw-r--r--chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc1
-rw-r--r--chrome/browser/ui/views/tabs/browser_tab_strip_controller.h1
-rw-r--r--chrome/common/extensions/api/extension_api.json222
-rw-r--r--chrome/common/extensions/docs/samples.json4
-rw-r--r--chrome/common/extensions/docs/tabs.html2025
-rw-r--r--chrome/test/data/extensions/api_test/tabs/basics/crud.html10
-rw-r--r--chrome/test/data/extensions/api_test/tabs/basics/crud2.html27
-rw-r--r--chrome/test/data/extensions/api_test/tabs/basics/highlight.html131
-rw-r--r--chrome/test/data/extensions/api_test/tabs/basics/move.html33
-rw-r--r--chrome/test/data/extensions/api_test/tabs/basics/query.html165
-rw-r--r--chrome/test/data/extensions/api_test/tabs/basics/tabs_util.js4
29 files changed, 2658 insertions, 553 deletions
diff --git a/chrome/browser/extensions/extension_browser_event_router.cc b/chrome/browser/extensions/extension_browser_event_router.cc
index 661cdb4..66b3236 100644
--- a/chrome/browser/extensions/extension_browser_event_router.cc
+++ b/chrome/browser/extensions/extension_browser_event_router.cc
@@ -345,8 +345,41 @@ void ExtensionBrowserEventRouter::ActiveTabChanged(
std::string json_args;
base::JSONWriter::Write(&args, false, &json_args);
+ // The onTabSelectionChanged event has been deprecated by onActiveChanged.
DispatchEvent(new_contents->profile(), events::kOnTabSelectionChanged,
json_args);
+ DispatchEvent(new_contents->profile(), events::kOnTabActiveChanged,
+ json_args);
+}
+
+void ExtensionBrowserEventRouter::TabSelectionChanged(
+ TabStripModel* tab_strip_model,
+ const TabStripSelectionModel& old_model) {
+ TabStripSelectionModel::SelectedIndices new_selection =
+ tab_strip_model->selection_model().selected_indices();
+ ListValue* all = new ListValue();
+
+ for (size_t i = 0; i < new_selection.size(); ++i) {
+ int index = new_selection[i];
+ int tab_id = ExtensionTabUtil::GetTabId(
+ tab_strip_model->GetTabContentsAt(index)->tab_contents());
+ all->Append(Value::CreateIntegerValue(tab_id));
+ }
+
+ ListValue args;
+ DictionaryValue* select_info = new DictionaryValue();
+
+ select_info->Set(tab_keys::kWindowIdKey, Value::CreateIntegerValue(
+ ExtensionTabUtil::GetWindowIdOfTabStripModel(tab_strip_model)));
+
+ select_info->Set(tab_keys::kTabIdsKey, all);
+ args.Append(select_info);
+
+ std::string json_args;
+ base::JSONWriter::Write(&args, false, &json_args);
+
+ DispatchEvent(tab_strip_model->profile(), events::kOnTabHighlightChanged,
+ json_args);
}
void ExtensionBrowserEventRouter::TabMoved(TabContentsWrapper* contents,
diff --git a/chrome/browser/extensions/extension_browser_event_router.h b/chrome/browser/extensions/extension_browser_event_router.h
index 409e744..c3f104f 100644
--- a/chrome/browser/extensions/extension_browser_event_router.h
+++ b/chrome/browser/extensions/extension_browser_event_router.h
@@ -68,6 +68,9 @@ class ExtensionBrowserEventRouter : public TabStripModelObserver,
TabContentsWrapper* new_contents,
int index,
bool user_gesture) OVERRIDE;
+ virtual void TabSelectionChanged(
+ TabStripModel* tab_strip_model,
+ const TabStripSelectionModel& old_model) OVERRIDE;
virtual void TabMoved(TabContentsWrapper* contents, int from_index,
int to_index) OVERRIDE;
virtual void TabChangedAt(TabContentsWrapper* contents, int index,
diff --git a/chrome/browser/extensions/extension_event_names.cc b/chrome/browser/extensions/extension_event_names.cc
index 76904bf..8c67a4d 100644
--- a/chrome/browser/extensions/extension_event_names.cc
+++ b/chrome/browser/extensions/extension_event_names.cc
@@ -6,9 +6,11 @@
namespace extension_event_names {
+const char kOnTabActiveChanged[] = "tabs.onActiveChanged";
const char kOnTabAttached[] = "tabs.onAttached";
const char kOnTabCreated[] = "tabs.onCreated";
const char kOnTabDetached[] = "tabs.onDetached";
+const char kOnTabHighlightChanged[] = "tabs.onHighlightChanged";
const char kOnTabMoved[] = "tabs.onMoved";
const char kOnTabRemoved[] = "tabs.onRemoved";
const char kOnTabSelectionChanged[] = "tabs.onSelectionChanged";
diff --git a/chrome/browser/extensions/extension_event_names.h b/chrome/browser/extensions/extension_event_names.h
index 2e44797..67b3dd2 100644
--- a/chrome/browser/extensions/extension_event_names.h
+++ b/chrome/browser/extensions/extension_event_names.h
@@ -11,9 +11,11 @@
namespace extension_event_names {
// Tabs.
+extern const char kOnTabActiveChanged[];
extern const char kOnTabAttached[];
extern const char kOnTabCreated[];
extern const char kOnTabDetached[];
+extern const char kOnTabHighlightChanged[];
extern const char kOnTabMoved[];
extern const char kOnTabRemoved[];
extern const char kOnTabSelectionChanged[];
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 74341d0..619d841 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -145,11 +145,13 @@ void FactoryRegistry::ResetFunctions() {
RegisterFunction<GetCurrentTabFunction>();
RegisterFunction<GetSelectedTabFunction>();
RegisterFunction<GetAllTabsInWindowFunction>();
+ RegisterFunction<QueryTabsFunction>();
+ RegisterFunction<HighlightTabsFunction>();
RegisterFunction<CreateTabFunction>();
RegisterFunction<UpdateTabFunction>();
- RegisterFunction<MoveTabFunction>();
+ RegisterFunction<MoveTabsFunction>();
RegisterFunction<ReloadTabFunction>();
- RegisterFunction<RemoveTabFunction>();
+ RegisterFunction<RemoveTabsFunction>();
RegisterFunction<DetectTabLanguageFunction>();
RegisterFunction<CaptureVisibleTabFunction>();
RegisterFunction<TabsExecuteScriptFunction>();
diff --git a/chrome/browser/extensions/extension_tab_util.cc b/chrome/browser/extensions/extension_tab_util.cc
index 6bf27d6..51030fe 100644
--- a/chrome/browser/extensions/extension_tab_util.cc
+++ b/chrome/browser/extensions/extension_tab_util.cc
@@ -20,6 +20,16 @@ int ExtensionTabUtil::GetWindowId(const Browser* browser) {
return browser->session_id().id();
}
+int ExtensionTabUtil::GetWindowIdOfTabStripModel(
+ const TabStripModel* tab_strip_model) {
+ for (BrowserList::const_iterator it = BrowserList::begin();
+ it != BrowserList::end(); ++it) {
+ if ((*it)->tabstrip_model() == tab_strip_model)
+ return GetWindowId(*it);
+ }
+ return -1;
+}
+
// TODO(sky): this function should really take a TabContentsWrapper.
int ExtensionTabUtil::GetTabId(const TabContents* tab_contents) {
const TabContentsWrapper* tab =
@@ -38,6 +48,17 @@ int ExtensionTabUtil::GetWindowIdOfTab(const TabContents* tab_contents) {
return tab ? tab->restore_tab_helper()->window_id().id() : -1;
}
+// Return the type name for a browser window type.
+std::string ExtensionTabUtil::GetWindowTypeText(const Browser* browser) {
+ if (browser->is_type_popup())
+ return keys::kWindowTypeValuePopup;
+ if (browser->is_type_panel())
+ return keys::kWindowTypeValuePanel;
+ if (browser->is_app())
+ return keys::kWindowTypeValueApp;
+ return keys::kWindowTypeValueNormal;
+}
+
DictionaryValue* ExtensionTabUtil::CreateTabValue(
const TabContents* contents) {
// Find the tab strip and index of this guy.
@@ -72,8 +93,12 @@ DictionaryValue* ExtensionTabUtil::CreateTabValue(const TabContents* contents,
ExtensionTabUtil::GetWindowIdOfTab(contents));
result->SetString(keys::kUrlKey, contents->GetURL().spec());
result->SetString(keys::kStatusKey, GetTabStatusText(is_loading));
+ result->SetBoolean(keys::kActiveKey,
+ tab_strip && tab_index == tab_strip->active_index());
result->SetBoolean(keys::kSelectedKey,
tab_strip && tab_index == tab_strip->active_index());
+ result->SetBoolean(keys::kHighlightedKey,
+ tab_strip && tab_strip->IsTabSelected(tab_index));
result->SetBoolean(keys::kPinnedKey,
tab_strip && tab_strip->IsTabPinned(tab_index));
result->SetString(keys::kTitleKey, contents->GetTitle());
@@ -99,17 +124,6 @@ DictionaryValue* ExtensionTabUtil::CreateTabValueActive(
return result;
}
-// Return the type name for a browser window type.
-static std::string GetWindowTypeText(const Browser* browser) {
- if (browser->is_type_popup())
- return keys::kWindowTypeValuePopup;
- if (browser->is_type_panel())
- return keys::kWindowTypeValuePanel;
- if (browser->is_app())
- return keys::kWindowTypeValueApp;
- return keys::kWindowTypeValueNormal;
-}
-
// if |populate| is true, each window gets a list property |tabs| which contains
// fully populated tab objects.
DictionaryValue* ExtensionTabUtil::CreateWindowValue(const Browser* browser,
diff --git a/chrome/browser/extensions/extension_tab_util.h b/chrome/browser/extensions/extension_tab_util.h
index 5dfb36f..37ada14 100644
--- a/chrome/browser/extensions/extension_tab_util.h
+++ b/chrome/browser/extensions/extension_tab_util.h
@@ -23,12 +23,14 @@ class ListValue;
class ExtensionTabUtil {
public:
static int GetWindowId(const Browser* browser);
+ static int GetWindowIdOfTabStripModel(const TabStripModel* tab_strip_model);
static int GetTabId(const TabContents* tab_contents);
static bool GetTabIdFromArgument(const base::ListValue &args,
int argument_index,
int *tab_id, std::string* error_message);
static std::string GetTabStatusText(bool is_loading);
static int GetWindowIdOfTab(const TabContents* tab_contents);
+ static std::string GetWindowTypeText(const Browser* browser);
static base::ListValue* CreateTabList(const Browser* browser);
static base::DictionaryValue* CreateTabValue(
const TabContents* tab_contents);
diff --git a/chrome/browser/extensions/extension_tabs_apitest.cc b/chrome/browser/extensions/extension_tabs_apitest.cc
index 3156ce7..c834e36 100644
--- a/chrome/browser/extensions/extension_tabs_apitest.cc
+++ b/chrome/browser/extensions/extension_tabs_apitest.cc
@@ -108,6 +108,16 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TabRelativeURLs) {
<< message_;
}
+IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TabQuery) {
+ ASSERT_TRUE(StartTestServer());
+ ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "query.html")) << message_;
+}
+
+IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TabHighlight) {
+ ASSERT_TRUE(StartTestServer());
+ ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "highlight.html")) << message_;
+}
+
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, TabCrashBrowser) {
ASSERT_TRUE(StartTestServer());
ASSERT_TRUE(RunExtensionSubtest("tabs/basics", "crash.html")) << message_;
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
index 5f55e70..1a2fd2d 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -10,6 +10,7 @@
#include "base/base64.h"
#include "base/memory/ref_counted_memory.h"
#include "base/stl_util.h"
+#include "base/string16.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
@@ -129,6 +130,53 @@ bool IsCrashURL(const GURL& url) {
fixed_url.host() == chrome::kChromeUICrashHost));
}
+// Reads the |value| as either a single integer value or a list of integers.
+bool ReadOneOrMoreIntegers(
+ Value* value, std::vector<int>* result) {
+ if (value->IsType(Value::TYPE_INTEGER)) {
+ int tab_id;
+ if (!value->GetAsInteger(&tab_id))
+ return false;
+ result->push_back(tab_id);
+ return true;
+
+ } else if (value->IsType(Value::TYPE_LIST)) {
+ ListValue* tabs = static_cast<ListValue*>(value);
+ for (size_t i = 0; i < tabs->GetSize(); ++i) {
+ int tab_id;
+ if (!tabs->GetInteger(i, &tab_id))
+ return false;
+ result->push_back(tab_id);
+ }
+ return true;
+ }
+ return false;
+}
+
+// A three state enum to distinguish between when a boolean query argument is
+// set or not.
+enum QueryArg {
+ NOT_SET = -1,
+ MATCH_FALSE,
+ MATCH_TRUE
+};
+
+bool MatchesQueryArg(QueryArg arg, bool value) {
+ if (arg == NOT_SET)
+ return true;
+
+ return (arg == MATCH_TRUE && value) || (arg == MATCH_FALSE && !value);
+}
+
+QueryArg ParseBoolQueryArg(base::DictionaryValue* query, const char* key) {
+ if (query->HasKey(key)) {
+ bool value = false;
+ CHECK(query->GetBoolean(key, &value));
+ return value ? MATCH_TRUE : MATCH_FALSE;
+ }
+ return NOT_SET;
+}
+
} // namespace
// Windows ---------------------------------------------------------------------
@@ -561,6 +609,92 @@ bool GetAllTabsInWindowFunction::RunImpl() {
return true;
}
+bool QueryTabsFunction::RunImpl() {
+ DictionaryValue* query = NULL;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &query));
+
+ QueryArg active = ParseBoolQueryArg(query, keys::kActiveKey);
+ QueryArg pinned = ParseBoolQueryArg(query, keys::kPinnedKey);
+ QueryArg selected = ParseBoolQueryArg(query, keys::kHighlightedKey);
+
+ QueryArg loading = NOT_SET;
+ if (query->HasKey(keys::kStatusKey)) {
+ std::string status;
+ EXTENSION_FUNCTION_VALIDATE(query->GetString(keys::kStatusKey, &status));
+ loading = (status == keys::kStatusValueLoading) ? MATCH_TRUE : MATCH_FALSE;
+ }
+
+ URLPattern url_pattern(URLPattern::SCHEME_ALL, "<all_urls>");
+ if (query->HasKey(keys::kUrlKey)) {
+ std::string value;
+ EXTENSION_FUNCTION_VALIDATE(query->GetString(keys::kUrlKey, &value));
+ url_pattern = URLPattern(URLPattern::SCHEME_ALL, value);
+ }
+
+ std::string title;
+ if (query->HasKey(keys::kTitleKey))
+ EXTENSION_FUNCTION_VALIDATE(
+ query->GetString(keys::kTitleKey, &title));
+
+ int window_id = -1;
+ if (query->HasKey(keys::kWindowIdKey))
+ EXTENSION_FUNCTION_VALIDATE(
+ query->GetInteger(keys::kWindowIdKey, &window_id));
+
+ std::string window_type;
+ if (query->HasKey(keys::kWindowTypeLongKey))
+ EXTENSION_FUNCTION_VALIDATE(
+ query->GetString(keys::kWindowTypeLongKey, &window_type));
+
+ ListValue* result = new ListValue();
+ for (BrowserList::const_iterator browser = BrowserList::begin();
+ browser != BrowserList::end(); ++browser) {
+ if (!profile()->IsSameProfile((*browser)->profile()))
+ continue;
+
+ if (!(*browser)->window())
+ continue;
+
+ if (window_id >= 0 && window_id != ExtensionTabUtil::GetWindowId(*browser))
+ continue;
+
+ if (!window_type.empty() &&
+ window_type != ExtensionTabUtil::GetWindowTypeText(*browser))
+ continue;
+
+ TabStripModel* tab_strip = (*browser)->tabstrip_model();
+ for (int i = 0; i < tab_strip->count(); ++i) {
+ const TabContents* tab_contents =
+ tab_strip->GetTabContentsAt(i)->tab_contents();
+
+ if (!MatchesQueryArg(selected, tab_strip->IsTabSelected(i)))
+ continue;
+
+ if (!MatchesQueryArg(active, i == tab_strip->active_index()))
+ continue;
+
+ if (!MatchesQueryArg(pinned, tab_strip->IsTabPinned(i)))
+ continue;
+
+ if (!title.empty() && !MatchPattern(tab_contents->GetTitle(),
+ UTF8ToUTF16(title)))
+ continue;
+
+ if (!url_pattern.MatchesURL(tab_contents->GetURL()))
+ continue;
+
+ if (!MatchesQueryArg(loading, tab_contents->IsLoading()))
+ continue;
+
+ result->Append(ExtensionTabUtil::CreateTabValue(
+ tab_contents, tab_strip, i));
+ }
+ }
+
+ result_.reset(result);
+ return true;
+}
+
bool CreateTabFunction::RunImpl() {
DictionaryValue* args;
EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &args));
@@ -605,11 +739,17 @@ bool CreateTabFunction::RunImpl() {
}
// Default to foreground for the new tab. The presence of 'selected' property
- // will override this default.
- bool selected = true;
+ // will override this default. This property is deprecated ('active' should
+ // be used instead).
+ bool active = true;
if (args->HasKey(keys::kSelectedKey))
- EXTENSION_FUNCTION_VALIDATE(args->GetBoolean(keys::kSelectedKey,
- &selected));
+ EXTENSION_FUNCTION_VALIDATE(
+ args->GetBoolean(keys::kSelectedKey, &active));
+
+ // The 'active' property has replaced the 'selected' property.
+ if (args->HasKey(keys::kActiveKey))
+ EXTENSION_FUNCTION_VALIDATE(
+ args->GetBoolean(keys::kActiveKey, &active));
// Default to not pinning the tab. Setting the 'pinned' property to true
// will override this default.
@@ -640,18 +780,18 @@ bool CreateTabFunction::RunImpl() {
index = std::min(std::max(index, -1), tab_strip->count());
- int add_types = selected ? TabStripModel::ADD_ACTIVE :
+ int add_types = active ? TabStripModel::ADD_ACTIVE :
TabStripModel::ADD_NONE;
add_types |= TabStripModel::ADD_FORCE_INDEX;
if (pinned)
add_types |= TabStripModel::ADD_PINNED;
browser::NavigateParams params(browser, url, PageTransition::LINK);
- params.disposition = selected ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB;
+ params.disposition = active ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB;
params.tabstrip_index = index;
params.tabstrip_add_types = add_types;
browser::Navigate(&params);
- if (selected)
+ if (active)
params.target_contents->view()->SetInitialFocus();
// Return data about the newly created tab.
@@ -693,6 +833,64 @@ bool GetCurrentTabFunction::RunImpl() {
return true;
}
+bool HighlightTabsFunction::RunImpl() {
+ DictionaryValue* info = NULL;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &info));
+
+ // Get the window id from the params.
+ int window_id = -1;
+ EXTENSION_FUNCTION_VALIDATE(
+ info->GetInteger(keys::kWindowIdKey, &window_id));
+
+ Browser* browser = GetBrowserInProfileWithId(
+ profile(), window_id, include_incognito(), &error_);
+
+ if (!browser || !browser->window()) {
+ error_ = ExtensionErrorUtils::FormatErrorMessage(
+ keys::kWindowNotFoundError, base::IntToString(window_id));
+ return false;
+ }
+
+ TabStripModel* tabstrip = browser->tabstrip_model();
+ TabStripSelectionModel selection;
+ int active_index = -1;
+
+ Value* tab_value = NULL;
+ EXTENSION_FUNCTION_VALIDATE(info->Get(keys::kTabsKey, &tab_value));
+
+ std::vector<int> tab_indices;
+ EXTENSION_FUNCTION_VALIDATE(ReadOneOrMoreIntegers(tab_value, &tab_indices));
+
+ // Create a new selection model as we read the list of tab indices.
+ for (size_t i = 0; i < tab_indices.size(); ++i) {
+ int index = tab_indices[i];
+
+ // Make sure the index is in range.
+ if (!tabstrip->ContainsIndex(index)) {
+ error_ = ExtensionErrorUtils::FormatErrorMessage(
+ keys::kTabIndexNotFoundError, base::IntToString(index));
+ return false;
+ }
+
+ // By default, we make the first tab in the list active.
+ if (active_index == -1)
+ active_index = index;
+
+ selection.AddIndexToSelection(index);
+ }
+
+ // Make sure they actually specified tabs to select.
+ if (selection.empty()) {
+ error_ = keys::kNoHighlightedTabError;
+ return false;
+ }
+
+ selection.set_active(active_index);
+ browser->tabstrip_model()->SetSelectionFromModel(selection);
+ result_.reset(ExtensionTabUtil::CreateWindowValue(browser, true));
+ return true;
+}
+
UpdateTabFunction::UpdateTabFunction() {
}
@@ -790,20 +988,32 @@ bool UpdateTabFunction::RunImpl() {
DCHECK_EQ(url.spec(), contents->tab_contents()->GetURL().spec());
}
- bool selected = false;
- // TODO(rafaelw): Setting |selected| from js doesn't make much sense.
+ bool active = false;
+ // TODO(rafaelw): Setting |active| from js doesn't make much sense.
// Move tab selection management up to window.
- if (update_props->HasKey(keys::kSelectedKey)) {
+ if (update_props->HasKey(keys::kSelectedKey))
EXTENSION_FUNCTION_VALIDATE(update_props->GetBoolean(
- keys::kSelectedKey,
- &selected));
- if (selected) {
- if (tab_strip->active_index() != tab_index) {
- tab_strip->ActivateTabAt(tab_index, false);
- DCHECK_EQ(contents, tab_strip->GetActiveTabContents());
- }
- contents->tab_contents()->Focus();
+ keys::kSelectedKey, &active));
+
+ // The 'active' property has replaced 'selected'.
+ if (update_props->HasKey(keys::kActiveKey))
+ EXTENSION_FUNCTION_VALIDATE(update_props->GetBoolean(
+ keys::kActiveKey, &active));
+
+ if (active) {
+ if (tab_strip->active_index() != tab_index) {
+ tab_strip->ActivateTabAt(tab_index, false);
+ DCHECK_EQ(contents, tab_strip->GetActiveTabContents());
}
+ contents->tab_contents()->Focus();
+ }
+
+ bool highlighted = false;
+ if (update_props->HasKey(keys::kHighlightedKey)) {
+ EXTENSION_FUNCTION_VALIDATE(update_props->GetBoolean(
+ keys::kHighlightedKey, &highlighted));
+ if (highlighted != tab_strip->IsTabSelected(tab_index))
+ tab_strip->ToggleSelectionAt(tab_index);
}
bool pinned = false;
@@ -865,9 +1075,13 @@ void UpdateTabFunction::OnExecuteCodeFinished(int request_id,
Release(); // balanced in Execute()
}
-bool MoveTabFunction::RunImpl() {
- int tab_id;
- EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id));
+bool MoveTabsFunction::RunImpl() {
+ Value* tab_value = NULL;
+ EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &tab_value));
+
+ std::vector<int> tab_ids;
+ EXTENSION_FUNCTION_VALIDATE(ReadOneOrMoreIntegers(tab_value, &tab_ids));
+
DictionaryValue* update_props;
EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &update_props));
@@ -876,86 +1090,103 @@ bool MoveTabFunction::RunImpl() {
keys::kIndexKey, &new_index));
EXTENSION_FUNCTION_VALIDATE(new_index >= 0);
- Browser* source_browser = NULL;
- TabStripModel* source_tab_strip = NULL;
- TabContentsWrapper* contents = NULL;
- int tab_index = -1;
- if (!GetTabById(tab_id, profile(), include_incognito(),
- &source_browser, &source_tab_strip, &contents,
- &tab_index, &error_))
- return false;
-
- // Don't let the extension move the tab if the user is dragging tabs.
- if (!source_browser->IsTabStripEditable()) {
- error_ = keys::kTabStripNotEditableError;
- return false;
- }
-
- if (update_props->HasKey(keys::kWindowIdKey)) {
- Browser* target_browser;
- int window_id;
- EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger(
- keys::kWindowIdKey, &window_id));
- target_browser = GetBrowserInProfileWithId(profile(), window_id,
- include_incognito(), &error_);
- if (!target_browser)
+ ListValue tab_values;
+ for (size_t i = 0; i < tab_ids.size(); ++i) {
+ Browser* source_browser = NULL;
+ TabStripModel* source_tab_strip = NULL;
+ TabContentsWrapper* contents = NULL;
+ int tab_index = -1;
+ if (!GetTabById(tab_ids[i], profile(), include_incognito(),
+ &source_browser, &source_tab_strip, &contents,
+ &tab_index, &error_))
return false;
- if (!target_browser->IsTabStripEditable()) {
+ // Don't let the extension move the tab if the user is dragging tabs.
+ if (!source_browser->IsTabStripEditable()) {
error_ = keys::kTabStripNotEditableError;
return false;
}
- if (!target_browser->is_type_tabbed()) {
- error_ = keys::kCanOnlyMoveTabsWithinNormalWindowsError;
- return false;
- }
+ // Insert the tabs one after another.
+ new_index += i;
+
+ if (update_props->HasKey(keys::kWindowIdKey)) {
+ Browser* target_browser;
+ int window_id;
+ EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger(
+ keys::kWindowIdKey, &window_id));
+ target_browser = GetBrowserInProfileWithId(profile(), window_id,
+ include_incognito(), &error_);
+ if (!target_browser)
+ return false;
- if (target_browser->profile() != source_browser->profile()) {
- error_ = keys::kCanOnlyMoveTabsWithinSameProfileError;
- return false;
- }
+ if (!target_browser->IsTabStripEditable()) {
+ error_ = keys::kTabStripNotEditableError;
+ return false;
+ }
- // If windowId is different from the current window, move between windows.
- if (ExtensionTabUtil::GetWindowId(target_browser) !=
- ExtensionTabUtil::GetWindowId(source_browser)) {
- TabStripModel* target_tab_strip = target_browser->tabstrip_model();
- contents = source_tab_strip->DetachTabContentsAt(tab_index);
- if (!contents) {
- error_ = ExtensionErrorUtils::FormatErrorMessage(
- keys::kTabNotFoundError, base::IntToString(tab_id));
+ if (!target_browser->is_type_tabbed()) {
+ error_ = keys::kCanOnlyMoveTabsWithinNormalWindowsError;
return false;
}
- // Clamp move location to the last position.
- // This is ">" because it can append to a new index position.
- if (new_index > target_tab_strip->count())
- new_index = target_tab_strip->count();
+ if (target_browser->profile() != source_browser->profile()) {
+ error_ = keys::kCanOnlyMoveTabsWithinSameProfileError;
+ return false;
+ }
- target_tab_strip->InsertTabContentsAt(new_index, contents,
- TabStripModel::ADD_NONE);
+ // If windowId is different from the current window, move between windows.
+ if (ExtensionTabUtil::GetWindowId(target_browser) !=
+ ExtensionTabUtil::GetWindowId(source_browser)) {
+ TabStripModel* target_tab_strip = target_browser->tabstrip_model();
+ contents = source_tab_strip->DetachTabContentsAt(tab_index);
+ if (!contents) {
+ error_ = ExtensionErrorUtils::FormatErrorMessage(
+ keys::kTabNotFoundError, base::IntToString(tab_ids[i]));
+ return false;
+ }
- if (has_callback())
- result_.reset(ExtensionTabUtil::CreateTabValue(contents->tab_contents(),
- target_tab_strip, new_index));
+ // Clamp move location to the last position.
+ // This is ">" because it can append to a new index position.
+ if (new_index > target_tab_strip->count())
+ new_index = target_tab_strip->count();
- return true;
+ target_tab_strip->InsertTabContentsAt(
+ new_index, contents, TabStripModel::ADD_NONE);
+
+ if (has_callback())
+ tab_values.Append(ExtensionTabUtil::CreateTabValue(
+ contents->tab_contents(), target_tab_strip, new_index));
+
+ continue;
+ }
}
- }
- // Perform a simple within-window move.
- // Clamp move location to the last position.
- // This is ">=" because the move must be to an existing location.
- if (new_index >= source_tab_strip->count())
- new_index = source_tab_strip->count() - 1;
+ // Perform a simple within-window move.
+ // Clamp move location to the last position.
+ // This is ">=" because the move must be to an existing location.
+ if (new_index >= source_tab_strip->count())
+ new_index = source_tab_strip->count() - 1;
- if (new_index != tab_index)
- source_tab_strip->MoveTabContentsAt(tab_index, new_index, false);
+ if (new_index != tab_index)
+ source_tab_strip->MoveTabContentsAt(tab_index, new_index, false);
+
+ if (has_callback())
+ tab_values.Append(ExtensionTabUtil::CreateTabValue(
+ contents->tab_contents(), source_tab_strip, new_index));
+ }
- if (has_callback())
- result_.reset(ExtensionTabUtil::CreateTabValue(contents->tab_contents(),
- source_tab_strip,
- new_index));
+ if (!has_callback())
+ return true;
+
+ // Only return the results as an array if there are multiple tabs.
+ if (tab_ids.size() > 1) {
+ result_.reset(tab_values.DeepCopy());
+ } else if (tab_ids.size() == 1) {
+ Value* value = NULL;
+ CHECK(tab_values.Get(0, &value));
+ result_.reset(value->DeepCopy());
+ }
return true;
}
@@ -1014,28 +1245,33 @@ bool ReloadTabFunction::RunImpl() {
return true;
}
-bool RemoveTabFunction::RunImpl() {
- int tab_id;
- EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id));
+bool RemoveTabsFunction::RunImpl() {
+ Value* tab_value = NULL;
+ EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &tab_value));
- Browser* browser = NULL;
- TabContentsWrapper* contents = NULL;
- if (!GetTabById(tab_id, profile(), include_incognito(),
- &browser, NULL, &contents, NULL, &error_))
- return false;
+ std::vector<int> tab_ids;
+ EXTENSION_FUNCTION_VALIDATE(ReadOneOrMoreIntegers(tab_value, &tab_ids));
- // Don't let the extension remove a tab if the user is dragging tabs around.
- if (!browser->IsTabStripEditable()) {
- error_ = keys::kTabStripNotEditableError;
- return false;
- }
+ for (size_t i = 0; i < tab_ids.size(); ++i) {
+ Browser* browser = NULL;
+ TabContentsWrapper* contents = NULL;
+ if (!GetTabById(tab_ids[i], profile(), include_incognito(),
+ &browser, NULL, &contents, NULL, &error_))
+ return false;
- // Close the tab in this convoluted way, since there's a chance that the tab
- // is being dragged, or we're in some other nested event loop. This code path
- // should ensure that the tab is safely closed under such circumstances,
- // whereas |Browser::CloseTabContents()| does not.
- RenderViewHost* render_view_host = contents->render_view_host();
- render_view_host->delegate()->Close(render_view_host);
+ // Don't let the extension remove a tab if the user is dragging tabs around.
+ if (!browser->IsTabStripEditable()) {
+ error_ = keys::kTabStripNotEditableError;
+ return false;
+ }
+
+ // Close the tab in this convoluted way, since there's a chance that the tab
+ // is being dragged, or we're in some other nested event loop. This code
+ // path should ensure that the tab is safely closed under such
+ // circumstances, whereas |Browser::CloseTabContents()| does not.
+ RenderViewHost* render_view_host = contents->render_view_host();
+ render_view_host->delegate()->Close(render_view_host);
+ }
return true;
}
diff --git a/chrome/browser/extensions/extension_tabs_module.h b/chrome/browser/extensions/extension_tabs_module.h
index a248c47..31ab2b5 100644
--- a/chrome/browser/extensions/extension_tabs_module.h
+++ b/chrome/browser/extensions/extension_tabs_module.h
@@ -75,11 +75,21 @@ class GetAllTabsInWindowFunction : public SyncExtensionFunction {
virtual bool RunImpl() OVERRIDE;
DECLARE_EXTENSION_FUNCTION_NAME("tabs.getAllInWindow")
};
+class QueryTabsFunction : public SyncExtensionFunction {
+ virtual ~QueryTabsFunction() {}
+ virtual bool RunImpl() OVERRIDE;
+ DECLARE_EXTENSION_FUNCTION_NAME("tabs.query")
+};
class CreateTabFunction : public SyncExtensionFunction {
virtual ~CreateTabFunction() {}
virtual bool RunImpl() OVERRIDE;
DECLARE_EXTENSION_FUNCTION_NAME("tabs.create")
};
+class HighlightTabsFunction : public SyncExtensionFunction {
+ virtual ~HighlightTabsFunction() {}
+ virtual bool RunImpl() OVERRIDE;
+ DECLARE_EXTENSION_FUNCTION_NAME("tabs.highlight")
+};
class UpdateTabFunction : public AsyncExtensionFunction,
public TabContentsObserver {
public:
@@ -93,8 +103,8 @@ class UpdateTabFunction : public AsyncExtensionFunction,
const std::string& error);
DECLARE_EXTENSION_FUNCTION_NAME("tabs.update")
};
-class MoveTabFunction : public SyncExtensionFunction {
- virtual ~MoveTabFunction() {}
+class MoveTabsFunction : public SyncExtensionFunction {
+ virtual ~MoveTabsFunction() {}
virtual bool RunImpl() OVERRIDE;
DECLARE_EXTENSION_FUNCTION_NAME("tabs.move")
};
@@ -103,8 +113,8 @@ class ReloadTabFunction : public SyncExtensionFunction {
virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME("tabs.reload")
};
-class RemoveTabFunction : public SyncExtensionFunction {
- virtual ~RemoveTabFunction() {}
+class RemoveTabsFunction : public SyncExtensionFunction {
+ virtual ~RemoveTabsFunction() {}
virtual bool RunImpl() OVERRIDE;
DECLARE_EXTENSION_FUNCTION_NAME("tabs.remove")
};
diff --git a/chrome/browser/extensions/extension_tabs_module_constants.cc b/chrome/browser/extensions/extension_tabs_module_constants.cc
index 6d469f2..b60e7da 100644
--- a/chrome/browser/extensions/extension_tabs_module_constants.cc
+++ b/chrome/browser/extensions/extension_tabs_module_constants.cc
@@ -6,6 +6,7 @@
namespace extension_tabs_module_constants {
+const char kActiveKey[] = "active";
const char kAllFramesKey[] = "allFrames";
const char kBypassCache[] = "bypassCache";
const char kCodeKey[] = "code";
@@ -27,9 +28,11 @@ const char kOldWindowIdKey[] = "oldWindowId";
const char kPinnedKey[] = "pinned";
const char kPopulateKey[] = "populate";
const char kQualityKey[] = "quality";
+const char kHighlightedKey[] = "highlighted";
const char kSelectedKey[] = "selected";
const char kStatusKey[] = "status";
const char kTabIdKey[] = "tabId";
+const char kTabIdsKey[] = "tabIds";
const char kTabsKey[] = "tabs";
const char kTabUrlKey[] = "tabUrl";
const char kTitleKey[] = "title";
@@ -40,6 +43,7 @@ const char kWindowClosing[] = "isWindowClosing";
const char kWidthKey[] = "width";
const char kWindowIdKey[] = "windowId";
const char kWindowTypeKey[] = "type";
+const char kWindowTypeLongKey[] = "windowType";
const char kFormatValueJpeg[] = "jpeg";
const char kFormatValuePng[] = "png";
@@ -64,10 +68,12 @@ const char kNoCrashBrowserError[] =
const char kNoCurrentWindowError[] = "No current window";
const char kNoLastFocusedWindowError[] = "No last-focused window";
const char kWindowNotFoundError[] = "No window with id: *.";
+const char kTabIndexNotFoundError[] = "No tab at index: *.";
const char kTabNotFoundError[] = "No tab with id: *.";
const char kTabStripNotEditableError[] =
"Tabs cannot be edited right now (user may be dragging a tab).";
const char kNoSelectedTabError[] = "No selected tab";
+const char kNoHighlightedTabError[] = "No highlighted tab";
const char kIncognitoModeIsDisabled[] = "Incognito mode is disabled.";
const char kInvalidUrlError[] = "Invalid url: \"*\".";
const char kInternalVisibleTabCaptureError[] =
diff --git a/chrome/browser/extensions/extension_tabs_module_constants.h b/chrome/browser/extensions/extension_tabs_module_constants.h
index 5347af7..d7f3167 100644
--- a/chrome/browser/extensions/extension_tabs_module_constants.h
+++ b/chrome/browser/extensions/extension_tabs_module_constants.h
@@ -11,6 +11,7 @@
namespace extension_tabs_module_constants {
// Keys used in serializing tab data & events.
+extern const char kActiveKey[];
extern const char kAllFramesKey[];
extern const char kBypassCache[];
extern const char kCodeKey[];
@@ -31,9 +32,11 @@ extern const char kOldWindowIdKey[];
extern const char kPinnedKey[];
extern const char kPopulateKey[];
extern const char kQualityKey[];
+extern const char kHighlightedKey[];
extern const char kSelectedKey[];
extern const char kStatusKey[];
extern const char kTabIdKey[];
+extern const char kTabIdsKey[];
extern const char kTabsKey[];
extern const char kTabUrlKey[];
extern const char kTitleKey[];
@@ -45,6 +48,7 @@ extern const char kWidthKey[];
extern const char kWindowIdKey[];
extern const char kIncognitoKey[];
extern const char kWindowTypeKey[];
+extern const char kWindowTypeLongKey[];
// Value consts.
extern const char kCanOnlyMoveTabsWithinNormalWindowsError[];
@@ -65,8 +69,10 @@ extern const char kNoCrashBrowserError[];
extern const char kNoCurrentWindowError[];
extern const char kNoLastFocusedWindowError[];
extern const char kWindowNotFoundError[];
+extern const char kTabIndexNotFoundError[];
extern const char kTabNotFoundError[];
extern const char kTabStripNotEditableError[];
+extern const char kNoHighlightedTabError[];
extern const char kNoSelectedTabError[];
extern const char kIncognitoModeIsDisabled[];
extern const char kInvalidUrlError[];
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index 278dcdb..2cc1dbd 100644
--- a/chrome/browser/tabs/tab_strip_model.cc
+++ b/chrome/browser/tabs/tab_strip_model.cc
@@ -247,7 +247,7 @@ TabContentsWrapper* TabStripModel::DetachTabContentsAt(int index) {
// |old_model| is stored after calling DecrementFrom().
if (was_selected) {
FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
- TabSelectionChanged(old_model));
+ TabSelectionChanged(this, old_model));
}
}
return removed_contents;
@@ -1225,7 +1225,7 @@ void TabStripModel::NotifyIfActiveOrSelectionChanged(
if (!selection_model().Equals(old_model)) {
FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
- TabSelectionChanged(old_model));
+ TabSelectionChanged(this, old_model));
}
}
diff --git a/chrome/browser/tabs/tab_strip_model_observer.cc b/chrome/browser/tabs/tab_strip_model_observer.cc
index cf0d1eb..e3035cf 100644
--- a/chrome/browser/tabs/tab_strip_model_observer.cc
+++ b/chrome/browser/tabs/tab_strip_model_observer.cc
@@ -28,6 +28,7 @@ void TabStripModelObserver::ActiveTabChanged(TabContentsWrapper* old_contents,
}
void TabStripModelObserver::TabSelectionChanged(
+ TabStripModel* tab_strip_model,
const TabStripSelectionModel& model) {
}
diff --git a/chrome/browser/tabs/tab_strip_model_observer.h b/chrome/browser/tabs/tab_strip_model_observer.h
index 5a69eb5..5b5e8ea 100644
--- a/chrome/browser/tabs/tab_strip_model_observer.h
+++ b/chrome/browser/tabs/tab_strip_model_observer.h
@@ -77,10 +77,12 @@ class TabStripModelObserver {
int index,
bool user_gesture);
- // Sent when the selection changes. More precisely when selected tabs, anchor
- // tab or active tab change. |old_model| is a snapshot of the selection model
- // before the change. See also ActiveTabChanged for details.
- virtual void TabSelectionChanged(const TabStripSelectionModel& old_model);
+ // Sent when the selection changes in |tab_strip_model|. More precisely when
+ // selected tabs, anchor tab or active tab change. |old_model| is a snapshot
+ // of the selection model before the change. See also ActiveTabChanged for
+ // details.
+ virtual void TabSelectionChanged(TabStripModel* tab_strip_model,
+ const TabStripSelectionModel& old_model);
// The specified TabContents at |from_index| was moved to |to_index|.
virtual void TabMoved(TabContentsWrapper* contents,
diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc
index e615744..64b40b0 100644
--- a/chrome/browser/tabs/tab_strip_model_unittest.cc
+++ b/chrome/browser/tabs/tab_strip_model_unittest.cc
@@ -358,7 +358,8 @@ class MockTabStripModelObserver : public TabStripModelObserver {
s->user_gesture = user_gesture;
states_.push_back(s);
}
- virtual void TabSelectionChanged(const TabStripSelectionModel& old_model) {
+ virtual void TabSelectionChanged(TabStripModel* tab_strip_model,
+ const TabStripSelectionModel& old_model) {
if (!log_tab_selection_changed())
return;
diff --git a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc
index d1eb188..8a7455d 100644
--- a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc
+++ b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc
@@ -1028,7 +1028,8 @@ void TabStripGtk::ActiveTabChanged(TabContentsWrapper* old_contents,
ReStack();
}
-void TabStripGtk::TabSelectionChanged(const TabStripSelectionModel& old_model) {
+void TabStripGtk::TabSelectionChanged(TabStripModel* tab_strip_model,
+ const TabStripSelectionModel& old_model) {
// We have "tiny tabs" if the tabs are so tiny that the unselected ones are
// a different size to the selected ones.
bool tiny_tabs = current_unselected_width_ != current_selected_width_;
diff --git a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.h b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.h
index 8a296c4..84a69d0 100644
--- a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.h
+++ b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.h
@@ -114,7 +114,8 @@ class TabStripGtk : public TabStripModelObserver,
TabContentsWrapper* new_contents,
int index,
bool user_gesture);
- virtual void TabSelectionChanged(const TabStripSelectionModel& old_model);
+ virtual void TabSelectionChanged(TabStripModel* tab_strip_model,
+ const TabStripSelectionModel& old_model);
virtual void TabChangedAt(TabContentsWrapper* contents, int index,
TabChangeType change_type);
virtual void TabReplacedAt(TabStripModel* tab_strip_model,
diff --git a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc
index 1a9ab98..b48d674 100644
--- a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc
+++ b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc
@@ -347,6 +347,7 @@ void BrowserTabStripController::TabDetachedAt(TabContentsWrapper* contents,
}
void BrowserTabStripController::TabSelectionChanged(
+ TabStripModel* tab_strip_model,
const TabStripSelectionModel& old_model) {
tabstrip_->SetSelection(old_model, model_->selection_model());
}
diff --git a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.h b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.h
index f1a2f85..d08147e 100644
--- a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.h
+++ b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.h
@@ -73,6 +73,7 @@ class BrowserTabStripController : public TabStripController,
virtual void TabDetachedAt(TabContentsWrapper* contents,
int model_index) OVERRIDE;
virtual void TabSelectionChanged(
+ TabStripModel* tab_strip_model,
const TabStripSelectionModel& old_model) OVERRIDE;
virtual void TabMoved(TabContentsWrapper* contents,
int from_model_index,
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json
index 2a9c1f4..4f4077a 100644
--- a/chrome/common/extensions/api/extension_api.json
+++ b/chrome/common/extensions/api/extension_api.json
@@ -1335,7 +1335,9 @@
"id": {"type": "integer", "minimum": 0, "description": "The ID of the tab. Tab IDs are unique within a browser session."},
"index": {"type": "integer", "minimum": 0, "description": "The zero-based index of the tab within its window."},
"windowId": {"type": "integer", "minimum": 0, "description": "The ID of the window the tab is contained within."},
- "selected": {"type": "boolean", "description": "Whether the tab is selected."},
+ "selected": {"type": "boolean", "description": "Whether the tab is selected.", "nodoc": true},
+ "highlighted": {"type": "boolean", "description": "Whether the tab is highlighted."},
+ "active": {"type": "boolean", "description": "Whether the tab is active in its window."},
"pinned": {"type": "boolean", "description": "Whether the tab is pinned."},
"url": {"type": "string", "description": "The URL the tab is displaying."},
"title": {"type": "string", "optional": true, "description": "The title of the tab. This may not be available if the tab is loading."},
@@ -1437,8 +1439,9 @@
},
{
"name": "getSelected",
+ "nodoc": true,
"type": "function",
- "description": "Gets the tab that is selected in the specified window.",
+ "description": "Deprecated. Please use query({'active': true}). Gets the tab that is selected in the specified window.",
"parameters": [
{
"type": "integer",
@@ -1459,7 +1462,8 @@
{
"name": "getAllInWindow",
"type": "function",
- "description": "Gets details about all tabs in the specified window.",
+ "nodoc": true,
+ "description": "Deprecated. Please use query({'windowId': windowId}). Gets details about all tabs in the specified window.",
"parameters": [
{
"type": "integer",
@@ -1503,7 +1507,13 @@
"optional": true,
"description": "The URL to navigate the tab to initially. Fully-qualified URLs must include a scheme (i.e. 'http://www.google.com', not 'www.google.com'). Relative URLs will be relative to the current page within the extension. Defaults to the New Tab Page."
},
+ "active": {
+ "type": "boolean",
+ "optional": true,
+ "description": "Whether the tab should become the active tab in the window. Defaults to <var>true</var>"
+ },
"selected": {
+ "nodoc": true,
"type": "boolean",
"optional": true,
"description": "Whether the tab should become the selected tab in the window. Defaults to <var>true</var>"
@@ -1530,6 +1540,109 @@
]
},
{
+ "name": "query",
+ "type": "function",
+ "description": "Gets all tabs that have the specified properties, or all tabs if no properties are specified.",
+ "parameters": [
+ {
+ "type": "object",
+ "name": "queryInfo",
+ "properties": {
+ "active": {
+ "type": "boolean",
+ "optional": true,
+ "description": "Whether the tabs are active in their windows."
+ },
+ "pinned": {
+ "type": "boolean",
+ "optional": true,
+ "description": "Whether the tabs are pinned."
+ },
+ "highlighted": {
+ "type": "boolean",
+ "optional": true,
+ "description": "Whether the tabs are highlighted."
+ },
+ "status": {
+ "type": "string",
+ "optional": true,
+ "enum": ["loading", "complete"],
+ "description": "Whether the tabs have completed loading."
+ },
+ "title": {
+ "type": "string",
+ "optional": true,
+ "description": "Match page titles against a pattern."
+ },
+ "url": {
+ "type": "string",
+ "optional": true,
+ "description": "Match tabs against a URL pattern."
+ },
+ "windowId": {
+ "type": "integer",
+ "optional": true,
+ "minimum": 0,
+ "description": "The ID of the parent window."
+ },
+ "windowType": {
+ "type": "string",
+ "optional": true,
+ "enum": ["normal", "popup", "panel", "app"],
+ "description": "The type of window the tabs are in."
+ }
+ }
+ },
+ {
+ "type": "function",
+ "name": "callback",
+ "parameters": [
+ {
+ "type": "array",
+ "items": {
+ "$ref": "Tab"
+ }
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "name": "highlight",
+ "type": "function",
+ "description": "Highlights the given tabs.",
+ "parameters": [
+ {
+ "type": "object",
+ "name": "highlightInfo",
+ "properties": {
+ "windowId": {
+ "type": "integer",
+ "description": "The window that contains the tabs."
+ },
+ "tabs": {
+ "description": "One or more tab indices to highlight.",
+ "choices": [
+ {"type": "array", "items": {"type": "integer", "minimum": 0}},
+ {"type": "integer"}
+ ]
+ }
+ }
+ },
+ {
+ "type": "function",
+ "name": "callback",
+ "parameters": [
+ {
+ "name": "window",
+ "$ref": "Window",
+ "description": "Contains details about the window whose tabs were highlighted."
+ }
+ ]
+ }
+ ]
+ },
+ {
"name": "update",
"type": "function",
"description": "Modifies the properties of a tab. Properties that are not specified in <var>updateProperties</var> are not modified. Note: This function can be used without requesting the 'tabs' permission in the manifest.",
@@ -1549,7 +1662,18 @@
"optional": true,
"description": "A URL to navigate the tab to."
},
+ "active": {
+ "type": "boolean",
+ "optional": true,
+ "description": "Whether the tab should be active."
+ },
+ "highlighted": {
+ "type": "boolean",
+ "optional": true,
+ "description": "Adds or removes the tab from the current selection."
+ },
"selected": {
+ "nodoc": true,
"type": "boolean",
"optional": true,
"description": "Whether the tab should be selected."
@@ -1579,9 +1703,16 @@
{
"name": "move",
"type": "function",
- "description": "Moves a tab to a new position within its window, or to a new window. Note that tabs can only be moved to and from normal (window.type === \"normal\") windows.",
+ "description": "Moves one or more tabs to a new position within its window, or to a new window. Note that tabs can only be moved to and from normal (window.type === \"normal\") windows.",
"parameters": [
- {"type": "integer", "name": "tabId", "minimum": 0},
+ {
+ "name": "tabIds",
+ "description": "The tab or list of tabs to move.",
+ "choices": [
+ {"type": "integer", "minimum": 0},
+ {"type": "array", "items": {"type": "integer", "minimum": 0}}
+ ]
+ },
{
"type": "object",
"name": "moveProperties",
@@ -1605,9 +1736,12 @@
"optional": true,
"parameters": [
{
- "name": "tab",
- "$ref": "Tab",
- "description": "Details about the moved tab."
+ "name": "tabs",
+ "description": "Details about the moved tabs.",
+ "choices": [
+ {"$ref": "Tab"},
+ {"type": "array", "items": {"$ref": "Tab"}}
+ ]
}
]
}
@@ -1637,9 +1771,16 @@
{
"name": "remove",
"type": "function",
- "description": "Closes a tab. Note: This function can be used without requesting the 'tabs' permission in the manifest.",
+ "description": "Closes one or more tabs. Note: This function can be used without requesting the 'tabs' permission in the manifest.",
"parameters": [
- {"type": "integer", "name": "tabId", "minimum": 0},
+ {
+ "name": "tabIds",
+ "description": "The tab or list of tabs to close.",
+ "choices": [
+ {"type": "integer", "minimum": 0},
+ {"type": "array", "items": {"type": "integer", "minimum": 0}}
+ ]
+ },
{"type": "function", "name": "callback", "optional": true, "parameters": []}
]
},
@@ -1653,7 +1794,7 @@
"name": "tabId",
"minimum": 0,
"optional": true,
- "description": "Defaults to the selected tab of the <a href='windows.html#current-window'>current window</a>."
+ "description": "Defaults to the active tab of the <a href='windows.html#current-window'>current window</a>."
},
{
"type": "function",
@@ -1671,7 +1812,7 @@
{
"name": "captureVisibleTab",
"type": "function",
- "description": "Captures the visible area of the currently selected tab in the specified window. You must have <a href='manifest.html#permissions'>host permission</a> for the URL displayed by the tab.",
+ "description": "Captures the visible area of the currently active tab in the specified window. You must have <a href='manifest.html#permissions'>host permission</a> for the URL displayed by the tab.",
"parameters": [
{
"type": "integer",
@@ -1714,7 +1855,7 @@
"type": "function",
"description": "Injects JavaScript code into a page. For details, see the <a href='content_scripts.html#pi'>programmatic injection</a> section of the content scripts doc.",
"parameters": [
- {"type": "integer", "name": "tabId", "optional": true, "description": "The ID of the tab in which to run the script; defaults to the selected tab of the current window."},
+ {"type": "integer", "name": "tabId", "optional": true, "description": "The ID of the tab in which to run the script; defaults to the active tab of the current window."},
{
"type": "object",
"name": "details",
@@ -1739,7 +1880,7 @@
"type": "function",
"description": "Injects CSS into a page. For details, see the <a href='content_scripts.html#pi'>programmatic injection</a> section of the content scripts doc.",
"parameters": [
- {"type": "integer", "name": "tabId", "optional": true, "description": "The ID of the tab in which to insert the CSS; defaults to the selected tab of the current window."},
+ {"type": "integer", "name": "tabId", "optional": true, "description": "The ID of the tab in which to insert the CSS; defaults to the active tab of the current window."},
{
"type": "object",
"name": "details",
@@ -1827,14 +1968,15 @@
},
{
"name": "onSelectionChanged",
+ "nodoc": true,
"type": "function",
- "description": "Fired when the selected tab in a window changes.",
+ "description": "Deprecated. Please use onActiveChanged.",
"parameters": [
{
"type": "integer",
"name": "tabId",
"minimum": 0,
- "description": "The ID of the tab that has become selected."
+ "description": "The ID of the tab that has become active."
},
{
"type": "object",
@@ -1850,6 +1992,54 @@
]
},
{
+ "name": "onActiveChanged",
+ "type": "function",
+ "description": "Fires when the selected tab in a window changes.",
+ "parameters": [
+ {
+ "type": "integer",
+ "name": "tabId",
+ "minimum": 0,
+ "description": "The ID of the tab that has become active."
+ },
+ {
+ "type": "object",
+ "name": "selectInfo",
+ "properties": {
+ "windowId": {
+ "type": "integer",
+ "minimum": 0,
+ "description": "The ID of the window the selected tab changed inside of."
+ }
+ }
+ }
+ ]
+ },
+ {
+ "name": "onHighlightChanged",
+ "type": "function",
+ "description": "Fired when the highlighted or selected tabs in a window changes.",
+ "parameters": [
+ {
+ "type": "object",
+ "name": "selectInfo",
+ "properties": {
+ "windowId": {
+ "type": "integer",
+ "minimum": 0,
+ "description": "The window whose tabs changed."
+ },
+ "tabIds": {
+ "type": "array",
+ "name": "tabIds",
+ "items": {"type": "integer", "minimum": 0},
+ "description": "All highlighted tabs in the window."
+ }
+ }
+ }
+ ]
+ },
+ {
"name": "onDetached",
"type": "function",
"description": "Fired when a tab is detached from a window, for example because it is being moved between windows.",
diff --git a/chrome/common/extensions/docs/samples.json b/chrome/common/extensions/docs/samples.json
index 0530332..66f22ed 100644
--- a/chrome/common/extensions/docs/samples.json
+++ b/chrome/common/extensions/docs/samples.json
@@ -157,15 +157,19 @@
"chrome.tabs.getAllInWindow": "tabs.html#method-getAllInWindow",
"chrome.tabs.getCurrent": "tabs.html#method-getCurrent",
"chrome.tabs.getSelected": "tabs.html#method-getSelected",
+ "chrome.tabs.highlight": "tabs.html#method-highlight",
"chrome.tabs.insertCSS": "tabs.html#method-insertCSS",
"chrome.tabs.move": "tabs.html#method-move",
+ "chrome.tabs.onActiveChanged": "tabs.html#event-onActiveChanged",
"chrome.tabs.onAttached": "tabs.html#event-onAttached",
"chrome.tabs.onCreated": "tabs.html#event-onCreated",
"chrome.tabs.onDetached": "tabs.html#event-onDetached",
+ "chrome.tabs.onHighlightChanged": "tabs.html#event-onHighlightChanged",
"chrome.tabs.onMoved": "tabs.html#event-onMoved",
"chrome.tabs.onRemoved": "tabs.html#event-onRemoved",
"chrome.tabs.onSelectionChanged": "tabs.html#event-onSelectionChanged",
"chrome.tabs.onUpdated": "tabs.html#event-onUpdated",
+ "chrome.tabs.query": "tabs.html#method-query",
"chrome.tabs.reload": "tabs.html#method-reload",
"chrome.tabs.remove": "tabs.html#method-remove",
"chrome.tabs.sendRequest": "tabs.html#method-sendRequest",
diff --git a/chrome/common/extensions/docs/tabs.html b/chrome/common/extensions/docs/tabs.html
index 10c3b6b..ba812f9 100644
--- a/chrome/common/extensions/docs/tabs.html
+++ b/chrome/common/extensions/docs/tabs.html
@@ -297,17 +297,21 @@
<a href="#method-executeScript">executeScript</a>
</li><li>
<a href="#method-get">get</a>
- </li><li>
- <a href="#method-getAllInWindow">getAllInWindow</a>
+ </li><li style="display: none; ">
+ <a href="#method-anchor">methodName</a>
</li><li>
<a href="#method-getCurrent">getCurrent</a>
+ </li><li style="display: none; ">
+ <a href="#method-anchor">methodName</a>
</li><li>
- <a href="#method-getSelected">getSelected</a>
+ <a href="#method-highlight">highlight</a>
</li><li>
<a href="#method-insertCSS">insertCSS</a>
</li><li>
<a href="#method-move">move</a>
</li><li>
+ <a href="#method-query">query</a>
+ </li><li>
<a href="#method-reload">reload</a>
</li><li>
<a href="#method-remove">remove</a>
@@ -322,17 +326,21 @@
<a href="#global-events">Events</a>
<ol>
<li>
+ <a href="#event-onActiveChanged">onActiveChanged</a>
+ </li><li>
<a href="#event-onAttached">onAttached</a>
</li><li>
<a href="#event-onCreated">onCreated</a>
</li><li>
<a href="#event-onDetached">onDetached</a>
</li><li>
+ <a href="#event-onHighlightChanged">onHighlightChanged</a>
+ </li><li>
<a href="#event-onMoved">onMoved</a>
</li><li>
<a href="#event-onRemoved">onRemoved</a>
- </li><li>
- <a href="#event-onSelectionChanged">onSelectionChanged</a>
+ </li><li style="display: none; ">
+ <a href="#event-anchor">eventName</a>
</li><li>
<a href="#event-onUpdated">onUpdated</a>
</li>
@@ -451,7 +459,7 @@ For other examples and for help in viewing the source code, see
<div class="description">
<p class="todo" style="display: none; ">Undocumented.</p>
- <p>Captures the visible area of the currently selected tab in the specified window. You must have <a href="manifest.html#permissions">host permission</a> for the URL displayed by the tab.</p>
+ <p>Captures the visible area of the currently active tab in the specified window. You must have <a href="manifest.html#permissions">host permission</a> for the URL displayed by the tab.</p>
<!-- PARAMETERS -->
<h4>Parameters</h4>
@@ -1508,7 +1516,7 @@ For other examples and for help in viewing the source code, see
</div><div>
<div>
<dt>
- <var>selected</var>
+ <var>active</var>
<em>
<!-- TYPE -->
@@ -1536,7 +1544,7 @@ For other examples and for help in viewing the source code, see
<dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd>Whether the tab should become the selected tab in the window. Defaults to <var>true</var></dd>
+ <dd>Whether the tab should become the active tab in the window. Defaults to <var>true</var></dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -1889,7 +1897,7 @@ For other examples and for help in viewing the source code, see
<dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd>Defaults to the selected tab of the <a href="windows.html#current-window">current window</a>.</dd>
+ <dd>Defaults to the active tab of the <a href="windows.html#current-window">current window</a>.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -2155,7 +2163,7 @@ For other examples and for help in viewing the source code, see
<dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd>The ID of the tab in which to run the script; defaults to the selected tab of the current window.</dd>
+ <dd>The ID of the tab in which to run the script; defaults to the active tab of the current window.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -2843,92 +2851,89 @@ For other examples and for help in viewing the source code, see
</p>
</div> <!-- /description -->
- </div><div class="apiItem">
- <a name="method-getAllInWindow"></a> <!-- method-anchor -->
- <h4>getAllInWindow</h4>
+ </div><div class="apiItem" style="display: none; ">
+ <a></a> <!-- method-anchor -->
+ <h4>method name</h4>
- <div class="summary"><span style="display: none; ">void</span>
+ <div class="summary"><span>void</span>
<!-- Note: intentionally longer 80 columns -->
- <span>chrome.tabs.getAllInWindow</span>(<span class="optional"><span style="display: none; ">, </span><span>integer</span>
- <var><span>windowId</span></var></span><span class="null"><span>, </span><span>function</span>
- <var><span>callback</span></var></span>)</div>
+ <span>chrome.module.methodName</span>(<span><span>, </span><span></span>
+ <var><span></span></var></span>)</div>
<div class="description">
- <p class="todo" style="display: none; ">Undocumented.</p>
- <p>Gets details about all tabs in the specified window.</p>
+ <p class="todo">Undocumented.</p>
+ <p>
+ A description from the json schema def of the function goes here.
+ </p>
<!-- PARAMETERS -->
<h4>Parameters</h4>
<dl>
<div>
<div>
- <dt>
- <var>windowId</var>
- <em>
-
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span class="enum" style="display: none; ">enumerated</span>
- <span id="typeTemplate">
- <span style="display: none; ">
- <a> Type</a>
- </span>
- <span>
- <span style="display: none; ">
- array of <span><span></span></span>
- </span>
- <span>integer</span>
- <span style="display: none; "></span>
- </span>
- </span>
- )
- </div>
+ </div>
+ </div>
+ </dl>
- </em>
- </dt>
- <dd class="todo" style="display: none; ">
- Undocumented.
- </dd>
- <dd>Defaults to the <a href="windows.html#current-window">current window</a>.</dd>
- <dd style="display: none; ">
- This parameter was added in version
- <b><span></span></b>.
- You must omit this parameter in earlier versions,
- and you may omit it in any version. If you require this
- parameter, the manifest key
- <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
- can ensure that your extension won't be run in an earlier browser version.
- </dd>
+ <!-- RETURNS -->
+ <h4>Returns</h4>
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
- <!-- OBJECT PROPERTIES -->
- <dd style="display: none; ">
- <dl>
- <div>
+ <!-- CALLBACK -->
<div>
+ <div>
+ <h4>Callback function</h4>
+ <p>
+ The callback <em>parameter</em> should specify a function
+ that looks like this:
+ </p>
+ <p>
+ If you specify the <em>callback</em> parameter, it should
+ specify a function that looks like this:
+ </p>
+
+ <!-- Note: intentionally longer 80 columns -->
+ <pre>function(<span>Type param1, Type param2</span>) <span class="subdued">{...}</span>;</pre>
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </div>
</div>
- </div>
- </dl>
- </dd>
- <!-- OBJECT METHODS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
+ <!-- MIN_VERSION -->
+ <p>
+ This function was added in version <b><span></span></b>.
+ If you require this function, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </p>
+ </div> <!-- /description -->
- <!-- OBJECT EVENT FIELDS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
+ </div><div class="apiItem">
+ <a name="method-getCurrent"></a> <!-- method-anchor -->
+ <h4>getCurrent</h4>
- <!-- FUNCTION PARAMETERS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
+ <div class="summary"><span style="display: none; ">void</span>
+ <!-- Note: intentionally longer 80 columns -->
+ <span>chrome.tabs.getCurrent</span>(<span class="null"><span style="display: none; ">, </span><span>function</span>
+ <var><span>callback</span></var></span>)</div>
- </div>
- </div><div>
+ <div class="description">
+ <p class="todo" style="display: none; ">Undocumented.</p>
+ <p>Gets the tab that this script call is being made from. May be undefined if called from a non-tab context (for example: a background page or popup view).</p>
+
+ <!-- PARAMETERS -->
+ <h4>Parameters</h4>
+ <dl>
+ <div>
<div>
<dt>
<var>callback</var>
@@ -3024,26 +3029,20 @@ For other examples and for help in viewing the source code, see
</p>
<!-- Note: intentionally longer 80 columns -->
- <pre>function(<span>array of Tab tabs</span>) <span class="subdued">{...}</span>;</pre>
+ <pre>function(<span>Tab tab</span>) <span class="subdued">{...}</span>;</pre>
<dl>
<div>
<div>
<dt>
- <var>tabs</var>
+ <var>tab</var>
<em>
<!-- TYPE -->
<div style="display:inline">
(
- <span class="optional" style="display: none; ">optional</span>
+ <span class="optional">optional</span>
<span class="enum" style="display: none; ">enumerated</span>
<span id="typeTemplate">
- <span style="display: none; ">
- <a> Type</a>
- </span>
- <span>
- <span>
- array of <span><span>
<span>
<a href="tabs.html#type-Tab">Tab</a>
</span>
@@ -3054,11 +3053,6 @@ For other examples and for help in viewing the source code, see
<span>paramType</span>
<span></span>
</span>
- </span></span>
- </span>
- <span style="display: none; ">paramType</span>
- <span style="display: none; "></span>
- </span>
</span>
)
</div>
@@ -3121,18 +3115,85 @@ For other examples and for help in viewing the source code, see
</p>
</div> <!-- /description -->
+ </div><div class="apiItem" style="display: none; ">
+ <a></a> <!-- method-anchor -->
+ <h4>method name</h4>
+
+ <div class="summary"><span>void</span>
+ <!-- Note: intentionally longer 80 columns -->
+ <span>chrome.module.methodName</span>(<span><span>, </span><span></span>
+ <var><span></span></var></span>)</div>
+
+ <div class="description">
+ <p class="todo">Undocumented.</p>
+ <p>
+ A description from the json schema def of the function goes here.
+ </p>
+
+ <!-- PARAMETERS -->
+ <h4>Parameters</h4>
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+
+ <!-- RETURNS -->
+ <h4>Returns</h4>
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+
+ <!-- CALLBACK -->
+ <div>
+ <div>
+ <h4>Callback function</h4>
+ <p>
+ The callback <em>parameter</em> should specify a function
+ that looks like this:
+ </p>
+ <p>
+ If you specify the <em>callback</em> parameter, it should
+ specify a function that looks like this:
+ </p>
+
+ <!-- Note: intentionally longer 80 columns -->
+ <pre>function(<span>Type param1, Type param2</span>) <span class="subdued">{...}</span>;</pre>
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </div>
+ </div>
+
+ <!-- MIN_VERSION -->
+ <p>
+ This function was added in version <b><span></span></b>.
+ If you require this function, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </p>
+ </div> <!-- /description -->
+
</div><div class="apiItem">
- <a name="method-getCurrent"></a> <!-- method-anchor -->
- <h4>getCurrent</h4>
+ <a name="method-highlight"></a> <!-- method-anchor -->
+ <h4>highlight</h4>
<div class="summary"><span style="display: none; ">void</span>
<!-- Note: intentionally longer 80 columns -->
- <span>chrome.tabs.getCurrent</span>(<span class="null"><span style="display: none; ">, </span><span>function</span>
+ <span>chrome.tabs.highlight</span>(<span class="null"><span style="display: none; ">, </span><span>object</span>
+ <var><span>highlightInfo</span></var></span><span class="null"><span>, </span><span>function</span>
<var><span>callback</span></var></span>)</div>
<div class="description">
<p class="todo" style="display: none; ">Undocumented.</p>
- <p>Gets the tab that this script call is being made from. May be undefined if called from a non-tab context (for example: a background page or popup view).</p>
+ <p>Highlights the given tabs.</p>
<!-- PARAMETERS -->
<h4>Parameters</h4>
@@ -3140,7 +3201,7 @@ For other examples and for help in viewing the source code, see
<div>
<div>
<dt>
- <var>callback</var>
+ <var>highlightInfo</var>
<em>
<!-- TYPE -->
@@ -3156,7 +3217,7 @@ For other examples and for help in viewing the source code, see
<span style="display: none; ">
array of <span><span></span></span>
</span>
- <span>function</span>
+ <span>object</span>
<span style="display: none; "></span>
</span>
</span>
@@ -3182,80 +3243,29 @@ For other examples and for help in viewing the source code, see
</dd>
<!-- OBJECT PROPERTIES -->
- <dd style="display: none; ">
+ <dd>
<dl>
<div>
<div>
- </div>
- </div>
- </dl>
- </dd>
-
- <!-- OBJECT METHODS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- <!-- OBJECT EVENT FIELDS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- <!-- FUNCTION PARAMETERS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- </div>
- </div>
- </dl>
-
- <!-- RETURNS -->
- <h4 style="display: none; ">Returns</h4>
- <dl>
- <div style="display: none; ">
- <div>
- </div>
- </div>
- </dl>
-
- <!-- CALLBACK -->
- <div>
- <div>
- <h4>Callback function</h4>
- <p>
- The callback <em>parameter</em> should specify a function
- that looks like this:
- </p>
- <p style="display: none; ">
- If you specify the <em>callback</em> parameter, it should
- specify a function that looks like this:
- </p>
-
- <!-- Note: intentionally longer 80 columns -->
- <pre>function(<span>Tab tab</span>) <span class="subdued">{...}</span>;</pre>
- <dl>
- <div>
- <div>
<dt>
- <var>tab</var>
+ <var>windowId</var>
<em>
<!-- TYPE -->
<div style="display:inline">
(
- <span class="optional">optional</span>
+ <span class="optional" style="display: none; ">optional</span>
<span class="enum" style="display: none; ">enumerated</span>
<span id="typeTemplate">
- <span>
- <a href="tabs.html#type-Tab">Tab</a>
- </span>
<span style="display: none; ">
- <span>
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
array of <span><span></span></span>
</span>
- <span>paramType</span>
- <span></span>
+ <span>integer</span>
+ <span style="display: none; "></span>
</span>
</span>
)
@@ -3263,12 +3273,10 @@ For other examples and for help in viewing the source code, see
</em>
</dt>
- <dd class="todo">
+ <dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd style="display: none; ">
- Description of this parameter from the json schema.
- </dd>
+ <dd>The window that contains the tabs.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -3305,47 +3313,16 @@ For other examples and for help in viewing the source code, see
</dd>
</div>
- </div>
- </dl>
- </div>
- </div>
-
- <!-- MIN_VERSION -->
- <p style="display: none; ">
- This function was added in version <b><span></span></b>.
- If you require this function, the manifest key
- <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
- can ensure that your extension won't be run in an earlier browser version.
- </p>
- </div> <!-- /description -->
-
- </div><div class="apiItem">
- <a name="method-getSelected"></a> <!-- method-anchor -->
- <h4>getSelected</h4>
-
- <div class="summary"><span style="display: none; ">void</span>
- <!-- Note: intentionally longer 80 columns -->
- <span>chrome.tabs.getSelected</span>(<span class="optional"><span style="display: none; ">, </span><span>integer</span>
- <var><span>windowId</span></var></span><span class="null"><span>, </span><span>function</span>
- <var><span>callback</span></var></span>)</div>
-
- <div class="description">
- <p class="todo" style="display: none; ">Undocumented.</p>
- <p>Gets the tab that is selected in the specified window.</p>
-
- <!-- PARAMETERS -->
- <h4>Parameters</h4>
- <dl>
- <div>
- <div>
+ </div><div>
+ <div>
<dt>
- <var>windowId</var>
+ <var>tabs</var>
<em>
<!-- TYPE -->
<div style="display:inline">
(
- <span class="optional">optional</span>
+ <span class="optional" style="display: none; ">optional</span>
<span class="enum" style="display: none; ">enumerated</span>
<span id="typeTemplate">
<span style="display: none; ">
@@ -3355,7 +3332,7 @@ For other examples and for help in viewing the source code, see
<span style="display: none; ">
array of <span><span></span></span>
</span>
- <span>integer</span>
+ <span>array of integer or integer</span>
<span style="display: none; "></span>
</span>
</span>
@@ -3367,7 +3344,7 @@ For other examples and for help in viewing the source code, see
<dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd>Defaults to the <a href="windows.html#current-window">current window</a>.</dd>
+ <dd>One or more tab indices to highlight.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -3404,6 +3381,26 @@ For other examples and for help in viewing the source code, see
</dd>
</div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
</div><div>
<div>
<dt>
@@ -3500,12 +3497,12 @@ For other examples and for help in viewing the source code, see
</p>
<!-- Note: intentionally longer 80 columns -->
- <pre>function(<span>Tab tab</span>) <span class="subdued">{...}</span>;</pre>
+ <pre>function(<span>Window window</span>) <span class="subdued">{...}</span>;</pre>
<dl>
<div>
<div>
<dt>
- <var>tab</var>
+ <var>window</var>
<em>
<!-- TYPE -->
@@ -3515,7 +3512,7 @@ For other examples and for help in viewing the source code, see
<span class="enum" style="display: none; ">enumerated</span>
<span id="typeTemplate">
<span>
- <a href="tabs.html#type-Tab">Tab</a>
+ <a href="windows.html#type-Window">Window</a>
</span>
<span style="display: none; ">
<span>
@@ -3530,12 +3527,10 @@ For other examples and for help in viewing the source code, see
</em>
</dt>
- <dd class="todo">
+ <dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd style="display: none; ">
- Description of this parameter from the json schema.
- </dd>
+ <dd>Contains details about the window whose tabs were highlighted.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -3635,7 +3630,7 @@ For other examples and for help in viewing the source code, see
<dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd>The ID of the tab in which to insert the CSS; defaults to the selected tab of the current window.</dd>
+ <dd>The ID of the tab in which to insert the CSS; defaults to the active tab of the current window.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -4060,14 +4055,14 @@ For other examples and for help in viewing the source code, see
<div class="summary"><span style="display: none; ">void</span>
<!-- Note: intentionally longer 80 columns -->
- <span>chrome.tabs.move</span>(<span class="null"><span style="display: none; ">, </span><span>integer</span>
- <var><span>tabId</span></var></span><span class="null"><span>, </span><span>object</span>
+ <span>chrome.tabs.move</span>(<span class="null"><span style="display: none; ">, </span><span>integer or array of integer</span>
+ <var><span>tabIds</span></var></span><span class="null"><span>, </span><span>object</span>
<var><span>moveProperties</span></var></span><span class="optional"><span>, </span><span>function</span>
<var><span>callback</span></var></span>)</div>
<div class="description">
<p class="todo" style="display: none; ">Undocumented.</p>
- <p>Moves a tab to a new position within its window, or to a new window. Note that tabs can only be moved to and from normal (window.type === "normal") windows.</p>
+ <p>Moves one or more tabs to a new position within its window, or to a new window. Note that tabs can only be moved to and from normal (window.type === "normal") windows.</p>
<!-- PARAMETERS -->
<h4>Parameters</h4>
@@ -4075,7 +4070,7 @@ For other examples and for help in viewing the source code, see
<div>
<div>
<dt>
- <var>tabId</var>
+ <var>tabIds</var>
<em>
<!-- TYPE -->
@@ -4091,7 +4086,7 @@ For other examples and for help in viewing the source code, see
<span style="display: none; ">
array of <span><span></span></span>
</span>
- <span>integer</span>
+ <span>integer or array of integer</span>
<span style="display: none; "></span>
</span>
</span>
@@ -4100,12 +4095,10 @@ For other examples and for help in viewing the source code, see
</em>
</dt>
- <dd class="todo">
+ <dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd style="display: none; ">
- Description of this parameter from the json schema.
- </dd>
+ <dd>The tab or list of tabs to move.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -4441,12 +4434,722 @@ For other examples and for help in viewing the source code, see
</p>
<!-- Note: intentionally longer 80 columns -->
- <pre>function(<span>Tab tab</span>) <span class="subdued">{...}</span>;</pre>
+ <pre>function(<span>Tab or array of Tab tabs</span>) <span class="subdued">{...}</span>;</pre>
<dl>
<div>
<div>
<dt>
- <var>tab</var>
+ <var>tabs</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional" style="display: none; ">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>Tab or array of Tab</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo" style="display: none; ">
+ Undocumented.
+ </dd>
+ <dd>Details about the moved tabs.</dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div>
+ </dl>
+ </div>
+ </div>
+
+ <!-- MIN_VERSION -->
+ <p style="display: none; ">
+ This function was added in version <b><span></span></b>.
+ If you require this function, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </p>
+ </div> <!-- /description -->
+
+ </div><div class="apiItem">
+ <a name="method-query"></a> <!-- method-anchor -->
+ <h4>query</h4>
+
+ <div class="summary"><span style="display: none; ">void</span>
+ <!-- Note: intentionally longer 80 columns -->
+ <span>chrome.tabs.query</span>(<span class="null"><span style="display: none; ">, </span><span>object</span>
+ <var><span>queryInfo</span></var></span><span class="null"><span>, </span><span>function</span>
+ <var><span>callback</span></var></span>)</div>
+
+ <div class="description">
+ <p class="todo" style="display: none; ">Undocumented.</p>
+ <p>Gets all tabs that have the specified properties, or all tabs if no properties are specified.</p>
+
+ <!-- PARAMETERS -->
+ <h4>Parameters</h4>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>queryInfo</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional" style="display: none; ">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>object</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo">
+ Undocumented.
+ </dd>
+ <dd style="display: none; ">
+ Description of this parameter from the json schema.
+ </dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>active</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>boolean</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo" style="display: none; ">
+ Undocumented.
+ </dd>
+ <dd>Whether the tabs are active in their windows.</dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>pinned</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>boolean</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo" style="display: none; ">
+ Undocumented.
+ </dd>
+ <dd>Whether the tabs are pinned.</dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>highlighted</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>boolean</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo" style="display: none; ">
+ Undocumented.
+ </dd>
+ <dd>Whether the tabs are highlighted.</dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>status</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span class="enum">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>string</span>
+ <span>["loading", "complete"]</span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo" style="display: none; ">
+ Undocumented.
+ </dd>
+ <dd>Whether the tabs have completed loading.</dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>title</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>string</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo" style="display: none; ">
+ Undocumented.
+ </dd>
+ <dd>Match page titles against a pattern.</dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>url</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>string</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo" style="display: none; ">
+ Undocumented.
+ </dd>
+ <dd>Match tabs against a URL pattern.</dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>windowId</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>integer</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo" style="display: none; ">
+ Undocumented.
+ </dd>
+ <dd>The ID of the parent window.</dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>windowType</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span class="enum">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>string</span>
+ <span>["normal", "popup", "panel", "app"]</span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo" style="display: none; ">
+ Undocumented.
+ </dd>
+ <dd>The type of window the tabs are in.</dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>callback</var>
<em>
<!-- TYPE -->
@@ -4455,6 +5158,110 @@ For other examples and for help in viewing the source code, see
<span class="optional" style="display: none; ">optional</span>
<span class="enum" style="display: none; ">enumerated</span>
<span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>function</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo">
+ Undocumented.
+ </dd>
+ <dd style="display: none; ">
+ Description of this parameter from the json schema.
+ </dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div>
+ </dl>
+
+ <!-- RETURNS -->
+ <h4 style="display: none; ">Returns</h4>
+ <dl>
+ <div style="display: none; ">
+ <div>
+ </div>
+ </div>
+ </dl>
+
+ <!-- CALLBACK -->
+ <div>
+ <div>
+ <h4>Callback function</h4>
+ <p>
+ The callback <em>parameter</em> should specify a function
+ that looks like this:
+ </p>
+ <p style="display: none; ">
+ If you specify the <em>callback</em> parameter, it should
+ specify a function that looks like this:
+ </p>
+
+ <!-- Note: intentionally longer 80 columns -->
+ <pre>function(<span>array of Tab undefined</span>) <span class="subdued">{...}</span>;</pre>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var style="display: none; ">paramName</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional" style="display: none; ">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span>
+ array of <span><span>
<span>
<a href="tabs.html#type-Tab">Tab</a>
</span>
@@ -4465,16 +5272,23 @@ For other examples and for help in viewing the source code, see
<span>paramType</span>
<span></span>
</span>
+ </span></span>
+ </span>
+ <span style="display: none; ">paramType</span>
+ <span style="display: none; "></span>
+ </span>
</span>
)
</div>
</em>
</dt>
- <dd class="todo" style="display: none; ">
+ <dd class="todo">
Undocumented.
</dd>
- <dd>Details about the moved tab.</dd>
+ <dd style="display: none; ">
+ Description of this parameter from the json schema.
+ </dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -4867,13 +5681,13 @@ For other examples and for help in viewing the source code, see
<div class="summary"><span style="display: none; ">void</span>
<!-- Note: intentionally longer 80 columns -->
- <span>chrome.tabs.remove</span>(<span class="null"><span style="display: none; ">, </span><span>integer</span>
- <var><span>tabId</span></var></span><span class="optional"><span>, </span><span>function</span>
+ <span>chrome.tabs.remove</span>(<span class="null"><span style="display: none; ">, </span><span>integer or array of integer</span>
+ <var><span>tabIds</span></var></span><span class="optional"><span>, </span><span>function</span>
<var><span>callback</span></var></span>)</div>
<div class="description">
<p class="todo" style="display: none; ">Undocumented.</p>
- <p>Closes a tab. Note: This function can be used without requesting the 'tabs' permission in the manifest.</p>
+ <p>Closes one or more tabs. Note: This function can be used without requesting the 'tabs' permission in the manifest.</p>
<!-- PARAMETERS -->
<h4>Parameters</h4>
@@ -4881,7 +5695,7 @@ For other examples and for help in viewing the source code, see
<div>
<div>
<dt>
- <var>tabId</var>
+ <var>tabIds</var>
<em>
<!-- TYPE -->
@@ -4897,7 +5711,7 @@ For other examples and for help in viewing the source code, see
<span style="display: none; ">
array of <span><span></span></span>
</span>
- <span>integer</span>
+ <span>integer or array of integer</span>
<span style="display: none; "></span>
</span>
</span>
@@ -4906,12 +5720,10 @@ For other examples and for help in viewing the source code, see
</em>
</dt>
- <dd class="todo">
+ <dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd style="display: none; ">
- Description of this parameter from the json schema.
- </dd>
+ <dd>The tab or list of tabs to close.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -5678,7 +6490,75 @@ For other examples and for help in viewing the source code, see
</div><div>
<div>
<dt>
- <var>selected</var>
+ <var>active</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>boolean</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo" style="display: none; ">
+ Undocumented.
+ </dd>
+ <dd>Whether the tab should be active.</dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>highlighted</var>
<em>
<!-- TYPE -->
@@ -5706,7 +6586,7 @@ For other examples and for help in viewing the source code, see
<dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd>Whether the tab should be selected.</dd>
+ <dd>Adds or removes the tab from the current selection.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -6021,6 +6901,251 @@ For other examples and for help in viewing the source code, see
<h3>Events</h3>
<!-- iterates over all events -->
<div class="apiItem">
+ <a name="event-onActiveChanged"></a>
+ <h4>onActiveChanged</h4>
+
+ <div class="summary">
+ <!-- Note: intentionally longer 80 columns -->
+ <span class="subdued">chrome.tabs.</span><span>onActiveChanged</span><span class="subdued">.addListener</span>(function(<span>integer tabId, object selectInfo</span>) <span class="subdued">{...}</span><span></span>);
+ </div>
+
+ <div class="description">
+ <p class="todo" style="display: none; ">Undocumented.</p>
+ <p>Fires when the selected tab in a window changes.</p>
+
+ <!-- LISTENER PARAMETERS -->
+ <div>
+ <h4>Listener parameters</h4>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>tabId</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional" style="display: none; ">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>integer</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo" style="display: none; ">
+ Undocumented.
+ </dd>
+ <dd>The ID of the tab that has become active.</dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>selectInfo</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional" style="display: none; ">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>object</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo">
+ Undocumented.
+ </dd>
+ <dd style="display: none; ">
+ Description of this parameter from the json schema.
+ </dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>windowId</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional" style="display: none; ">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>integer</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo" style="display: none; ">
+ Undocumented.
+ </dd>
+ <dd>The ID of the window the selected tab changed inside of.</dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div>
+ </dl>
+ </div>
+
+ <!-- EXTRA PARAMETERS -->
+ <div style="display: none; ">
+ <h4>Extra parameters to addListener</h4>
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </div>
+
+ <!-- LISTENER RETURN VALUE -->
+ <h4 style="display: none; ">Listener returns</h4>
+ <dl>
+ <div style="display: none; ">
+ <div>
+ </div>
+ </div>
+ </dl>
+
+ </div> <!-- /description -->
+ </div><div class="apiItem">
<a name="event-onAttached"></a>
<h4>onAttached</h4>
@@ -6769,17 +7894,17 @@ For other examples and for help in viewing the source code, see
</div> <!-- /description -->
</div><div class="apiItem">
- <a name="event-onMoved"></a>
- <h4>onMoved</h4>
+ <a name="event-onHighlightChanged"></a>
+ <h4>onHighlightChanged</h4>
<div class="summary">
<!-- Note: intentionally longer 80 columns -->
- <span class="subdued">chrome.tabs.</span><span>onMoved</span><span class="subdued">.addListener</span>(function(<span>integer tabId, object moveInfo</span>) <span class="subdued">{...}</span><span></span>);
+ <span class="subdued">chrome.tabs.</span><span>onHighlightChanged</span><span class="subdued">.addListener</span>(function(<span>object selectInfo</span>) <span class="subdued">{...}</span><span></span>);
</div>
<div class="description">
<p class="todo" style="display: none; ">Undocumented.</p>
- <p>Fired when a tab is moved within a window. Only one move event is fired, representing the tab the user directly moved. Move events are not fired for the other tabs that must move in response. This event is not fired when a tab is moved between windows. For that, see <a href="#event-onDetached">onDetached</a>.</p>
+ <p>Fired when the highlighted or selected tabs in a window changes.</p>
<!-- LISTENER PARAMETERS -->
<div>
@@ -6788,7 +7913,7 @@ For other examples and for help in viewing the source code, see
<div>
<div>
<dt>
- <var>tabId</var>
+ <var>selectInfo</var>
<em>
<!-- TYPE -->
@@ -6804,7 +7929,7 @@ For other examples and for help in viewing the source code, see
<span style="display: none; ">
array of <span><span></span></span>
</span>
- <span>integer</span>
+ <span>object</span>
<span style="display: none; "></span>
</span>
</span>
@@ -6830,35 +7955,12 @@ For other examples and for help in viewing the source code, see
</dd>
<!-- OBJECT PROPERTIES -->
- <dd style="display: none; ">
+ <dd>
<dl>
<div>
<div>
- </div>
- </div>
- </dl>
- </dd>
-
- <!-- OBJECT METHODS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- <!-- OBJECT EVENT FIELDS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- <!-- FUNCTION PARAMETERS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- </div>
- </div><div>
- <div>
<dt>
- <var>moveInfo</var>
+ <var>windowId</var>
<em>
<!-- TYPE -->
@@ -6874,7 +7976,7 @@ For other examples and for help in viewing the source code, see
<span style="display: none; ">
array of <span><span></span></span>
</span>
- <span>object</span>
+ <span>integer</span>
<span style="display: none; "></span>
</span>
</span>
@@ -6883,12 +7985,10 @@ For other examples and for help in viewing the source code, see
</em>
</dt>
- <dd class="todo">
+ <dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd style="display: none; ">
- Description of this parameter from the json schema.
- </dd>
+ <dd>The window whose tabs changed.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -6900,12 +8000,35 @@ For other examples and for help in viewing the source code, see
</dd>
<!-- OBJECT PROPERTIES -->
- <dd>
+ <dd style="display: none; ">
<dl>
<div>
<div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div><div>
+ <div>
<dt>
- <var>windowId</var>
+ <var>tabIds</var>
<em>
<!-- TYPE -->
@@ -6918,24 +8041,33 @@ For other examples and for help in viewing the source code, see
<a> Type</a>
</span>
<span>
+ <span>
+ array of <span><span>
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
<span style="display: none; ">
array of <span><span></span></span>
</span>
<span>integer</span>
<span style="display: none; "></span>
</span>
+ </span></span>
+ </span>
+ <span style="display: none; ">paramType</span>
+ <span style="display: none; "></span>
+ </span>
</span>
)
</div>
</em>
</dt>
- <dd class="todo">
+ <dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd style="display: none; ">
- Description of this parameter from the json schema.
- </dd>
+ <dd>All highlighted tabs in the window.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -6972,10 +8104,72 @@ For other examples and for help in viewing the source code, see
</dd>
</div>
- </div><div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div>
+ </dl>
+ </div>
+
+ <!-- EXTRA PARAMETERS -->
+ <div style="display: none; ">
+ <h4>Extra parameters to addListener</h4>
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </div>
+
+ <!-- LISTENER RETURN VALUE -->
+ <h4 style="display: none; ">Listener returns</h4>
+ <dl>
+ <div style="display: none; ">
+ <div>
+ </div>
+ </div>
+ </dl>
+
+ </div> <!-- /description -->
+ </div><div class="apiItem">
+ <a name="event-onMoved"></a>
+ <h4>onMoved</h4>
+
+ <div class="summary">
+ <!-- Note: intentionally longer 80 columns -->
+ <span class="subdued">chrome.tabs.</span><span>onMoved</span><span class="subdued">.addListener</span>(function(<span>integer tabId, object moveInfo</span>) <span class="subdued">{...}</span><span></span>);
+ </div>
+
+ <div class="description">
+ <p class="todo" style="display: none; ">Undocumented.</p>
+ <p>Fired when a tab is moved within a window. Only one move event is fired, representing the tab the user directly moved. Move events are not fired for the other tabs that must move in response. This event is not fired when a tab is moved between windows. For that, see <a href="#event-onDetached">onDetached</a>.</p>
+
+ <!-- LISTENER PARAMETERS -->
<div>
+ <h4>Listener parameters</h4>
+ <dl>
+ <div>
+ <div>
<dt>
- <var>fromIndex</var>
+ <var>tabId</var>
<em>
<!-- TYPE -->
@@ -7042,10 +8236,10 @@ For other examples and for help in viewing the source code, see
</dd>
</div>
- </div><div>
- <div>
+ </div><div>
+ <div>
<dt>
- <var>toIndex</var>
+ <var>moveInfo</var>
<em>
<!-- TYPE -->
@@ -7061,7 +8255,7 @@ For other examples and for help in viewing the source code, see
<span style="display: none; ">
array of <span><span></span></span>
</span>
- <span>integer</span>
+ <span>object</span>
<span style="display: none; "></span>
</span>
</span>
@@ -7087,97 +8281,12 @@ For other examples and for help in viewing the source code, see
</dd>
<!-- OBJECT PROPERTIES -->
- <dd style="display: none; ">
+ <dd>
<dl>
<div>
<div>
- </div>
- </div>
- </dl>
- </dd>
-
- <!-- OBJECT METHODS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- <!-- OBJECT EVENT FIELDS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- <!-- FUNCTION PARAMETERS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- </div>
- </div>
- </dl>
- </dd>
-
- <!-- OBJECT METHODS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- <!-- OBJECT EVENT FIELDS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- <!-- FUNCTION PARAMETERS -->
- <dd style="display: none; ">
- <div></div>
- </dd>
-
- </div>
- </div>
- </dl>
- </div>
-
- <!-- EXTRA PARAMETERS -->
- <div style="display: none; ">
- <h4>Extra parameters to addListener</h4>
- <dl>
- <div>
- <div>
- </div>
- </div>
- </dl>
- </div>
-
- <!-- LISTENER RETURN VALUE -->
- <h4 style="display: none; ">Listener returns</h4>
- <dl>
- <div style="display: none; ">
- <div>
- </div>
- </div>
- </dl>
-
- </div> <!-- /description -->
- </div><div class="apiItem">
- <a name="event-onRemoved"></a>
- <h4>onRemoved</h4>
-
- <div class="summary">
- <!-- Note: intentionally longer 80 columns -->
- <span class="subdued">chrome.tabs.</span><span>onRemoved</span><span class="subdued">.addListener</span>(function(<span>integer tabId, object removeInfo</span>) <span class="subdued">{...}</span><span></span>);
- </div>
-
- <div class="description">
- <p class="todo" style="display: none; ">Undocumented.</p>
- <p>Fired when a tab is closed. Note: A listener can be registered for this event without requesting the 'tabs' permission in the manifest.</p>
-
- <!-- LISTENER PARAMETERS -->
- <div>
- <h4>Listener parameters</h4>
- <dl>
- <div>
- <div>
<dt>
- <var>tabId</var>
+ <var>windowId</var>
<em>
<!-- TYPE -->
@@ -7244,10 +8353,10 @@ For other examples and for help in viewing the source code, see
</dd>
</div>
- </div><div>
- <div>
+ </div><div>
+ <div>
<dt>
- <var>removeInfo</var>
+ <var>fromIndex</var>
<em>
<!-- TYPE -->
@@ -7263,7 +8372,7 @@ For other examples and for help in viewing the source code, see
<span style="display: none; ">
array of <span><span></span></span>
</span>
- <span>object</span>
+ <span>integer</span>
<span style="display: none; "></span>
</span>
</span>
@@ -7289,12 +8398,35 @@ For other examples and for help in viewing the source code, see
</dd>
<!-- OBJECT PROPERTIES -->
- <dd>
+ <dd style="display: none; ">
<dl>
<div>
<div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div><div>
+ <div>
<dt>
- <var>isWindowClosing</var>
+ <var>toIndex</var>
<em>
<!-- TYPE -->
@@ -7310,7 +8442,7 @@ For other examples and for help in viewing the source code, see
<span style="display: none; ">
array of <span><span></span></span>
</span>
- <span>boolean</span>
+ <span>integer</span>
<span style="display: none; "></span>
</span>
</span>
@@ -7319,10 +8451,12 @@ For other examples and for help in viewing the source code, see
</em>
</dt>
- <dd class="todo" style="display: none; ">
+ <dd class="todo">
Undocumented.
</dd>
- <dd>True when the tab is being closed because its window is being closed.</dd>
+ <dd style="display: none; ">
+ Description of this parameter from the json schema.
+ </dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -7405,17 +8539,17 @@ For other examples and for help in viewing the source code, see
</div> <!-- /description -->
</div><div class="apiItem">
- <a name="event-onSelectionChanged"></a>
- <h4>onSelectionChanged</h4>
+ <a name="event-onRemoved"></a>
+ <h4>onRemoved</h4>
<div class="summary">
<!-- Note: intentionally longer 80 columns -->
- <span class="subdued">chrome.tabs.</span><span>onSelectionChanged</span><span class="subdued">.addListener</span>(function(<span>integer tabId, object selectInfo</span>) <span class="subdued">{...}</span><span></span>);
+ <span class="subdued">chrome.tabs.</span><span>onRemoved</span><span class="subdued">.addListener</span>(function(<span>integer tabId, object removeInfo</span>) <span class="subdued">{...}</span><span></span>);
</div>
<div class="description">
<p class="todo" style="display: none; ">Undocumented.</p>
- <p>Fired when the selected tab in a window changes.</p>
+ <p>Fired when a tab is closed. Note: A listener can be registered for this event without requesting the 'tabs' permission in the manifest.</p>
<!-- LISTENER PARAMETERS -->
<div>
@@ -7449,10 +8583,12 @@ For other examples and for help in viewing the source code, see
</em>
</dt>
- <dd class="todo" style="display: none; ">
+ <dd class="todo">
Undocumented.
</dd>
- <dd>The ID of the tab that has become selected.</dd>
+ <dd style="display: none; ">
+ Description of this parameter from the json schema.
+ </dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -7492,7 +8628,7 @@ For other examples and for help in viewing the source code, see
</div><div>
<div>
<dt>
- <var>selectInfo</var>
+ <var>removeInfo</var>
<em>
<!-- TYPE -->
@@ -7539,7 +8675,7 @@ For other examples and for help in viewing the source code, see
<div>
<div>
<dt>
- <var>windowId</var>
+ <var>isWindowClosing</var>
<em>
<!-- TYPE -->
@@ -7555,7 +8691,7 @@ For other examples and for help in viewing the source code, see
<span style="display: none; ">
array of <span><span></span></span>
</span>
- <span>integer</span>
+ <span>boolean</span>
<span style="display: none; "></span>
</span>
</span>
@@ -7567,7 +8703,7 @@ For other examples and for help in viewing the source code, see
<dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd>The ID of the window the selected tab changed inside of.</dd>
+ <dd>True when the tab is being closed because its window is being closed.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
@@ -7649,6 +8785,53 @@ For other examples and for help in viewing the source code, see
</dl>
</div> <!-- /description -->
+ </div><div class="apiItem" style="display: none; ">
+ <a></a>
+ <h4>event name</h4>
+
+ <div class="summary">
+ <!-- Note: intentionally longer 80 columns -->
+ <span class="subdued">chrome.bookmarks</span><span>onEvent</span><span class="subdued">.addListener</span>(function(<span>Type param1, Type param2</span>) <span class="subdued">{...}</span><span>, Type opt_param1, Type opt_param2</span>);
+ </div>
+
+ <div class="description">
+ <p class="todo">Undocumented.</p>
+ <p>
+ A description from the json schema def of the event goes here.
+ </p>
+
+ <!-- LISTENER PARAMETERS -->
+ <div>
+ <h4>Listener parameters</h4>
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </div>
+
+ <!-- EXTRA PARAMETERS -->
+ <div>
+ <h4>Extra parameters to addListener</h4>
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </div>
+
+ <!-- LISTENER RETURN VALUE -->
+ <h4>Listener returns</h4>
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+
+ </div> <!-- /description -->
</div><div class="apiItem">
<a name="event-onUpdated"></a>
<h4>onUpdated</h4>
@@ -8365,7 +9548,75 @@ For other examples and for help in viewing the source code, see
</div><div>
<div>
<dt>
- <var>selected</var>
+ <var>highlighted</var>
+ <em>
+
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional" style="display: none; ">optional</span>
+ <span class="enum" style="display: none; ">enumerated</span>
+ <span id="typeTemplate">
+ <span style="display: none; ">
+ <a> Type</a>
+ </span>
+ <span>
+ <span style="display: none; ">
+ array of <span><span></span></span>
+ </span>
+ <span>boolean</span>
+ <span style="display: none; "></span>
+ </span>
+ </span>
+ )
+ </div>
+
+ </em>
+ </dt>
+ <dd class="todo" style="display: none; ">
+ Undocumented.
+ </dd>
+ <dd>Whether the tab is highlighted.</dd>
+ <dd style="display: none; ">
+ This parameter was added in version
+ <b><span></span></b>.
+ You must omit this parameter in earlier versions,
+ and you may omit it in any version. If you require this
+ parameter, the manifest key
+ <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
+ can ensure that your extension won't be run in an earlier browser version.
+ </dd>
+
+ <!-- OBJECT PROPERTIES -->
+ <dd style="display: none; ">
+ <dl>
+ <div>
+ <div>
+ </div>
+ </div>
+ </dl>
+ </dd>
+
+ <!-- OBJECT METHODS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- OBJECT EVENT FIELDS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ <!-- FUNCTION PARAMETERS -->
+ <dd style="display: none; ">
+ <div></div>
+ </dd>
+
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>active</var>
<em>
<!-- TYPE -->
@@ -8393,7 +9644,7 @@ For other examples and for help in viewing the source code, see
<dd class="todo" style="display: none; ">
Undocumented.
</dd>
- <dd>Whether the tab is selected.</dd>
+ <dd>Whether the tab is active in its window.</dd>
<dd style="display: none; ">
This parameter was added in version
<b><span></span></b>.
diff --git a/chrome/test/data/extensions/api_test/tabs/basics/crud.html b/chrome/test/data/extensions/api_test/tabs/basics/crud.html
index 1a5f4a9..3420139 100644
--- a/chrome/test/data/extensions/api_test/tabs/basics/crud.html
+++ b/chrome/test/data/extensions/api_test/tabs/basics/crud.html
@@ -13,7 +13,7 @@ chrome.test.runTests([
},
function create() {
- chrome.tabs.create({"windowId" : firstWindowId, "selected" : false},
+ chrome.tabs.create({"windowId" : firstWindowId, "active" : false},
pass(function(tab){
assertEq(1, tab.index);
assertEq(firstWindowId, tab.windowId);
@@ -26,7 +26,7 @@ chrome.test.runTests([
function createInOtherWindow() {
chrome.windows.create({}, pass(function(win) {
// Create a tab in the older window.
- chrome.tabs.create({"windowId" : firstWindowId, "selected" : false},
+ chrome.tabs.create({"windowId" : firstWindowId, "active" : false},
pass(function(tab) {
assertEq(firstWindowId, tab.windowId);
}));
@@ -45,9 +45,9 @@ chrome.test.runTests([
},
function createSelected() {
- chrome.tabs.create({"windowId" : firstWindowId, "selected" : true},
+ chrome.tabs.create({"windowId" : firstWindowId, "active" : true},
pass(function(tab) {
- assertTrue(tab.selected);
+ assertTrue(tab.active && tab.selected);
chrome.tabs.getSelected(firstWindowId, pass(function(selectedTab) {
assertEq(tab.id, selectedTab.id);
}));
@@ -70,7 +70,7 @@ chrome.test.runTests([
function createWindowWithExistingTab() {
// Create a tab in the old window
chrome.tabs.create({"windowId" : firstWindowId, "url": pageUrl('a'),
- "selected" : false},
+ "active" : false},
pass(function(tab) {
assertEq(firstWindowId, tab.windowId);
assertEq(pageUrl('a'), tab.url);
diff --git a/chrome/test/data/extensions/api_test/tabs/basics/crud2.html b/chrome/test/data/extensions/api_test/tabs/basics/crud2.html
index 761ce592..e845d1c 100644
--- a/chrome/test/data/extensions/api_test/tabs/basics/crud2.html
+++ b/chrome/test/data/extensions/api_test/tabs/basics/crud2.html
@@ -28,8 +28,8 @@ chrome.test.runTests([
assertEq(secondWindowId, tabs[i].windowId);
assertEq(i, tabs[i].index);
- // The first tab should be selected
- assertEq((i == 0), tabs[i].selected);
+ // The first tab should be active
+ assertEq((i == 0), tabs[i].active && tabs[i].selected);
}
assertEq("about:blank", tabs[0].url);
assertEq("chrome://newtab/", tabs[1].url);
@@ -50,26 +50,27 @@ chrome.test.runTests([
function updateSelect() {
chrome.tabs.getAllInWindow(secondWindowId, pass(function(tabs) {
- assertEq(true, tabs[0].selected);
- assertEq(false, tabs[1].selected);
- assertEq(false, tabs[2].selected);
+ assertEq(true, tabs[0].active && tabs[0].selected);
+ assertEq(false, tabs[1].active || tabs[1].selected);
+ assertEq(false, tabs[2].active || tabs[2].selected);
+
// Select tab[1].
- chrome.tabs.update(tabs[1].id, {selected: true},
+ chrome.tabs.update(tabs[1].id, {active: true},
pass(function(tab1){
// Check update of tab[1].
- chrome.test.assertEq(true, tab1.selected);
+ chrome.test.assertEq(true, tab1.active);
chrome.tabs.getAllInWindow(secondWindowId, pass(function(tabs) {
- assertEq(true, tabs[1].selected);
- assertEq(false, tabs[2].selected);
+ assertEq(true, tabs[1].active && tabs[1].selected);
+ assertEq(false, tabs[2].active || tabs[2].selected);
// Select tab[2].
chrome.tabs.update(tabs[2].id,
- {selected: true},
+ {active: true},
pass(function(tab2){
// Check update of tab[2].
- chrome.test.assertEq(true, tab2.selected);
+ chrome.test.assertEq(true, tab2.active);
chrome.tabs.getAllInWindow(secondWindowId, pass(function(tabs) {
- assertEq(false, tabs[1].selected);
- assertEq(true, tabs[2].selected);
+ assertEq(false, tabs[1].active || tabs[1].selected);
+ assertEq(true, tabs[2].active && tabs[2].selected);
}));
}));
}));
diff --git a/chrome/test/data/extensions/api_test/tabs/basics/highlight.html b/chrome/test/data/extensions/api_test/tabs/basics/highlight.html
new file mode 100644
index 0000000..2b70358
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tabs/basics/highlight.html
@@ -0,0 +1,131 @@
+<script src="tabs_util.js"></script>
+
+<script>
+var testWindowId1, testWindowId2;
+
+function contains(arr, value) {
+ return arr.some(function(element) { return element == value; });
+}
+
+function checkEqualSets(set1, set2) {
+ if (set1.length != set2.length)
+ return false;
+
+ for (var x = 0; x < set1.length; x++) {
+ if (!set2.some(function(v) { return v == set1[x]; }))
+ return false;
+ }
+
+ return true;
+}
+
+chrome.test.runTests([
+ function setup() {
+ var tabs1 = ['http://e.com', 'http://a.com', 'http://a.com/b.html',
+ 'http://b.com', 'http://a.com/d.html', 'http://a.com/c.html'];
+ var tabs2 = ['http://c.com/', 'http://a.com', 'http://a.com/b.html'];
+ chrome.windows.create({url: tabs1}, pass(function(win) {
+ testWindowId1 = win.id;
+ }));
+ chrome.windows.create({url: tabs2}, pass(function(win) {
+ testWindowId2 = win.id;
+ }));
+ },
+
+ function highlightA() {
+ chrome.tabs.query({windowId: testWindowId1, url: 'http://a.com/*'},
+ pass(function(tabs) {
+ assertEq(4, tabs.length);
+ chrome.test.listenOnce(chrome.tabs.onHighlightChanged,
+ function(highlightInfo) {
+ var tabIds = tabs.map(function(tab) { return tab.id; });
+ assertEq(highlightInfo.windowId, testWindowId1);
+ assertTrue(checkEqualSets(tabIds, highlightInfo.tabIds));
+ });
+ var tabIndices = tabs.map(function(tab) { return tab.index; });
+ chrome.tabs.highlight({
+ windowId: testWindowId1,
+ tabs: tabIndices
+ }, pass(function(win) {
+ // Verify the 'highlighted' property for every tab.
+ win.tabs.forEach(function(tab) {
+ assertEq(contains(tabIndices, tab.index), tab.highlighted);
+ });
+ }));
+ }));
+ },
+
+ function highlightB() {
+ chrome.tabs.query({windowId: testWindowId1, url: 'http://b.com/*'},
+ pass(function(tabs) {
+ assertEq(1, tabs.length);
+ chrome.test.listenOnce(chrome.tabs.onHighlightChanged,
+ function(highlightInfo) {
+ var tabIds = tabs.map(function(tab) { return tab.id; });
+ assertEq(highlightInfo.windowId, testWindowId1);
+ assertTrue(checkEqualSets(tabIds, highlightInfo.tabIds));
+ });
+ var tabIndices = tabs.map(function(tab) { return tab.index; });
+ chrome.tabs.highlight({windowId: testWindowId1, tabs: tabIndices},
+ pass(function(win) {
+ // Verify the 'highlighted' property for every tab.
+ win.tabs.forEach(function(tab) {
+ assertEq(contains(tabIndices, tab.index), tab.highlighted);
+ });
+ }));
+ }));
+ },
+
+ function highlightAWindow2() {
+ chrome.tabs.query({windowId: testWindowId2, url: 'http://a.com/*'},
+ pass(function(tabs) {
+ assertEq(2, tabs.length);
+ chrome.test.listenOnce(chrome.tabs.onHighlightChanged,
+ function(highlightInfo) {
+ var tabIds = tabs.map(function(tab) { return tab.id; });
+ assertEq(highlightInfo.windowId, testWindowId2);
+ assertTrue(checkEqualSets(tabIds, highlightInfo.tabIds));
+ });
+ var tabIndices = tabs.map(function(tab) { return tab.index; });
+ chrome.tabs.highlight({windowId: testWindowId2, tabs: tabIndices},
+ pass(function(win) {
+ // Verify the 'highlighted' property for every tab.
+ win.tabs.forEach(function(tab) {
+ assertEq(contains(tabIndices, tab.index), tab.highlighted);
+ });
+
+ // Verify that nothing has changed in window 1.
+ chrome.tabs.query({windowId: testWindowId1, highlighted: true},
+ pass(function(tabs) {
+ assertEq(1, tabs.length);
+ }));
+ }));
+ }));
+ },
+
+ function removeTab() {
+ chrome.tabs.query(
+ {windowId: testWindowId2, highlighted: true, active: false},
+ pass(function(tabs) {
+ var tabId = tabs[0].id;
+ chrome.test.listenOnce(chrome.tabs.onHighlightChanged,
+ function(highlightInfo) {
+ assertEq(1, highlightInfo.tabIds.length);
+ assertTrue(tabId != highlightInfo.tabIds[0]);
+ });
+ chrome.tabs.remove(tabId, pass(function() { assertTrue(true); }));
+ }));
+ },
+
+ function noTabsHighlighted() {
+ chrome.tabs.highlight({windowId: testWindowId1, tabs: []},
+ fail("No highlighted tab"));
+ },
+
+ function indexNotFound() {
+ chrome.tabs.highlight({windowId: testWindowId1, tabs: [3333]},
+ fail("No tab at index: 3333."));
+ }
+]);
+
+</script>
diff --git a/chrome/test/data/extensions/api_test/tabs/basics/move.html b/chrome/test/data/extensions/api_test/tabs/basics/move.html
index 55eb71b..b9e6c9e 100644
--- a/chrome/test/data/extensions/api_test/tabs/basics/move.html
+++ b/chrome/test/data/extensions/api_test/tabs/basics/move.html
@@ -6,15 +6,15 @@ var secondWindowId;
var moveTabIds = {};
chrome.test.runTests([
- // Do a series of moves so that we get the following
+ // Do a series of moves and removes so that we get the following
//
// Before:
// Window1: (newtab),a,b,c,d,e
// Window2: (newtab)
//
// After:
- // Window1: (newtab),a,e,c
- // Window2: b,(newtab),d
+ // Window1: (newtab),a
+ // Window2: b,(newtab)
function setupLetterPages() {
var pages = ["chrome://newtab/", pageUrl('a'), pageUrl('b'),
pageUrl('c'), pageUrl('d'), pageUrl('e')];
@@ -82,6 +82,33 @@ chrome.test.runTests([
}));
},
+ function moveMultipleTabs() {
+ chrome.tabs.move([moveTabIds['e'], moveTabIds['c']],
+ {windowId: secondWindowId, index: 1},
+ pass(function(tabsA) {
+ assertEq(2, tabsA.length);
+ assertEq(secondWindowId, tabsA[0].windowId);
+ assertEq(pageUrl('e'), tabsA[0].url);
+ assertEq(1, tabsA[0].index);
+ assertEq(secondWindowId, tabsA[1].windowId);
+ assertEq(pageUrl('c'), tabsA[1].url);
+ assertEq(2, tabsA[1].index);
+ chrome.tabs.query({windowId: secondWindowId}, pass(function(tabsB) {
+ assertEq(4, tabsB.length);
+ }));
+ }));
+ },
+
+ function removeMultipleTabs() {
+ chrome.tabs.remove([moveTabIds['e'], moveTabIds['c']], pass(function() {
+ chrome.tabs.query({windowId: secondWindowId}, pass(function(tabs) {
+ assertEq(2, tabs.length);
+ assertEq(pageUrl("b"), tabs[0].url);
+ assertEq("chrome://newtab/", tabs[1].url);
+ }));
+ }));
+ },
+
// Make sure we don't crash when the index is out of range.
function moveToInvalidTab() {
var error_msg = "Invalid value for argument 2. Property 'index': " +
diff --git a/chrome/test/data/extensions/api_test/tabs/basics/query.html b/chrome/test/data/extensions/api_test/tabs/basics/query.html
new file mode 100644
index 0000000..3b13a7f
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tabs/basics/query.html
@@ -0,0 +1,165 @@
+<script src="tabs_util.js"></script>
+
+<script>
+var testWindowId;
+var active_tabs = [];
+var highlighted_tabs = [];
+var window_tabs = [];
+var pinned_tabs = [];
+var active_and_window_tabs = [];
+
+chrome.test.runTests([
+ function setup() {
+ var tabs = ['http://example.org/a.html', 'http://google.com'];
+ chrome.windows.create({url: tabs}, pass(function(window) {
+ assertEq(2, window.tabs.length);
+ testWindowId = window.id;
+ chrome.tabs.create({
+ windowId: testWindowId,
+ url: 'about:blank',
+ pinned: true
+ }, pass(function(tab) {
+ assertTrue(tab.pinned);
+ assertEq(testWindowId, tab.windowId);
+ }));
+ }));
+ },
+
+ function queryAll() {
+ chrome.tabs.query({}, pass(function(tabs) {
+ assertEq(4, tabs.length);
+ for (var x = 0; x < tabs.length; x++) {
+ if (tabs[x].highlighted)
+ highlighted_tabs.push(tabs[x]);
+ if (tabs[x].active)
+ active_tabs.push(tabs[x]);
+ if (tabs[x].windowId == testWindowId) {
+ window_tabs.push(tabs[x]);
+ if (tabs[x].active)
+ active_and_window_tabs.push(tabs[x]);
+ }
+ if (tabs[x].pinned)
+ pinned_tabs.push(tabs[x]);
+ }
+ }));
+ },
+
+ function queryHighlighted() {
+ chrome.tabs.query({highlighted:true}, pass(function(tabs) {
+ assertEq(highlighted_tabs.length, tabs.length);
+ for (var x = 0; x < tabs.length; x++)
+ assertTrue(tabs[x].highlighted);
+ }));
+ chrome.tabs.query({highlighted:false}, pass(function(tabs) {
+ assertEq(4-highlighted_tabs.length, tabs.length);
+ for (var x = 0; x < tabs.length; x++)
+ assertFalse(tabs[x].highlighted);
+ }));
+ },
+
+ function queryActive() {
+ chrome.tabs.query({active: true}, pass(function(tabs) {
+ assertEq(active_tabs.length, tabs.length);
+ for (var x = 0; x < tabs.length; x++)
+ assertTrue(tabs[x].active);
+ }));
+ chrome.tabs.query({active: false}, pass(function(tabs) {
+ assertEq(4-active_tabs.length, tabs.length);
+ for (var x = 0; x < tabs.length; x++)
+ assertFalse(tabs[x].active);
+ }));
+ },
+
+ function queryWindowID() {
+ chrome.tabs.query({windowId: testWindowId}, pass(function(tabs) {
+ assertEq(window_tabs.length, tabs.length);
+ for (var x = 0; x < tabs.length; x++)
+ assertEq(testWindowId, tabs[x].windowId);
+ }));
+ },
+
+ function queryPinned() {
+ chrome.tabs.query({pinned: true}, pass(function(tabs) {
+ assertEq(pinned_tabs.length, tabs.length);
+ for (var x = 0; x < tabs.length; x++)
+ assertTrue(tabs[x].pinned);
+ }));
+ chrome.tabs.query({pinned: false}, pass(function(tabs) {
+ assertEq(4-pinned_tabs.length, tabs.length);
+ for (var x = 0; x < tabs.length; x++)
+ assertFalse(tabs[x].pinned);
+ }));
+ },
+
+ function queryActiveAndWindowID() {
+ chrome.tabs.query({
+ active: true,
+ windowId: testWindowId
+ }, pass(function(tabs) {
+ assertEq(active_and_window_tabs.length, tabs.length);
+ for (var x = 0; x < tabs.length; x++) {
+ assertTrue(tabs[x].active);
+ assertEq(testWindowId, tabs[x].windowId);
+ }
+ }));
+ },
+
+ function queryUrl() {
+ chrome.tabs.query({url: "http://*.example.org/*"}, pass(function(tabs) {
+ assertEq(1, tabs.length);
+ assertEq("http://example.org/a.html", tabs[0].url);
+ }));
+ },
+
+ function queryStatus() {
+ chrome.tabs.query({status: "complete"}, pass(function(tabs) {
+ for (var x = 0; x < tabs.length; x++)
+ assertEq("complete", tabs[x].status);
+ }));
+ },
+
+ function queryTitle() {
+ chrome.tabs.query({title: "*query.html"}, pass(function(tabs) {
+ assertEq(1, tabs.length);
+ assertEq(chrome.extension.getURL("query.html"), tabs[0].title);
+ }));
+ },
+
+ function queryWindowType() {
+ chrome.tabs.query({windowType: "normal"}, pass(function(tabs) {
+ assertEq(4, tabs.length);
+ for (var x = 0; x < tabs.length; x++) {
+ chrome.windows.get(tabs[x].windowId, pass(function(win) {
+ assertTrue(win.type == "normal");
+ }));
+ }
+ }));
+ chrome.windows.create({
+ url: 'about:blank',
+ type: 'popup'
+ }, pass(function(win) {
+ chrome.windows.create({
+ url: 'about:blank',
+ type: 'popup'
+ }, pass(function(win) {
+ chrome.tabs.query({
+ windowId: win.id,
+ windowType: 'popup'
+ }, pass(function(tabs) {
+ assertEq(1, tabs.length);
+ }));
+ chrome.tabs.query({windowType: 'popup'}, pass(function(tabs) {
+ assertEq(2, tabs.length);
+ }));
+ chrome.tabs.query({
+ windowType: 'popup',
+ url: 'about:*'
+ }, pass(function(tabs) {
+ assertEq(2, tabs.length);
+ }));
+ }));
+ }));
+ }
+]);
+
+</script>
diff --git a/chrome/test/data/extensions/api_test/tabs/basics/tabs_util.js b/chrome/test/data/extensions/api_test/tabs/basics/tabs_util.js
index 9b1a9ba..757cd6b 100644
--- a/chrome/test/data/extensions/api_test/tabs/basics/tabs_util.js
+++ b/chrome/test/data/extensions/api_test/tabs/basics/tabs_util.js
@@ -1,9 +1,11 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var pass = chrome.test.callbackPass;
+var fail = chrome.test.callbackFail;
var assertEq = chrome.test.assertEq;
+var assertFalse = chrome.test.assertFalse;
var assertTrue = chrome.test.assertTrue;
function pageUrl(letter) {