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