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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chrome/browser/ui/panels/panel.h" | 9 #include "chrome/browser/ui/panels/panel.h" |
10 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" | 10 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 GetWidget()->RemoveObserver(this); | 68 GetWidget()->RemoveObserver(this); |
69 closed_ = true; | 69 closed_ = true; |
70 | 70 |
71 // Cancel any currently running animation since we're closing down. | 71 // Cancel any currently running animation since we're closing down. |
72 if (bounds_animator_.get()) | 72 if (bounds_animator_.get()) |
73 bounds_animator_.reset(); | 73 bounds_animator_.reset(); |
74 | 74 |
75 ::BrowserView::Close(); | 75 ::BrowserView::Close(); |
76 } | 76 } |
77 | 77 |
78 void PanelBrowserView::Deactivate() { | |
79 if (!IsActive()) | |
80 return; | |
81 | |
82 #if defined(OS_WIN) | |
83 gfx::NativeWindow native_window = NULL; | |
84 BrowserWindow* browser_window = | |
85 panel_->manager()->GetNextPanelToActivate(panel_.get()); | |
Dmitry Titov
2011/10/07 20:29:15
This can be split in 2 methods - platform-independ
jianli
2011/10/07 22:01:54
As discussed, we keep as it is since the only thin
| |
86 if (browser_window) | |
87 native_window = browser_window->GetNativeHandle(); | |
88 else | |
89 native_window = ::GetDesktopWindow(); | |
90 if (native_window) | |
91 ::SetForegroundWindow(native_window); | |
92 else | |
93 ::SetFocus(NULL); | |
94 #else | |
95 // TODO(jianli): to be implemented for other platform. | |
96 BrowserView::Deactivate(); | |
97 #endif | |
98 } | |
99 | |
78 bool PanelBrowserView::CanResize() const { | 100 bool PanelBrowserView::CanResize() const { |
79 return false; | 101 return false; |
80 } | 102 } |
81 | 103 |
82 bool PanelBrowserView::CanMaximize() const { | 104 bool PanelBrowserView::CanMaximize() const { |
83 return false; | 105 return false; |
84 } | 106 } |
85 | 107 |
86 void PanelBrowserView::SetBounds(const gfx::Rect& bounds) { | 108 void PanelBrowserView::SetBounds(const gfx::Rect& bounds) { |
87 if (bounds_ == bounds) | 109 if (bounds_ == bounds) |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 explicit NativePanelTestingWin(PanelBrowserView* panel_browser_view); | 464 explicit NativePanelTestingWin(PanelBrowserView* panel_browser_view); |
443 | 465 |
444 private: | 466 private: |
445 virtual void PressLeftMouseButtonTitlebar( | 467 virtual void PressLeftMouseButtonTitlebar( |
446 const gfx::Point& point) OVERRIDE; | 468 const gfx::Point& point) OVERRIDE; |
447 virtual void ReleaseMouseButtonTitlebar() OVERRIDE; | 469 virtual void ReleaseMouseButtonTitlebar() OVERRIDE; |
448 virtual void DragTitlebar(int delta_x, int delta_y) OVERRIDE; | 470 virtual void DragTitlebar(int delta_x, int delta_y) OVERRIDE; |
449 virtual void CancelDragTitlebar() OVERRIDE; | 471 virtual void CancelDragTitlebar() OVERRIDE; |
450 virtual void FinishDragTitlebar() OVERRIDE; | 472 virtual void FinishDragTitlebar() OVERRIDE; |
451 virtual bool VerifyDrawingAttention() const OVERRIDE; | 473 virtual bool VerifyDrawingAttention() const OVERRIDE; |
452 | 474 virtual bool VerifyTitlebarPaintedAsActive(bool as_active) OVERRIDE; |
453 | 475 |
454 PanelBrowserView* panel_browser_view_; | 476 PanelBrowserView* panel_browser_view_; |
455 }; | 477 }; |
456 | 478 |
457 // static | 479 // static |
458 NativePanelTesting* NativePanelTesting::Create(NativePanel* native_panel) { | 480 NativePanelTesting* NativePanelTesting::Create(NativePanel* native_panel) { |
459 return new NativePanelTestingWin(static_cast<PanelBrowserView*>( | 481 return new NativePanelTestingWin(static_cast<PanelBrowserView*>( |
460 native_panel)); | 482 native_panel)); |
461 } | 483 } |
462 | 484 |
(...skipping 27 matching lines...) Expand all Loading... | |
490 void NativePanelTestingWin::FinishDragTitlebar() { | 512 void NativePanelTestingWin::FinishDragTitlebar() { |
491 panel_browser_view_->OnTitlebarMouseReleased(); | 513 panel_browser_view_->OnTitlebarMouseReleased(); |
492 } | 514 } |
493 | 515 |
494 bool NativePanelTestingWin::VerifyDrawingAttention() const { | 516 bool NativePanelTestingWin::VerifyDrawingAttention() const { |
495 PanelBrowserFrameView* frame_view = panel_browser_view_->GetFrameView(); | 517 PanelBrowserFrameView* frame_view = panel_browser_view_->GetFrameView(); |
496 SkColor attention_color = frame_view->GetTitleColor( | 518 SkColor attention_color = frame_view->GetTitleColor( |
497 PanelBrowserFrameView::PAINT_FOR_ATTENTION); | 519 PanelBrowserFrameView::PAINT_FOR_ATTENTION); |
498 return attention_color == frame_view->title_label_->GetColor(); | 520 return attention_color == frame_view->title_label_->GetColor(); |
499 } | 521 } |
522 | |
523 bool NativePanelTestingWin::VerifyTitlebarPaintedAsActive(bool as_active) { | |
524 PanelBrowserFrameView* frame_view = panel_browser_view_->GetFrameView(); | |
525 | |
526 PanelBrowserFrameView::PaintState expected_paint_state = | |
527 as_active ? PanelBrowserFrameView::PAINT_AS_ACTIVE | |
528 : PanelBrowserFrameView::PAINT_AS_INACTIVE; | |
529 if (frame_view->paint_state_ != expected_paint_state) | |
530 return false; | |
531 | |
532 SkColor expected_color = frame_view->GetTitleColor(expected_paint_state); | |
533 return expected_color == frame_view->title_label_->GetColor(); | |
534 } | |
OLD | NEW |