| 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 "extensions/browser/api/app_window/app_window_api.h" | 5 #include "extensions/browser/api/app_window/app_window_api.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 if (input_spec->max_width.get()) | 122 if (input_spec->max_width.get()) |
| 123 create_spec->maximum_size.set_width(*input_spec->max_width); | 123 create_spec->maximum_size.set_width(*input_spec->max_width); |
| 124 if (input_spec->max_height.get()) | 124 if (input_spec->max_height.get()) |
| 125 create_spec->maximum_size.set_height(*input_spec->max_height); | 125 create_spec->maximum_size.set_height(*input_spec->max_height); |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace | 128 } // namespace |
| 129 | 129 |
| 130 AppWindowCreateFunction::AppWindowCreateFunction() {} | 130 AppWindowCreateFunction::AppWindowCreateFunction() {} |
| 131 | 131 |
| 132 bool AppWindowCreateFunction::RunAsync() { | 132 ExtensionFunction::ResponseAction AppWindowCreateFunction::Run() { |
| 133 // Don't create app window if the system is shutting down. | 133 // Don't create app window if the system is shutting down. |
| 134 if (ExtensionsBrowserClient::Get()->IsShuttingDown()) | 134 if (ExtensionsBrowserClient::Get()->IsShuttingDown()) |
| 135 return false; | 135 return RespondNow(Error(kUnknownErrorDoNotUse)); |
| 136 | 136 |
| 137 std::unique_ptr<Create::Params> params(Create::Params::Create(*args_)); | 137 std::unique_ptr<Create::Params> params(Create::Params::Create(*args_)); |
| 138 EXTENSION_FUNCTION_VALIDATE(params.get()); | 138 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 139 | 139 |
| 140 GURL url = extension()->GetResourceURL(params->url); | 140 GURL url = extension()->GetResourceURL(params->url); |
| 141 // Allow absolute URLs for component apps, otherwise prepend the extension | 141 // Allow absolute URLs for component apps, otherwise prepend the extension |
| 142 // path. | 142 // path. |
| 143 // TODO(devlin): Investigate if this is still used. If not, kill it dead! | 143 // TODO(devlin): Investigate if this is still used. If not, kill it dead! |
| 144 GURL absolute = GURL(params->url); | 144 GURL absolute = GURL(params->url); |
| 145 if (absolute.has_scheme()) { | 145 if (absolute.has_scheme()) { |
| 146 if (extension()->location() == Manifest::COMPONENT) { | 146 if (extension()->location() == Manifest::COMPONENT) { |
| 147 url = absolute; | 147 url = absolute; |
| 148 } else { | 148 } else { |
| 149 // Show error when url passed isn't local. | 149 // Show error when url passed isn't local. |
| 150 error_ = app_window_constants::kInvalidUrlParameter; | 150 return RespondNow(Error(app_window_constants::kInvalidUrlParameter)); |
| 151 return false; | |
| 152 } | 151 } |
| 153 } | 152 } |
| 154 | 153 |
| 155 // TODO(jeremya): figure out a way to pass the opening WebContents through to | 154 // TODO(jeremya): figure out a way to pass the opening WebContents through to |
| 156 // AppWindow::Create so we can set the opener at create time rather than | 155 // AppWindow::Create so we can set the opener at create time rather than |
| 157 // with a hack in AppWindowCustomBindings::GetView(). | 156 // with a hack in AppWindowCustomBindings::GetView(). |
| 158 AppWindow::CreateParams create_params; | 157 AppWindow::CreateParams create_params; |
| 159 app_window::CreateWindowOptions* options = params->options.get(); | 158 app_window::CreateWindowOptions* options = params->options.get(); |
| 160 if (options) { | 159 if (options) { |
| 161 if (options->id.get()) { | 160 if (options->id.get()) { |
| 162 // TODO(mek): use URL if no id specified? | 161 // TODO(mek): use URL if no id specified? |
| 163 // Limit length of id to 256 characters. | 162 // Limit length of id to 256 characters. |
| 164 if (options->id->length() > 256) { | 163 if (options->id->length() > 256) |
| 165 error_ = app_window_constants::kInvalidWindowId; | 164 return RespondNow(Error(app_window_constants::kInvalidWindowId)); |
| 166 return false; | |
| 167 } | |
| 168 | 165 |
| 169 create_params.window_key = *options->id; | 166 create_params.window_key = *options->id; |
| 170 | 167 |
| 171 if (options->singleton && *options->singleton == false) { | 168 if (options->singleton && *options->singleton == false) { |
| 172 WriteToConsole( | 169 WriteToConsole( |
| 173 content::CONSOLE_MESSAGE_LEVEL_WARNING, | 170 content::CONSOLE_MESSAGE_LEVEL_WARNING, |
| 174 "The 'singleton' option in chrome.apps.window.create() is deprecated!" | 171 "The 'singleton' option in chrome.apps.window.create() is deprecated!" |
| 175 " Change your code to no longer rely on this."); | 172 " Change your code to no longer rely on this."); |
| 176 } | 173 } |
| 177 | 174 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 194 existing_window->Show(AppWindow::SHOW_INACTIVE); | 191 existing_window->Show(AppWindow::SHOW_INACTIVE); |
| 195 else | 192 else |
| 196 existing_window->Show(AppWindow::SHOW_ACTIVE); | 193 existing_window->Show(AppWindow::SHOW_ACTIVE); |
| 197 } | 194 } |
| 198 | 195 |
| 199 std::unique_ptr<base::DictionaryValue> result( | 196 std::unique_ptr<base::DictionaryValue> result( |
| 200 new base::DictionaryValue); | 197 new base::DictionaryValue); |
| 201 result->Set("frameId", new base::Value(frame_id)); | 198 result->Set("frameId", new base::Value(frame_id)); |
| 202 existing_window->GetSerializedState(result.get()); | 199 existing_window->GetSerializedState(result.get()); |
| 203 result->SetBoolean("existingWindow", true); | 200 result->SetBoolean("existingWindow", true); |
| 204 SetResult(std::move(result)); | 201 return RespondNow(OneArgument(std::move(result))); |
| 205 SendResponse(true); | |
| 206 return true; | |
| 207 } | 202 } |
| 208 } | 203 } |
| 209 } | 204 } |
| 210 | 205 |
| 211 if (!GetBoundsSpec(*options, &create_params, &error_)) | 206 std::string error; |
| 212 return false; | 207 if (!GetBoundsSpec(*options, &create_params, &error)) |
| 208 return RespondNow(Error(error)); |
| 213 | 209 |
| 214 if (options->type == app_window::WINDOW_TYPE_PANEL) { | 210 if (options->type == app_window::WINDOW_TYPE_PANEL) { |
| 215 #if defined(OS_CHROMEOS) | 211 #if defined(OS_CHROMEOS) |
| 216 // Panels for v2 apps are only supported on Chrome OS. | 212 // Panels for v2 apps are only supported on Chrome OS. |
| 217 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL; | 213 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL; |
| 218 #else | 214 #else |
| 219 WriteToConsole(content::CONSOLE_MESSAGE_LEVEL_WARNING, | 215 WriteToConsole(content::CONSOLE_MESSAGE_LEVEL_WARNING, |
| 220 "Panels are not supported on this platform"); | 216 "Panels are not supported on this platform"); |
| 221 #endif | 217 #endif |
| 222 } | 218 } |
| 223 | 219 |
| 224 if (!GetFrameOptions(*options, &create_params)) | 220 if (!GetFrameOptions(*options, &create_params, &error)) |
| 225 return false; | 221 return RespondNow(Error(error)); |
| 226 | 222 |
| 227 if (extension()->GetType() == Manifest::TYPE_EXTENSION) { | 223 if (extension()->GetType() == Manifest::TYPE_EXTENSION) { |
| 228 // Whitelisted IME extensions are allowed to use this API to create IME | 224 // Whitelisted IME extensions are allowed to use this API to create IME |
| 229 // specific windows to show accented characters or suggestions. | 225 // specific windows to show accented characters or suggestions. |
| 230 if (!extension()->permissions_data()->HasAPIPermission( | 226 if (!extension()->permissions_data()->HasAPIPermission( |
| 231 APIPermission::kImeWindowEnabled)) { | 227 APIPermission::kImeWindowEnabled)) { |
| 232 error_ = app_window_constants::kImeWindowMissingPermission; | 228 return RespondNow( |
| 233 return false; | 229 Error(app_window_constants::kImeWindowMissingPermission)); |
| 234 } | 230 } |
| 235 | 231 |
| 236 #if !defined(OS_CHROMEOS) | 232 #if !defined(OS_CHROMEOS) |
| 237 // IME window is only supported on ChromeOS. | 233 // IME window is only supported on ChromeOS. |
| 238 error_ = app_window_constants::kImeWindowUnsupportedPlatform; | 234 return RespondNow( |
| 239 return false; | 235 Error(app_window_constants::kImeWindowUnsupportedPlatform)); |
| 240 #else | 236 #else |
| 241 // IME extensions must create ime window (with "ime: true" and | 237 // IME extensions must create ime window (with "ime: true" and |
| 242 // "frame: none") or panel window (with "type: panel"). | 238 // "frame: none") or panel window (with "type: panel"). |
| 243 if (options->ime.get() && *options->ime.get() && | 239 if (options->ime.get() && *options->ime.get() && |
| 244 create_params.frame == AppWindow::FRAME_NONE) { | 240 create_params.frame == AppWindow::FRAME_NONE) { |
| 245 create_params.is_ime_window = true; | 241 create_params.is_ime_window = true; |
| 246 } else if (options->type == app_window::WINDOW_TYPE_PANEL) { | 242 } else if (options->type == app_window::WINDOW_TYPE_PANEL) { |
| 247 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL; | 243 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL; |
| 248 } else { | 244 } else { |
| 249 error_ = app_window_constants::kImeWindowMustBeImeWindowOrPanel; | 245 return RespondNow( |
| 250 return false; | 246 Error(app_window_constants::kImeWindowMustBeImeWindowOrPanel)); |
| 251 } | 247 } |
| 252 #endif // OS_CHROMEOS | 248 #endif // OS_CHROMEOS |
| 253 } else { | 249 } else { |
| 254 if (options->ime.get()) { | 250 if (options->ime.get()) { |
| 255 error_ = app_window_constants::kImeOptionIsNotSupported; | 251 return RespondNow( |
| 256 return false; | 252 Error(app_window_constants::kImeOptionIsNotSupported)); |
| 257 } | 253 } |
| 258 } | 254 } |
| 259 | 255 |
| 260 if (options->alpha_enabled.get()) { | 256 if (options->alpha_enabled.get()) { |
| 261 const char* const kWhitelist[] = { | 257 const char* const kWhitelist[] = { |
| 262 #if defined(OS_CHROMEOS) | 258 #if defined(OS_CHROMEOS) |
| 263 "B58B99751225318C7EB8CF4688B5434661083E07", // http://crbug.com/410550 | 259 "B58B99751225318C7EB8CF4688B5434661083E07", // http://crbug.com/410550 |
| 264 "06BE211D5F014BAB34BC22D9DDA09C63A81D828E", // http://crbug.com/425539 | 260 "06BE211D5F014BAB34BC22D9DDA09C63A81D828E", // http://crbug.com/425539 |
| 265 "F94EE6AB36D6C6588670B2B01EB65212D9C64E33", | 261 "F94EE6AB36D6C6588670B2B01EB65212D9C64E33", |
| 266 "B9EF10DDFEA11EF77873CC5009809E5037FC4C7A", // http://crbug.com/435380 | 262 "B9EF10DDFEA11EF77873CC5009809E5037FC4C7A", // http://crbug.com/435380 |
| 267 #endif | 263 #endif |
| 268 "0F42756099D914A026DADFA182871C015735DD95", // http://crbug.com/323773 | 264 "0F42756099D914A026DADFA182871C015735DD95", // http://crbug.com/323773 |
| 269 "2D22CDB6583FD0A13758AEBE8B15E45208B4E9A7", | 265 "2D22CDB6583FD0A13758AEBE8B15E45208B4E9A7", |
| 270 "E7E2461CE072DF036CF9592740196159E2D7C089", // http://crbug.com/356200 | 266 "E7E2461CE072DF036CF9592740196159E2D7C089", // http://crbug.com/356200 |
| 271 "A74A4D44C7CFCD8844830E6140C8D763E12DD8F3", | 267 "A74A4D44C7CFCD8844830E6140C8D763E12DD8F3", |
| 272 "312745D9BF916161191143F6490085EEA0434997", | 268 "312745D9BF916161191143F6490085EEA0434997", |
| 273 "53041A2FA309EECED01FFC751E7399186E860B2C", | 269 "53041A2FA309EECED01FFC751E7399186E860B2C", |
| 274 "A07A5B743CD82A1C2579DB77D353C98A23201EEF", // http://crbug.com/413748 | 270 "A07A5B743CD82A1C2579DB77D353C98A23201EEF", // http://crbug.com/413748 |
| 275 "F16F23C83C5F6DAD9B65A120448B34056DD80691", | 271 "F16F23C83C5F6DAD9B65A120448B34056DD80691", |
| 276 "0F585FB1D0FDFBEBCE1FEB5E9DFFB6DA476B8C9B" | 272 "0F585FB1D0FDFBEBCE1FEB5E9DFFB6DA476B8C9B" |
| 277 }; | 273 }; |
| 278 if (AppWindowClient::Get()->IsCurrentChannelOlderThanDev() && | 274 if (AppWindowClient::Get()->IsCurrentChannelOlderThanDev() && |
| 279 !SimpleFeature::IsIdInArray( | 275 !SimpleFeature::IsIdInArray( |
| 280 extension_id(), kWhitelist, arraysize(kWhitelist))) { | 276 extension_id(), kWhitelist, arraysize(kWhitelist))) { |
| 281 error_ = app_window_constants::kAlphaEnabledWrongChannel; | 277 return RespondNow( |
| 282 return false; | 278 Error(app_window_constants::kAlphaEnabledWrongChannel)); |
| 283 } | 279 } |
| 284 if (!extension()->permissions_data()->HasAPIPermission( | 280 if (!extension()->permissions_data()->HasAPIPermission( |
| 285 APIPermission::kAlphaEnabled)) { | 281 APIPermission::kAlphaEnabled)) { |
| 286 error_ = app_window_constants::kAlphaEnabledMissingPermission; | 282 return RespondNow( |
| 287 return false; | 283 Error(app_window_constants::kAlphaEnabledMissingPermission)); |
| 288 } | 284 } |
| 289 if (create_params.frame != AppWindow::FRAME_NONE) { | 285 if (create_params.frame != AppWindow::FRAME_NONE) { |
| 290 error_ = app_window_constants::kAlphaEnabledNeedsFrameNone; | 286 return RespondNow( |
| 291 return false; | 287 Error(app_window_constants::kAlphaEnabledNeedsFrameNone)); |
| 292 } | 288 } |
| 293 #if defined(USE_AURA) | 289 #if defined(USE_AURA) |
| 294 create_params.alpha_enabled = *options->alpha_enabled; | 290 create_params.alpha_enabled = *options->alpha_enabled; |
| 295 #else | 291 #else |
| 296 // Transparency is only supported on Aura. | 292 // Transparency is only supported on Aura. |
| 297 // Fallback to creating an opaque window (by ignoring alphaEnabled). | 293 // Fallback to creating an opaque window (by ignoring alphaEnabled). |
| 298 #endif | 294 #endif |
| 299 } | 295 } |
| 300 | 296 |
| 301 if (options->hidden.get()) | 297 if (options->hidden.get()) |
| 302 create_params.hidden = *options->hidden; | 298 create_params.hidden = *options->hidden; |
| 303 | 299 |
| 304 if (options->resizable.get()) | 300 if (options->resizable.get()) |
| 305 create_params.resizable = *options->resizable; | 301 create_params.resizable = *options->resizable; |
| 306 | 302 |
| 307 if (options->always_on_top.get()) { | 303 if (options->always_on_top.get()) { |
| 308 create_params.always_on_top = *options->always_on_top; | 304 create_params.always_on_top = *options->always_on_top; |
| 309 | 305 |
| 310 if (create_params.always_on_top && | 306 if (create_params.always_on_top && |
| 311 !extension()->permissions_data()->HasAPIPermission( | 307 !extension()->permissions_data()->HasAPIPermission( |
| 312 APIPermission::kAlwaysOnTopWindows)) { | 308 APIPermission::kAlwaysOnTopWindows)) { |
| 313 error_ = app_window_constants::kAlwaysOnTopPermission; | 309 return RespondNow(Error(app_window_constants::kAlwaysOnTopPermission)); |
| 314 return false; | |
| 315 } | 310 } |
| 316 } | 311 } |
| 317 | 312 |
| 318 if (options->focused.get()) | 313 if (options->focused.get()) |
| 319 create_params.focused = *options->focused; | 314 create_params.focused = *options->focused; |
| 320 | 315 |
| 321 if (options->visible_on_all_workspaces.get()) { | 316 if (options->visible_on_all_workspaces.get()) { |
| 322 create_params.visible_on_all_workspaces = | 317 create_params.visible_on_all_workspaces = |
| 323 *options->visible_on_all_workspaces; | 318 *options->visible_on_all_workspaces; |
| 324 } | 319 } |
| 325 | 320 |
| 326 if (options->show_in_shelf.get()) { | 321 if (options->show_in_shelf.get()) { |
| 327 create_params.show_in_shelf = *options->show_in_shelf.get(); | 322 create_params.show_in_shelf = *options->show_in_shelf.get(); |
| 328 | 323 |
| 329 if (create_params.show_in_shelf && create_params.window_key.empty()) { | 324 if (create_params.show_in_shelf && create_params.window_key.empty()) { |
| 330 error_ = app_window_constants::kShowInShelfWindowKeyNotSet; | 325 return RespondNow( |
| 331 return false; | 326 Error(app_window_constants::kShowInShelfWindowKeyNotSet)); |
| 332 } | 327 } |
| 333 } | 328 } |
| 334 | 329 |
| 335 if (options->icon.get()) { | 330 if (options->icon.get()) { |
| 336 // First, check if the window icon URL is a valid global URL. | 331 // First, check if the window icon URL is a valid global URL. |
| 337 create_params.window_icon_url = GURL(*options->icon.get()); | 332 create_params.window_icon_url = GURL(*options->icon.get()); |
| 338 | 333 |
| 339 // If the URL is not global, check for a valid extension local URL. | 334 // If the URL is not global, check for a valid extension local URL. |
| 340 if (!create_params.window_icon_url.is_valid()) { | 335 if (!create_params.window_icon_url.is_valid()) { |
| 341 create_params.window_icon_url = | 336 create_params.window_icon_url = |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 content::RenderFrameHost* created_frame = | 372 content::RenderFrameHost* created_frame = |
| 378 app_window->web_contents()->GetMainFrame(); | 373 app_window->web_contents()->GetMainFrame(); |
| 379 int frame_id = MSG_ROUTING_NONE; | 374 int frame_id = MSG_ROUTING_NONE; |
| 380 if (create_params.creator_process_id == created_frame->GetProcess()->GetID()) | 375 if (create_params.creator_process_id == created_frame->GetProcess()->GetID()) |
| 381 frame_id = created_frame->GetRoutingID(); | 376 frame_id = created_frame->GetRoutingID(); |
| 382 | 377 |
| 383 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue); | 378 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue); |
| 384 result->Set("frameId", new base::Value(frame_id)); | 379 result->Set("frameId", new base::Value(frame_id)); |
| 385 result->Set("id", new base::Value(app_window->window_key())); | 380 result->Set("id", new base::Value(app_window->window_key())); |
| 386 app_window->GetSerializedState(result.get()); | 381 app_window->GetSerializedState(result.get()); |
| 387 SetResult(std::move(result)); | 382 ResponseValue result_arg = OneArgument(std::move(result)); |
| 388 | 383 |
| 389 if (AppWindowRegistry::Get(browser_context()) | 384 if (AppWindowRegistry::Get(browser_context()) |
| 390 ->HadDevToolsAttached(app_window->web_contents())) { | 385 ->HadDevToolsAttached(app_window->web_contents())) { |
| 391 AppWindowClient::Get()->OpenDevToolsWindow( | 386 AppWindowClient::Get()->OpenDevToolsWindow( |
| 392 app_window->web_contents(), | 387 app_window->web_contents(), |
| 393 base::Bind(&AppWindowCreateFunction::SendResponse, this, true)); | 388 base::Bind(&AppWindowCreateFunction::Respond, this, |
| 394 return true; | 389 base::Passed(&result_arg))); |
| 390 // OpenDevToolsWindow might have already responded. |
| 391 return did_respond() ? AlreadyResponded() : RespondLater(); |
| 395 } | 392 } |
| 396 | 393 |
| 397 // PlzNavigate: delay sending the response until the newly created window has | 394 // PlzNavigate: delay sending the response until the newly created window has |
| 398 // been told to navigate, and blink has been correctly initialized in the | 395 // been told to navigate, and blink has been correctly initialized in the |
| 399 // renderer. | 396 // renderer. |
| 400 if (content::IsBrowserSideNavigationEnabled()) { | 397 if (content::IsBrowserSideNavigationEnabled()) { |
| 401 app_window->SetOnFirstCommitCallback( | 398 // SetOnFirstCommitCallback() will respond asynchronously. |
| 402 base::Bind(&AppWindowCreateFunction::SendResponse, this, true)); | 399 app_window->SetOnFirstCommitCallback(base::Bind( |
| 403 return true; | 400 &AppWindowCreateFunction::Respond, this, base::Passed(&result_arg))); |
| 401 return RespondLater(); |
| 404 } | 402 } |
| 405 | 403 return RespondNow(std::move(result_arg)); |
| 406 SendResponse(true); | |
| 407 | |
| 408 return true; | |
| 409 } | 404 } |
| 410 | 405 |
| 411 bool AppWindowCreateFunction::GetBoundsSpec( | 406 bool AppWindowCreateFunction::GetBoundsSpec( |
| 412 const app_window::CreateWindowOptions& options, | 407 const app_window::CreateWindowOptions& options, |
| 413 AppWindow::CreateParams* params, | 408 AppWindow::CreateParams* params, |
| 414 std::string* error) { | 409 std::string* error) { |
| 415 DCHECK(params); | 410 DCHECK(params); |
| 416 DCHECK(error); | 411 DCHECK(error); |
| 417 | 412 |
| 418 if (options.inner_bounds.get() || options.outer_bounds.get()) { | 413 if (options.inner_bounds.get() || options.outer_bounds.get()) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 AppWindow::Frame AppWindowCreateFunction::GetFrameFromString( | 518 AppWindow::Frame AppWindowCreateFunction::GetFrameFromString( |
| 524 const std::string& frame_string) { | 519 const std::string& frame_string) { |
| 525 if (frame_string == kNoneFrameOption) | 520 if (frame_string == kNoneFrameOption) |
| 526 return AppWindow::FRAME_NONE; | 521 return AppWindow::FRAME_NONE; |
| 527 | 522 |
| 528 return AppWindow::FRAME_CHROME; | 523 return AppWindow::FRAME_CHROME; |
| 529 } | 524 } |
| 530 | 525 |
| 531 bool AppWindowCreateFunction::GetFrameOptions( | 526 bool AppWindowCreateFunction::GetFrameOptions( |
| 532 const app_window::CreateWindowOptions& options, | 527 const app_window::CreateWindowOptions& options, |
| 533 AppWindow::CreateParams* create_params) { | 528 AppWindow::CreateParams* create_params, |
| 529 std::string* error) { |
| 534 if (!options.frame) | 530 if (!options.frame) |
| 535 return true; | 531 return true; |
| 536 | 532 |
| 537 DCHECK(options.frame->as_string || options.frame->as_frame_options); | 533 DCHECK(options.frame->as_string || options.frame->as_frame_options); |
| 538 if (options.frame->as_string) { | 534 if (options.frame->as_string) { |
| 539 create_params->frame = GetFrameFromString(*options.frame->as_string); | 535 create_params->frame = GetFrameFromString(*options.frame->as_string); |
| 540 return true; | 536 return true; |
| 541 } | 537 } |
| 542 | 538 |
| 543 if (options.frame->as_frame_options->type) | 539 if (options.frame->as_frame_options->type) |
| 544 create_params->frame = | 540 create_params->frame = |
| 545 GetFrameFromString(*options.frame->as_frame_options->type); | 541 GetFrameFromString(*options.frame->as_frame_options->type); |
| 546 | 542 |
| 547 if (options.frame->as_frame_options->color.get()) { | 543 if (options.frame->as_frame_options->color.get()) { |
| 548 if (create_params->frame != AppWindow::FRAME_CHROME) { | 544 if (create_params->frame != AppWindow::FRAME_CHROME) { |
| 549 error_ = app_window_constants::kColorWithFrameNone; | 545 *error = app_window_constants::kColorWithFrameNone; |
| 550 return false; | 546 return false; |
| 551 } | 547 } |
| 552 | 548 |
| 553 if (!image_util::ParseHexColorString( | 549 if (!image_util::ParseHexColorString( |
| 554 *options.frame->as_frame_options->color, | 550 *options.frame->as_frame_options->color, |
| 555 &create_params->active_frame_color)) { | 551 &create_params->active_frame_color)) { |
| 556 error_ = app_window_constants::kInvalidColorSpecification; | 552 *error = app_window_constants::kInvalidColorSpecification; |
| 557 return false; | 553 return false; |
| 558 } | 554 } |
| 559 | 555 |
| 560 create_params->has_frame_color = true; | 556 create_params->has_frame_color = true; |
| 561 create_params->inactive_frame_color = create_params->active_frame_color; | 557 create_params->inactive_frame_color = create_params->active_frame_color; |
| 562 | 558 |
| 563 if (options.frame->as_frame_options->inactive_color.get()) { | 559 if (options.frame->as_frame_options->inactive_color.get()) { |
| 564 if (!image_util::ParseHexColorString( | 560 if (!image_util::ParseHexColorString( |
| 565 *options.frame->as_frame_options->inactive_color, | 561 *options.frame->as_frame_options->inactive_color, |
| 566 &create_params->inactive_frame_color)) { | 562 &create_params->inactive_frame_color)) { |
| 567 error_ = app_window_constants::kInvalidColorSpecification; | 563 *error = app_window_constants::kInvalidColorSpecification; |
| 568 return false; | 564 return false; |
| 569 } | 565 } |
| 570 } | 566 } |
| 571 | 567 |
| 572 return true; | 568 return true; |
| 573 } | 569 } |
| 574 | 570 |
| 575 if (options.frame->as_frame_options->inactive_color.get()) { | 571 if (options.frame->as_frame_options->inactive_color.get()) { |
| 576 error_ = app_window_constants::kInactiveColorWithoutColor; | 572 *error = app_window_constants::kInactiveColorWithoutColor; |
| 577 return false; | 573 return false; |
| 578 } | 574 } |
| 579 | 575 |
| 580 return true; | 576 return true; |
| 581 } | 577 } |
| 582 | 578 |
| 583 } // namespace extensions | 579 } // namespace extensions |
| OLD | NEW |