Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 5578722

Browse files
authored
Add additional exceptions from Selenium IDE extension
1 parent df3bd52 commit 5578722

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

chrome/browser/extensions/extension_tab_util.cc

+32-2
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,11 @@ std::unique_ptr<api::tabs::Tab> ExtensionTabUtil::CreateTabObject(
426426
// LOG(INFO) << "[EXTENSIONS] ExtensionTabUtil::CreateTabObject - Step 2" << contents;
427427
tab_object->id = std::make_unique<int>(GetTabIdForExtensions(contents));
428428
tab_object->index = tab_index;
429-
tab_object->window_id = GetWindowIdOfTab(contents);
429+
if (extension && extension->id() == "mooikfkahbdckldjjndioackbalphokd") {
430+
tab_object->window_id = SessionTabHelper::IdForTab(contents).id();
431+
} else {
432+
tab_object->window_id = GetWindowIdOfTab(contents);
433+
}
430434
tab_object->status =
431435
std::make_unique<std::string>(GetTabStatusText(is_loading));
432436
tab_object->active = false;
@@ -436,6 +440,8 @@ std::unique_ptr<api::tabs::Tab> ExtensionTabUtil::CreateTabObject(
436440
tab_strip_android = *(TabModelList::begin());
437441
if (tab_strip_android) {
438442
int openingTab = (tab_strip_android->GetLastNonExtensionActiveIndex());
443+
if (extension && extension->id() == "mooikfkahbdckldjjndioackbalphokd")
444+
openingTab = (tab_strip_android->GetActiveIndex());
439445
if (openingTab == -1)
440446
openingTab = 0;
441447
if (tab_index == openingTab) {
@@ -444,6 +450,8 @@ std::unique_ptr<api::tabs::Tab> ExtensionTabUtil::CreateTabObject(
444450
// LOG(INFO) << "[EXTENSIONS] ExtensionTabUtil::CreateTabObject - Step 4";
445451
for (int i = 0; i < tab_strip_android->GetTabCount(); ++i) {
446452
int openingTab = (tab_strip_android->GetLastNonExtensionActiveIndex());
453+
if (extension && extension->id() == "mooikfkahbdckldjjndioackbalphokd")
454+
openingTab = (tab_strip_android->GetActiveIndex());
447455
if (openingTab == -1)
448456
openingTab = 0;
449457

@@ -532,7 +540,6 @@ ExtensionTabUtil::CreateWindowValueForExtension(
532540
auto result = std::make_unique<base::DictionaryValue>();
533541

534542
// LOG(INFO) << "[EXTENSIONS] Preparing data in CreateWindowValueForExtension - Step 1";
535-
result->SetInteger(keys::kIdKey, browser.session_id().id());
536543
result->SetString(keys::kWindowTypeKey, GetBrowserWindowTypeText(browser));
537544
ui::BaseWindow* window = browser.window();
538545
result->SetBoolean(keys::kFocusedKey, window->IsActive());
@@ -566,6 +573,29 @@ ExtensionTabUtil::CreateWindowValueForExtension(
566573
result->Set(keys::kTabsKey, CreateTabList(&browser, extension));
567574
// LOG(INFO) << "[EXTENSIONS] Preparing data in CreateWindowValueForExtension - Step 2";
568575

576+
if (extension && extension->id() == "mooikfkahbdckldjjndioackbalphokd") {
577+
int activeTab = browser.session_id().id();
578+
TabModel *tab_strip = nullptr;
579+
if (!TabModelList::empty())
580+
tab_strip = *(TabModelList::begin());
581+
if (tab_strip) {
582+
for (int i = 0; i < tab_strip->GetTabCount(); ++i) {
583+
WebContents* web_contents = tab_strip->GetWebContentsAt(i);
584+
int openingTab = (tab_strip->GetLastNonExtensionActiveIndex());
585+
if (extension && extension->id() == "mooikfkahbdckldjjndioackbalphokd")
586+
openingTab = (tab_strip->GetActiveIndex());
587+
if (openingTab == -1)
588+
openingTab = 0;
589+
if (i != openingTab)
590+
continue;
591+
activeTab = SessionTabHelper::IdForTab(web_contents).id();
592+
}
593+
}
594+
result->SetInteger(keys::kIdKey, activeTab);
595+
}
596+
else
597+
result->SetInteger(keys::kIdKey, browser.session_id().id());
598+
569599
return result;
570600
}
571601

0 commit comments

Comments
 (0)