Chromium Code Reviews| Index: chrome/browser/extensions/api/tabs/tabs_api.cc |
| diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc |
| index 3bcf3db1f36819a2804ad06844a2ba1d22171df6..835a6387cd36b14c092f254acee8476f4832a5b2 100644 |
| --- a/chrome/browser/extensions/api/tabs/tabs_api.cc |
| +++ b/chrome/browser/extensions/api/tabs/tabs_api.cc |
| @@ -198,6 +198,33 @@ ui::WindowShowState ConvertToWindowShowState(windows::WindowState state) { |
| return ui::SHOW_STATE_DEFAULT; |
| } |
| +bool IsValidStateForWindowsCreateFunction( |
| + const windows::Create::Params::CreateData* create_data) { |
| + if (!create_data) |
| + return true; |
| + |
| + bool focused = create_data->focused && *create_data->focused; |
| + bool has_bound = create_data->left || create_data->top || |
| + create_data->width || create_data->height; |
| + bool is_panel = |
| + create_data->type == windows::CreateType::CREATE_TYPE_PANEL || |
| + create_data->type == windows::CreateType::CREATE_TYPE_DETACHED_PANEL; |
| + |
| + switch (create_data->state) { |
| + case windows::WINDOW_STATE_MINIMIZED: |
| + return !focused && !has_bound && !is_panel; |
| + case windows::WINDOW_STATE_MAXIMIZED: |
| + case windows::WINDOW_STATE_FULLSCREEN: |
| + // 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.
|
| + return (create_data->focused ? focused : true) && !has_bound && !is_panel; |
| + case windows::WINDOW_STATE_NORMAL: |
| + case windows::WINDOW_STATE_NONE: |
| + return true; |
| + } |
| + NOTREACHED(); |
| + return true; |
| +} |
| + |
| } // namespace |
| void ZoomModeToZoomSettings(ZoomController::ZoomMode zoom_mode, |
| @@ -421,6 +448,11 @@ bool WindowsCreateFunction::RunSync() { |
| return false; |
| } |
| + if (!IsValidStateForWindowsCreateFunction(create_data)) { |
| + error_ = keys::kInvalidWindowStateError; |
| + return false; |
| + } |
| + |
| Profile* window_profile = GetProfile(); |
| Browser::Type window_type = Browser::TYPE_TABBED; |
| bool create_panel = false; |