| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/ui/panels/panel.h" | 8 #include "chrome/browser/ui/panels/panel.h" |
| 9 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" | 9 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" |
| 10 #include "chrome/browser/ui/panels/panel_manager.h" | 10 #include "chrome/browser/ui/panels/panel_manager.h" |
| 11 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" | 11 #include "chrome/browser/ui/panels/panel_mouse_watcher_win.h" |
| 12 #include "chrome/browser/ui/views/frame/browser_frame.h" | 12 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 13 #include "grit/chromium_strings.h" | 13 #include "grit/chromium_strings.h" |
| 14 #include "ui/base/animation/slide_animation.h" | 14 #include "ui/base/animation/slide_animation.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "views/widget/widget.h" | 16 #include "views/widget/widget.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 // This value is experimental and subjective. | 19 // This value is experimental and subjective. |
| 20 const int kSetBoundsAnimationMs = 180; | 20 const int kSetBoundsAnimationMs = 180; |
| 21 | 21 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 44 restored_height_(bounds.height()), | 44 restored_height_(bounds.height()), |
| 45 closed_(false), | 45 closed_(false), |
| 46 focused_(false), | 46 focused_(false), |
| 47 mouse_pressed_(false), | 47 mouse_pressed_(false), |
| 48 mouse_dragging_state_(NO_DRAGGING), | 48 mouse_dragging_state_(NO_DRAGGING), |
| 49 is_drawing_attention_(false), | 49 is_drawing_attention_(false), |
| 50 old_focused_view_(NULL) { | 50 old_focused_view_(NULL) { |
| 51 } | 51 } |
| 52 | 52 |
| 53 PanelBrowserView::~PanelBrowserView() { | 53 PanelBrowserView::~PanelBrowserView() { |
| 54 if (PanelMouseWatcher::GetInstance()->IsSubscribed(this)) | |
| 55 PanelMouseWatcher::GetInstance()->RemoveSubscriber(this); | |
| 56 } | 54 } |
| 57 | 55 |
| 58 void PanelBrowserView::Init() { | 56 void PanelBrowserView::Init() { |
| 59 BrowserView::Init(); | 57 BrowserView::Init(); |
| 60 | 58 |
| 61 GetWidget()->SetAlwaysOnTop(true); | 59 GetWidget()->SetAlwaysOnTop(true); |
| 62 GetWidget()->non_client_view()->SetAccessibleName( | 60 GetWidget()->non_client_view()->SetAccessibleName( |
| 63 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 61 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 64 } | 62 } |
| 65 | 63 |
| 66 void PanelBrowserView::Close() { | 64 void PanelBrowserView::Close() { |
| 67 GetWidget()->RemoveObserver(this); | 65 GetWidget()->RemoveObserver(this); |
| 68 closed_ = true; | 66 closed_ = true; |
| 69 | 67 |
| 70 // Cancel any currently running animation since we're closing down. | 68 // Cancel any currently running animation since we're closing down. |
| 71 if (bounds_animator_.get()) | 69 if (bounds_animator_.get()) |
| 72 bounds_animator_.reset(); | 70 bounds_animator_.reset(); |
| 73 | 71 |
| 74 ::BrowserView::Close(); | 72 ::BrowserView::Close(); |
| 73 |
| 74 // Stop the global mouse watcher only if we do not have any panels up. |
| 75 #if defined(OS_WIN) |
| 76 if (panel_->manager()->num_panels() == 1) |
| 77 StopMouseWatcher(); |
| 78 #endif |
| 75 } | 79 } |
| 76 | 80 |
| 77 bool PanelBrowserView::CanResize() const { | 81 bool PanelBrowserView::CanResize() const { |
| 78 return false; | 82 return false; |
| 79 } | 83 } |
| 80 | 84 |
| 81 bool PanelBrowserView::CanMaximize() const { | 85 bool PanelBrowserView::CanMaximize() const { |
| 82 return false; | 86 return false; |
| 83 } | 87 } |
| 84 | 88 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 208 |
| 205 void PanelBrowserView::SetPanelBounds(const gfx::Rect& bounds) { | 209 void PanelBrowserView::SetPanelBounds(const gfx::Rect& bounds) { |
| 206 SetBounds(bounds); | 210 SetBounds(bounds); |
| 207 } | 211 } |
| 208 | 212 |
| 209 void PanelBrowserView::OnPanelExpansionStateChanged( | 213 void PanelBrowserView::OnPanelExpansionStateChanged( |
| 210 Panel::ExpansionState expansion_state) { | 214 Panel::ExpansionState expansion_state) { |
| 211 int height; | 215 int height; |
| 212 switch (expansion_state) { | 216 switch (expansion_state) { |
| 213 case Panel::EXPANDED: | 217 case Panel::EXPANDED: |
| 214 PanelMouseWatcher::GetInstance()->RemoveSubscriber(this); | |
| 215 height = restored_height_; | 218 height = restored_height_; |
| 216 break; | 219 break; |
| 217 case Panel::TITLE_ONLY: | 220 case Panel::TITLE_ONLY: |
| 218 height = GetFrameView()->NonClientTopBorderHeight(); | 221 height = GetFrameView()->NonClientTopBorderHeight(); |
| 219 break; | 222 break; |
| 220 case Panel::MINIMIZED: | 223 case Panel::MINIMIZED: |
| 221 height = PanelManager::minimized_panel_height(); | 224 height = PanelManager::minimized_panel_height(); |
| 222 PanelMouseWatcher::GetInstance()->AddSubscriber(this); | 225 |
| 226 // Start the mouse watcher so that we can bring up the minimized panels. |
| 227 // TODO(jianli): Need to support mouse watching in ChromeOS. |
| 228 #if defined(OS_WIN) |
| 229 EnsureMouseWatcherStarted(); |
| 230 #endif |
| 223 break; | 231 break; |
| 224 default: | 232 default: |
| 225 NOTREACHED(); | 233 NOTREACHED(); |
| 226 height = restored_height_; | 234 height = restored_height_; |
| 227 break; | 235 break; |
| 228 } | 236 } |
| 229 | 237 |
| 230 int bottom = panel_->manager()->GetBottomPositionForExpansionState( | 238 int bottom = panel_->manager()->GetBottomPositionForExpansionState( |
| 231 expansion_state); | 239 expansion_state); |
| 232 gfx::Rect bounds = bounds_; | 240 gfx::Rect bounds = bounds_; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 }; | 473 }; |
| 466 | 474 |
| 467 // static | 475 // static |
| 468 NativePanelTesting* NativePanelTesting::Create(NativePanel* native_panel) { | 476 NativePanelTesting* NativePanelTesting::Create(NativePanel* native_panel) { |
| 469 return new NativePanelTestingWin(static_cast<PanelBrowserView*>( | 477 return new NativePanelTestingWin(static_cast<PanelBrowserView*>( |
| 470 native_panel)); | 478 native_panel)); |
| 471 } | 479 } |
| 472 | 480 |
| 473 // static | 481 // static |
| 474 PanelMouseWatcher* NativePanelTesting::GetPanelMouseWatcherInstance() { | 482 PanelMouseWatcher* NativePanelTesting::GetPanelMouseWatcherInstance() { |
| 475 return PanelMouseWatcher::GetInstance(); | 483 return NULL; |
| 476 } | 484 } |
| 477 | 485 |
| 478 NativePanelTestingWin::NativePanelTestingWin( | 486 NativePanelTestingWin::NativePanelTestingWin( |
| 479 PanelBrowserView* panel_browser_view) : | 487 PanelBrowserView* panel_browser_view) : |
| 480 panel_browser_view_(panel_browser_view) { | 488 panel_browser_view_(panel_browser_view) { |
| 481 } | 489 } |
| 482 | 490 |
| 483 void NativePanelTestingWin::PressLeftMouseButtonTitlebar( | 491 void NativePanelTestingWin::PressLeftMouseButtonTitlebar( |
| 484 const gfx::Point& point) { | 492 const gfx::Point& point) { |
| 485 panel_browser_view_->OnTitlebarMousePressed(point); | 493 panel_browser_view_->OnTitlebarMousePressed(point); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 501 void NativePanelTestingWin::CancelDragTitlebar() { | 509 void NativePanelTestingWin::CancelDragTitlebar() { |
| 502 panel_browser_view_->OnTitlebarMouseCaptureLost(); | 510 panel_browser_view_->OnTitlebarMouseCaptureLost(); |
| 503 } | 511 } |
| 504 | 512 |
| 505 void NativePanelTestingWin::FinishDragTitlebar() { | 513 void NativePanelTestingWin::FinishDragTitlebar() { |
| 506 panel_browser_view_->OnTitlebarMouseReleased(); | 514 panel_browser_view_->OnTitlebarMouseReleased(); |
| 507 } | 515 } |
| 508 | 516 |
| 509 void NativePanelTestingWin::SetMousePositionForMinimizeRestore( | 517 void NativePanelTestingWin::SetMousePositionForMinimizeRestore( |
| 510 const gfx::Point& hover_point) { | 518 const gfx::Point& hover_point) { |
| 511 PanelMouseWatcher::GetInstance()->HandleMouseMovement(hover_point); | 519 NOTIMPLEMENTED(); |
| 512 MessageLoopForUI::current()->RunAllPending(); | |
| 513 } | 520 } |
| 514 | 521 |
| 515 int NativePanelTestingWin::TitleOnlyHeight() const { | 522 int NativePanelTestingWin::TitleOnlyHeight() const { |
| 516 return panel_browser_view_->GetFrameView()->NonClientTopBorderHeight(); | 523 NOTIMPLEMENTED(); |
| 524 return -1; |
| 517 } | 525 } |
| OLD | NEW |