Chromium Code Reviews| 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 windows::WindowState state = create_data->state; | |
| 207 if (create_data->focused) { | |
| 208 if (*create_data->focused) { | |
| 209 if (state == windows::WINDOW_STATE_MINIMIZED) { | |
| 210 return false; | |
| 211 } | |
| 212 } else { | |
| 213 if ((state == windows::WINDOW_STATE_MAXIMIZED || | |
| 214 state == windows::WINDOW_STATE_FULLSCREEN)) { | |
| 215 return false; | |
| 216 } | |
| 217 } | |
| 218 } | |
|
not at google - send to devlin
2015/04/20 16:32:55
Let's try to make this as compact as possible, it'
limasdf
2015/04/22 15:49:33
Great idea. Done.
| |
| 219 bool has_bound = create_data->left || create_data->top || | |
| 220 create_data->width || create_data->height; | |
| 221 if (has_bound && (state == windows::WINDOW_STATE_MINIMIZED || | |
| 222 state == windows::WINDOW_STATE_MAXIMIZED || | |
| 223 state == windows::WINDOW_STATE_FULLSCREEN)) { | |
| 224 return false; | |
| 225 } | |
| 226 bool is_panel = | |
| 227 create_data->type == windows::CreateType::CREATE_TYPE_PANEL || | |
| 228 create_data->type == windows::CreateType::CREATE_TYPE_DETACHED_PANEL; | |
| 229 if (is_panel && (state == windows::WINDOW_STATE_MINIMIZED || | |
| 230 state == windows::WINDOW_STATE_MAXIMIZED || | |
| 231 state == windows::WINDOW_STATE_FULLSCREEN)) { | |
| 232 return false; | |
| 233 } | |
| 234 return true; | |
| 235 } | |
| 236 | |
| 201 } // namespace | 237 } // namespace |
| 202 | 238 |
| 203 void ZoomModeToZoomSettings(ZoomController::ZoomMode zoom_mode, | 239 void ZoomModeToZoomSettings(ZoomController::ZoomMode zoom_mode, |
| 204 api::tabs::ZoomSettings* zoom_settings) { | 240 api::tabs::ZoomSettings* zoom_settings) { |
| 205 DCHECK(zoom_settings); | 241 DCHECK(zoom_settings); |
| 206 switch (zoom_mode) { | 242 switch (zoom_mode) { |
| 207 case ZoomController::ZOOM_MODE_DEFAULT: | 243 case ZoomController::ZOOM_MODE_DEFAULT: |
| 208 zoom_settings->mode = api::tabs::ZOOM_SETTINGS_MODE_AUTOMATIC; | 244 zoom_settings->mode = api::tabs::ZOOM_SETTINGS_MODE_AUTOMATIC; |
| 209 zoom_settings->scope = api::tabs::ZOOM_SETTINGS_SCOPE_PER_ORIGIN; | 245 zoom_settings->scope = api::tabs::ZOOM_SETTINGS_SCOPE_PER_ORIGIN; |
| 210 break; | 246 break; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 GetProfile(), | 450 GetProfile(), |
| 415 include_incognito(), | 451 include_incognito(), |
| 416 NULL, | 452 NULL, |
| 417 &source_tab_strip, | 453 &source_tab_strip, |
| 418 NULL, | 454 NULL, |
| 419 &tab_index, | 455 &tab_index, |
| 420 &error_)) | 456 &error_)) |
| 421 return false; | 457 return false; |
| 422 } | 458 } |
| 423 | 459 |
| 460 if (!IsValidStateForWindowsCreateFunction(create_data)) { | |
| 461 error_ = keys::kInvalidWindowStateError; | |
| 462 return false; | |
| 463 } | |
| 464 | |
| 424 Profile* window_profile = GetProfile(); | 465 Profile* window_profile = GetProfile(); |
| 425 Browser::Type window_type = Browser::TYPE_TABBED; | 466 Browser::Type window_type = Browser::TYPE_TABBED; |
| 426 bool create_panel = false; | 467 bool create_panel = false; |
| 427 | 468 |
| 428 // panel_create_mode only applies if create_panel = true | 469 // panel_create_mode only applies if create_panel = true |
| 429 PanelManager::CreateMode panel_create_mode = PanelManager::CREATE_AS_DOCKED; | 470 PanelManager::CreateMode panel_create_mode = PanelManager::CREATE_AS_DOCKED; |
| 430 | 471 |
| 431 gfx::Rect window_bounds; | 472 gfx::Rect window_bounds; |
| 432 bool focused = true; | 473 bool focused = true; |
| 433 bool saw_focus_key = false; | 474 bool saw_focus_key = false; |
| (...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1971 ZoomModeToZoomSettings(zoom_mode, &zoom_settings); | 2012 ZoomModeToZoomSettings(zoom_mode, &zoom_settings); |
| 1972 zoom_settings.default_zoom_factor.reset(new double( | 2013 zoom_settings.default_zoom_factor.reset(new double( |
| 1973 content::ZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel()))); | 2014 content::ZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel()))); |
| 1974 | 2015 |
| 1975 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); | 2016 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); |
| 1976 SendResponse(true); | 2017 SendResponse(true); |
| 1977 return true; | 2018 return true; |
| 1978 } | 2019 } |
| 1979 | 2020 |
| 1980 } // namespace extensions | 2021 } // namespace extensions |
| OLD | NEW |