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

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

Issue 11308012: Remove some TabContentses from extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 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_tab_util.h" 5 #include "chrome/browser/extensions/extension_tab_util.h"
6 6
7 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 7 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
8 #include "chrome/browser/extensions/tab_helper.h" 8 #include "chrome/browser/extensions/tab_helper.h"
9 #include "chrome/browser/extensions/window_controller.h" 9 #include "chrome/browser/extensions/window_controller.h"
10 #include "chrome/browser/net/url_fixer_upper.h" 10 #include "chrome/browser/net/url_fixer_upper.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 has_permission ? INCLUDE_PRIVACY_SENSITIVE_FIELDS : 74 has_permission ? INCLUDE_PRIVACY_SENSITIVE_FIELDS :
75 OMIT_PRIVACY_SENSITIVE_FIELDS); 75 OMIT_PRIVACY_SENSITIVE_FIELDS);
76 } 76 }
77 77
78 ListValue* ExtensionTabUtil::CreateTabList( 78 ListValue* ExtensionTabUtil::CreateTabList(
79 const Browser* browser, 79 const Browser* browser,
80 const Extension* extension) { 80 const Extension* extension) {
81 ListValue* tab_list = new ListValue(); 81 ListValue* tab_list = new ListValue();
82 TabStripModel* tab_strip = browser->tab_strip_model(); 82 TabStripModel* tab_strip = browser->tab_strip_model();
83 for (int i = 0; i < tab_strip->count(); ++i) { 83 for (int i = 0; i < tab_strip->count(); ++i) {
84 tab_list->Append(CreateTabValue( 84 tab_list->Append(CreateTabValue(tab_strip->GetWebContentsAt(i),
85 tab_strip->GetTabContentsAt(i)->web_contents(), 85 tab_strip,
86 tab_strip, 86 i,
87 i, 87 extension));
88 extension));
89 } 88 }
90 89
91 return tab_list; 90 return tab_list;
92 } 91 }
93 92
94 DictionaryValue* ExtensionTabUtil::CreateTabValue( 93 DictionaryValue* ExtensionTabUtil::CreateTabValue(
95 const WebContents* contents, 94 const WebContents* contents,
96 TabStripModel* tab_strip, 95 TabStripModel* tab_strip,
97 int tab_index, 96 int tab_index,
98 IncludePrivacySensitiveFields include_privacy_sensitive_fields) { 97 IncludePrivacySensitiveFields include_privacy_sensitive_fields) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 *tab_strip_model = tab_strip; 149 *tab_strip_model = tab_strip;
151 *tab_index = index; 150 *tab_index = index;
152 return true; 151 return true;
153 } 152 }
154 } 153 }
155 154
156 return false; 155 return false;
157 } 156 }
158 157
159 bool ExtensionTabUtil::GetDefaultTab(Browser* browser, 158 bool ExtensionTabUtil::GetDefaultTab(Browser* browser,
160 TabContents** contents, 159 WebContents** contents,
161 int* tab_id) { 160 int* tab_id) {
162 DCHECK(browser); 161 DCHECK(browser);
163 DCHECK(contents); 162 DCHECK(contents);
164 163
165 *contents = chrome::GetActiveTabContents(browser); 164 *contents = chrome::GetActiveWebContents(browser);
166 if (*contents) { 165 if (*contents) {
167 if (tab_id) 166 if (tab_id)
168 *tab_id = GetTabId((*contents)->web_contents()); 167 *tab_id = GetTabId(*contents);
169 return true; 168 return true;
170 } 169 }
171 170
172 return false; 171 return false;
173 } 172 }
174 173
175 bool ExtensionTabUtil::GetTabById(int tab_id, 174 bool ExtensionTabUtil::GetTabById(int tab_id,
176 Profile* profile, 175 Profile* profile,
177 bool include_incognito, 176 bool include_incognito,
178 Browser** browser, 177 Browser** browser,
179 TabStripModel** tab_strip, 178 TabStripModel** tab_strip,
180 TabContents** contents, 179 WebContents** contents,
181 int* tab_index) { 180 int* tab_index) {
182 Profile* incognito_profile = 181 Profile* incognito_profile =
183 include_incognito && profile->HasOffTheRecordProfile() ? 182 include_incognito && profile->HasOffTheRecordProfile() ?
184 profile->GetOffTheRecordProfile() : NULL; 183 profile->GetOffTheRecordProfile() : NULL;
185 for (BrowserList::const_iterator iter = BrowserList::begin(); 184 for (BrowserList::const_iterator iter = BrowserList::begin();
186 iter != BrowserList::end(); ++iter) { 185 iter != BrowserList::end(); ++iter) {
187 Browser* target_browser = *iter; 186 Browser* target_browser = *iter;
188 if (target_browser->profile() == profile || 187 if (target_browser->profile() == profile ||
189 target_browser->profile() == incognito_profile) { 188 target_browser->profile() == incognito_profile) {
190 TabStripModel* target_tab_strip = target_browser->tab_strip_model(); 189 TabStripModel* target_tab_strip = target_browser->tab_strip_model();
191 for (int i = 0; i < target_tab_strip->count(); ++i) { 190 for (int i = 0; i < target_tab_strip->count(); ++i) {
192 TabContents* target_contents = target_tab_strip->GetTabContentsAt(i); 191 WebContents* target_contents = target_tab_strip->GetWebContentsAt(i);
193 if (SessionID::IdForTab(target_contents->web_contents()) == tab_id) { 192 if (SessionID::IdForTab(target_contents) == tab_id) {
194 if (browser) 193 if (browser)
195 *browser = target_browser; 194 *browser = target_browser;
196 if (tab_strip) 195 if (tab_strip)
197 *tab_strip = target_tab_strip; 196 *tab_strip = target_tab_strip;
198 if (contents) 197 if (contents)
199 *contents = target_contents; 198 *contents = target_contents;
200 if (tab_index) 199 if (tab_index)
201 *tab_index = i; 200 *tab_index = i;
202 return true; 201 return true;
203 } 202 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 267
269 // static 268 // static
270 extensions::WindowController* ExtensionTabUtil::GetWindowControllerOfTab( 269 extensions::WindowController* ExtensionTabUtil::GetWindowControllerOfTab(
271 const WebContents* web_contents) { 270 const WebContents* web_contents) {
272 Browser* browser = browser::FindBrowserWithWebContents(web_contents); 271 Browser* browser = browser::FindBrowserWithWebContents(web_contents);
273 if (browser != NULL) 272 if (browser != NULL)
274 return browser->extension_window_controller(); 273 return browser->extension_window_controller();
275 274
276 return NULL; 275 return NULL;
277 } 276 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_tab_util.h ('k') | chrome/browser/extensions/extension_tab_util_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698