Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(463)

Side by Side Diff: chrome/browser/ui/views/apps/chrome_native_app_window_views.cc

Issue 181503009: Rename BaseNativeAppWindowViews and NativeAppWindowViews (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (native_app_window) Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/views/apps/native_app_window_views.h" 5 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views.h"
6 6
7 #include "apps/ui/views/app_window_frame_view.h" 7 #include "apps/ui/views/app_window_frame_view.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/app_mode/app_mode_utils.h" 10 #include "chrome/browser/app_mode/app_mode_utils.h"
11 #include "chrome/browser/chrome_page_zoom.h" 11 #include "chrome/browser/chrome_page_zoom.h"
12 #include "chrome/browser/favicon/favicon_tab_helper.h" 12 #include "chrome/browser/favicon/favicon_tab_helper.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/host_desktop.h" 14 #include "chrome/browser/ui/host_desktop.h"
15 #include "chrome/browser/ui/views/apps/shaped_app_window_targeter.h" 15 #include "chrome/browser/ui/views/apps/shaped_app_window_targeter.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // Not owned. 184 // Not owned.
185 AppWindow* app_window_; 185 AppWindow* app_window_;
186 ash::wm::WindowState* window_state_; 186 ash::wm::WindowState* window_state_;
187 187
188 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowStateDelegate); 188 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowStateDelegate);
189 }; 189 };
190 #endif // USE_ASH 190 #endif // USE_ASH
191 191
192 } // namespace 192 } // namespace
193 193
194 NativeAppWindowViews::NativeAppWindowViews() 194 ChromeNativeAppWindowViews::ChromeNativeAppWindowViews()
195 : is_fullscreen_(false), 195 : is_fullscreen_(false),
196 has_frame_color_(false), 196 has_frame_color_(false),
197 frame_color_(SK_ColorBLACK) {} 197 frame_color_(SK_ColorBLACK) {}
198 198
199 NativeAppWindowViews::~NativeAppWindowViews() {} 199 ChromeNativeAppWindowViews::~ChromeNativeAppWindowViews() {}
200 200
201 void NativeAppWindowViews::OnBeforeWidgetInit( 201 void ChromeNativeAppWindowViews::OnBeforeWidgetInit(
202 views::Widget::InitParams* init_params, 202 views::Widget::InitParams* init_params,
203 views::Widget* widget) {} 203 views::Widget* widget) {}
204 204
205 void NativeAppWindowViews::InitializeDefaultWindow( 205 void ChromeNativeAppWindowViews::InitializeDefaultWindow(
206 const AppWindow::CreateParams& create_params) { 206 const AppWindow::CreateParams& create_params) {
207 std::string app_name = 207 std::string app_name =
208 web_app::GenerateApplicationNameFromExtensionId( 208 web_app::GenerateApplicationNameFromExtensionId(
209 app_window()->extension()->id()); 209 app_window()->extension()->id());
210 210
211 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW); 211 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW);
212 init_params.delegate = this; 212 init_params.delegate = this;
213 init_params.remove_standard_frame = !ShouldUseNativeFrame(); 213 init_params.remove_standard_frame = !ShouldUseNativeFrame();
214 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 214 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
215 // On Linux, remove the standard frame. Instead, we will use CustomFrameView 215 // On Linux, remove the standard frame. Instead, we will use CustomFrameView
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 accelerator_table.begin(); 271 accelerator_table.begin();
272 iter != accelerator_table.end(); ++iter) { 272 iter != accelerator_table.end(); ++iter) {
273 if (is_kiosk_app_mode && !chrome::IsCommandAllowedInAppMode(iter->second)) 273 if (is_kiosk_app_mode && !chrome::IsCommandAllowedInAppMode(iter->second))
274 continue; 274 continue;
275 275
276 focus_manager->RegisterAccelerator( 276 focus_manager->RegisterAccelerator(
277 iter->first, ui::AcceleratorManager::kNormalPriority, this); 277 iter->first, ui::AcceleratorManager::kNormalPriority, this);
278 } 278 }
279 } 279 }
280 280
281 void NativeAppWindowViews::InitializePanelWindow( 281 void ChromeNativeAppWindowViews::InitializePanelWindow(
282 const AppWindow::CreateParams& create_params) { 282 const AppWindow::CreateParams& create_params) {
283 views::Widget::InitParams params(views::Widget::InitParams::TYPE_PANEL); 283 views::Widget::InitParams params(views::Widget::InitParams::TYPE_PANEL);
284 params.delegate = this; 284 params.delegate = this;
285 285
286 preferred_size_ = gfx::Size(create_params.bounds.width(), 286 preferred_size_ = gfx::Size(create_params.bounds.width(),
287 create_params.bounds.height()); 287 create_params.bounds.height());
288 if (preferred_size_.width() == 0) 288 if (preferred_size_.width() == 0)
289 preferred_size_.set_width(kDefaultPanelWidth); 289 preferred_size_.set_width(kDefaultPanelWidth);
290 else if (preferred_size_.width() < kMinPanelWidth) 290 else if (preferred_size_.width() < kMinPanelWidth)
291 preferred_size_.set_width(kMinPanelWidth); 291 preferred_size_.set_width(kMinPanelWidth);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 native_window->GetRootWindow(), 324 native_window->GetRootWindow(),
325 native_window->GetBoundsInScreen()); 325 native_window->GetBoundsInScreen());
326 window()->SetBounds(window_bounds); 326 window()->SetBounds(window_bounds);
327 } 327 }
328 #else 328 #else
329 // TODO(stevenjb): NativeAppWindow panels need to be implemented for other 329 // TODO(stevenjb): NativeAppWindow panels need to be implemented for other
330 // platforms. 330 // platforms.
331 #endif 331 #endif
332 } 332 }
333 333
334 bool NativeAppWindowViews::ShouldUseNativeFrame() const { 334 bool ChromeNativeAppWindowViews::ShouldUseNativeFrame() const {
335 return !IsFrameless() & !has_frame_color_; 335 return !IsFrameless() & !has_frame_color_;
336 } 336 }
337 337
338 void NativeAppWindowViews::InstallEasyResizeTargeterOnContainer() const { 338 void ChromeNativeAppWindowViews::InstallEasyResizeTargeterOnContainer() const {
339 aura::Window* root_window = window()->GetNativeWindow()->GetRootWindow(); 339 aura::Window* root_window = window()->GetNativeWindow()->GetRootWindow();
340 gfx::Insets inset(kResizeInsideBoundsSize, kResizeInsideBoundsSize, 340 gfx::Insets inset(kResizeInsideBoundsSize, kResizeInsideBoundsSize,
341 kResizeInsideBoundsSize, kResizeInsideBoundsSize); 341 kResizeInsideBoundsSize, kResizeInsideBoundsSize);
342 root_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>( 342 root_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>(
343 new wm::EasyResizeWindowTargeter(root_window, inset, inset))); 343 new wm::EasyResizeWindowTargeter(root_window, inset, inset)));
344 } 344 }
345 345
346 apps::AppWindowFrameView* 346 apps::AppWindowFrameView*
347 NativeAppWindowViews::CreateAppWindowFrameView() { 347 ChromeNativeAppWindowViews::CreateAppWindowFrameView() {
348 // By default the user can resize the window from slightly inside the bounds. 348 // By default the user can resize the window from slightly inside the bounds.
349 int resize_inside_bounds_size = kResizeInsideBoundsSize; 349 int resize_inside_bounds_size = kResizeInsideBoundsSize;
350 int resize_outside_bounds_size = 0; 350 int resize_outside_bounds_size = 0;
351 int resize_outside_scale_for_touch = 1; 351 int resize_outside_scale_for_touch = 1;
352 int resize_area_corner_size = kResizeAreaCornerSize; 352 int resize_area_corner_size = kResizeAreaCornerSize;
353 #if defined(USE_ASH) 353 #if defined(USE_ASH)
354 // For Aura windows on the Ash desktop the sizes are different and the user 354 // For Aura windows on the Ash desktop the sizes are different and the user
355 // can resize the window from slightly outside the bounds as well. 355 // can resize the window from slightly outside the bounds as well.
356 if (chrome::IsNativeWindowInAsh(window()->GetNativeWindow())) { 356 if (chrome::IsNativeWindowInAsh(window()->GetNativeWindow())) {
357 resize_inside_bounds_size = ash::kResizeInsideBoundsSize; 357 resize_inside_bounds_size = ash::kResizeInsideBoundsSize;
358 resize_outside_bounds_size = ash::kResizeOutsideBoundsSize; 358 resize_outside_bounds_size = ash::kResizeOutsideBoundsSize;
359 resize_outside_scale_for_touch = ash::kResizeOutsideBoundsScaleForTouch; 359 resize_outside_scale_for_touch = ash::kResizeOutsideBoundsScaleForTouch;
360 resize_area_corner_size = ash::kResizeAreaCornerSize; 360 resize_area_corner_size = ash::kResizeAreaCornerSize;
361 } 361 }
362 #endif 362 #endif
363 apps::AppWindowFrameView* frame_view = new apps::AppWindowFrameView(this); 363 apps::AppWindowFrameView* frame_view = new apps::AppWindowFrameView(this);
364 frame_view->Init(window(), 364 frame_view->Init(window(),
365 frame_color_, 365 frame_color_,
366 resize_inside_bounds_size, 366 resize_inside_bounds_size,
367 resize_outside_bounds_size, 367 resize_outside_bounds_size,
368 resize_outside_scale_for_touch, 368 resize_outside_scale_for_touch,
369 resize_area_corner_size); 369 resize_area_corner_size);
370 return frame_view; 370 return frame_view;
371 } 371 }
372 372
373 // ui::BaseWindow implementation. 373 // ui::BaseWindow implementation.
374 374
375 ui::WindowShowState NativeAppWindowViews::GetRestoredState() const { 375 ui::WindowShowState ChromeNativeAppWindowViews::GetRestoredState() const {
376 if (IsMaximized()) 376 if (IsMaximized())
377 return ui::SHOW_STATE_MAXIMIZED; 377 return ui::SHOW_STATE_MAXIMIZED;
378 if (IsFullscreen()) { 378 if (IsFullscreen()) {
379 #if defined(USE_ASH) 379 #if defined(USE_ASH)
380 if (immersive_fullscreen_controller_.get() && 380 if (immersive_fullscreen_controller_.get() &&
381 immersive_fullscreen_controller_->IsEnabled()) { 381 immersive_fullscreen_controller_->IsEnabled()) {
382 // Restore windows which were previously in immersive fullscreen to 382 // Restore windows which were previously in immersive fullscreen to
383 // maximized. Restoring the window to a different fullscreen type 383 // maximized. Restoring the window to a different fullscreen type
384 // makes for a bad experience. 384 // makes for a bad experience.
385 return ui::SHOW_STATE_MAXIMIZED; 385 return ui::SHOW_STATE_MAXIMIZED;
(...skipping 18 matching lines...) Expand all
404 case ui::SHOW_STATE_DEFAULT: 404 case ui::SHOW_STATE_DEFAULT:
405 case ui::SHOW_STATE_MINIMIZED: 405 case ui::SHOW_STATE_MINIMIZED:
406 case ui::SHOW_STATE_INACTIVE: 406 case ui::SHOW_STATE_INACTIVE:
407 case ui::SHOW_STATE_END: 407 case ui::SHOW_STATE_END:
408 return ui::SHOW_STATE_NORMAL; 408 return ui::SHOW_STATE_NORMAL;
409 } 409 }
410 #endif 410 #endif
411 return ui::SHOW_STATE_NORMAL; 411 return ui::SHOW_STATE_NORMAL;
412 } 412 }
413 413
414 bool NativeAppWindowViews::IsAlwaysOnTop() const { 414 bool ChromeNativeAppWindowViews::IsAlwaysOnTop() const {
415 if (app_window()->window_type_is_panel()) { 415 if (app_window()->window_type_is_panel()) {
416 #if defined(USE_ASH) 416 #if defined(USE_ASH)
417 return ash::wm::GetWindowState(window()->GetNativeWindow())-> 417 return ash::wm::GetWindowState(window()->GetNativeWindow())->
418 panel_attached(); 418 panel_attached();
419 #else 419 #else
420 return true; 420 return true;
421 #endif 421 #endif
422 } else { 422 } else {
423 return window()->IsAlwaysOnTop(); 423 return window()->IsAlwaysOnTop();
424 } 424 }
425 } 425 }
426 426
427 // views::ContextMenuController implementation. 427 // views::ContextMenuController implementation.
428 428
429 void NativeAppWindowViews::ShowContextMenuForView( 429 void ChromeNativeAppWindowViews::ShowContextMenuForView(
430 views::View* source, 430 views::View* source,
431 const gfx::Point& p, 431 const gfx::Point& p,
432 ui::MenuSourceType source_type) { 432 ui::MenuSourceType source_type) {
433 #if defined(USE_ASH) && defined(OS_CHROMEOS) 433 #if defined(USE_ASH) && defined(OS_CHROMEOS)
434 scoped_ptr<ui::MenuModel> model = 434 scoped_ptr<ui::MenuModel> model =
435 CreateMultiUserContextMenu(app_window()->GetNativeWindow()); 435 CreateMultiUserContextMenu(app_window()->GetNativeWindow());
436 if (!model.get()) 436 if (!model.get())
437 return; 437 return;
438 438
439 // Only show context menu if point is in caption. 439 // Only show context menu if point is in caption.
440 gfx::Point point_in_view_coords(p); 440 gfx::Point point_in_view_coords(p);
441 views::View::ConvertPointFromScreen(window()->non_client_view(), 441 views::View::ConvertPointFromScreen(window()->non_client_view(),
442 &point_in_view_coords); 442 &point_in_view_coords);
443 int hit_test = window()->non_client_view()->NonClientHitTest( 443 int hit_test = window()->non_client_view()->NonClientHitTest(
444 point_in_view_coords); 444 point_in_view_coords);
445 if (hit_test == HTCAPTION) { 445 if (hit_test == HTCAPTION) {
446 menu_runner_.reset(new views::MenuRunner(model.get())); 446 menu_runner_.reset(new views::MenuRunner(model.get()));
447 if (menu_runner_->RunMenuAt(source->GetWidget(), NULL, 447 if (menu_runner_->RunMenuAt(source->GetWidget(), NULL,
448 gfx::Rect(p, gfx::Size(0,0)), views::MenuItemView::TOPLEFT, 448 gfx::Rect(p, gfx::Size(0,0)), views::MenuItemView::TOPLEFT,
449 source_type, 449 source_type,
450 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) == 450 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) ==
451 views::MenuRunner::MENU_DELETED) 451 views::MenuRunner::MENU_DELETED)
452 return; 452 return;
453 } 453 }
454 #endif 454 #endif
455 } 455 }
456 456
457 // views::WidgetDelegate implementation. 457 // views::WidgetDelegate implementation.
458 458
459 gfx::ImageSkia NativeAppWindowViews::GetWindowAppIcon() { 459 gfx::ImageSkia ChromeNativeAppWindowViews::GetWindowAppIcon() {
460 gfx::Image app_icon = app_window()->app_icon(); 460 gfx::Image app_icon = app_window()->app_icon();
461 if (app_icon.IsEmpty()) 461 if (app_icon.IsEmpty())
462 return GetWindowIcon(); 462 return GetWindowIcon();
463 else 463 else
464 return *app_icon.ToImageSkia(); 464 return *app_icon.ToImageSkia();
465 } 465 }
466 466
467 gfx::ImageSkia NativeAppWindowViews::GetWindowIcon() { 467 gfx::ImageSkia ChromeNativeAppWindowViews::GetWindowIcon() {
468 content::WebContents* web_contents = app_window()->web_contents(); 468 content::WebContents* web_contents = app_window()->web_contents();
469 if (web_contents) { 469 if (web_contents) {
470 FaviconTabHelper* favicon_tab_helper = 470 FaviconTabHelper* favicon_tab_helper =
471 FaviconTabHelper::FromWebContents(web_contents); 471 FaviconTabHelper::FromWebContents(web_contents);
472 gfx::Image app_icon = favicon_tab_helper->GetFavicon(); 472 gfx::Image app_icon = favicon_tab_helper->GetFavicon();
473 if (!app_icon.IsEmpty()) 473 if (!app_icon.IsEmpty())
474 return *app_icon.ToImageSkia(); 474 return *app_icon.ToImageSkia();
475 } 475 }
476 return gfx::ImageSkia(); 476 return gfx::ImageSkia();
477 } 477 }
478 478
479 views::NonClientFrameView* NativeAppWindowViews::CreateNonClientFrameView( 479 views::NonClientFrameView* ChromeNativeAppWindowViews::CreateNonClientFrameView(
480 views::Widget* widget) { 480 views::Widget* widget) {
481 #if defined(USE_ASH) 481 #if defined(USE_ASH)
482 if (chrome::IsNativeViewInAsh(widget->GetNativeView())) { 482 if (chrome::IsNativeViewInAsh(widget->GetNativeView())) {
483 // Set the delegate now because CustomFrameViewAsh sets the 483 // Set the delegate now because CustomFrameViewAsh sets the
484 // WindowStateDelegate if one is not already set. 484 // WindowStateDelegate if one is not already set.
485 ash::wm::GetWindowState(GetNativeWindow())->SetDelegate( 485 ash::wm::GetWindowState(GetNativeWindow())->SetDelegate(
486 scoped_ptr<ash::wm::WindowStateDelegate>( 486 scoped_ptr<ash::wm::WindowStateDelegate>(
487 new NativeAppWindowStateDelegate(app_window(), this)).Pass()); 487 new NativeAppWindowStateDelegate(app_window(), this)).Pass());
488 488
489 if (app_window()->window_type_is_panel()) { 489 if (app_window()->window_type_is_panel()) {
(...skipping 22 matching lines...) Expand all
512 custom_frame_view->GetHeaderView()->set_context_menu_controller(this); 512 custom_frame_view->GetHeaderView()->set_context_menu_controller(this);
513 return custom_frame_view; 513 return custom_frame_view;
514 } 514 }
515 } 515 }
516 #endif 516 #endif
517 if (!ShouldUseNativeFrame()) 517 if (!ShouldUseNativeFrame())
518 return CreateAppWindowFrameView(); 518 return CreateAppWindowFrameView();
519 return views::WidgetDelegateView::CreateNonClientFrameView(widget); 519 return views::WidgetDelegateView::CreateNonClientFrameView(widget);
520 } 520 }
521 521
522 bool NativeAppWindowViews::WidgetHasHitTestMask() const { 522 bool ChromeNativeAppWindowViews::WidgetHasHitTestMask() const {
523 return shape_ != NULL; 523 return shape_ != NULL;
524 } 524 }
525 525
526 void NativeAppWindowViews::GetWidgetHitTestMask(gfx::Path* mask) const { 526 void ChromeNativeAppWindowViews::GetWidgetHitTestMask(gfx::Path* mask) const {
527 shape_->getBoundaryPath(mask); 527 shape_->getBoundaryPath(mask);
528 } 528 }
529 529
530 // views::View implementation. 530 // views::View implementation.
531 531
532 gfx::Size NativeAppWindowViews::GetPreferredSize() { 532 gfx::Size ChromeNativeAppWindowViews::GetPreferredSize() {
533 if (!preferred_size_.IsEmpty()) 533 if (!preferred_size_.IsEmpty())
534 return preferred_size_; 534 return preferred_size_;
535 return BaseNativeAppWindowViews::GetPreferredSize(); 535 return NativeAppWindowViews::GetPreferredSize();
536 } 536 }
537 537
538 bool NativeAppWindowViews::AcceleratorPressed( 538 bool ChromeNativeAppWindowViews::AcceleratorPressed(
539 const ui::Accelerator& accelerator) { 539 const ui::Accelerator& accelerator) {
540 const std::map<ui::Accelerator, int>& accelerator_table = 540 const std::map<ui::Accelerator, int>& accelerator_table =
541 GetAcceleratorTable(); 541 GetAcceleratorTable();
542 std::map<ui::Accelerator, int>::const_iterator iter = 542 std::map<ui::Accelerator, int>::const_iterator iter =
543 accelerator_table.find(accelerator); 543 accelerator_table.find(accelerator);
544 DCHECK(iter != accelerator_table.end()); 544 DCHECK(iter != accelerator_table.end());
545 int command_id = iter->second; 545 int command_id = iter->second;
546 switch (command_id) { 546 switch (command_id) {
547 case IDC_CLOSE_WINDOW: 547 case IDC_CLOSE_WINDOW:
548 Close(); 548 Close();
549 return true; 549 return true;
550 case IDC_ZOOM_MINUS: 550 case IDC_ZOOM_MINUS:
551 chrome_page_zoom::Zoom(web_view()->GetWebContents(), 551 chrome_page_zoom::Zoom(web_view()->GetWebContents(),
552 content::PAGE_ZOOM_OUT); 552 content::PAGE_ZOOM_OUT);
553 return true; 553 return true;
554 case IDC_ZOOM_NORMAL: 554 case IDC_ZOOM_NORMAL:
555 chrome_page_zoom::Zoom(web_view()->GetWebContents(), 555 chrome_page_zoom::Zoom(web_view()->GetWebContents(),
556 content::PAGE_ZOOM_RESET); 556 content::PAGE_ZOOM_RESET);
557 return true; 557 return true;
558 case IDC_ZOOM_PLUS: 558 case IDC_ZOOM_PLUS:
559 chrome_page_zoom::Zoom(web_view()->GetWebContents(), 559 chrome_page_zoom::Zoom(web_view()->GetWebContents(),
560 content::PAGE_ZOOM_IN); 560 content::PAGE_ZOOM_IN);
561 return true; 561 return true;
562 default: 562 default:
563 NOTREACHED() << "Unknown accelerator sent to app window."; 563 NOTREACHED() << "Unknown accelerator sent to app window.";
564 } 564 }
565 return BaseNativeAppWindowViews::AcceleratorPressed(accelerator); 565 return NativeAppWindowViews::AcceleratorPressed(accelerator);
566 } 566 }
567 567
568 // NativeAppWindow implementation. 568 // NativeAppWindow implementation.
569 569
570 void NativeAppWindowViews::SetFullscreen(int fullscreen_types) { 570 void ChromeNativeAppWindowViews::SetFullscreen(int fullscreen_types) {
571 // Fullscreen not supported by panels. 571 // Fullscreen not supported by panels.
572 if (app_window()->window_type_is_panel()) 572 if (app_window()->window_type_is_panel())
573 return; 573 return;
574 is_fullscreen_ = (fullscreen_types != AppWindow::FULLSCREEN_TYPE_NONE); 574 is_fullscreen_ = (fullscreen_types != AppWindow::FULLSCREEN_TYPE_NONE);
575 window()->SetFullscreen(is_fullscreen_); 575 window()->SetFullscreen(is_fullscreen_);
576 576
577 #if defined(USE_ASH) 577 #if defined(USE_ASH)
578 if (immersive_fullscreen_controller_.get()) { 578 if (immersive_fullscreen_controller_.get()) {
579 // |immersive_fullscreen_controller_| should only be set if immersive 579 // |immersive_fullscreen_controller_| should only be set if immersive
580 // fullscreen is the fullscreen type used by the OS. 580 // fullscreen is the fullscreen type used by the OS.
581 immersive_fullscreen_controller_->SetEnabled( 581 immersive_fullscreen_controller_->SetEnabled(
582 ash::ImmersiveFullscreenController::WINDOW_TYPE_PACKAGED_APP, 582 ash::ImmersiveFullscreenController::WINDOW_TYPE_PACKAGED_APP,
583 (fullscreen_types & AppWindow::FULLSCREEN_TYPE_OS) != 0); 583 (fullscreen_types & AppWindow::FULLSCREEN_TYPE_OS) != 0);
584 // Autohide the shelf instead of hiding the shelf completely when only in 584 // Autohide the shelf instead of hiding the shelf completely when only in
585 // OS fullscreen. 585 // OS fullscreen.
586 ash::wm::WindowState* window_state = 586 ash::wm::WindowState* window_state =
587 ash::wm::GetWindowState(window()->GetNativeWindow()); 587 ash::wm::GetWindowState(window()->GetNativeWindow());
588 window_state->set_hide_shelf_when_fullscreen(fullscreen_types != 588 window_state->set_hide_shelf_when_fullscreen(fullscreen_types !=
589 AppWindow::FULLSCREEN_TYPE_OS); 589 AppWindow::FULLSCREEN_TYPE_OS);
590 DCHECK(ash::Shell::HasInstance()); 590 DCHECK(ash::Shell::HasInstance());
591 ash::Shell::GetInstance()->UpdateShelfVisibility(); 591 ash::Shell::GetInstance()->UpdateShelfVisibility();
592 } 592 }
593 #endif 593 #endif
594 594
595 // TODO(jeremya) we need to call RenderViewHost::ExitFullscreen() if we 595 // TODO(jeremya) we need to call RenderViewHost::ExitFullscreen() if we
596 // ever drop the window out of fullscreen in response to something that 596 // ever drop the window out of fullscreen in response to something that
597 // wasn't the app calling webkitCancelFullScreen(). 597 // wasn't the app calling webkitCancelFullScreen().
598 } 598 }
599 599
600 bool NativeAppWindowViews::IsFullscreenOrPending() const { 600 bool ChromeNativeAppWindowViews::IsFullscreenOrPending() const {
601 return is_fullscreen_; 601 return is_fullscreen_;
602 } 602 }
603 603
604 bool NativeAppWindowViews::IsDetached() const { 604 bool ChromeNativeAppWindowViews::IsDetached() const {
605 if (!app_window()->window_type_is_panel()) 605 if (!app_window()->window_type_is_panel())
606 return false; 606 return false;
607 #if defined(USE_ASH) 607 #if defined(USE_ASH)
608 return !ash::wm::GetWindowState(window()->GetNativeWindow()) 608 return !ash::wm::GetWindowState(window()->GetNativeWindow())
609 ->panel_attached(); 609 ->panel_attached();
610 #else 610 #else
611 return false; 611 return false;
612 #endif 612 #endif
613 } 613 }
614 614
615 void NativeAppWindowViews::UpdateBadgeIcon() { 615 void ChromeNativeAppWindowViews::UpdateBadgeIcon() {
616 const gfx::Image* icon = NULL; 616 const gfx::Image* icon = NULL;
617 if (!app_window()->badge_icon().IsEmpty()) { 617 if (!app_window()->badge_icon().IsEmpty()) {
618 icon = &app_window()->badge_icon(); 618 icon = &app_window()->badge_icon();
619 // chrome::DrawTaskbarDecoration can do interesting things with non-square 619 // chrome::DrawTaskbarDecoration can do interesting things with non-square
620 // bitmaps. 620 // bitmaps.
621 // TODO(benwells): Refactor chrome::DrawTaskbarDecoration to not be avatar 621 // TODO(benwells): Refactor chrome::DrawTaskbarDecoration to not be avatar
622 // specific, and lift this restriction. 622 // specific, and lift this restriction.
623 if (icon->Width() != icon->Height()) { 623 if (icon->Width() != icon->Height()) {
624 LOG(ERROR) << "Attempt to set a non-square badge; request ignored."; 624 LOG(ERROR) << "Attempt to set a non-square badge; request ignored.";
625 return; 625 return;
626 } 626 }
627 } 627 }
628 chrome::DrawTaskbarDecoration(GetNativeWindow(), icon); 628 chrome::DrawTaskbarDecoration(GetNativeWindow(), icon);
629 } 629 }
630 630
631 void NativeAppWindowViews::UpdateShape(scoped_ptr<SkRegion> region) { 631 void ChromeNativeAppWindowViews::UpdateShape(scoped_ptr<SkRegion> region) {
632 bool had_shape = shape_; 632 bool had_shape = shape_;
633 shape_ = region.Pass(); 633 shape_ = region.Pass();
634 634
635 aura::Window* native_window = window()->GetNativeWindow(); 635 aura::Window* native_window = window()->GetNativeWindow();
636 if (shape_) { 636 if (shape_) {
637 window()->SetShape(new SkRegion(*shape_)); 637 window()->SetShape(new SkRegion(*shape_));
638 if (!had_shape) { 638 if (!had_shape) {
639 native_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>( 639 native_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>(
640 new ShapedAppWindowTargeter(native_window, this))); 640 new ShapedAppWindowTargeter(native_window, this)));
641 } 641 }
642 } else { 642 } else {
643 window()->SetShape(NULL); 643 window()->SetShape(NULL);
644 if (had_shape) 644 if (had_shape)
645 native_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>()); 645 native_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>());
646 } 646 }
647 } 647 }
648 648
649 bool NativeAppWindowViews::HasFrameColor() const { 649 bool ChromeNativeAppWindowViews::HasFrameColor() const {
650 return has_frame_color_; 650 return has_frame_color_;
651 } 651 }
652 652
653 SkColor NativeAppWindowViews::FrameColor() const { return frame_color_; } 653 SkColor ChromeNativeAppWindowViews::FrameColor() const { return frame_color_; }
654 654
655 // BaseNativeAppWindowViews implementation. 655 // NativeAppWindowViews implementation.
656 656
657 void NativeAppWindowViews::InitializeWindow( 657 void ChromeNativeAppWindowViews::InitializeWindow(
658 AppWindow* app_window, 658 AppWindow* app_window,
659 const AppWindow::CreateParams& create_params) { 659 const AppWindow::CreateParams& create_params) {
660 DCHECK(window()); 660 DCHECK(window());
661 has_frame_color_ = create_params.has_frame_color; 661 has_frame_color_ = create_params.has_frame_color;
662 frame_color_ = create_params.frame_color; 662 frame_color_ = create_params.frame_color;
663 if (create_params.window_type == AppWindow::WINDOW_TYPE_PANEL || 663 if (create_params.window_type == AppWindow::WINDOW_TYPE_PANEL ||
664 create_params.window_type == AppWindow::WINDOW_TYPE_V1_PANEL) { 664 create_params.window_type == AppWindow::WINDOW_TYPE_V1_PANEL) {
665 InitializePanelWindow(create_params); 665 InitializePanelWindow(create_params);
666 } else { 666 } else {
667 InitializeDefaultWindow(create_params); 667 InitializeDefaultWindow(create_params);
668 } 668 }
669 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( 669 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews(
670 Profile::FromBrowserContext(app_window->browser_context()), 670 Profile::FromBrowserContext(app_window->browser_context()),
671 window()->GetFocusManager(), 671 window()->GetFocusManager(),
672 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, 672 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY,
673 app_window)); 673 app_window));
674 674
675 #if defined(OS_WIN) 675 #if defined(OS_WIN)
676 if (ShouldUseNativeFrame() && 676 if (ShouldUseNativeFrame() &&
677 chrome::GetHostDesktopTypeForNativeWindow(window()->GetNativeWindow()) != 677 chrome::GetHostDesktopTypeForNativeWindow(window()->GetNativeWindow()) !=
678 chrome::HOST_DESKTOP_TYPE_ASH) { 678 chrome::HOST_DESKTOP_TYPE_ASH) {
679 InstallEasyResizeTargeterOnContainer(); 679 InstallEasyResizeTargeterOnContainer();
680 } 680 }
681 #endif 681 #endif
682 } 682 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698