OLD | NEW |
---|---|
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/api/tabs/tabs_api.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 return ui::SHOW_STATE_MAXIMIZED; | 191 return ui::SHOW_STATE_MAXIMIZED; |
192 case windows::WINDOW_STATE_FULLSCREEN: | 192 case windows::WINDOW_STATE_FULLSCREEN: |
193 return ui::SHOW_STATE_FULLSCREEN; | 193 return ui::SHOW_STATE_FULLSCREEN; |
194 case windows::WINDOW_STATE_NONE: | 194 case windows::WINDOW_STATE_NONE: |
195 return ui::SHOW_STATE_DEFAULT; | 195 return ui::SHOW_STATE_DEFAULT; |
196 } | 196 } |
197 NOTREACHED(); | 197 NOTREACHED(); |
198 return ui::SHOW_STATE_DEFAULT; | 198 return ui::SHOW_STATE_DEFAULT; |
199 } | 199 } |
200 | 200 |
201 bool IsValidStateForWindowsCreateFunction( | |
202 const windows::Create::Params::CreateData* create_data) { | |
203 if (!create_data) | |
204 return true; | |
205 | |
206 bool focused = create_data->focused && *create_data->focused; | |
207 bool has_bound = create_data->left || create_data->top || | |
208 create_data->width || create_data->height; | |
209 bool is_panel = | |
210 create_data->type == windows::CreateType::CREATE_TYPE_PANEL || | |
211 create_data->type == windows::CreateType::CREATE_TYPE_DETACHED_PANEL; | |
212 | |
213 switch (create_data->state) { | |
214 case windows::WINDOW_STATE_MINIMIZED: | |
215 return !focused && !has_bound && !is_panel; | |
216 case windows::WINDOW_STATE_MAXIMIZED: | |
217 case windows::WINDOW_STATE_FULLSCREEN: | |
218 // If 'focused' is not set, then treat it as focused true. | |
not at google - send to devlin
2015/04/22 17:46:32
So is focused default true, or default false? or d
limasdf
2015/04/23 14:45:32
It depends on initial state. if |focused| is (!cr
not at google - send to devlin
2015/04/23 20:58:52
ah :) in that case having a |focused| variable is
limasdf
2015/04/23 23:51:41
Done.
| |
219 return (create_data->focused ? focused : true) && !has_bound && !is_panel; | |
220 case windows::WINDOW_STATE_NORMAL: | |
221 case windows::WINDOW_STATE_NONE: | |
222 return true; | |
223 } | |
224 NOTREACHED(); | |
225 return true; | |
226 } | |
227 | |
201 } // namespace | 228 } // namespace |
202 | 229 |
203 void ZoomModeToZoomSettings(ZoomController::ZoomMode zoom_mode, | 230 void ZoomModeToZoomSettings(ZoomController::ZoomMode zoom_mode, |
204 api::tabs::ZoomSettings* zoom_settings) { | 231 api::tabs::ZoomSettings* zoom_settings) { |
205 DCHECK(zoom_settings); | 232 DCHECK(zoom_settings); |
206 switch (zoom_mode) { | 233 switch (zoom_mode) { |
207 case ZoomController::ZOOM_MODE_DEFAULT: | 234 case ZoomController::ZOOM_MODE_DEFAULT: |
208 zoom_settings->mode = api::tabs::ZOOM_SETTINGS_MODE_AUTOMATIC; | 235 zoom_settings->mode = api::tabs::ZOOM_SETTINGS_MODE_AUTOMATIC; |
209 zoom_settings->scope = api::tabs::ZOOM_SETTINGS_SCOPE_PER_ORIGIN; | 236 zoom_settings->scope = api::tabs::ZOOM_SETTINGS_SCOPE_PER_ORIGIN; |
210 break; | 237 break; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 GetProfile(), | 441 GetProfile(), |
415 include_incognito(), | 442 include_incognito(), |
416 NULL, | 443 NULL, |
417 &source_tab_strip, | 444 &source_tab_strip, |
418 NULL, | 445 NULL, |
419 &tab_index, | 446 &tab_index, |
420 &error_)) | 447 &error_)) |
421 return false; | 448 return false; |
422 } | 449 } |
423 | 450 |
451 if (!IsValidStateForWindowsCreateFunction(create_data)) { | |
452 error_ = keys::kInvalidWindowStateError; | |
453 return false; | |
454 } | |
455 | |
424 Profile* window_profile = GetProfile(); | 456 Profile* window_profile = GetProfile(); |
425 Browser::Type window_type = Browser::TYPE_TABBED; | 457 Browser::Type window_type = Browser::TYPE_TABBED; |
426 bool create_panel = false; | 458 bool create_panel = false; |
427 | 459 |
428 // panel_create_mode only applies if create_panel = true | 460 // panel_create_mode only applies if create_panel = true |
429 PanelManager::CreateMode panel_create_mode = PanelManager::CREATE_AS_DOCKED; | 461 PanelManager::CreateMode panel_create_mode = PanelManager::CREATE_AS_DOCKED; |
430 | 462 |
431 gfx::Rect window_bounds; | 463 gfx::Rect window_bounds; |
432 bool focused = true; | 464 bool focused = true; |
433 bool saw_focus_key = false; | 465 bool saw_focus_key = false; |
(...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1971 ZoomModeToZoomSettings(zoom_mode, &zoom_settings); | 2003 ZoomModeToZoomSettings(zoom_mode, &zoom_settings); |
1972 zoom_settings.default_zoom_factor.reset(new double( | 2004 zoom_settings.default_zoom_factor.reset(new double( |
1973 content::ZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel()))); | 2005 content::ZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel()))); |
1974 | 2006 |
1975 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); | 2007 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); |
1976 SendResponse(true); | 2008 SendResponse(true); |
1977 return true; | 2009 return true; |
1978 } | 2010 } |
1979 | 2011 |
1980 } // namespace extensions | 2012 } // namespace extensions |
OLD | NEW |