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

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

Issue 9428018: Create BaseWindow and ExtensionWindowWrapper for extension API access to Panels (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 10 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
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"
6
5 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
6 #include "chrome/browser/extensions/extension_tab_util.h"
7 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/tabs/tab_strip_model.h" 9 #include "chrome/browser/tabs/tab_strip_model.h"
9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
10 #include "chrome/browser/ui/browser_window.h" 11 #include "chrome/browser/ui/browser_window.h"
11 #include "chrome/browser/ui/browser_list.h" 12 #include "chrome/browser/ui/browser_list.h"
12 #include "chrome/browser/sessions/restore_tab_helper.h" 13 #include "chrome/browser/sessions/restore_tab_helper.h"
13 #include "chrome/browser/extensions/extension_tabs_module_constants.h" 14 #include "chrome/browser/extensions/extension_tabs_module_constants.h"
14 #include "content/public/browser/favicon_status.h" 15 #include "content/public/browser/favicon_status.h"
15 #include "content/public/browser/navigation_entry.h" 16 #include "content/public/browser/navigation_entry.h"
16 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 141 }
141 142
142 DictionaryValue* ExtensionTabUtil::CreateTabValueActive( 143 DictionaryValue* ExtensionTabUtil::CreateTabValueActive(
143 const WebContents* contents, 144 const WebContents* contents,
144 bool active) { 145 bool active) {
145 DictionaryValue* result = ExtensionTabUtil::CreateTabValue(contents); 146 DictionaryValue* result = ExtensionTabUtil::CreateTabValue(contents);
146 result->SetBoolean(keys::kSelectedKey, active); 147 result->SetBoolean(keys::kSelectedKey, active);
147 return result; 148 return result;
148 } 149 }
149 150
150 // if |populate| is true, each window gets a list property |tabs| which contains
151 // fully populated tab objects.
152 DictionaryValue* ExtensionTabUtil::CreateWindowValue(const Browser* browser,
153 bool populate_tabs) {
154 DCHECK(browser);
155 DCHECK(browser->window());
156 DictionaryValue* result = new DictionaryValue();
157 result->SetInteger(keys::kIdKey, ExtensionTabUtil::GetWindowId(browser));
158 result->SetBoolean(keys::kIncognitoKey,
159 browser->profile()->IsOffTheRecord());
160 result->SetBoolean(keys::kFocusedKey, browser->window()->IsActive());
161 gfx::Rect bounds;
162 if (browser->window()->IsMaximized() || browser->window()->IsFullscreen())
163 bounds = browser->window()->GetBounds();
164 else
165 bounds = browser->window()->GetRestoredBounds();
166
167 result->SetInteger(keys::kLeftKey, bounds.x());
168 result->SetInteger(keys::kTopKey, bounds.y());
169 result->SetInteger(keys::kWidthKey, bounds.width());
170 result->SetInteger(keys::kHeightKey, bounds.height());
171 result->SetString(keys::kWindowTypeKey, GetWindowTypeText(browser));
172 result->SetString(keys::kShowStateKey, GetWindowShowStateText(browser));
173
174 if (populate_tabs) {
175 result->Set(keys::kTabsKey, ExtensionTabUtil::CreateTabList(browser));
176 }
177
178 return result;
179 }
180
181 bool ExtensionTabUtil::GetTabStripModel(const WebContents* web_contents, 151 bool ExtensionTabUtil::GetTabStripModel(const WebContents* web_contents,
182 TabStripModel** tab_strip_model, 152 TabStripModel** tab_strip_model,
183 int* tab_index) { 153 int* tab_index) {
184 DCHECK(web_contents); 154 DCHECK(web_contents);
185 DCHECK(tab_strip_model); 155 DCHECK(tab_strip_model);
186 DCHECK(tab_index); 156 DCHECK(tab_index);
187 157
188 for (BrowserList::const_iterator it = BrowserList::begin(); 158 for (BrowserList::const_iterator it = BrowserList::begin();
189 it != BrowserList::end(); ++it) { 159 it != BrowserList::end(); ++it) {
190 TabStripModel* tab_strip = (*it)->tabstrip_model(); 160 TabStripModel* tab_strip = (*it)->tabstrip_model();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 *contents = target_contents; 214 *contents = target_contents;
245 if (tab_index) 215 if (tab_index)
246 *tab_index = i; 216 *tab_index = i;
247 return true; 217 return true;
248 } 218 }
249 } 219 }
250 } 220 }
251 } 221 }
252 return false; 222 return false;
253 } 223 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698