| 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/app_window/app_window_api.h" | 5 #include "chrome/browser/extensions/api/app_window/app_window_api.h" |
| 6 | 6 |
| 7 #include "apps/app_window.h" | 7 #include "apps/app_window.h" |
| 8 #include "apps/app_window_contents.h" | 8 #include "apps/app_window_contents.h" |
| 9 #include "apps/app_window_registry.h" | 9 #include "apps/app_window_registry.h" |
| 10 #include "apps/apps_client.h" | 10 #include "apps/apps_client.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 namespace app_window = extensions::api::app_window; | 36 namespace app_window = extensions::api::app_window; |
| 37 namespace Create = app_window::Create; | 37 namespace Create = app_window::Create; |
| 38 | 38 |
| 39 namespace extensions { | 39 namespace extensions { |
| 40 | 40 |
| 41 namespace app_window_constants { | 41 namespace app_window_constants { |
| 42 const char kInvalidWindowId[] = | 42 const char kInvalidWindowId[] = |
| 43 "The window id can not be more than 256 characters long."; | 43 "The window id can not be more than 256 characters long."; |
| 44 const char kInvalidColorSpecification[] = | 44 const char kInvalidColorSpecification[] = |
| 45 "The color specification could not be parsed."; | 45 "The color specification could not be parsed."; |
| 46 const char kInvalidChannelForFrameOptions[] = | |
| 47 "Frame options are only available in dev channel."; | |
| 48 const char kColorWithFrameNone[] = "Windows with no frame cannot have a color."; | 46 const char kColorWithFrameNone[] = "Windows with no frame cannot have a color."; |
| 49 const char kInactiveColorWithoutColor[] = | 47 const char kInactiveColorWithoutColor[] = |
| 50 "frame.inactiveColor must be used with frame.color."; | 48 "frame.inactiveColor must be used with frame.color."; |
| 51 const char kConflictingBoundsOptions[] = | 49 const char kConflictingBoundsOptions[] = |
| 52 "The $1 property cannot be specified for both inner and outer bounds."; | 50 "The $1 property cannot be specified for both inner and outer bounds."; |
| 53 } // namespace app_window_constants | 51 } // namespace app_window_constants |
| 54 | 52 |
| 55 const char kNoneFrameOption[] = "none"; | 53 const char kNoneFrameOption[] = "none"; |
| 56 // TODO(benwells): Remove HTML titlebar injection. | 54 // TODO(benwells): Remove HTML titlebar injection. |
| 57 const char kHtmlFrameOption[] = "experimental-html"; | 55 const char kHtmlFrameOption[] = "experimental-html"; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 case extensions::api::app_window::STATE_MAXIMIZED: | 252 case extensions::api::app_window::STATE_MAXIMIZED: |
| 255 create_params.state = ui::SHOW_STATE_MAXIMIZED; | 253 create_params.state = ui::SHOW_STATE_MAXIMIZED; |
| 256 break; | 254 break; |
| 257 case extensions::api::app_window::STATE_MINIMIZED: | 255 case extensions::api::app_window::STATE_MINIMIZED: |
| 258 create_params.state = ui::SHOW_STATE_MINIMIZED; | 256 create_params.state = ui::SHOW_STATE_MINIMIZED; |
| 259 break; | 257 break; |
| 260 } | 258 } |
| 261 } | 259 } |
| 262 } | 260 } |
| 263 | 261 |
| 264 UpdateFrameOptionsForChannel(&create_params); | |
| 265 | |
| 266 create_params.creator_process_id = | 262 create_params.creator_process_id = |
| 267 render_view_host_->GetProcess()->GetID(); | 263 render_view_host_->GetProcess()->GetID(); |
| 268 | 264 |
| 269 AppWindow* app_window = apps::AppsClient::Get()->CreateAppWindow( | 265 AppWindow* app_window = apps::AppsClient::Get()->CreateAppWindow( |
| 270 browser_context(), GetExtension()); | 266 browser_context(), GetExtension()); |
| 271 app_window->Init( | 267 app_window->Init( |
| 272 url, new apps::AppWindowContentsImpl(app_window), create_params); | 268 url, new apps::AppWindowContentsImpl(app_window), create_params); |
| 273 | 269 |
| 274 if (ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode()) | 270 if (ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode()) |
| 275 app_window->ForcedFullscreen(); | 271 app_window->ForcedFullscreen(); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 AppWindow::CreateParams* create_params) { | 427 AppWindow::CreateParams* create_params) { |
| 432 if (!options.frame) | 428 if (!options.frame) |
| 433 return true; | 429 return true; |
| 434 | 430 |
| 435 DCHECK(options.frame->as_string || options.frame->as_frame_options); | 431 DCHECK(options.frame->as_string || options.frame->as_frame_options); |
| 436 if (options.frame->as_string) { | 432 if (options.frame->as_string) { |
| 437 create_params->frame = GetFrameFromString(*options.frame->as_string); | 433 create_params->frame = GetFrameFromString(*options.frame->as_string); |
| 438 return true; | 434 return true; |
| 439 } | 435 } |
| 440 | 436 |
| 441 if (GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV) { | |
| 442 error_ = app_window_constants::kInvalidChannelForFrameOptions; | |
| 443 return false; | |
| 444 } | |
| 445 | |
| 446 if (options.frame->as_frame_options->type) | 437 if (options.frame->as_frame_options->type) |
| 447 create_params->frame = | 438 create_params->frame = |
| 448 GetFrameFromString(*options.frame->as_frame_options->type); | 439 GetFrameFromString(*options.frame->as_frame_options->type); |
| 449 | 440 |
| 450 if (options.frame->as_frame_options->color.get()) { | 441 if (options.frame->as_frame_options->color.get()) { |
| 451 if (create_params->frame != AppWindow::FRAME_CHROME) { | 442 if (create_params->frame != AppWindow::FRAME_CHROME) { |
| 452 error_ = app_window_constants::kColorWithFrameNone; | 443 error_ = app_window_constants::kColorWithFrameNone; |
| 453 return false; | 444 return false; |
| 454 } | 445 } |
| 455 | 446 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 476 } | 467 } |
| 477 | 468 |
| 478 if (options.frame->as_frame_options->inactive_color.get()) { | 469 if (options.frame->as_frame_options->inactive_color.get()) { |
| 479 error_ = app_window_constants::kInactiveColorWithoutColor; | 470 error_ = app_window_constants::kInactiveColorWithoutColor; |
| 480 return false; | 471 return false; |
| 481 } | 472 } |
| 482 | 473 |
| 483 return true; | 474 return true; |
| 484 } | 475 } |
| 485 | 476 |
| 486 void AppWindowCreateFunction::UpdateFrameOptionsForChannel( | |
| 487 apps::AppWindow::CreateParams* create_params) { | |
| 488 #if defined(OS_WIN) | |
| 489 if (create_params->frame == AppWindow::FRAME_CHROME && | |
| 490 GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV) { | |
| 491 // If not on trunk or dev channel, always use the standard white frame. | |
| 492 // TODO(benwells): Remove this code once we get agreement to use the new | |
| 493 // native style frame. | |
| 494 create_params->has_frame_color = true; | |
| 495 create_params->active_frame_color = SK_ColorWHITE; | |
| 496 create_params->inactive_frame_color = SK_ColorWHITE; | |
| 497 } | |
| 498 #endif | |
| 499 } | |
| 500 | |
| 501 } // namespace extensions | 477 } // namespace extensions |
| OLD | NEW |