| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/command_line.h" | |
| 6 | |
| 7 #include "chrome/browser/views/frame/browser_view.h" | 5 #include "chrome/browser/views/frame/browser_view.h" |
| 8 | 6 |
| 7 #include "base/command_line.h" |
| 9 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
| 10 #include "base/time.h" | 9 #include "base/time.h" |
| 11 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
| 12 #include "chrome/browser/app_modal_dialog_queue.h" | 11 #include "chrome/browser/app_modal_dialog_queue.h" |
| 13 #include "chrome/browser/browser.h" | 12 #include "chrome/browser/browser.h" |
| 14 #include "chrome/browser/browser_list.h" | 13 #include "chrome/browser/browser_list.h" |
| 15 #include "chrome/browser/encoding_menu_controller_delegate.h" | 14 #include "chrome/browser/encoding_menu_controller_delegate.h" |
| 16 #include "chrome/browser/view_ids.h" | 15 #include "chrome/browser/view_ids.h" |
| 17 #include "chrome/browser/views/about_chrome_view.h" | 16 #include "chrome/browser/views/about_chrome_view.h" |
| 18 #include "chrome/browser/views/bookmark_bar_view.h" | 17 #include "chrome/browser/views/bookmark_bar_view.h" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 accelerator_table_->begin(); | 358 accelerator_table_->begin(); |
| 360 for (; it != accelerator_table_->end(); ++it) { | 359 for (; it != accelerator_table_->end(); ++it) { |
| 361 if (it->second == cmd_id) { | 360 if (it->second == cmd_id) { |
| 362 *accelerator = it->first; | 361 *accelerator = it->first; |
| 363 return true; | 362 return true; |
| 364 } | 363 } |
| 365 } | 364 } |
| 366 return false; | 365 return false; |
| 367 } | 366 } |
| 368 | 367 |
| 369 bool BrowserView::SystemCommandReceived(UINT notification_code, | |
| 370 const gfx::Point& point) { | |
| 371 bool handled = false; | |
| 372 | |
| 373 if (browser_->command_updater()->SupportsCommand(notification_code) && | |
| 374 browser_->command_updater()->IsCommandEnabled(notification_code)) { | |
| 375 browser_->ExecuteCommand(notification_code); | |
| 376 handled = true; | |
| 377 } | |
| 378 | |
| 379 return handled; | |
| 380 } | |
| 381 | |
| 382 void BrowserView::AddViewToDropList(views::View* view) { | 368 void BrowserView::AddViewToDropList(views::View* view) { |
| 383 dropable_views_.insert(view); | 369 dropable_views_.insert(view); |
| 384 } | 370 } |
| 385 | 371 |
| 386 bool BrowserView::ActivateAppModalDialog() const { | 372 bool BrowserView::ActivateAppModalDialog() const { |
| 387 // If another browser is app modal, flash and activate the modal browser. | 373 // If another browser is app modal, flash and activate the modal browser. |
| 388 if (AppModalDialogQueue::HasActiveDialog()) { | 374 if (AppModalDialogQueue::HasActiveDialog()) { |
| 389 Browser* active_browser = BrowserList::GetLastActive(); | 375 Browser* active_browser = BrowserList::GetLastActive(); |
| 390 if (active_browser && (browser_ != active_browser)) { | 376 if (active_browser && (browser_ != active_browser)) { |
| 391 active_browser->window()->FlashFrame(); | 377 active_browser->window()->FlashFrame(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 personalization_ = Personalization::CreateFramePersonalization( | 467 personalization_ = Personalization::CreateFramePersonalization( |
| 482 browser_->profile(), this); | 468 browser_->profile(), this); |
| 483 } | 469 } |
| 484 #endif | 470 #endif |
| 485 | 471 |
| 486 InitSystemMenu(); | 472 InitSystemMenu(); |
| 487 } | 473 } |
| 488 | 474 |
| 489 void BrowserView::Show() { | 475 void BrowserView::Show() { |
| 490 // If the window is already visible, just activate it. | 476 // If the window is already visible, just activate it. |
| 491 if (frame_->GetWindow()->IsVisible()) { | 477 if (frame_->IsVisible()) { |
| 492 frame_->GetWindow()->Activate(); | 478 frame_->Activate(); |
| 493 return; | 479 return; |
| 494 } | 480 } |
| 495 | 481 |
| 496 // Setting the focus doesn't work when the window is invisible, so any focus | 482 // Setting the focus doesn't work when the window is invisible, so any focus |
| 497 // initialization that happened before this will be lost. | 483 // initialization that happened before this will be lost. |
| 498 // | 484 // |
| 499 // We really "should" restore the focus whenever the window becomes unhidden, | 485 // We really "should" restore the focus whenever the window becomes unhidden, |
| 500 // but I think initializing is the only time where this can happen where | 486 // but I think initializing is the only time where this can happen where |
| 501 // there is some focus change we need to pick up, and this is easier than | 487 // there is some focus change we need to pick up, and this is easier than |
| 502 // plumbing through an un-hide message all the way from the frame. | 488 // plumbing through an un-hide message all the way from the frame. |
| 503 // | 489 // |
| 504 // If we do find there are cases where we need to restore the focus on show, | 490 // If we do find there are cases where we need to restore the focus on show, |
| 505 // that should be added and this should be removed. | 491 // that should be added and this should be removed. |
| 506 TabContents* selected_tab_contents = GetSelectedTabContents(); | 492 TabContents* selected_tab_contents = GetSelectedTabContents(); |
| 507 if (selected_tab_contents) | 493 if (selected_tab_contents) |
| 508 selected_tab_contents->RestoreFocus(); | 494 selected_tab_contents->RestoreFocus(); |
| 509 | 495 |
| 510 frame_->GetWindow()->Show(); | 496 frame_->Show(); |
| 511 int show_state = frame_->GetWindow()->GetShowState(); | |
| 512 if (show_state == SW_SHOWNORMAL || show_state == SW_SHOWMAXIMIZED) | |
| 513 frame_->GetWindow()->Activate(); | |
| 514 } | 497 } |
| 515 | 498 |
| 516 void BrowserView::SetBounds(const gfx::Rect& bounds) { | 499 void BrowserView::SetBounds(const gfx::Rect& bounds) { |
| 517 frame_->GetWindow()->SetBounds(bounds); | 500 frame_->SetBounds(bounds); |
| 518 } | 501 } |
| 519 | 502 |
| 520 void BrowserView::Close() { | 503 void BrowserView::Close() { |
| 521 frame_->GetWindow()->Close(); | 504 frame_->Close(); |
| 522 } | 505 } |
| 523 | 506 |
| 524 void BrowserView::Activate() { | 507 void BrowserView::Activate() { |
| 525 frame_->GetWindow()->Activate(); | 508 frame_->Activate(); |
| 526 } | 509 } |
| 527 | 510 |
| 528 bool BrowserView::IsActive() const { | 511 bool BrowserView::IsActive() const { |
| 529 return frame_->GetWindow()->IsActive(); | 512 return frame_->IsActive(); |
| 530 } | 513 } |
| 531 | 514 |
| 532 void BrowserView::FlashFrame() { | 515 void BrowserView::FlashFrame() { |
| 533 FLASHWINFO fwi; | 516 FLASHWINFO fwi; |
| 534 fwi.cbSize = sizeof(fwi); | 517 fwi.cbSize = sizeof(fwi); |
| 535 fwi.hwnd = frame_->GetWindow()->GetHWND(); | 518 fwi.hwnd = frame_->GetHWND(); |
| 536 fwi.dwFlags = FLASHW_ALL; | 519 fwi.dwFlags = FLASHW_ALL; |
| 537 fwi.uCount = 4; | 520 fwi.uCount = 4; |
| 538 fwi.dwTimeout = 0; | 521 fwi.dwTimeout = 0; |
| 539 FlashWindowEx(&fwi); | 522 FlashWindowEx(&fwi); |
| 540 } | 523 } |
| 541 | 524 |
| 542 void* BrowserView::GetNativeHandle() { | 525 void* BrowserView::GetNativeHandle() { |
| 543 return GetWidget()->GetHWND(); | 526 return GetWidget()->GetHWND(); |
| 544 } | 527 } |
| 545 | 528 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 556 contents_container_->set_fast_resize(true); | 539 contents_container_->set_fast_resize(true); |
| 557 UpdateUIForContents(browser_->GetSelectedTabContents()); | 540 UpdateUIForContents(browser_->GetSelectedTabContents()); |
| 558 contents_container_->set_fast_resize(false); | 541 contents_container_->set_fast_resize(false); |
| 559 } else { | 542 } else { |
| 560 UpdateUIForContents(browser_->GetSelectedTabContents()); | 543 UpdateUIForContents(browser_->GetSelectedTabContents()); |
| 561 contents_container_->UpdateHWNDBounds(); | 544 contents_container_->UpdateHWNDBounds(); |
| 562 } | 545 } |
| 563 } | 546 } |
| 564 | 547 |
| 565 void BrowserView::UpdateTitleBar() { | 548 void BrowserView::UpdateTitleBar() { |
| 566 frame_->GetWindow()->UpdateWindowTitle(); | 549 frame_->UpdateWindowTitle(); |
| 567 if (ShouldShowWindowIcon()) | 550 if (ShouldShowWindowIcon()) |
| 568 frame_->GetWindow()->UpdateWindowIcon(); | 551 frame_->UpdateWindowIcon(); |
| 569 } | 552 } |
| 570 | 553 |
| 571 void BrowserView::UpdateLoadingAnimations(bool should_animate) { | 554 void BrowserView::UpdateLoadingAnimations(bool should_animate) { |
| 572 if (should_animate) { | 555 if (should_animate) { |
| 573 if (!loading_animation_timer_.IsRunning()) { | 556 if (!loading_animation_timer_.IsRunning()) { |
| 574 // Loads are happening, and the timer isn't running, so start it. | 557 // Loads are happening, and the timer isn't running, so start it. |
| 575 loading_animation_timer_.Start( | 558 loading_animation_timer_.Start( |
| 576 TimeDelta::FromMilliseconds(kLoadingAnimationFrameTimeMs), this, | 559 TimeDelta::FromMilliseconds(kLoadingAnimationFrameTimeMs), this, |
| 577 &BrowserView::LoadingAnimationCallback); | 560 &BrowserView::LoadingAnimationCallback); |
| 578 } | 561 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 590 } | 573 } |
| 591 | 574 |
| 592 gfx::Rect BrowserView::GetNormalBounds() const { | 575 gfx::Rect BrowserView::GetNormalBounds() const { |
| 593 // If we're in fullscreen mode, we've changed the normal bounds to the monitor | 576 // If we're in fullscreen mode, we've changed the normal bounds to the monitor |
| 594 // rect, so return the saved bounds instead. | 577 // rect, so return the saved bounds instead. |
| 595 if (fullscreen_) | 578 if (fullscreen_) |
| 596 return gfx::Rect(saved_window_info_.window_rect); | 579 return gfx::Rect(saved_window_info_.window_rect); |
| 597 | 580 |
| 598 WINDOWPLACEMENT wp; | 581 WINDOWPLACEMENT wp; |
| 599 wp.length = sizeof(wp); | 582 wp.length = sizeof(wp); |
| 600 const bool ret = !!GetWindowPlacement(frame_->GetWindow()->GetHWND(), &wp); | 583 const bool ret = !!GetWindowPlacement(frame_->GetHWND(), &wp); |
| 601 DCHECK(ret); | 584 DCHECK(ret); |
| 602 return gfx::Rect(wp.rcNormalPosition); | 585 return gfx::Rect(wp.rcNormalPosition); |
| 603 } | 586 } |
| 604 | 587 |
| 605 bool BrowserView::IsMaximized() const { | 588 bool BrowserView::IsMaximized() const { |
| 606 return frame_->GetWindow()->IsMaximized(); | 589 return frame_->IsMaximized(); |
| 607 } | 590 } |
| 608 | 591 |
| 609 void BrowserView::SetFullscreen(bool fullscreen) { | 592 void BrowserView::SetFullscreen(bool fullscreen) { |
| 610 if (fullscreen_ == fullscreen) | 593 if (fullscreen_ == fullscreen) |
| 611 return; // Nothing to do. | 594 return; // Nothing to do. |
| 612 | 595 |
| 613 // Move focus out of the location bar if necessary, and make it unfocusable. | 596 // Move focus out of the location bar if necessary, and make it unfocusable. |
| 614 LocationBarView* location_bar = toolbar_->GetLocationBarView(); | 597 LocationBarView* location_bar = toolbar_->GetLocationBarView(); |
| 615 if (!fullscreen_) { | 598 if (!fullscreen_) { |
| 616 views::FocusManager* focus_manager = GetFocusManager(); | 599 views::FocusManager* focus_manager = GetFocusManager(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 629 | 612 |
| 630 // Size/position/style window appropriately. | 613 // Size/position/style window appropriately. |
| 631 views::Widget* widget = GetWidget(); | 614 views::Widget* widget = GetWidget(); |
| 632 HWND hwnd = widget->GetHWND(); | 615 HWND hwnd = widget->GetHWND(); |
| 633 if (fullscreen_) { | 616 if (fullscreen_) { |
| 634 // Save current window information. We force the window into restored mode | 617 // Save current window information. We force the window into restored mode |
| 635 // before going fullscreen because Windows doesn't seem to hide the | 618 // before going fullscreen because Windows doesn't seem to hide the |
| 636 // taskbar if the window is in the maximized state. | 619 // taskbar if the window is in the maximized state. |
| 637 saved_window_info_.maximized = IsMaximized(); | 620 saved_window_info_.maximized = IsMaximized(); |
| 638 if (saved_window_info_.maximized) | 621 if (saved_window_info_.maximized) |
| 639 frame_->GetWindow()->ExecuteSystemMenuCommand(SC_RESTORE); | 622 frame_->ExecuteSystemMenuCommand(SC_RESTORE); |
| 640 saved_window_info_.style = GetWindowLong(hwnd, GWL_STYLE); | 623 saved_window_info_.style = GetWindowLong(hwnd, GWL_STYLE); |
| 641 saved_window_info_.ex_style = GetWindowLong(hwnd, GWL_EXSTYLE); | 624 saved_window_info_.ex_style = GetWindowLong(hwnd, GWL_EXSTYLE); |
| 642 GetWindowRect(hwnd, &saved_window_info_.window_rect); | 625 GetWindowRect(hwnd, &saved_window_info_.window_rect); |
| 643 | 626 |
| 644 // Set new window style and size. | 627 // Set new window style and size. |
| 645 SetWindowLong(hwnd, GWL_STYLE, | 628 SetWindowLong(hwnd, GWL_STYLE, |
| 646 saved_window_info_.style & ~(WS_CAPTION | WS_THICKFRAME)); | 629 saved_window_info_.style & ~(WS_CAPTION | WS_THICKFRAME)); |
| 647 SetWindowLong(hwnd, GWL_EXSTYLE, | 630 SetWindowLong(hwnd, GWL_EXSTYLE, |
| 648 saved_window_info_.ex_style & ~(WS_EX_DLGMODALFRAME | | 631 saved_window_info_.ex_style & ~(WS_EX_DLGMODALFRAME | |
| 649 WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE)); | 632 WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE)); |
| 650 MONITORINFO monitor_info; | 633 MONITORINFO monitor_info; |
| 651 monitor_info.cbSize = sizeof(monitor_info); | 634 monitor_info.cbSize = sizeof(monitor_info); |
| 652 GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY), | 635 GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY), |
| 653 &monitor_info); | 636 &monitor_info); |
| 654 gfx::Rect new_rect(monitor_info.rcMonitor); | 637 gfx::Rect new_rect(monitor_info.rcMonitor); |
| 655 SetWindowPos(hwnd, NULL, new_rect.x(), new_rect.y(), new_rect.width(), | 638 SetWindowPos(hwnd, NULL, new_rect.x(), new_rect.y(), new_rect.width(), |
| 656 new_rect.height(), | 639 new_rect.height(), |
| 657 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); | 640 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); |
| 658 } else { | 641 } else { |
| 659 // Reset original window style and size. The multiple window size/moves | 642 // Reset original window style and size. The multiple window size/moves |
| 660 // here are ugly, but if SetWindowPos() doesn't redraw, the taskbar won't be | 643 // here are ugly, but if SetWindowPos() doesn't redraw, the taskbar won't be |
| 661 // repainted. Better-looking methods welcome. | 644 // repainted. Better-looking methods welcome. |
| 662 gfx::Rect new_rect(saved_window_info_.window_rect); | 645 gfx::Rect new_rect(saved_window_info_.window_rect); |
| 663 SetWindowLong(hwnd, GWL_STYLE, saved_window_info_.style); | 646 SetWindowLong(hwnd, GWL_STYLE, saved_window_info_.style); |
| 664 SetWindowLong(hwnd, GWL_EXSTYLE, saved_window_info_.ex_style); | 647 SetWindowLong(hwnd, GWL_EXSTYLE, saved_window_info_.ex_style); |
| 665 SetWindowPos(hwnd, NULL, new_rect.x(), new_rect.y(), new_rect.width(), | 648 SetWindowPos(hwnd, NULL, new_rect.x(), new_rect.y(), new_rect.width(), |
| 666 new_rect.height(), | 649 new_rect.height(), |
| 667 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); | 650 SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); |
| 668 if (saved_window_info_.maximized) | 651 if (saved_window_info_.maximized) |
| 669 frame_->GetWindow()->ExecuteSystemMenuCommand(SC_MAXIMIZE); | 652 frame_->ExecuteSystemMenuCommand(SC_MAXIMIZE); |
| 670 } | 653 } |
| 671 | 654 |
| 672 // Turn fullscreen bubble on or off. | 655 // Turn fullscreen bubble on or off. |
| 673 fullscreen_bubble_.reset(fullscreen_ ? | 656 fullscreen_bubble_.reset(fullscreen_ ? |
| 674 new FullscreenExitBubble(widget, browser_.get()) : NULL); | 657 new FullscreenExitBubble(widget, browser_.get()) : NULL); |
| 675 } | 658 } |
| 676 | 659 |
| 677 bool BrowserView::IsFullscreen() const { | 660 bool BrowserView::IsFullscreen() const { |
| 678 return fullscreen_; | 661 return fullscreen_; |
| 679 } | 662 } |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 if (browser_->type() & Browser::TYPE_APP) | 974 if (browser_->type() & Browser::TYPE_APP) |
| 992 return browser_->GetCurrentPageIcon(); | 975 return browser_->GetCurrentPageIcon(); |
| 993 return SkBitmap(); | 976 return SkBitmap(); |
| 994 } | 977 } |
| 995 | 978 |
| 996 bool BrowserView::ShouldShowWindowIcon() const { | 979 bool BrowserView::ShouldShowWindowIcon() const { |
| 997 return SupportsWindowFeature(FEATURE_TITLEBAR); | 980 return SupportsWindowFeature(FEATURE_TITLEBAR); |
| 998 } | 981 } |
| 999 | 982 |
| 1000 bool BrowserView::ExecuteWindowsCommand(int command_id) { | 983 bool BrowserView::ExecuteWindowsCommand(int command_id) { |
| 984 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND. |
| 985 |
| 1001 // Translate WM_APPCOMMAND command ids into a command id that the browser | 986 // Translate WM_APPCOMMAND command ids into a command id that the browser |
| 1002 // knows how to handle. | 987 // knows how to handle. |
| 1003 int command_id_from_app_command = GetCommandIDForAppCommandID(command_id); | 988 int command_id_from_app_command = GetCommandIDForAppCommandID(command_id); |
| 1004 if (command_id_from_app_command != -1) | 989 if (command_id_from_app_command != -1) |
| 1005 command_id = command_id_from_app_command; | 990 command_id = command_id_from_app_command; |
| 1006 | 991 |
| 1007 if (browser_->command_updater()->SupportsCommand(command_id)) { | 992 if (browser_->command_updater()->SupportsCommand(command_id)) { |
| 1008 if (browser_->command_updater()->IsCommandEnabled(command_id)) | 993 if (browser_->command_updater()->IsCommandEnabled(command_id)) |
| 1009 browser_->ExecuteCommand(command_id); | 994 browser_->ExecuteCommand(command_id); |
| 1010 return true; | 995 return true; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1039 // position of the resulting window. | 1024 // position of the resulting window. |
| 1040 if (IsToolbarVisible()) { | 1025 if (IsToolbarVisible()) { |
| 1041 // If we're showing the toolbar, we need to adjust |*bounds| to include | 1026 // If we're showing the toolbar, we need to adjust |*bounds| to include |
| 1042 // its desired height, since the toolbar is considered part of the | 1027 // its desired height, since the toolbar is considered part of the |
| 1043 // window's client area as far as GetWindowBoundsForClientBounds is | 1028 // window's client area as far as GetWindowBoundsForClientBounds is |
| 1044 // concerned... | 1029 // concerned... |
| 1045 bounds->set_height( | 1030 bounds->set_height( |
| 1046 bounds->height() + toolbar_->GetPreferredSize().height()); | 1031 bounds->height() + toolbar_->GetPreferredSize().height()); |
| 1047 } | 1032 } |
| 1048 | 1033 |
| 1049 gfx::Rect window_rect = frame_->GetWindowBoundsForClientBounds(*bounds); | 1034 gfx::Rect window_rect = |
| 1035 frame_->GetWindowBoundsForClientBounds(*bounds); |
| 1050 window_rect.set_origin(bounds->origin()); | 1036 window_rect.set_origin(bounds->origin()); |
| 1051 | 1037 |
| 1052 // When we are given x/y coordinates of 0 on a created popup window, | 1038 // When we are given x/y coordinates of 0 on a created popup window, |
| 1053 // assume none were given by the window.open() command. | 1039 // assume none were given by the window.open() command. |
| 1054 if (window_rect.x() == 0 && window_rect.y() == 0) { | 1040 if (window_rect.x() == 0 && window_rect.y() == 0) { |
| 1055 gfx::Size size = window_rect.size(); | 1041 gfx::Size size = window_rect.size(); |
| 1056 window_rect.set_origin(WindowSizer::GetDefaultPopupOrigin(size)); | 1042 window_rect.set_origin(WindowSizer::GetDefaultPopupOrigin(size)); |
| 1057 } | 1043 } |
| 1058 | 1044 |
| 1059 *bounds = window_rect; | 1045 *bounds = window_rect; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 | 1080 |
| 1095 // Give beforeunload handlers the chance to cancel the close before we hide | 1081 // Give beforeunload handlers the chance to cancel the close before we hide |
| 1096 // the window below. | 1082 // the window below. |
| 1097 if (!browser_->ShouldCloseWindow()) | 1083 if (!browser_->ShouldCloseWindow()) |
| 1098 return false; | 1084 return false; |
| 1099 | 1085 |
| 1100 if (!browser_->tabstrip_model()->empty()) { | 1086 if (!browser_->tabstrip_model()->empty()) { |
| 1101 // Tab strip isn't empty. Hide the frame (so it appears to have closed | 1087 // Tab strip isn't empty. Hide the frame (so it appears to have closed |
| 1102 // immediately) and close all the tabs, allowing the renderers to shut | 1088 // immediately) and close all the tabs, allowing the renderers to shut |
| 1103 // down. When the tab strip is empty we'll be called back again. | 1089 // down. When the tab strip is empty we'll be called back again. |
| 1104 frame_->GetWindow()->Hide(); | 1090 frame_->Hide(); |
| 1105 browser_->OnWindowClosing(); | 1091 browser_->OnWindowClosing(); |
| 1106 return false; | 1092 return false; |
| 1107 } | 1093 } |
| 1108 | 1094 |
| 1109 // Empty TabStripModel, it's now safe to allow the Window to be closed. | 1095 // Empty TabStripModel, it's now safe to allow the Window to be closed. |
| 1110 NotificationService::current()->Notify( | 1096 NotificationService::current()->Notify( |
| 1111 NotificationType::WINDOW_CLOSED, | 1097 NotificationType::WINDOW_CLOSED, |
| 1112 Source<HWND>(frame_->GetWindow()->GetHWND()), | 1098 Source<HWND>(frame_->GetHWND()), |
| 1113 NotificationService::NoDetails()); | 1099 NotificationService::NoDetails()); |
| 1114 return true; | 1100 return true; |
| 1115 } | 1101 } |
| 1116 | 1102 |
| 1117 int BrowserView::NonClientHitTest(const gfx::Point& point) { | 1103 int BrowserView::NonClientHitTest(const gfx::Point& point) { |
| 1118 // Since the TabStrip only renders in some parts of the top of the window, | 1104 // Since the TabStrip only renders in some parts of the top of the window, |
| 1119 // the un-obscured area is considered to be part of the non-client caption | 1105 // the un-obscured area is considered to be part of the non-client caption |
| 1120 // area of the window. So we need to treat hit-tests in these regions as | 1106 // area of the window. So we need to treat hit-tests in these regions as |
| 1121 // hit-tests of the titlebar. | 1107 // hit-tests of the titlebar. |
| 1122 | 1108 |
| 1123 if (CanCurrentlyResize()) { | 1109 if (CanCurrentlyResize()) { |
| 1124 CRect client_rect; | 1110 CRect client_rect; |
| 1125 ::GetClientRect(frame_->GetWindow()->GetHWND(), &client_rect); | 1111 ::GetClientRect(frame_->GetHWND(), &client_rect); |
| 1126 gfx::Size resize_corner_size = ResizeCorner::GetSize(); | 1112 gfx::Size resize_corner_size = ResizeCorner::GetSize(); |
| 1127 gfx::Rect resize_corner_rect(client_rect.right - resize_corner_size.width(), | 1113 gfx::Rect resize_corner_rect(client_rect.right - resize_corner_size.width(), |
| 1128 client_rect.bottom - resize_corner_size.height(), | 1114 client_rect.bottom - resize_corner_size.height(), |
| 1129 resize_corner_size.width(), resize_corner_size.height()); | 1115 resize_corner_size.width(), resize_corner_size.height()); |
| 1130 bool rtl_dir = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT); | 1116 bool rtl_dir = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT); |
| 1131 if (rtl_dir) | 1117 if (rtl_dir) |
| 1132 resize_corner_rect.set_x(0); | 1118 resize_corner_rect.set_x(0); |
| 1133 if (resize_corner_rect.Contains(point)) { | 1119 if (resize_corner_rect.Contains(point)) { |
| 1134 if (rtl_dir) | 1120 if (rtl_dir) |
| 1135 return HTBOTTOMLEFT; | 1121 return HTBOTTOMLEFT; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 return tabstrip_->OnPerformDrop(*mapped_event.get()); | 1261 return tabstrip_->OnPerformDrop(*mapped_event.get()); |
| 1276 } | 1262 } |
| 1277 return DragDropTypes::DRAG_NONE; | 1263 return DragDropTypes::DRAG_NONE; |
| 1278 } | 1264 } |
| 1279 | 1265 |
| 1280 | 1266 |
| 1281 /////////////////////////////////////////////////////////////////////////////// | 1267 /////////////////////////////////////////////////////////////////////////////// |
| 1282 // BrowserView, private: | 1268 // BrowserView, private: |
| 1283 | 1269 |
| 1284 void BrowserView::InitSystemMenu() { | 1270 void BrowserView::InitSystemMenu() { |
| 1285 HMENU system_menu = GetSystemMenu(frame_->GetWindow()->GetHWND(), FALSE); | 1271 HMENU system_menu = GetSystemMenu(frame_->GetHWND(), FALSE); |
| 1286 system_menu_.reset(new Menu(system_menu)); | 1272 system_menu_.reset(new Menu(system_menu)); |
| 1287 int insertion_index = std::max(0, system_menu_->ItemCount() - 1); | 1273 int insertion_index = std::max(0, system_menu_->ItemCount() - 1); |
| 1288 // We add the menu items in reverse order so that insertion_index never needs | 1274 // We add the menu items in reverse order so that insertion_index never needs |
| 1289 // to change. | 1275 // to change. |
| 1290 if (IsBrowserTypeNormal()) { | 1276 if (IsBrowserTypeNormal()) { |
| 1291 system_menu_->AddSeparator(insertion_index); | 1277 system_menu_->AddSeparator(insertion_index); |
| 1292 system_menu_->AddMenuItemWithLabel(insertion_index, IDC_TASK_MANAGER, | 1278 system_menu_->AddMenuItemWithLabel(insertion_index, IDC_TASK_MANAGER, |
| 1293 l10n_util::GetString(IDS_TASK_MANAGER)); | 1279 l10n_util::GetString(IDS_TASK_MANAGER)); |
| 1294 // If it's a regular browser window with tabs, we don't add any more items, | 1280 // If it's a regular browser window with tabs, we don't add any more items, |
| 1295 // since it already has menus (Page, Chrome). | 1281 // since it already has menus (Page, Chrome). |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1426 active_download_shelf_->Layout(); | 1412 active_download_shelf_->Layout(); |
| 1427 bottom -= height; | 1413 bottom -= height; |
| 1428 } | 1414 } |
| 1429 return bottom; | 1415 return bottom; |
| 1430 } | 1416 } |
| 1431 | 1417 |
| 1432 void BrowserView::LayoutStatusBubble(int top) { | 1418 void BrowserView::LayoutStatusBubble(int top) { |
| 1433 // In restored mode, the client area has a client edge between it and the | 1419 // In restored mode, the client area has a client edge between it and the |
| 1434 // frame. | 1420 // frame. |
| 1435 int overlap = kStatusBubbleOverlap + | 1421 int overlap = kStatusBubbleOverlap + |
| 1436 (IsMaximized() ? 0 : views::NonClientView::kClientEdgeThickness); | 1422 (IsMaximized() ? 0 : views::NonClientFrameView::kClientEdgeThickness); |
| 1437 gfx::Point origin(-overlap, top - kStatusBubbleHeight + overlap); | 1423 gfx::Point origin(-overlap, top - kStatusBubbleHeight + overlap); |
| 1438 ConvertPointToView(this, GetParent(), &origin); | 1424 ConvertPointToView(this, GetParent(), &origin); |
| 1439 status_bubble_->SetBounds(origin.x(), origin.y(), width() / 3, | 1425 status_bubble_->SetBounds(origin.x(), origin.y(), width() / 3, |
| 1440 kStatusBubbleHeight); | 1426 kStatusBubbleHeight); |
| 1441 } | 1427 } |
| 1442 | 1428 |
| 1443 bool BrowserView::MaybeShowBookmarkBar(TabContents* contents) { | 1429 bool BrowserView::MaybeShowBookmarkBar(TabContents* contents) { |
| 1444 views::View* new_bookmark_bar_view = NULL; | 1430 views::View* new_bookmark_bar_view = NULL; |
| 1445 if (SupportsWindowFeature(FEATURE_BOOKMARKBAR) && contents) { | 1431 if (SupportsWindowFeature(FEATURE_BOOKMARKBAR) && contents) { |
| 1446 if (!bookmark_bar_view_.get()) { | 1432 if (!bookmark_bar_view_.get()) { |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1671 | 1657 |
| 1672 // static | 1658 // static |
| 1673 void BrowserView::InitClass() { | 1659 void BrowserView::InitClass() { |
| 1674 static bool initialized = false; | 1660 static bool initialized = false; |
| 1675 if (!initialized) { | 1661 if (!initialized) { |
| 1676 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 1662 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 1677 default_favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); | 1663 default_favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); |
| 1678 initialized = true; | 1664 initialized = true; |
| 1679 } | 1665 } |
| 1680 } | 1666 } |
| 1667 |
| 1668 // static |
| 1669 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 1670 BrowserView* browser_view = new BrowserView(browser); |
| 1671 (new BrowserFrame(browser_view))->Init(); |
| 1672 return browser_view; |
| 1673 } |
| 1674 |
| OLD | NEW |