| 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/ui/views/extensions/shell_window_views.h" | 5 #include "chrome/browser/ui/views/extensions/native_app_window_views.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
| 9 #include "chrome/browser/favicon/favicon_tab_helper.h" | 9 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 10 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" | 10 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" |
| 11 #include "chrome/common/extensions/draggable_region.h" | 11 #include "chrome/common/extensions/draggable_region.h" |
| 12 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
| 13 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
| 14 #include "content/public/browser/render_widget_host_view.h" | 14 #include "content/public/browser/render_widget_host_view.h" |
| 15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 // Height of the chrome-style caption, in pixels. | 52 // Height of the chrome-style caption, in pixels. |
| 53 const int kCaptionHeight = 25; | 53 const int kCaptionHeight = 25; |
| 54 } // namespace | 54 } // namespace |
| 55 | 55 |
| 56 class ShellWindowFrameView : public views::NonClientFrameView, | 56 class ShellWindowFrameView : public views::NonClientFrameView, |
| 57 public views::ButtonListener { | 57 public views::ButtonListener { |
| 58 public: | 58 public: |
| 59 static const char kViewClassName[]; | 59 static const char kViewClassName[]; |
| 60 | 60 |
| 61 explicit ShellWindowFrameView(ShellWindowViews* window); | 61 explicit ShellWindowFrameView(NativeAppWindowViews* window); |
| 62 virtual ~ShellWindowFrameView(); | 62 virtual ~ShellWindowFrameView(); |
| 63 | 63 |
| 64 void Init(views::Widget* frame); | 64 void Init(views::Widget* frame); |
| 65 | 65 |
| 66 // views::NonClientFrameView implementation. | 66 // views::NonClientFrameView implementation. |
| 67 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; | 67 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; |
| 68 virtual gfx::Rect GetWindowBoundsForClientBounds( | 68 virtual gfx::Rect GetWindowBoundsForClientBounds( |
| 69 const gfx::Rect& client_bounds) const OVERRIDE; | 69 const gfx::Rect& client_bounds) const OVERRIDE; |
| 70 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; | 70 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; |
| 71 virtual void GetWindowMask(const gfx::Size& size, | 71 virtual void GetWindowMask(const gfx::Size& size, |
| 72 gfx::Path* window_mask) OVERRIDE; | 72 gfx::Path* window_mask) OVERRIDE; |
| 73 virtual void ResetWindowControls() OVERRIDE {} | 73 virtual void ResetWindowControls() OVERRIDE {} |
| 74 virtual void UpdateWindowIcon() OVERRIDE {} | 74 virtual void UpdateWindowIcon() OVERRIDE {} |
| 75 virtual void UpdateWindowTitle() OVERRIDE {} | 75 virtual void UpdateWindowTitle() OVERRIDE {} |
| 76 | 76 |
| 77 // views::View implementation. | 77 // views::View implementation. |
| 78 virtual gfx::Size GetPreferredSize() OVERRIDE; | 78 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 79 virtual void Layout() OVERRIDE; | 79 virtual void Layout() OVERRIDE; |
| 80 virtual std::string GetClassName() const OVERRIDE; | 80 virtual std::string GetClassName() const OVERRIDE; |
| 81 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 81 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 82 virtual gfx::Size GetMinimumSize() OVERRIDE; | 82 virtual gfx::Size GetMinimumSize() OVERRIDE; |
| 83 virtual gfx::Size GetMaximumSize() OVERRIDE; | 83 virtual gfx::Size GetMaximumSize() OVERRIDE; |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 // views::ButtonListener implementation. | 86 // views::ButtonListener implementation. |
| 87 virtual void ButtonPressed(views::Button* sender, const ui::Event& event) | 87 virtual void ButtonPressed(views::Button* sender, const ui::Event& event) |
| 88 OVERRIDE; | 88 OVERRIDE; |
| 89 | 89 |
| 90 ShellWindowViews* window_; | 90 NativeAppWindowViews* window_; |
| 91 views::Widget* frame_; | 91 views::Widget* frame_; |
| 92 views::ImageButton* close_button_; | 92 views::ImageButton* close_button_; |
| 93 views::ImageButton* maximize_button_; | 93 views::ImageButton* maximize_button_; |
| 94 views::ImageButton* restore_button_; | 94 views::ImageButton* restore_button_; |
| 95 views::ImageButton* minimize_button_; | 95 views::ImageButton* minimize_button_; |
| 96 | 96 |
| 97 DISALLOW_COPY_AND_ASSIGN(ShellWindowFrameView); | 97 DISALLOW_COPY_AND_ASSIGN(ShellWindowFrameView); |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 const char ShellWindowFrameView::kViewClassName[] = | 100 const char ShellWindowFrameView::kViewClassName[] = |
| 101 "browser/ui/views/extensions/ShellWindowFrameView"; | 101 "browser/ui/views/extensions/ShellWindowFrameView"; |
| 102 | 102 |
| 103 ShellWindowFrameView::ShellWindowFrameView(ShellWindowViews* window) | 103 ShellWindowFrameView::ShellWindowFrameView(NativeAppWindowViews* window) |
| 104 : window_(window), | 104 : window_(window), |
| 105 frame_(NULL), | 105 frame_(NULL), |
| 106 close_button_(NULL) { | 106 close_button_(NULL) { |
| 107 } | 107 } |
| 108 | 108 |
| 109 ShellWindowFrameView::~ShellWindowFrameView() { | 109 ShellWindowFrameView::~ShellWindowFrameView() { |
| 110 } | 110 } |
| 111 | 111 |
| 112 void ShellWindowFrameView::Init(views::Widget* frame) { | 112 void ShellWindowFrameView::Init(views::Widget* frame) { |
| 113 frame_ = frame; | 113 frame_ = frame; |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 if (sender == close_button_) | 388 if (sender == close_button_) |
| 389 frame_->Close(); | 389 frame_->Close(); |
| 390 else if (sender == maximize_button_) | 390 else if (sender == maximize_button_) |
| 391 frame_->Maximize(); | 391 frame_->Maximize(); |
| 392 else if (sender == restore_button_) | 392 else if (sender == restore_button_) |
| 393 frame_->Restore(); | 393 frame_->Restore(); |
| 394 else if (sender == minimize_button_) | 394 else if (sender == minimize_button_) |
| 395 frame_->Minimize(); | 395 frame_->Minimize(); |
| 396 } | 396 } |
| 397 | 397 |
| 398 ShellWindowViews::ShellWindowViews(ShellWindow* shell_window, | 398 NativeAppWindowViews::NativeAppWindowViews( |
| 399 const ShellWindow::CreateParams& win_params) | 399 ShellWindow* shell_window, |
| 400 const ShellWindow::CreateParams& win_params) |
| 400 : shell_window_(shell_window), | 401 : shell_window_(shell_window), |
| 401 web_view_(NULL), | 402 web_view_(NULL), |
| 402 is_fullscreen_(false), | 403 is_fullscreen_(false), |
| 403 frameless_(win_params.frame == ShellWindow::CreateParams::FRAME_NONE) { | 404 frameless_(win_params.frame == ShellWindow::CreateParams::FRAME_NONE) { |
| 404 window_ = new views::Widget; | 405 window_ = new views::Widget; |
| 405 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 406 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 406 params.delegate = this; | 407 params.delegate = this; |
| 407 params.remove_standard_frame = true; | 408 params.remove_standard_frame = true; |
| 408 params.use_system_default_icon = true; | 409 params.use_system_default_icon = true; |
| 409 minimum_size_ = win_params.minimum_size; | 410 minimum_size_ = win_params.minimum_size; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 430 extension_keybinding_registry_.reset( | 431 extension_keybinding_registry_.reset( |
| 431 new ExtensionKeybindingRegistryViews(shell_window_->profile(), | 432 new ExtensionKeybindingRegistryViews(shell_window_->profile(), |
| 432 window_->GetFocusManager(), | 433 window_->GetFocusManager(), |
| 433 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, | 434 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, |
| 434 shell_window_)); | 435 shell_window_)); |
| 435 | 436 |
| 436 OnViewWasResized(); | 437 OnViewWasResized(); |
| 437 window_->AddObserver(this); | 438 window_->AddObserver(this); |
| 438 } | 439 } |
| 439 | 440 |
| 440 views::View* ShellWindowViews::GetInitiallyFocusedView() { | 441 views::View* NativeAppWindowViews::GetInitiallyFocusedView() { |
| 441 return web_view_; | 442 return web_view_; |
| 442 } | 443 } |
| 443 | 444 |
| 444 bool ShellWindowViews::ShouldDescendIntoChildForEventHandling( | 445 bool NativeAppWindowViews::ShouldDescendIntoChildForEventHandling( |
| 445 gfx::NativeView child, | 446 gfx::NativeView child, |
| 446 const gfx::Point& location) { | 447 const gfx::Point& location) { |
| 447 #if defined(USE_AURA) | 448 #if defined(USE_AURA) |
| 448 DCHECK_EQ(child, web_view_->web_contents()->GetView()->GetNativeView()); | 449 DCHECK_EQ(child, web_view_->web_contents()->GetView()->GetNativeView()); |
| 449 // Shell window should claim mouse events that fall within the draggable | 450 // Shell window should claim mouse events that fall within the draggable |
| 450 // region. | 451 // region. |
| 451 return !draggable_region_.get() || | 452 return !draggable_region_.get() || |
| 452 !draggable_region_->contains(location.x(), location.y()); | 453 !draggable_region_->contains(location.x(), location.y()); |
| 453 #else | 454 #else |
| 454 return true; | 455 return true; |
| 455 #endif | 456 #endif |
| 456 } | 457 } |
| 457 | 458 |
| 458 void ShellWindowViews::OnFocus() { | 459 void NativeAppWindowViews::OnFocus() { |
| 459 web_view_->RequestFocus(); | 460 web_view_->RequestFocus(); |
| 460 } | 461 } |
| 461 | 462 |
| 462 void ShellWindowViews::ViewHierarchyChanged( | 463 void NativeAppWindowViews::ViewHierarchyChanged( |
| 463 bool is_add, views::View *parent, views::View *child) { | 464 bool is_add, views::View *parent, views::View *child) { |
| 464 if (is_add && child == this) { | 465 if (is_add && child == this) { |
| 465 web_view_ = new views::WebView(NULL); | 466 web_view_ = new views::WebView(NULL); |
| 466 AddChildView(web_view_); | 467 AddChildView(web_view_); |
| 467 web_view_->SetWebContents(web_contents()); | 468 web_view_->SetWebContents(web_contents()); |
| 468 } | 469 } |
| 469 } | 470 } |
| 470 | 471 |
| 471 gfx::Size ShellWindowViews::GetMinimumSize() { | 472 gfx::Size NativeAppWindowViews::GetMinimumSize() { |
| 472 return minimum_size_; | 473 return minimum_size_; |
| 473 } | 474 } |
| 474 | 475 |
| 475 gfx::Size ShellWindowViews::GetMaximumSize() { | 476 gfx::Size NativeAppWindowViews::GetMaximumSize() { |
| 476 return maximum_size_; | 477 return maximum_size_; |
| 477 } | 478 } |
| 478 | 479 |
| 479 void ShellWindowViews::SetFullscreen(bool fullscreen) { | 480 void NativeAppWindowViews::SetFullscreen(bool fullscreen) { |
| 480 is_fullscreen_ = fullscreen; | 481 is_fullscreen_ = fullscreen; |
| 481 window_->SetFullscreen(fullscreen); | 482 window_->SetFullscreen(fullscreen); |
| 482 // TODO(jeremya) we need to call RenderViewHost::ExitFullscreen() if we | 483 // TODO(jeremya) we need to call RenderViewHost::ExitFullscreen() if we |
| 483 // ever drop the window out of fullscreen in response to something that | 484 // ever drop the window out of fullscreen in response to something that |
| 484 // wasn't the app calling webkitCancelFullScreen(). | 485 // wasn't the app calling webkitCancelFullScreen(). |
| 485 } | 486 } |
| 486 | 487 |
| 487 bool ShellWindowViews::IsFullscreenOrPending() const { | 488 bool NativeAppWindowViews::IsFullscreenOrPending() const { |
| 488 return is_fullscreen_; | 489 return is_fullscreen_; |
| 489 } | 490 } |
| 490 | 491 |
| 491 ShellWindowViews::~ShellWindowViews() { | 492 NativeAppWindowViews::~NativeAppWindowViews() { |
| 492 web_view_->SetWebContents(NULL); | 493 web_view_->SetWebContents(NULL); |
| 493 } | 494 } |
| 494 | 495 |
| 495 bool ShellWindowViews::IsActive() const { | 496 bool NativeAppWindowViews::IsActive() const { |
| 496 return window_->IsActive(); | 497 return window_->IsActive(); |
| 497 } | 498 } |
| 498 | 499 |
| 499 bool ShellWindowViews::IsMaximized() const { | 500 bool NativeAppWindowViews::IsMaximized() const { |
| 500 return window_->IsMaximized(); | 501 return window_->IsMaximized(); |
| 501 } | 502 } |
| 502 | 503 |
| 503 bool ShellWindowViews::IsMinimized() const { | 504 bool NativeAppWindowViews::IsMinimized() const { |
| 504 return window_->IsMinimized(); | 505 return window_->IsMinimized(); |
| 505 } | 506 } |
| 506 | 507 |
| 507 bool ShellWindowViews::IsFullscreen() const { | 508 bool NativeAppWindowViews::IsFullscreen() const { |
| 508 return window_->IsFullscreen(); | 509 return window_->IsFullscreen(); |
| 509 } | 510 } |
| 510 | 511 |
| 511 gfx::NativeWindow ShellWindowViews::GetNativeWindow() { | 512 gfx::NativeWindow NativeAppWindowViews::GetNativeWindow() { |
| 512 return window_->GetNativeWindow(); | 513 return window_->GetNativeWindow(); |
| 513 } | 514 } |
| 514 | 515 |
| 515 gfx::Rect ShellWindowViews::GetRestoredBounds() const { | 516 gfx::Rect NativeAppWindowViews::GetRestoredBounds() const { |
| 516 return window_->GetRestoredBounds(); | 517 return window_->GetRestoredBounds(); |
| 517 } | 518 } |
| 518 | 519 |
| 519 gfx::Rect ShellWindowViews::GetBounds() const { | 520 gfx::Rect NativeAppWindowViews::GetBounds() const { |
| 520 return window_->GetWindowBoundsInScreen(); | 521 return window_->GetWindowBoundsInScreen(); |
| 521 } | 522 } |
| 522 | 523 |
| 523 void ShellWindowViews::Show() { | 524 void NativeAppWindowViews::Show() { |
| 524 if (window_->IsVisible()) { | 525 if (window_->IsVisible()) { |
| 525 window_->Activate(); | 526 window_->Activate(); |
| 526 return; | 527 return; |
| 527 } | 528 } |
| 528 | 529 |
| 529 window_->Show(); | 530 window_->Show(); |
| 530 } | 531 } |
| 531 | 532 |
| 532 void ShellWindowViews::ShowInactive() { | 533 void NativeAppWindowViews::ShowInactive() { |
| 533 if (window_->IsVisible()) | 534 if (window_->IsVisible()) |
| 534 return; | 535 return; |
| 535 window_->ShowInactive(); | 536 window_->ShowInactive(); |
| 536 } | 537 } |
| 537 | 538 |
| 538 void ShellWindowViews::Hide() { | 539 void NativeAppWindowViews::Hide() { |
| 539 window_->Hide(); | 540 window_->Hide(); |
| 540 } | 541 } |
| 541 | 542 |
| 542 void ShellWindowViews::Close() { | 543 void NativeAppWindowViews::Close() { |
| 543 window_->Close(); | 544 window_->Close(); |
| 544 } | 545 } |
| 545 | 546 |
| 546 void ShellWindowViews::Activate() { | 547 void NativeAppWindowViews::Activate() { |
| 547 window_->Activate(); | 548 window_->Activate(); |
| 548 } | 549 } |
| 549 | 550 |
| 550 void ShellWindowViews::Deactivate() { | 551 void NativeAppWindowViews::Deactivate() { |
| 551 window_->Deactivate(); | 552 window_->Deactivate(); |
| 552 } | 553 } |
| 553 | 554 |
| 554 void ShellWindowViews::Maximize() { | 555 void NativeAppWindowViews::Maximize() { |
| 555 window_->Maximize(); | 556 window_->Maximize(); |
| 556 } | 557 } |
| 557 | 558 |
| 558 void ShellWindowViews::Minimize() { | 559 void NativeAppWindowViews::Minimize() { |
| 559 window_->Minimize(); | 560 window_->Minimize(); |
| 560 } | 561 } |
| 561 | 562 |
| 562 void ShellWindowViews::Restore() { | 563 void NativeAppWindowViews::Restore() { |
| 563 window_->Restore(); | 564 window_->Restore(); |
| 564 } | 565 } |
| 565 | 566 |
| 566 void ShellWindowViews::SetBounds(const gfx::Rect& bounds) { | 567 void NativeAppWindowViews::SetBounds(const gfx::Rect& bounds) { |
| 567 GetWidget()->SetBounds(bounds); | 568 GetWidget()->SetBounds(bounds); |
| 568 } | 569 } |
| 569 | 570 |
| 570 void ShellWindowViews::FlashFrame(bool flash) { | 571 void NativeAppWindowViews::FlashFrame(bool flash) { |
| 571 window_->FlashFrame(flash); | 572 window_->FlashFrame(flash); |
| 572 } | 573 } |
| 573 | 574 |
| 574 bool ShellWindowViews::IsAlwaysOnTop() const { | 575 bool NativeAppWindowViews::IsAlwaysOnTop() const { |
| 575 return false; | 576 return false; |
| 576 } | 577 } |
| 577 | 578 |
| 578 void ShellWindowViews::DeleteDelegate() { | 579 void NativeAppWindowViews::DeleteDelegate() { |
| 579 window_->RemoveObserver(this); | 580 window_->RemoveObserver(this); |
| 580 shell_window_->OnNativeClose(); | 581 shell_window_->OnNativeClose(); |
| 581 } | 582 } |
| 582 | 583 |
| 583 bool ShellWindowViews::CanResize() const { | 584 bool NativeAppWindowViews::CanResize() const { |
| 584 return maximum_size_.IsEmpty() || minimum_size_ != maximum_size_; | 585 return maximum_size_.IsEmpty() || minimum_size_ != maximum_size_; |
| 585 } | 586 } |
| 586 | 587 |
| 587 bool ShellWindowViews::CanMaximize() const { | 588 bool NativeAppWindowViews::CanMaximize() const { |
| 588 return maximum_size_.IsEmpty(); | 589 return maximum_size_.IsEmpty(); |
| 589 } | 590 } |
| 590 | 591 |
| 591 views::View* ShellWindowViews::GetContentsView() { | 592 views::View* NativeAppWindowViews::GetContentsView() { |
| 592 return this; | 593 return this; |
| 593 } | 594 } |
| 594 | 595 |
| 595 views::NonClientFrameView* ShellWindowViews::CreateNonClientFrameView( | 596 views::NonClientFrameView* NativeAppWindowViews::CreateNonClientFrameView( |
| 596 views::Widget* widget) { | 597 views::Widget* widget) { |
| 597 #if defined(USE_ASH) | 598 #if defined(USE_ASH) |
| 598 if (chrome::IsNativeViewInAsh(widget->GetNativeView()) && !frameless_) { | 599 if (chrome::IsNativeViewInAsh(widget->GetNativeView()) && !frameless_) { |
| 599 ash::CustomFrameViewAsh* frame = new ash::CustomFrameViewAsh(); | 600 ash::CustomFrameViewAsh* frame = new ash::CustomFrameViewAsh(); |
| 600 frame->Init(widget); | 601 frame->Init(widget); |
| 601 return frame; | 602 return frame; |
| 602 } | 603 } |
| 603 #endif | 604 #endif |
| 604 ShellWindowFrameView* frame_view = new ShellWindowFrameView(this); | 605 ShellWindowFrameView* frame_view = new ShellWindowFrameView(this); |
| 605 frame_view->Init(window_); | 606 frame_view->Init(window_); |
| 606 return frame_view; | 607 return frame_view; |
| 607 } | 608 } |
| 608 | 609 |
| 609 string16 ShellWindowViews::GetWindowTitle() const { | 610 string16 NativeAppWindowViews::GetWindowTitle() const { |
| 610 return shell_window_->GetTitle(); | 611 return shell_window_->GetTitle(); |
| 611 } | 612 } |
| 612 | 613 |
| 613 views::Widget* ShellWindowViews::GetWidget() { | 614 views::Widget* NativeAppWindowViews::GetWidget() { |
| 614 return window_; | 615 return window_; |
| 615 } | 616 } |
| 616 | 617 |
| 617 const views::Widget* ShellWindowViews::GetWidget() const { | 618 const views::Widget* NativeAppWindowViews::GetWidget() const { |
| 618 return window_; | 619 return window_; |
| 619 } | 620 } |
| 620 | 621 |
| 621 void ShellWindowViews::OnViewWasResized() { | 622 void NativeAppWindowViews::OnViewWasResized() { |
| 622 // TODO(jeremya): this doesn't seem like a terribly elegant way to keep the | 623 // TODO(jeremya): this doesn't seem like a terribly elegant way to keep the |
| 623 // window shape in sync. | 624 // window shape in sync. |
| 624 #if defined(OS_WIN) && !defined(USE_AURA) | 625 #if defined(OS_WIN) && !defined(USE_AURA) |
| 625 // Set the window shape of the RWHV. | 626 // Set the window shape of the RWHV. |
| 626 DCHECK(window_); | 627 DCHECK(window_); |
| 627 DCHECK(web_view_); | 628 DCHECK(web_view_); |
| 628 gfx::Size sz = web_view_->size(); | 629 gfx::Size sz = web_view_->size(); |
| 629 int height = sz.height(), width = sz.width(); | 630 int height = sz.height(), width = sz.width(); |
| 630 int radius = 1; | 631 int radius = 1; |
| 631 gfx::Path path; | 632 gfx::Path path; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 SkRegion::kUnion_Op); | 664 SkRegion::kUnion_Op); |
| 664 rgn->op(0, height - kResizeInsideBoundsSize, width, height, | 665 rgn->op(0, height - kResizeInsideBoundsSize, width, height, |
| 665 SkRegion::kUnion_Op); | 666 SkRegion::kUnion_Op); |
| 666 } | 667 } |
| 667 } | 668 } |
| 668 if (web_contents()->GetRenderViewHost()->GetView()) | 669 if (web_contents()->GetRenderViewHost()->GetView()) |
| 669 web_contents()->GetRenderViewHost()->GetView()->SetClickthroughRegion(rgn); | 670 web_contents()->GetRenderViewHost()->GetView()->SetClickthroughRegion(rgn); |
| 670 #endif | 671 #endif |
| 671 } | 672 } |
| 672 | 673 |
| 673 gfx::ImageSkia ShellWindowViews::GetWindowAppIcon() { | 674 gfx::ImageSkia NativeAppWindowViews::GetWindowAppIcon() { |
| 674 gfx::Image app_icon = shell_window_->app_icon(); | 675 gfx::Image app_icon = shell_window_->app_icon(); |
| 675 if (app_icon.IsEmpty()) | 676 if (app_icon.IsEmpty()) |
| 676 return GetWindowIcon(); | 677 return GetWindowIcon(); |
| 677 else | 678 else |
| 678 return *app_icon.ToImageSkia(); | 679 return *app_icon.ToImageSkia(); |
| 679 } | 680 } |
| 680 | 681 |
| 681 gfx::ImageSkia ShellWindowViews::GetWindowIcon() { | 682 gfx::ImageSkia NativeAppWindowViews::GetWindowIcon() { |
| 682 content::WebContents* web_contents = shell_window_->web_contents(); | 683 content::WebContents* web_contents = shell_window_->web_contents(); |
| 683 if (web_contents) { | 684 if (web_contents) { |
| 684 FaviconTabHelper* favicon_tab_helper = | 685 FaviconTabHelper* favicon_tab_helper = |
| 685 FaviconTabHelper::FromWebContents(web_contents); | 686 FaviconTabHelper::FromWebContents(web_contents); |
| 686 gfx::Image app_icon = favicon_tab_helper->GetFavicon(); | 687 gfx::Image app_icon = favicon_tab_helper->GetFavicon(); |
| 687 if (!app_icon.IsEmpty()) | 688 if (!app_icon.IsEmpty()) |
| 688 return *app_icon.ToImageSkia(); | 689 return *app_icon.ToImageSkia(); |
| 689 } | 690 } |
| 690 return gfx::ImageSkia(); | 691 return gfx::ImageSkia(); |
| 691 } | 692 } |
| 692 | 693 |
| 693 bool ShellWindowViews::ShouldShowWindowTitle() const { | 694 bool NativeAppWindowViews::ShouldShowWindowTitle() const { |
| 694 return false; | 695 return false; |
| 695 } | 696 } |
| 696 | 697 |
| 697 void ShellWindowViews::OnWidgetMove() { | 698 void NativeAppWindowViews::OnWidgetMove() { |
| 698 shell_window_->OnNativeWindowChanged(); | 699 shell_window_->OnNativeWindowChanged(); |
| 699 } | 700 } |
| 700 | 701 |
| 701 void ShellWindowViews::OnWidgetVisibilityChanged(views::Widget* widget, | 702 void NativeAppWindowViews::OnWidgetVisibilityChanged(views::Widget* widget, |
| 702 bool visible) { | 703 bool visible) { |
| 703 shell_window_->OnNativeWindowChanged(); | 704 shell_window_->OnNativeWindowChanged(); |
| 704 } | 705 } |
| 705 | 706 |
| 706 void ShellWindowViews::OnWidgetActivationChanged(views::Widget* widget, | 707 void NativeAppWindowViews::OnWidgetActivationChanged(views::Widget* widget, |
| 707 bool active) { | 708 bool active) { |
| 708 shell_window_->OnNativeWindowChanged(); | 709 shell_window_->OnNativeWindowChanged(); |
| 709 } | 710 } |
| 710 | 711 |
| 711 void ShellWindowViews::Layout() { | 712 void NativeAppWindowViews::Layout() { |
| 712 DCHECK(web_view_); | 713 DCHECK(web_view_); |
| 713 web_view_->SetBounds(0, 0, width(), height()); | 714 web_view_->SetBounds(0, 0, width(), height()); |
| 714 OnViewWasResized(); | 715 OnViewWasResized(); |
| 715 } | 716 } |
| 716 | 717 |
| 717 void ShellWindowViews::UpdateWindowIcon() { | 718 void NativeAppWindowViews::UpdateWindowIcon() { |
| 718 window_->UpdateWindowIcon(); | 719 window_->UpdateWindowIcon(); |
| 719 } | 720 } |
| 720 | 721 |
| 721 void ShellWindowViews::UpdateWindowTitle() { | 722 void NativeAppWindowViews::UpdateWindowTitle() { |
| 722 window_->UpdateWindowTitle(); | 723 window_->UpdateWindowTitle(); |
| 723 } | 724 } |
| 724 | 725 |
| 725 void ShellWindowViews::UpdateDraggableRegions( | 726 void NativeAppWindowViews::UpdateDraggableRegions( |
| 726 const std::vector<extensions::DraggableRegion>& regions) { | 727 const std::vector<extensions::DraggableRegion>& regions) { |
| 727 // Draggable region is not supported for non-frameless window. | 728 // Draggable region is not supported for non-frameless window. |
| 728 if (!frameless_) | 729 if (!frameless_) |
| 729 return; | 730 return; |
| 730 | 731 |
| 731 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions)); | 732 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions)); |
| 732 OnViewWasResized(); | 733 OnViewWasResized(); |
| 733 } | 734 } |
| 734 | 735 |
| 735 void ShellWindowViews::HandleKeyboardEvent( | 736 void NativeAppWindowViews::HandleKeyboardEvent( |
| 736 const content::NativeWebKeyboardEvent& event) { | 737 const content::NativeWebKeyboardEvent& event) { |
| 737 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, | 738 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, |
| 738 GetFocusManager()); | 739 GetFocusManager()); |
| 739 } | 740 } |
| 740 | 741 |
| 741 void ShellWindowViews::RenderViewHostChanged() { | 742 void NativeAppWindowViews::RenderViewHostChanged() { |
| 742 OnViewWasResized(); | 743 OnViewWasResized(); |
| 743 } | 744 } |
| 744 | 745 |
| 745 void ShellWindowViews::SaveWindowPlacement(const gfx::Rect& bounds, | 746 void NativeAppWindowViews::SaveWindowPlacement(const gfx::Rect& bounds, |
| 746 ui::WindowShowState show_state) { | 747 ui::WindowShowState show_state) { |
| 747 views::WidgetDelegate::SaveWindowPlacement(bounds, show_state); | 748 views::WidgetDelegate::SaveWindowPlacement(bounds, show_state); |
| 748 shell_window_->OnNativeWindowChanged(); | 749 shell_window_->OnNativeWindowChanged(); |
| 749 } | 750 } |
| 750 | 751 |
| 751 // static | 752 // static |
| 752 NativeShellWindow* NativeShellWindow::Create( | 753 NativeAppWindow* NativeAppWindow::Create( |
| 753 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { | 754 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { |
| 754 return new ShellWindowViews(shell_window, params); | 755 return new NativeAppWindowViews(shell_window, params); |
| 755 } | 756 } |
| OLD | NEW |