| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/views/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 | 1507 |
| 1508 bool BrowserView::CanMaximize() const { | 1508 bool BrowserView::CanMaximize() const { |
| 1509 return true; | 1509 return true; |
| 1510 } | 1510 } |
| 1511 | 1511 |
| 1512 bool BrowserView::CanMinimize() const { | 1512 bool BrowserView::CanMinimize() const { |
| 1513 return true; | 1513 return true; |
| 1514 } | 1514 } |
| 1515 | 1515 |
| 1516 bool BrowserView::CanActivate() const { | 1516 bool BrowserView::CanActivate() const { |
| 1517 if (!AppModalDialogQueue::GetInstance()->active_dialog() || | 1517 app_modal::AppModalDialogQueue* queue = |
| 1518 !AppModalDialogQueue::GetInstance()->active_dialog()->native_dialog()) | 1518 app_modal::AppModalDialogQueue::GetInstance(); |
| 1519 if (!queue->active_dialog() || !queue->active_dialog()->native_dialog()) |
| 1519 return true; | 1520 return true; |
| 1520 | 1521 |
| 1521 #if defined(USE_AURA) && defined(OS_CHROMEOS) | 1522 #if defined(USE_AURA) && defined(OS_CHROMEOS) |
| 1522 // On Aura window manager controls all windows so settings focus via PostTask | 1523 // On Aura window manager controls all windows so settings focus via PostTask |
| 1523 // will make only worse because posted task will keep trying to steal focus. | 1524 // will make only worse because posted task will keep trying to steal focus. |
| 1524 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); | 1525 queue->ActivateModalDialog(); |
| 1525 #else | 1526 #else |
| 1526 // If another browser is app modal, flash and activate the modal browser. This | 1527 // If another browser is app modal, flash and activate the modal browser. This |
| 1527 // has to be done in a post task, otherwise if the user clicked on a window | 1528 // has to be done in a post task, otherwise if the user clicked on a window |
| 1528 // that doesn't have the modal dialog the windows keep trying to get the focus | 1529 // that doesn't have the modal dialog the windows keep trying to get the focus |
| 1529 // from each other on Windows. http://crbug.com/141650. | 1530 // from each other on Windows. http://crbug.com/141650. |
| 1530 base::MessageLoop::current()->PostTask( | 1531 base::MessageLoop::current()->PostTask( |
| 1531 FROM_HERE, | 1532 FROM_HERE, |
| 1532 base::Bind(&BrowserView::ActivateAppModalDialog, | 1533 base::Bind(&BrowserView::ActivateAppModalDialog, |
| 1533 activate_modal_dialog_factory_.GetWeakPtr())); | 1534 activate_modal_dialog_factory_.GetWeakPtr())); |
| 1534 #endif | 1535 #endif |
| (...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2475 if (contents->GetRenderWidgetHostView()->HasFocus()) { | 2476 if (contents->GetRenderWidgetHostView()->HasFocus()) { |
| 2476 (contents->*method)(); | 2477 (contents->*method)(); |
| 2477 return true; | 2478 return true; |
| 2478 } | 2479 } |
| 2479 | 2480 |
| 2480 return false; | 2481 return false; |
| 2481 } | 2482 } |
| 2482 | 2483 |
| 2483 void BrowserView::ActivateAppModalDialog() const { | 2484 void BrowserView::ActivateAppModalDialog() const { |
| 2484 // If another browser is app modal, flash and activate the modal browser. | 2485 // If another browser is app modal, flash and activate the modal browser. |
| 2485 AppModalDialog* active_dialog = | 2486 app_modal::AppModalDialog* active_dialog = |
| 2486 AppModalDialogQueue::GetInstance()->active_dialog(); | 2487 app_modal::AppModalDialogQueue::GetInstance()->active_dialog(); |
| 2487 if (!active_dialog) | 2488 if (!active_dialog) |
| 2488 return; | 2489 return; |
| 2489 | 2490 |
| 2490 Browser* modal_browser = | 2491 Browser* modal_browser = |
| 2491 chrome::FindBrowserWithWebContents(active_dialog->web_contents()); | 2492 chrome::FindBrowserWithWebContents(active_dialog->web_contents()); |
| 2492 if (modal_browser && (browser_ != modal_browser)) { | 2493 if (modal_browser && (browser_ != modal_browser)) { |
| 2493 modal_browser->window()->FlashFrame(true); | 2494 modal_browser->window()->FlashFrame(true); |
| 2494 modal_browser->window()->Activate(); | 2495 modal_browser->window()->Activate(); |
| 2495 } | 2496 } |
| 2496 | 2497 |
| 2497 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); | 2498 app_modal::AppModalDialogQueue::GetInstance()->ActivateModalDialog(); |
| 2498 } | 2499 } |
| 2499 | 2500 |
| 2500 int BrowserView::GetMaxTopInfoBarArrowHeight() { | 2501 int BrowserView::GetMaxTopInfoBarArrowHeight() { |
| 2501 int top_arrow_height = 0; | 2502 int top_arrow_height = 0; |
| 2502 // Only show the arrows when not in fullscreen and when there's no omnibox | 2503 // Only show the arrows when not in fullscreen and when there's no omnibox |
| 2503 // popup. | 2504 // popup. |
| 2504 if (!IsFullscreen() && | 2505 if (!IsFullscreen() && |
| 2505 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { | 2506 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { |
| 2506 gfx::Point icon_bottom( | 2507 gfx::Point icon_bottom( |
| 2507 toolbar_->location_bar()->GetLocationBarAnchorPoint()); | 2508 toolbar_->location_bar()->GetLocationBarAnchorPoint()); |
| 2508 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); | 2509 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); |
| 2509 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(nullptr)); | 2510 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(nullptr)); |
| 2510 ConvertPointToTarget(infobar_container_, this, &infobar_top); | 2511 ConvertPointToTarget(infobar_container_, this, &infobar_top); |
| 2511 top_arrow_height = infobar_top.y() - icon_bottom.y(); | 2512 top_arrow_height = infobar_top.y() - icon_bottom.y(); |
| 2512 } | 2513 } |
| 2513 return top_arrow_height; | 2514 return top_arrow_height; |
| 2514 } | 2515 } |
| OLD | NEW |