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

Side by Side Diff: chrome/browser/extensions/extension_tabs_module.cc

Issue 9162002: Query the current window with chrome.tabs.query using -1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/common/extensions/api/tabs.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/extension_tabs_module.h" 5 #include "chrome/browser/extensions/extension_tabs_module.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 std::string value; 775 std::string value;
776 EXTENSION_FUNCTION_VALIDATE(query->GetString(keys::kUrlKey, &value)); 776 EXTENSION_FUNCTION_VALIDATE(query->GetString(keys::kUrlKey, &value));
777 url_pattern = URLPattern(URLPattern::SCHEME_ALL, value); 777 url_pattern = URLPattern(URLPattern::SCHEME_ALL, value);
778 } 778 }
779 779
780 std::string title; 780 std::string title;
781 if (query->HasKey(keys::kTitleKey)) 781 if (query->HasKey(keys::kTitleKey))
782 EXTENSION_FUNCTION_VALIDATE( 782 EXTENSION_FUNCTION_VALIDATE(
783 query->GetString(keys::kTitleKey, &title)); 783 query->GetString(keys::kTitleKey, &title));
784 784
785 int window_id = -1; 785 int window_id = extension_misc::kUnknownWindowId;
786 if (query->HasKey(keys::kWindowIdKey)) 786 if (query->HasKey(keys::kWindowIdKey))
787 EXTENSION_FUNCTION_VALIDATE( 787 EXTENSION_FUNCTION_VALIDATE(
788 query->GetInteger(keys::kWindowIdKey, &window_id)); 788 query->GetInteger(keys::kWindowIdKey, &window_id));
789 789
790 std::string window_type; 790 std::string window_type;
791 if (query->HasKey(keys::kWindowTypeLongKey)) 791 if (query->HasKey(keys::kWindowTypeLongKey))
792 EXTENSION_FUNCTION_VALIDATE( 792 EXTENSION_FUNCTION_VALIDATE(
793 query->GetString(keys::kWindowTypeLongKey, &window_type)); 793 query->GetString(keys::kWindowTypeLongKey, &window_type));
794 794
795 ListValue* result = new ListValue(); 795 ListValue* result = new ListValue();
796 for (BrowserList::const_iterator browser = BrowserList::begin(); 796 for (BrowserList::const_iterator browser = BrowserList::begin();
797 browser != BrowserList::end(); ++browser) { 797 browser != BrowserList::end(); ++browser) {
798 if (!profile()->IsSameProfile((*browser)->profile())) 798 if (!profile()->IsSameProfile((*browser)->profile()))
799 continue; 799 continue;
800 800
801 if (!(*browser)->window()) 801 if (!(*browser)->window())
802 continue; 802 continue;
803 803
804 if (window_id >= 0 && window_id != ExtensionTabUtil::GetWindowId(*browser)) 804 if (window_id >= 0 && window_id != ExtensionTabUtil::GetWindowId(*browser))
805 continue; 805 continue;
806 806
807 if (window_id == extension_misc::kCurrentWindowId &&
808 *browser != GetCurrentBrowser())
809 continue;
810
807 if (!window_type.empty() && 811 if (!window_type.empty() &&
808 window_type != ExtensionTabUtil::GetWindowTypeText(*browser)) 812 window_type != ExtensionTabUtil::GetWindowTypeText(*browser))
809 continue; 813 continue;
810 814
811 TabStripModel* tab_strip = (*browser)->tabstrip_model(); 815 TabStripModel* tab_strip = (*browser)->tabstrip_model();
812 for (int i = 0; i < tab_strip->count(); ++i) { 816 for (int i = 0; i < tab_strip->count(); ++i) {
813 const WebContents* web_contents = 817 const WebContents* web_contents =
814 tab_strip->GetTabContentsAt(i)->web_contents(); 818 tab_strip->GetTabContentsAt(i)->web_contents();
815 819
816 if (!MatchesQueryArg(selected, tab_strip->IsTabSelected(i))) 820 if (!MatchesQueryArg(selected, tab_strip->IsTabSelected(i)))
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 // called for every API call the extension made. 1666 // called for every API call the extension made.
1663 GotLanguage(language); 1667 GotLanguage(language);
1664 } 1668 }
1665 1669
1666 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { 1670 void DetectTabLanguageFunction::GotLanguage(const std::string& language) {
1667 result_.reset(Value::CreateStringValue(language.c_str())); 1671 result_.reset(Value::CreateStringValue(language.c_str()));
1668 SendResponse(true); 1672 SendResponse(true);
1669 1673
1670 Release(); // Balanced in Run() 1674 Release(); // Balanced in Run()
1671 } 1675 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/api/tabs.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698