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

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: Rebase Created 8 years, 9 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 143 }
143 144
144 DictionaryValue* ExtensionTabUtil::CreateTabValueActive( 145 DictionaryValue* ExtensionTabUtil::CreateTabValueActive(
145 const WebContents* contents, 146 const WebContents* contents,
146 bool active) { 147 bool active) {
147 DictionaryValue* result = ExtensionTabUtil::CreateTabValue(contents); 148 DictionaryValue* result = ExtensionTabUtil::CreateTabValue(contents);
148 result->SetBoolean(keys::kSelectedKey, active); 149 result->SetBoolean(keys::kSelectedKey, active);
149 return result; 150 return result;
150 } 151 }
151 152
152 // if |populate| is true, each window gets a list property |tabs| which contains
153 // fully populated tab objects.
154 DictionaryValue* ExtensionTabUtil::CreateWindowValue(const Browser* browser,
155 bool populate_tabs) {
156 DCHECK(browser);
157 DCHECK(browser->window());
158 DictionaryValue* result = new DictionaryValue();
159 result->SetInteger(keys::kIdKey, ExtensionTabUtil::GetWindowId(browser));
160 result->SetBoolean(keys::kIncognitoKey,
161 browser->profile()->IsOffTheRecord());
162 result->SetBoolean(keys::kFocusedKey, browser->window()->IsActive());
163 gfx::Rect bounds;
164 if (browser->window()->IsMaximized() || browser->window()->IsFullscreen())
165 bounds = browser->window()->GetBounds();
166 else
167 bounds = browser->window()->GetRestoredBounds();
168
169 result->SetInteger(keys::kLeftKey, bounds.x());
170 result->SetInteger(keys::kTopKey, bounds.y());
171 result->SetInteger(keys::kWidthKey, bounds.width());
172 result->SetInteger(keys::kHeightKey, bounds.height());
173 result->SetString(keys::kWindowTypeKey, GetWindowTypeText(browser));
174 result->SetString(keys::kShowStateKey, GetWindowShowStateText(browser));
175
176 if (populate_tabs) {
177 result->Set(keys::kTabsKey, ExtensionTabUtil::CreateTabList(browser));
178 }
179
180 return result;
181 }
182
183 bool ExtensionTabUtil::GetTabStripModel(const WebContents* web_contents, 153 bool ExtensionTabUtil::GetTabStripModel(const WebContents* web_contents,
184 TabStripModel** tab_strip_model, 154 TabStripModel** tab_strip_model,
185 int* tab_index) { 155 int* tab_index) {
186 DCHECK(web_contents); 156 DCHECK(web_contents);
187 DCHECK(tab_strip_model); 157 DCHECK(tab_strip_model);
188 DCHECK(tab_index); 158 DCHECK(tab_index);
189 159
190 for (BrowserList::const_iterator it = BrowserList::begin(); 160 for (BrowserList::const_iterator it = BrowserList::begin();
191 it != BrowserList::end(); ++it) { 161 it != BrowserList::end(); ++it) {
192 TabStripModel* tab_strip = (*it)->tabstrip_model(); 162 TabStripModel* tab_strip = (*it)->tabstrip_model();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 *contents = target_contents; 216 *contents = target_contents;
247 if (tab_index) 217 if (tab_index)
248 *tab_index = i; 218 *tab_index = i;
249 return true; 219 return true;
250 } 220 }
251 } 221 }
252 } 222 }
253 } 223 }
254 return false; 224 return false;
255 } 225 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_tab_util.h ('k') | chrome/browser/extensions/extension_tabs_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698