OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/views/frame/browser_view.h" | 5 #include "chrome/browser/views/frame/browser_view.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include "chrome/common/pref_names.h" | 52 #include "chrome/common/pref_names.h" |
53 #include "chrome/common/pref_service.h" | 53 #include "chrome/common/pref_service.h" |
54 #include "chrome/common/resource_bundle.h" | 54 #include "chrome/common/resource_bundle.h" |
55 #include "chrome/common/win_util.h" | 55 #include "chrome/common/win_util.h" |
56 #include "chrome/views/controls/scrollbar/native_scroll_bar.h" | 56 #include "chrome/views/controls/scrollbar/native_scroll_bar.h" |
57 #include "chrome/views/fill_layout.h" | 57 #include "chrome/views/fill_layout.h" |
58 #include "chrome/views/view.h" | 58 #include "chrome/views/view.h" |
59 #include "chrome/views/widget/hwnd_notification_source.h" | 59 #include "chrome/views/widget/hwnd_notification_source.h" |
60 #include "chrome/views/widget/root_view.h" | 60 #include "chrome/views/widget/root_view.h" |
61 #include "chrome/views/window/non_client_view.h" | 61 #include "chrome/views/window/non_client_view.h" |
62 #include "chrome/views/window/window.h" | 62 #include "chrome/views/window/window_win.h" |
63 #include "grit/chromium_strings.h" | 63 #include "grit/chromium_strings.h" |
64 #include "grit/generated_resources.h" | 64 #include "grit/generated_resources.h" |
65 #include "grit/theme_resources.h" | 65 #include "grit/theme_resources.h" |
66 #include "grit/webkit_resources.h" | 66 #include "grit/webkit_resources.h" |
67 | 67 |
68 | 68 |
69 using base::TimeDelta; | 69 using base::TimeDelta; |
70 | 70 |
71 // static | 71 // static |
72 SkBitmap BrowserView::default_favicon_; | 72 SkBitmap BrowserView::default_favicon_; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 }; | 129 }; |
130 | 130 |
131 /////////////////////////////////////////////////////////////////////////////// | 131 /////////////////////////////////////////////////////////////////////////////// |
132 // ResizeCorner, private: | 132 // ResizeCorner, private: |
133 | 133 |
134 class ResizeCorner : public views::View { | 134 class ResizeCorner : public views::View { |
135 public: | 135 public: |
136 ResizeCorner() { } | 136 ResizeCorner() { } |
137 | 137 |
138 virtual void Paint(ChromeCanvas* canvas) { | 138 virtual void Paint(ChromeCanvas* canvas) { |
139 BrowserView* browser = GetBrowserView(); | 139 views::WindowWin* window = GetWindow(); |
140 if (browser && !browser->CanCurrentlyResize()) | 140 if (!window || (window->IsMaximized() || window->IsFullscreen())) |
141 return; | 141 return; |
142 | 142 |
143 SkBitmap* bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed( | 143 SkBitmap* bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed( |
144 IDR_TEXTAREA_RESIZER); | 144 IDR_TEXTAREA_RESIZER); |
145 bitmap->buildMipMap(false); | 145 bitmap->buildMipMap(false); |
146 bool rtl_dir = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT); | 146 bool rtl_dir = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT); |
147 if (rtl_dir) { | 147 if (rtl_dir) { |
148 canvas->TranslateInt(width(), 0); | 148 canvas->TranslateInt(width(), 0); |
149 canvas->ScaleInt(-1, 1); | 149 canvas->ScaleInt(-1, 1); |
150 canvas->save(); | 150 canvas->save(); |
151 } | 151 } |
152 canvas->DrawBitmapInt(*bitmap, width() - bitmap->width(), | 152 canvas->DrawBitmapInt(*bitmap, width() - bitmap->width(), |
153 height() - bitmap->height()); | 153 height() - bitmap->height()); |
154 if (rtl_dir) | 154 if (rtl_dir) |
155 canvas->restore(); | 155 canvas->restore(); |
156 } | 156 } |
157 | 157 |
158 static gfx::Size GetSize() { | 158 static gfx::Size GetSize() { |
159 // This is disabled until we find what makes us slower when we let | 159 // This is disabled until we find what makes us slower when we let |
160 // WebKit know that we have a resizer rect... | 160 // WebKit know that we have a resizer rect... |
161 // return gfx::Size(views::NativeScrollBar::GetVerticalScrollBarWidth(), | 161 // return gfx::Size(views::NativeScrollBar::GetVerticalScrollBarWidth(), |
162 // views::NativeScrollBar::GetHorizontalScrollBarHeight()); | 162 // views::NativeScrollBar::GetHorizontalScrollBarHeight()); |
163 return gfx::Size(); | 163 return gfx::Size(); |
164 } | 164 } |
165 | 165 |
166 virtual gfx::Size GetPreferredSize() { | 166 virtual gfx::Size GetPreferredSize() { |
167 BrowserView* browser = GetBrowserView(); | 167 views::WindowWin* window = GetWindow(); |
168 return (browser && !browser->CanCurrentlyResize()) ? | 168 return (!window || window->IsMaximized() || window->IsFullscreen()) ? |
169 gfx::Size() : GetSize(); | 169 gfx::Size() : GetSize(); |
170 } | 170 } |
171 | 171 |
172 virtual void Layout() { | 172 virtual void Layout() { |
173 views::View* parent_view = GetParent(); | 173 views::View* parent_view = GetParent(); |
174 if (parent_view) { | 174 if (parent_view) { |
175 gfx::Size ps = GetPreferredSize(); | 175 gfx::Size ps = GetPreferredSize(); |
176 // No need to handle Right to left text direction here, | 176 // No need to handle Right to left text direction here, |
177 // our parent must take care of it for us... | 177 // our parent must take care of it for us... |
178 SetBounds(parent_view->width() - ps.width(), | 178 SetBounds(parent_view->width() - ps.width(), |
179 parent_view->height() - ps.height(), ps.width(), ps.height()); | 179 parent_view->height() - ps.height(), ps.width(), ps.height()); |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 private: | 183 private: |
184 // Returns the BrowserView we're displayed in. Returns NULL if we're not | 184 // Returns the WindowWin we're displayed in. Returns NULL if we're not |
185 // currently in a browser view. | 185 // currently in a window. |
186 BrowserView* GetBrowserView() { | 186 views::WindowWin* GetWindow() { |
187 View* browser = GetAncestorWithClassName(kBrowserViewClassName); | 187 views::Widget* widget = GetWidget(); |
188 return browser ? static_cast<BrowserView*>(browser) : NULL; | 188 return widget ? static_cast<views::WindowWin*>(widget) : NULL; |
189 } | 189 } |
190 | 190 |
191 DISALLOW_COPY_AND_ASSIGN(ResizeCorner); | 191 DISALLOW_COPY_AND_ASSIGN(ResizeCorner); |
192 }; | 192 }; |
193 | 193 |
194 //////////////////////////////////////////////////////////////////////////////// | 194 //////////////////////////////////////////////////////////////////////////////// |
195 // DownloadInProgressConfirmDialogDelegate | 195 // DownloadInProgressConfirmDialogDelegate |
196 | 196 |
197 class DownloadInProgressConfirmDialogDelegate : public views::DialogDelegate, | 197 class DownloadInProgressConfirmDialogDelegate : public views::DialogDelegate, |
198 public views::View { | 198 public views::View { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 frame_(NULL), | 270 frame_(NULL), |
271 browser_(browser), | 271 browser_(browser), |
272 active_bookmark_bar_(NULL), | 272 active_bookmark_bar_(NULL), |
273 active_download_shelf_(NULL), | 273 active_download_shelf_(NULL), |
274 tabstrip_(NULL), | 274 tabstrip_(NULL), |
275 toolbar_(NULL), | 275 toolbar_(NULL), |
276 infobar_container_(NULL), | 276 infobar_container_(NULL), |
277 find_bar_y_(0), | 277 find_bar_y_(0), |
278 contents_container_(NULL), | 278 contents_container_(NULL), |
279 initialized_(false), | 279 initialized_(false), |
280 fullscreen_(false), | |
281 ignore_layout_(false), | 280 ignore_layout_(false), |
282 hung_window_detector_(&hung_plugin_action_), | 281 hung_window_detector_(&hung_plugin_action_), |
283 ticker_(0) | 282 ticker_(0) |
284 #ifdef CHROME_PERSONALIZATION | 283 #ifdef CHROME_PERSONALIZATION |
285 , personalization_enabled_(false), | 284 , personalization_enabled_(false), |
286 personalization_(NULL) | 285 personalization_(NULL) |
287 #endif | 286 #endif |
288 { | 287 { |
289 InitClass(); | 288 InitClass(); |
290 browser_->tabstrip_model()->AddObserver(this); | 289 browser_->tabstrip_model()->AddObserver(this); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 if (toolbar_->GetLocationBarView()) | 332 if (toolbar_->GetLocationBarView()) |
334 toolbar_->GetLocationBarView()->location_entry()->ClosePopup(); | 333 toolbar_->GetLocationBarView()->location_entry()->ClosePopup(); |
335 } | 334 } |
336 | 335 |
337 void BrowserView::WindowMoveOrResizeStarted() { | 336 void BrowserView::WindowMoveOrResizeStarted() { |
338 TabContents* tab_contents = GetSelectedTabContents(); | 337 TabContents* tab_contents = GetSelectedTabContents(); |
339 if (tab_contents && tab_contents->AsWebContents()) | 338 if (tab_contents && tab_contents->AsWebContents()) |
340 tab_contents->AsWebContents()->WindowMoveOrResizeStarted(); | 339 tab_contents->AsWebContents()->WindowMoveOrResizeStarted(); |
341 } | 340 } |
342 | 341 |
343 bool BrowserView::CanCurrentlyResize() const { | |
344 return !IsMaximized() && !IsFullscreen(); | |
345 } | |
346 | |
347 gfx::Rect BrowserView::GetToolbarBounds() const { | 342 gfx::Rect BrowserView::GetToolbarBounds() const { |
348 return toolbar_->bounds(); | 343 return toolbar_->bounds(); |
349 } | 344 } |
350 | 345 |
351 gfx::Rect BrowserView::GetClientAreaBounds() const { | 346 gfx::Rect BrowserView::GetClientAreaBounds() const { |
352 gfx::Rect container_bounds = contents_container_->bounds(); | 347 gfx::Rect container_bounds = contents_container_->bounds(); |
353 gfx::Point container_origin = container_bounds.origin(); | 348 gfx::Point container_origin = container_bounds.origin(); |
354 ConvertPointToView(this, GetParent(), &container_origin); | 349 ConvertPointToView(this, GetParent(), &container_origin); |
355 container_bounds.set_origin(container_origin); | 350 container_bounds.set_origin(container_origin); |
356 return container_bounds; | 351 return container_bounds; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 LoadingAnimationCallback(); | 591 LoadingAnimationCallback(); |
597 } | 592 } |
598 } | 593 } |
599 } | 594 } |
600 | 595 |
601 void BrowserView::SetStarredState(bool is_starred) { | 596 void BrowserView::SetStarredState(bool is_starred) { |
602 toolbar_->star_button()->SetToggled(is_starred); | 597 toolbar_->star_button()->SetToggled(is_starred); |
603 } | 598 } |
604 | 599 |
605 gfx::Rect BrowserView::GetNormalBounds() const { | 600 gfx::Rect BrowserView::GetNormalBounds() const { |
606 // If we're in fullscreen mode, we've changed the normal bounds to the monitor | 601 return frame_->GetNormalBounds(); |
607 // rect, so return the saved bounds instead. | |
608 if (fullscreen_) | |
609 return gfx::Rect(saved_window_info_.window_rect); | |
610 | |
611 WINDOWPLACEMENT wp; | |
612 wp.length = sizeof(wp); | |
613 const bool ret = !!GetWindowPlacement(frame_->GetNativeView(), &wp); | |
614 DCHECK(ret); | |
615 return gfx::Rect(wp.rcNormalPosition); | |
616 } | 602 } |
617 | 603 |
618 bool BrowserView::IsMaximized() const { | 604 bool BrowserView::IsMaximized() const { |
619 return frame_->IsMaximized(); | 605 return frame_->IsMaximized(); |
620 } | 606 } |
621 | 607 |
622 void BrowserView::SetFullscreen(bool fullscreen) { | 608 void BrowserView::SetFullscreen(bool fullscreen) { |
623 if (fullscreen_ == fullscreen) | 609 if (IsFullscreen() == fullscreen) |
624 return; // Nothing to do. | 610 return; // Nothing to do. |
625 | 611 |
626 // Move focus out of the location bar if necessary. | |
627 LocationBarView* location_bar = toolbar_->GetLocationBarView(); | |
628 if (!fullscreen_) { | |
629 views::FocusManager* focus_manager = GetFocusManager(); | |
630 DCHECK(focus_manager); | |
631 if (focus_manager->GetFocusedView() == location_bar) | |
632 focus_manager->ClearFocus(); | |
633 } | |
634 AutocompleteEditViewWin* edit_view = | |
635 static_cast<AutocompleteEditViewWin*>(location_bar->location_entry()); | |
636 | |
637 // Toggle fullscreen mode. | |
638 fullscreen_ = fullscreen; | |
639 | |
640 // Reduce jankiness during the following position changes by: | 612 // Reduce jankiness during the following position changes by: |
641 // * Hiding the window until it's in the final position | 613 // * Hiding the window until it's in the final position |
642 // * Ignoring all intervening Layout() calls, which resize the webpage and | 614 // * Ignoring all intervening Layout() calls, which resize the webpage and |
643 // thus are slow and look ugly | 615 // thus are slow and look ugly |
644 ignore_layout_ = true; | 616 ignore_layout_ = true; |
645 frame_->set_force_hidden(true); | 617 LocationBarView* location_bar = toolbar_->GetLocationBarView(); |
646 if (fullscreen_) { | 618 AutocompleteEditViewWin* edit_view = |
| 619 static_cast<AutocompleteEditViewWin*>(location_bar->location_entry()); |
| 620 if (IsFullscreen()) { |
| 621 // Hide the fullscreen bubble as soon as possible, since the mode toggle can |
| 622 // take enough time for the user to notice. |
| 623 fullscreen_bubble_.reset(); |
| 624 } else { |
| 625 // Move focus out of the location bar if necessary. |
| 626 views::FocusManager* focus_manager = GetFocusManager(); |
| 627 DCHECK(focus_manager); |
| 628 if (focus_manager->GetFocusedView() == location_bar) |
| 629 focus_manager->ClearFocus(); |
| 630 |
647 // If we don't hide the edit and force it to not show until we come out of | 631 // If we don't hide the edit and force it to not show until we come out of |
648 // fullscreen, then if the user was on the New Tab Page, the edit contents | 632 // fullscreen, then if the user was on the New Tab Page, the edit contents |
649 // will appear atop the web contents once we go into fullscreen mode. This | 633 // will appear atop the web contents once we go into fullscreen mode. This |
650 // has something to do with how we move the main window while it's hidden; | 634 // has something to do with how we move the main window while it's hidden; |
651 // if we don't hide the main window below, we don't get this problem. | 635 // if we don't hide the main window below, we don't get this problem. |
652 edit_view->set_force_hidden(true); | 636 edit_view->set_force_hidden(true); |
653 ShowWindow(edit_view->m_hWnd, SW_HIDE); | 637 ShowWindow(edit_view->m_hWnd, SW_HIDE); |
654 } | 638 } |
655 frame_->Hide(); | 639 frame_->PushForceHidden(); |
656 | 640 |
657 // Notify bookmark bar, so it can set itself to the appropriate drawing state. | 641 // Notify bookmark bar, so it can set itself to the appropriate drawing state. |
658 if (bookmark_bar_view_.get()) | 642 if (bookmark_bar_view_.get()) |
659 bookmark_bar_view_->OnFullscreenToggled(fullscreen_); | 643 bookmark_bar_view_->OnFullscreenToggled(fullscreen); |
660 | 644 |
661 // Size/position/style window appropriately. | 645 // Toggle fullscreen mode. |
662 views::Widget* widget = GetWidget(); | 646 frame_->SetFullscreen(fullscreen); |
663 HWND hwnd = widget->GetNativeView(); | |
664 MONITORINFO monitor_info; | |
665 monitor_info.cbSize = sizeof(monitor_info); | |
666 GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY), | |
667 &monitor_info); | |
668 gfx::Rect monitor_rect(monitor_info.rcMonitor); | |
669 if (fullscreen_) { | |
670 // Save current window information. We force the window into restored mode | |
671 // before going fullscreen because Windows doesn't seem to hide the | |
672 // taskbar if the window is in the maximized state. | |
673 saved_window_info_.maximized = IsMaximized(); | |
674 if (saved_window_info_.maximized) | |
675 frame_->ExecuteSystemMenuCommand(SC_RESTORE); | |
676 saved_window_info_.style = GetWindowLong(hwnd, GWL_STYLE); | |
677 saved_window_info_.ex_style = GetWindowLong(hwnd, GWL_EXSTYLE); | |
678 GetWindowRect(hwnd, &saved_window_info_.window_rect); | |
679 | 647 |
680 // Set new window style and size. | 648 if (IsFullscreen()) { |
681 SetWindowLong(hwnd, GWL_STYLE, | 649 fullscreen_bubble_.reset(new FullscreenExitBubble(frame_, browser_.get())); |
682 saved_window_info_.style & ~(WS_CAPTION | WS_THICKFRAME)); | |
683 SetWindowLong(hwnd, GWL_EXSTYLE, | |
684 saved_window_info_.ex_style & ~(WS_EX_DLGMODALFRAME | | |
685 WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE)); | |
686 SetWindowPos(hwnd, NULL, monitor_rect.x(), monitor_rect.y(), | |
687 monitor_rect.width(), monitor_rect.height(), | |
688 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); | |
689 | |
690 fullscreen_bubble_.reset(new FullscreenExitBubble(widget, browser_.get())); | |
691 } else { | 650 } else { |
692 // Hide the fullscreen bubble as soon as possible, since the calls below can | |
693 // take enough time for the user to notice. | |
694 fullscreen_bubble_.reset(); | |
695 | |
696 // Reset original window style and size. The multiple window size/moves | |
697 // here are ugly, but if SetWindowPos() doesn't redraw, the taskbar won't be | |
698 // repainted. Better-looking methods welcome. | |
699 gfx::Rect new_rect(saved_window_info_.window_rect); | |
700 SetWindowLong(hwnd, GWL_STYLE, saved_window_info_.style); | |
701 SetWindowLong(hwnd, GWL_EXSTYLE, saved_window_info_.ex_style); | |
702 SetWindowPos(hwnd, NULL, new_rect.x(), new_rect.y(), new_rect.width(), | |
703 new_rect.height(), | |
704 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); | |
705 if (saved_window_info_.maximized) | |
706 frame_->ExecuteSystemMenuCommand(SC_MAXIMIZE); | |
707 | |
708 // Show the edit again since we're no longer in fullscreen mode. | 651 // Show the edit again since we're no longer in fullscreen mode. |
709 edit_view->set_force_hidden(false); | 652 edit_view->set_force_hidden(false); |
710 ShowWindow(edit_view->m_hWnd, SW_SHOW); | 653 ShowWindow(edit_view->m_hWnd, SW_SHOW); |
711 } | 654 } |
712 | 655 |
713 // Undo our anti-jankiness hacks and force the window to relayout now that | 656 // Undo our anti-jankiness hacks and force the window to relayout now that |
714 // it's in its final position. | 657 // it's in its final position. |
715 ignore_layout_ = false; | 658 ignore_layout_ = false; |
716 Layout(); | 659 Layout(); |
717 frame_->set_force_hidden(false); | 660 frame_->PopForceHidden(); |
718 ShowWindow(hwnd, SW_SHOW); | |
719 } | 661 } |
720 | 662 |
721 bool BrowserView::IsFullscreen() const { | 663 bool BrowserView::IsFullscreen() const { |
722 return fullscreen_; | 664 return frame_->IsFullscreen(); |
723 } | 665 } |
724 | 666 |
725 LocationBar* BrowserView::GetLocationBar() const { | 667 LocationBar* BrowserView::GetLocationBar() const { |
726 return toolbar_->GetLocationBarView(); | 668 return toolbar_->GetLocationBarView(); |
727 } | 669 } |
728 | 670 |
729 void BrowserView::SetFocusToLocationBar() { | 671 void BrowserView::SetFocusToLocationBar() { |
730 LocationBarView* location_bar = toolbar_->GetLocationBarView(); | 672 LocationBarView* location_bar = toolbar_->GetLocationBarView(); |
731 if (location_bar->IsFocusable()) { | 673 if (location_bar->IsFocusable()) { |
732 location_bar->FocusLocation(); | 674 location_bar->FocusLocation(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 browser_.reset(); | 707 browser_.reset(); |
766 } | 708 } |
767 | 709 |
768 bool BrowserView::IsBookmarkBarVisible() const { | 710 bool BrowserView::IsBookmarkBarVisible() const { |
769 return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR) && | 711 return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR) && |
770 active_bookmark_bar_ && | 712 active_bookmark_bar_ && |
771 (active_bookmark_bar_->GetPreferredSize().height() != 0); | 713 (active_bookmark_bar_->GetPreferredSize().height() != 0); |
772 } | 714 } |
773 | 715 |
774 gfx::Rect BrowserView::GetRootWindowResizerRect() const { | 716 gfx::Rect BrowserView::GetRootWindowResizerRect() const { |
775 if (!CanCurrentlyResize()) | 717 if (frame_->IsMaximized() || frame_->IsFullscreen()) |
776 return gfx::Rect(); | 718 return gfx::Rect(); |
777 | 719 |
778 // We don't specify a resize corner size if we have a bottom shelf either. | 720 // We don't specify a resize corner size if we have a bottom shelf either. |
779 // This is because we take care of drawing the resize corner on top of that | 721 // This is because we take care of drawing the resize corner on top of that |
780 // shelf, so we don't want others to do it for us in this case. | 722 // shelf, so we don't want others to do it for us in this case. |
781 // Currently, the only visible bottom shelf is the download shelf. | 723 // Currently, the only visible bottom shelf is the download shelf. |
782 // Other tests should be added here if we add more bottom shelves. | 724 // Other tests should be added here if we add more bottom shelves. |
783 TabContents* current_tab = browser_->GetSelectedTabContents(); | 725 TabContents* current_tab = browser_->GetSelectedTabContents(); |
784 if (current_tab && current_tab->IsDownloadShelfVisible()) { | 726 if (current_tab && current_tab->IsDownloadShelfVisible()) { |
785 DownloadShelf* download_shelf = current_tab->GetDownloadShelf(); | 727 DownloadShelf* download_shelf = current_tab->GetDownloadShelf(); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 return false; | 988 return false; |
1047 } | 989 } |
1048 | 990 |
1049 std::wstring BrowserView::GetWindowName() const { | 991 std::wstring BrowserView::GetWindowName() const { |
1050 return browser_->GetWindowPlacementKey(); | 992 return browser_->GetWindowPlacementKey(); |
1051 } | 993 } |
1052 | 994 |
1053 void BrowserView::SaveWindowPlacement(const gfx::Rect& bounds, | 995 void BrowserView::SaveWindowPlacement(const gfx::Rect& bounds, |
1054 bool maximized, | 996 bool maximized, |
1055 bool always_on_top) { | 997 bool always_on_top) { |
1056 // If fullscreen_ is true, we've just changed into fullscreen mode, and we're | 998 // If IsFullscreen() is true, we've just changed into fullscreen mode, and |
1057 // catching the going-into-fullscreen sizing and positioning calls, which we | 999 // we're catching the going-into-fullscreen sizing and positioning calls, |
1058 // want to ignore. | 1000 // which we want to ignore. |
1059 if (!fullscreen_ && browser_->ShouldSaveWindowPlacement()) { | 1001 if (!IsFullscreen() && browser_->ShouldSaveWindowPlacement()) { |
1060 WindowDelegate::SaveWindowPlacement(bounds, maximized, always_on_top); | 1002 WindowDelegate::SaveWindowPlacement(bounds, maximized, always_on_top); |
1061 browser_->SaveWindowPlacement(bounds, maximized); | 1003 browser_->SaveWindowPlacement(bounds, maximized); |
1062 } | 1004 } |
1063 } | 1005 } |
1064 | 1006 |
1065 bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const { | 1007 bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const { |
1066 *bounds = browser_->GetSavedWindowBounds(); | 1008 *bounds = browser_->GetSavedWindowBounds(); |
1067 if (browser_->type() & Browser::TYPE_POPUP) { | 1009 if (browser_->type() & Browser::TYPE_POPUP) { |
1068 // We are a popup window. The value passed in |bounds| represents two | 1010 // We are a popup window. The value passed in |bounds| represents two |
1069 // pieces of information: | 1011 // pieces of information: |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 NotificationService::NoDetails()); | 1087 NotificationService::NoDetails()); |
1146 return true; | 1088 return true; |
1147 } | 1089 } |
1148 | 1090 |
1149 int BrowserView::NonClientHitTest(const gfx::Point& point) { | 1091 int BrowserView::NonClientHitTest(const gfx::Point& point) { |
1150 // Since the TabStrip only renders in some parts of the top of the window, | 1092 // Since the TabStrip only renders in some parts of the top of the window, |
1151 // the un-obscured area is considered to be part of the non-client caption | 1093 // the un-obscured area is considered to be part of the non-client caption |
1152 // area of the window. So we need to treat hit-tests in these regions as | 1094 // area of the window. So we need to treat hit-tests in these regions as |
1153 // hit-tests of the titlebar. | 1095 // hit-tests of the titlebar. |
1154 | 1096 |
1155 if (CanCurrentlyResize()) { | 1097 if (!frame_->IsMaximized() && !frame_->IsFullscreen()) { |
1156 CRect client_rect; | 1098 CRect client_rect; |
1157 ::GetClientRect(frame_->GetNativeView(), &client_rect); | 1099 ::GetClientRect(frame_->GetNativeView(), &client_rect); |
1158 gfx::Size resize_corner_size = ResizeCorner::GetSize(); | 1100 gfx::Size resize_corner_size = ResizeCorner::GetSize(); |
1159 gfx::Rect resize_corner_rect(client_rect.right - resize_corner_size.width(), | 1101 gfx::Rect resize_corner_rect(client_rect.right - resize_corner_size.width(), |
1160 client_rect.bottom - resize_corner_size.height(), | 1102 client_rect.bottom - resize_corner_size.height(), |
1161 resize_corner_size.width(), resize_corner_size.height()); | 1103 resize_corner_size.width(), resize_corner_size.height()); |
1162 bool rtl_dir = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT); | 1104 bool rtl_dir = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT); |
1163 if (rtl_dir) | 1105 if (rtl_dir) |
1164 resize_corner_rect.set_x(0); | 1106 resize_corner_rect.set_x(0); |
1165 if (resize_corner_rect.Contains(point)) { | 1107 if (resize_corner_rect.Contains(point)) { |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1679 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 1621 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
1680 BrowserView* browser_view = new BrowserView(browser); | 1622 BrowserView* browser_view = new BrowserView(browser); |
1681 (new BrowserFrame(browser_view))->Init(); | 1623 (new BrowserFrame(browser_view))->Init(); |
1682 return browser_view; | 1624 return browser_view; |
1683 } | 1625 } |
1684 | 1626 |
1685 // static | 1627 // static |
1686 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 1628 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
1687 return new FindBarWin(static_cast<BrowserView*>(browser->window())); | 1629 return new FindBarWin(static_cast<BrowserView*>(browser->window())); |
1688 } | 1630 } |
OLD | NEW |