| 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/panels/panel_browser_view.h" | 5 #include "chrome/browser/ui/panels/panel_browser_view.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/browser/native_window_notification_source.h" | 9 #include "chrome/browser/native_window_notification_source.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| 11 #include "chrome/browser/ui/panels/display_settings_provider.h" | 11 #include "chrome/browser/ui/panels/display_settings_provider.h" |
| 12 #include "chrome/browser/ui/panels/panel.h" | 12 #include "chrome/browser/ui/panels/panel.h" |
| 13 #include "chrome/browser/ui/panels/panel_bounds_animation.h" | 13 #include "chrome/browser/ui/panels/panel_bounds_animation.h" |
| 14 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" | 14 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" |
| 15 #include "chrome/browser/ui/panels/panel_manager.h" | 15 #include "chrome/browser/ui/panels/panel_manager.h" |
| 16 #include "chrome/browser/ui/panels/panel_strip.h" | 16 #include "chrome/browser/ui/panels/panel_strip.h" |
| 17 #include "chrome/browser/ui/views/frame/browser_frame.h" | 17 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 18 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "content/public/browser/native_web_keyboard_event.h" | 19 #include "content/public/browser/native_web_keyboard_event.h" |
| 20 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
| 21 #include "grit/chromium_strings.h" | 21 #include "grit/chromium_strings.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 23 #include "ui/gfx/canvas.h" |
| 23 #include "ui/views/controls/button/image_button.h" | 24 #include "ui/views/controls/button/image_button.h" |
| 24 #include "ui/views/controls/label.h" | 25 #include "ui/views/controls/label.h" |
| 25 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
| 26 | 27 |
| 28 #if defined(OS_WIN) && !defined(USE_ASH) && !defined(USE_AURA) |
| 29 #include "base/win/windows_version.h" |
| 30 #include "chrome/browser/ui/panels/taskbar_window_thumbnailer_win.h" |
| 31 #endif |
| 32 |
| 27 using content::NativeWebKeyboardEvent; | 33 using content::NativeWebKeyboardEvent; |
| 28 using content::WebContents; | 34 using content::WebContents; |
| 29 | 35 |
| 30 NativePanel* Panel::CreateNativePanel(Browser* browser, Panel* panel, | 36 NativePanel* Panel::CreateNativePanel(Browser* browser, Panel* panel, |
| 31 const gfx::Rect& bounds) { | 37 const gfx::Rect& bounds) { |
| 32 PanelBrowserView* view = new PanelBrowserView(browser, panel, bounds); | 38 PanelBrowserView* view = new PanelBrowserView(browser, panel, bounds); |
| 33 (new BrowserFrame(view))->InitBrowserFrame(); | 39 (new BrowserFrame(view))->InitBrowserFrame(); |
| 34 return view; | 40 return view; |
| 35 } | 41 } |
| 36 | 42 |
| 37 PanelBrowserView::PanelBrowserView(Browser* browser, Panel* panel, | 43 PanelBrowserView::PanelBrowserView(Browser* browser, Panel* panel, |
| 38 const gfx::Rect& bounds) | 44 const gfx::Rect& bounds) |
| 39 : BrowserView(browser), | 45 : BrowserView(browser), |
| 40 panel_(panel), | 46 panel_(panel), |
| 41 bounds_(bounds), | 47 bounds_(bounds), |
| 42 closed_(false), | 48 closed_(false), |
| 43 focused_(false), | 49 focused_(false), |
| 44 mouse_pressed_(false), | 50 mouse_pressed_(false), |
| 45 mouse_dragging_state_(NO_DRAGGING), | 51 mouse_dragging_state_(NO_DRAGGING), |
| 46 is_drawing_attention_(false), | 52 is_drawing_attention_(false), |
| 53 force_to_paint_as_inactive_(false), |
| 54 #if defined(OS_WIN) && !defined(USE_ASH) && !defined(USE_AURA) |
| 55 old_focused_view_(NULL), |
| 56 thumbnailer_(NULL) { |
| 57 #else |
| 47 old_focused_view_(NULL) { | 58 old_focused_view_(NULL) { |
| 59 #endif |
| 48 } | 60 } |
| 49 | 61 |
| 50 PanelBrowserView::~PanelBrowserView() { | 62 PanelBrowserView::~PanelBrowserView() { |
| 51 } | 63 } |
| 52 | 64 |
| 53 void PanelBrowserView::Init() { | 65 void PanelBrowserView::Init() { |
| 54 if (!panel_->manager()->display_settings_provider()->is_full_screen()) { | 66 if (!panel_->manager()->display_settings_provider()->is_full_screen()) { |
| 55 // TODO(prasadt): Implement this code. | 67 // TODO(prasadt): Implement this code. |
| 56 // HideThePanel. | 68 // HideThePanel. |
| 57 } | 69 } |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 return bounds_animator_.get() && bounds_animator_->is_animating(); | 526 return bounds_animator_.get() && bounds_animator_->is_animating(); |
| 515 } | 527 } |
| 516 | 528 |
| 517 void PanelBrowserView::EnableResizeByMouse(bool enable) { | 529 void PanelBrowserView::EnableResizeByMouse(bool enable) { |
| 518 } | 530 } |
| 519 | 531 |
| 520 void PanelBrowserView::UpdatePanelMinimizeRestoreButtonVisibility() { | 532 void PanelBrowserView::UpdatePanelMinimizeRestoreButtonVisibility() { |
| 521 GetFrameView()->UpdateTitleBarMinimizeRestoreButtonVisibility(); | 533 GetFrameView()->UpdateTitleBarMinimizeRestoreButtonVisibility(); |
| 522 } | 534 } |
| 523 | 535 |
| 524 | |
| 525 #if defined(OS_WIN) && !defined(USE_AURA) | 536 #if defined(OS_WIN) && !defined(USE_AURA) |
| 526 void PanelBrowserView::UpdateWindowAttribute(int attribute_index, | 537 void PanelBrowserView::UpdateWindowAttribute(int attribute_index, |
| 527 int attribute_value, | 538 int attribute_value, |
| 528 bool to_set) { | 539 bool to_set) { |
| 529 gfx::NativeWindow native_window = GetNativePanelHandle(); | 540 gfx::NativeWindow native_window = GetNativePanelHandle(); |
| 530 int value = ::GetWindowLong(native_window, attribute_index); | 541 int value = ::GetWindowLong(native_window, attribute_index); |
| 531 int expected_value; | 542 int expected_value; |
| 532 if (to_set) | 543 if (to_set) |
| 533 expected_value = value | attribute_value; | 544 expected_value = value | attribute_value; |
| 534 else | 545 else |
| 535 expected_value = value & ~attribute_value; | 546 expected_value = value & ~attribute_value; |
| 536 if (value != expected_value) | 547 if (value != expected_value) |
| 537 ::SetWindowLong(native_window, attribute_index, expected_value); | 548 ::SetWindowLong(native_window, attribute_index, expected_value); |
| 538 } | 549 } |
| 539 #endif | 550 #endif |
| 540 | 551 |
| 552 void PanelBrowserView::PanelExpansionStateChanging( |
| 553 Panel::ExpansionState old_state, Panel::ExpansionState new_state) { |
| 554 #if defined(OS_WIN) && !defined(USE_ASH) && !defined(USE_AURA) |
| 555 // Live preview is only available since Windows 7. |
| 556 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
| 557 return; |
| 558 |
| 559 bool is_minimized = old_state != Panel::EXPANDED; |
| 560 bool will_be_minimized = new_state != Panel::EXPANDED; |
| 561 if (is_minimized == will_be_minimized) |
| 562 return; |
| 563 |
| 564 HWND native_window = GetNativeHandle(); |
| 565 |
| 566 if (!thumbnail_subclass_.get()) { |
| 567 thumbnail_subclass_.reset(new ui::HWNDSubclass(native_window)); |
| 568 // thumbnailer_ is owned by thumbnail_subclass_. |
| 569 thumbnailer_ = new TaskbarWindowThumbnailerWin(native_window); |
| 570 thumbnail_subclass_->SetFilter(thumbnailer_); |
| 571 } |
| 572 |
| 573 // Cache the image at this point. |
| 574 if (will_be_minimized) { |
| 575 // If the panel is still active (we will deactivate the minimizd panel at |
| 576 // later time), we need to paint it immediately as inactive so that we can |
| 577 // take a snapshot of inactive panel. |
| 578 if (focused_) { |
| 579 force_to_paint_as_inactive_ = true; |
| 580 ::RedrawWindow(native_window, NULL, NULL, |
| 581 RDW_NOCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW); |
| 582 } |
| 583 |
| 584 thumbnailer_->Start(); |
| 585 } else { |
| 586 force_to_paint_as_inactive_ = false; |
| 587 thumbnailer_->Stop(); |
| 588 } |
| 589 |
| 590 #endif |
| 591 } |
| 592 |
| 541 // NativePanelTesting implementation. | 593 // NativePanelTesting implementation. |
| 542 class NativePanelTestingWin : public NativePanelTesting { | 594 class NativePanelTestingWin : public NativePanelTesting { |
| 543 public: | 595 public: |
| 544 explicit NativePanelTestingWin(PanelBrowserView* panel_browser_view); | 596 explicit NativePanelTestingWin(PanelBrowserView* panel_browser_view); |
| 545 | 597 |
| 546 private: | 598 private: |
| 547 virtual void PressLeftMouseButtonTitlebar( | 599 virtual void PressLeftMouseButtonTitlebar( |
| 548 const gfx::Point& mouse_location, panel::ClickModifier modifier) OVERRIDE; | 600 const gfx::Point& mouse_location, panel::ClickModifier modifier) OVERRIDE; |
| 549 virtual void ReleaseMouseButtonTitlebar( | 601 virtual void ReleaseMouseButtonTitlebar( |
| 550 panel::ClickModifier modifier) OVERRIDE; | 602 panel::ClickModifier modifier) OVERRIDE; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 return frame_view->close_button_->visible(); | 684 return frame_view->close_button_->visible(); |
| 633 case MINIMIZE_BUTTON: | 685 case MINIMIZE_BUTTON: |
| 634 return frame_view->minimize_button_->visible(); | 686 return frame_view->minimize_button_->visible(); |
| 635 case RESTORE_BUTTON: | 687 case RESTORE_BUTTON: |
| 636 return frame_view->restore_button_->visible(); | 688 return frame_view->restore_button_->visible(); |
| 637 default: | 689 default: |
| 638 NOTREACHED(); | 690 NOTREACHED(); |
| 639 } | 691 } |
| 640 return false; | 692 return false; |
| 641 } | 693 } |
| OLD | NEW |