@@ -733,46 +733,28 @@ ExtensionFunction::ResponseAction TabsGetSelectedFunction::Run() {
733
733
EXTENSION_FUNCTION_VALIDATE (params.get ());
734
734
735
735
736
- // LOG(INFO) << "[EXTENSIONS] TabsGetSelectedFunction::Run - Step 1";
737
736
738
737
std::unique_ptr<base::ListValue> result (new base::ListValue ());
739
- // LOG(INFO) << "[EXTENSIONS] TabsGetSelectedFunction::Run - Step 4";
740
- // Profile* profile = Profile::FromBrowserContext(browser_context());
741
- // Browser* last_active_browser =
742
- // chrome::FindAnyBrowser(profile, include_incognito());
743
- // Browser* current_browser =
744
- // ChromeExtensionFunctionDetails(this).GetCurrentBrowser();
745
- // LOG(INFO) << "[EXTENSIONS] TabsGetSelectedFunction::Run - Step 5: " << profile;
746
- // LOG(INFO) << "[EXTENSIONS] TabsGetSelectedFunction::Run - Step 5-1: " << last_active_browser;
747
- // LOG(INFO) << "[EXTENSIONS] TabsGetSelectedFunction::Run - Step 5-2: " << current_browser;
748
- // LOG(INFO) << "[EXTENSIONS] TabsGetSelectedFunction::Run - IsOffTheRecordSessionActive: " << TabModelList::IsOffTheRecordSessionActive();
749
738
TabModel *tab_strip = nullptr ;
750
739
if (!TabModelList::empty ())
751
740
tab_strip = *(TabModelList::begin ());
752
- // LOG(INFO) << "[EXTENSIONS] TabsGetSelectedFunction::Run - TabModel: " << tab_strip;
753
741
if (tab_strip) {
754
- // LOG(INFO) << "[EXTENSIONS] TabsGetSelectedFunction::Run - TabModel - Open tabs: " << tab_strip->GetTabCount();
755
- // LOG(INFO) << "[EXTENSIONS] TabsGetSelectedFunction::Run - TabModel - Active index: " << tab_strip->GetActiveIndex();
756
- // LOG(INFO) << "[EXTENSIONS] TabsGetSelectedFunction::Run - TabModel - Last user-interacted active index: " << tab_strip->GetLastNonExtensionActiveIndex();
757
742
for (int i = 0 ; i < tab_strip->GetTabCount (); ++i) {
758
743
WebContents* web_contents = tab_strip->GetWebContentsAt (i);
759
- // LOG(INFO) << "[EXTENSIONS] TabsGetSelectedFunction::Run - Step 5d-1 (tab loop)";
760
744
761
745
int openingTab = (tab_strip->GetLastNonExtensionActiveIndex ());
746
+ if (extension () && extension ()->id () == " mooikfkahbdckldjjndioackbalphokd" )
747
+ openingTab = (tab_strip->GetActiveIndex ());
762
748
if (openingTab == -1 )
763
749
openingTab = 0 ;
764
750
765
751
if (i != openingTab)
766
752
continue ;
767
753
768
754
if (!web_contents) {
769
- // LOG(INFO) << "[EXTENSIONS] TabsGetSelectedFunction::Run - Step 5d-1b (there is no webcontents)";
770
755
continue ;
771
756
}
772
757
773
- // LOG(INFO) << "[EXTENSIONS] TabsGetSelectedFunction::Run - Step 5d-2";
774
-
775
- // LOG(INFO) << "[EXTENSIONS] TabsGetSelectedFunction::Run - Step 5d-5";
776
758
777
759
return RespondNow (ArgumentList (
778
760
tabs::Get::Results::Create (*ExtensionTabUtil::CreateTabObject (
@@ -837,13 +819,10 @@ ExtensionFunction::ResponseAction TabsQueryFunction::Run() {
837
819
tabs::Query::Params::Create (*args_));
838
820
EXTENSION_FUNCTION_VALIDATE (params.get ());
839
821
840
- // LOG(INFO) << "[EXTENSIONS] TabsQueryFunction::Run - Step 1";
841
-
842
822
bool loading_status_set = params->query_info .status != tabs::TAB_STATUS_NONE;
843
823
bool loading = params->query_info .status == tabs::TAB_STATUS_LOADING;
844
824
845
825
URLPatternSet url_patterns;
846
- // LOG(INFO) << "[EXTENSIONS] TabsQueryFunction::Run - Step 2";
847
826
if (params->query_info .url .get ()) {
848
827
std::vector<std::string> url_pattern_strings;
849
828
if (params->query_info .url ->as_string )
@@ -879,40 +858,44 @@ ExtensionFunction::ResponseAction TabsQueryFunction::Run() {
879
858
window_type = tabs::ToString (params->query_info .window_type );
880
859
881
860
std::unique_ptr<base::ListValue> result (new base::ListValue ());
882
- // LOG(INFO) << "[EXTENSIONS] TabsQueryFunction::Run - Step 4";
883
- // Profile* profile = Profile::FromBrowserContext(browser_context());
884
- // Browser* last_active_browser =
885
- // chrome::FindAnyBrowser(profile, include_incognito());
886
- // Browser* current_browser =
887
- // ChromeExtensionFunctionDetails(this).GetCurrentBrowser();
888
- // LOG(INFO) << "[EXTENSIONS] TabsQueryFunction::Run - Step 5: " << profile;
889
- // LOG(INFO) << "[EXTENSIONS] TabsQueryFunction::Run - Step 5-1: " << last_active_browser;
890
- // LOG(INFO) << "[EXTENSIONS] TabsQueryFunction::Run - Step 5-2: " << current_browser;
891
- // LOG(INFO) << "[EXTENSIONS] TabsQueryFunction::Run - IsOffTheRecordSessionActive: " << TabModelList::IsOffTheRecordSessionActive();
892
861
TabModel *tab_strip = nullptr ;
893
862
if (!TabModelList::empty ())
894
863
tab_strip = *(TabModelList::begin ());
895
- // LOG(INFO) << "[EXTENSIONS] TabsQueryFunction::Run - TabModel: " << tab_strip;
896
864
if (tab_strip) {
897
- // LOG(INFO) << "[EXTENSIONS] TabsQueryFunction::Run - TabModel - Open tabs: " << tab_strip->GetTabCount();
898
- // LOG(INFO) << "[EXTENSIONS] TabsQueryFunction::Run - TabModel - Active index: " << tab_strip->GetActiveIndex();
899
- // LOG(INFO) << "[EXTENSIONS] TabsQueryFunction::Run - TabModel - Last user-interacted active index: " << tab_strip->GetLastNonExtensionActiveIndex();
900
865
for (int i = 0 ; i < tab_strip->GetTabCount (); ++i) {
901
866
WebContents* web_contents = tab_strip->GetWebContentsAt (i);
902
- // LOG(INFO) << "[EXTENSIONS] TabsQueryFunction::Run - Step 5d-1 (tab loop)";
903
867
904
868
if (index > -1 && i != index ) {
905
- // LOG(INFO) << "[EXTENSIONS] TabsQueryFunction::Run - Step 5d-1a (oob-index): " << i << " vs " << index;
906
869
continue ;
907
870
}
908
871
909
872
int openingTab = (tab_strip->GetLastNonExtensionActiveIndex ());
910
- if (openingTab == -1 )
873
+ // To Selenium IDE we show the current active window even if it's an extension window
874
+ // when they try to access a specific window because it means
875
+ // that it Selenium is looking for its own IDE
876
+ if (extension () && extension ()->id () == " mooikfkahbdckldjjndioackbalphokd" )
877
+ openingTab = (tab_strip->GetActiveIndex ());
878
+ if (openingTab == -1 )
911
879
openingTab = 0 ;
912
880
913
- if (!MatchesBool (params->query_info .active .get (),
914
- i == openingTab)) {
915
- continue ;
881
+ // For Selenium IDE we do not check the active flag
882
+ if (extension () && extension ()->id () != " mooikfkahbdckldjjndioackbalphokd" ) {
883
+ if (!MatchesBool (params->query_info .active .get (),
884
+ i == openingTab)) {
885
+ continue ;
886
+ }
887
+ }
888
+ // except if there is status == complete
889
+ if (extension () && extension ()->id () == " mooikfkahbdckldjjndioackbalphokd" && params->query_info .status == tabs::TAB_STATUS_COMPLETE) {
890
+ if (!MatchesBool (params->query_info .active .get (),
891
+ i == openingTab)) {
892
+ continue ;
893
+ }
894
+ }
895
+
896
+ if (extension () && extension ()->id () == " mooikfkahbdckldjjndioackbalphokd" ) {
897
+ if (window_id >= 0 && window_id != SessionTabHelper::IdForTab (web_contents).id ())
898
+ continue ;
916
899
}
917
900
918
901
if (!web_contents) {
@@ -1154,6 +1137,8 @@ bool TabsUpdateFunction::RunAsync() {
1154
1137
if (tab_strip) {
1155
1138
for (int i = 0 ; i < tab_strip->GetTabCount (); ++i) {
1156
1139
int openingTab = (tab_strip->GetLastNonExtensionActiveIndex ());
1140
+ if (extension () && extension ()->id () == " mooikfkahbdckldjjndioackbalphokd" )
1141
+ openingTab = (tab_strip->GetActiveIndex ());
1157
1142
if (openingTab == -1 )
1158
1143
openingTab = 0 ;
1159
1144
@@ -1782,7 +1767,6 @@ bool ExecuteCodeInTabFunction::HasPermission() {
1782
1767
}
1783
1768
1784
1769
ExecuteCodeFunction::InitResult ExecuteCodeInTabFunction::Init () {
1785
- LOG (INFO) << " [EXTENSIONS] ExecuteCodeInTabFunction::Init - Step 1" ;
1786
1770
if (init_result_)
1787
1771
return init_result_.value ();
1788
1772
@@ -1799,24 +1783,19 @@ ExecuteCodeFunction::InitResult ExecuteCodeInTabFunction::Init() {
1799
1783
if (!InjectDetails::Populate (*details_value, details.get ()))
1800
1784
return set_init_result (VALIDATION_FAILURE);
1801
1785
1802
- LOG (INFO) << " [EXTENSIONS] ExecuteCodeInTabFunction::Init - Step 2" ;
1803
1786
// If the tab ID wasn't given then it needs to be converted to the
1804
1787
// currently active tab's ID.
1805
1788
if (tab_id == -1 ) {
1806
- LOG (INFO) << " [EXTENSIONS] ExecuteCodeInTabFunction::Init - Step 2a" ;
1807
1789
TabModel *tab_strip = nullptr ;
1808
1790
if (!TabModelList::empty ())
1809
1791
tab_strip = *(TabModelList::begin ());
1810
- LOG (INFO) << " [EXTENSIONS] ExecuteCodeInTabFunction::Init - TabModel: " << tab_strip;
1811
1792
if (tab_strip) {
1812
- LOG (INFO) << " [EXTENSIONS] ExecuteCodeInTabFunction::Init - TabModel - Open tabs: " << tab_strip->GetTabCount ();
1813
- LOG (INFO) << " [EXTENSIONS] ExecuteCodeInTabFunction::Init - TabModel - Active index: " << tab_strip->GetActiveIndex ();
1814
- LOG (INFO) << " [EXTENSIONS] ExecuteCodeInTabFunction::Init - TabModel - Last user-interacted active index: " << tab_strip->GetLastNonExtensionActiveIndex ();
1815
1793
for (int i = 0 ; i < tab_strip->GetTabCount (); ++i) {
1816
1794
WebContents* web_contents = tab_strip->GetWebContentsAt (i);
1817
- LOG (INFO) << " [EXTENSIONS] ExecuteCodeInTabFunction::Init - Step 2aa-1 (tab loop)" ;
1818
1795
1819
1796
int openingTab = (tab_strip->GetLastNonExtensionActiveIndex ());
1797
+ if (extension () && extension ()->id () == " mooikfkahbdckldjjndioackbalphokd" )
1798
+ openingTab = (tab_strip->GetActiveIndex ());
1820
1799
if (openingTab == -1 )
1821
1800
openingTab = 0 ;
1822
1801
@@ -1825,19 +1804,15 @@ ExecuteCodeFunction::InitResult ExecuteCodeInTabFunction::Init() {
1825
1804
1826
1805
if (web_contents && ExtensionTabUtil::GetTabId (web_contents) >= 0 ) {
1827
1806
tab_id = ExtensionTabUtil::GetTabId (web_contents);
1828
- LOG (INFO) << " [EXTENSIONS] ExecuteCodeInTabFunction::Init - Step 2a (found) with id: " << tab_id;
1829
1807
break ;
1830
1808
}
1831
1809
}
1832
1810
}
1833
1811
}
1834
1812
if (tab_id == -1 ) {
1835
- LOG (INFO) << " [EXTENSIONS] ExecuteCodeInTabFunction::Init - Step 2b" ;
1836
1813
return set_init_result_error (keys::kNoCurrentWindowError );
1837
1814
}
1838
1815
1839
- LOG (INFO) << " [EXTENSIONS] ExecuteCodeInTabFunction::Init - Step 3" ;
1840
-
1841
1816
execute_tab_id_ = tab_id;
1842
1817
details_ = std::move (details);
1843
1818
set_host_id (HostID (HostID::EXTENSIONS, extension ()->id ()));
0 commit comments