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

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

Issue 8586045: Add extension API to change window show state using chrome.windows.update(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/profiles/profile.h" 5 #include "chrome/browser/profiles/profile.h"
6 #include "chrome/browser/extensions/extension_tab_util.h" 6 #include "chrome/browser/extensions/extension_tab_util.h"
7 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/tabs/tab_strip_model.h" 8 #include "chrome/browser/tabs/tab_strip_model.h"
9 #include "content/browser/tab_contents/tab_contents.h" 9 #include "content/browser/tab_contents/tab_contents.h"
10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 std::string ExtensionTabUtil::GetWindowTypeText(const Browser* browser) { 52 std::string ExtensionTabUtil::GetWindowTypeText(const Browser* browser) {
53 if (browser->is_type_popup()) 53 if (browser->is_type_popup())
54 return keys::kWindowTypeValuePopup; 54 return keys::kWindowTypeValuePopup;
55 if (browser->is_type_panel()) 55 if (browser->is_type_panel())
56 return keys::kWindowTypeValuePanel; 56 return keys::kWindowTypeValuePanel;
57 if (browser->is_app()) 57 if (browser->is_app())
58 return keys::kWindowTypeValueApp; 58 return keys::kWindowTypeValueApp;
59 return keys::kWindowTypeValueNormal; 59 return keys::kWindowTypeValueNormal;
60 } 60 }
61 61
62 // Return the state name for a browser window state.
63 std::string ExtensionTabUtil::GetWindowShowStateText(const Browser* browser) {
64 BrowserWindow* window = browser->window();
65 if (window->IsMinimized())
66 return keys::kShowStateValueMinimized;
67 if (window->IsMaximized() || window->IsFullscreen())
68 return keys::kShowStateValueMaximized;
69 return keys::kShowStateValueNormal;
70 }
71
62 DictionaryValue* ExtensionTabUtil::CreateTabValue( 72 DictionaryValue* ExtensionTabUtil::CreateTabValue(
63 const TabContents* contents) { 73 const TabContents* contents) {
64 // Find the tab strip and index of this guy. 74 // Find the tab strip and index of this guy.
65 TabStripModel* tab_strip = NULL; 75 TabStripModel* tab_strip = NULL;
66 int tab_index; 76 int tab_index;
67 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) 77 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index))
68 return ExtensionTabUtil::CreateTabValue(contents, tab_strip, tab_index); 78 return ExtensionTabUtil::CreateTabValue(contents, tab_strip, tab_index);
69 79
70 // Couldn't find it. This can happen if the tab is being dragged. 80 // Couldn't find it. This can happen if the tab is being dragged.
71 return ExtensionTabUtil::CreateTabValue(contents, NULL, -1); 81 return ExtensionTabUtil::CreateTabValue(contents, NULL, -1);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 if (browser->window()->IsMaximized() || browser->window()->IsFullscreen()) 149 if (browser->window()->IsMaximized() || browser->window()->IsFullscreen())
140 bounds = browser->window()->GetBounds(); 150 bounds = browser->window()->GetBounds();
141 else 151 else
142 bounds = browser->window()->GetRestoredBounds(); 152 bounds = browser->window()->GetRestoredBounds();
143 153
144 result->SetInteger(keys::kLeftKey, bounds.x()); 154 result->SetInteger(keys::kLeftKey, bounds.x());
145 result->SetInteger(keys::kTopKey, bounds.y()); 155 result->SetInteger(keys::kTopKey, bounds.y());
146 result->SetInteger(keys::kWidthKey, bounds.width()); 156 result->SetInteger(keys::kWidthKey, bounds.width());
147 result->SetInteger(keys::kHeightKey, bounds.height()); 157 result->SetInteger(keys::kHeightKey, bounds.height());
148 result->SetString(keys::kWindowTypeKey, GetWindowTypeText(browser)); 158 result->SetString(keys::kWindowTypeKey, GetWindowTypeText(browser));
159 result->SetString(keys::kShowStateKey, GetWindowShowStateText(browser));
149 160
150 if (populate_tabs) { 161 if (populate_tabs) {
151 result->Set(keys::kTabsKey, ExtensionTabUtil::CreateTabList(browser)); 162 result->Set(keys::kTabsKey, ExtensionTabUtil::CreateTabList(browser));
152 } 163 }
153 164
154 return result; 165 return result;
155 } 166 }
156 167
157 bool ExtensionTabUtil::GetTabStripModel(const TabContents* tab_contents, 168 bool ExtensionTabUtil::GetTabStripModel(const TabContents* tab_contents,
158 TabStripModel** tab_strip_model, 169 TabStripModel** tab_strip_model,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 *contents = target_contents; 231 *contents = target_contents;
221 if (tab_index) 232 if (tab_index)
222 *tab_index = i; 233 *tab_index = i;
223 return true; 234 return true;
224 } 235 }
225 } 236 }
226 } 237 }
227 } 238 }
228 return false; 239 return false;
229 } 240 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_tab_util.h ('k') | chrome/browser/extensions/extension_tabs_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698