| 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 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1495 | 1495 |
| 1496 bool BrowserView::CanMaximize() const { | 1496 bool BrowserView::CanMaximize() const { |
| 1497 return true; | 1497 return true; |
| 1498 } | 1498 } |
| 1499 | 1499 |
| 1500 bool BrowserView::CanMinimize() const { | 1500 bool BrowserView::CanMinimize() const { |
| 1501 return true; | 1501 return true; |
| 1502 } | 1502 } |
| 1503 | 1503 |
| 1504 bool BrowserView::CanActivate() const { | 1504 bool BrowserView::CanActivate() const { |
| 1505 if (!AppModalDialogQueue::GetInstance()->active_dialog() || | 1505 app_modal_dialogs::AppModalDialogQueue* queue = |
| 1506 !AppModalDialogQueue::GetInstance()->active_dialog()->native_dialog()) | 1506 app_modal_dialogs::AppModalDialogQueue::GetInstance(); |
| 1507 if (!queue->active_dialog() || !queue->active_dialog()->native_dialog()) |
| 1507 return true; | 1508 return true; |
| 1508 | 1509 |
| 1509 #if defined(USE_AURA) && defined(OS_CHROMEOS) | 1510 #if defined(USE_AURA) && defined(OS_CHROMEOS) |
| 1510 // On Aura window manager controls all windows so settings focus via PostTask | 1511 // On Aura window manager controls all windows so settings focus via PostTask |
| 1511 // will make only worse because posted task will keep trying to steal focus. | 1512 // will make only worse because posted task will keep trying to steal focus. |
| 1512 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); | 1513 app_modal_dialogs::AppModalDialogQueue::GetInstance()->ActivateModalDialog(); |
| 1513 #else | 1514 #else |
| 1514 // If another browser is app modal, flash and activate the modal browser. This | 1515 // If another browser is app modal, flash and activate the modal browser. This |
| 1515 // has to be done in a post task, otherwise if the user clicked on a window | 1516 // has to be done in a post task, otherwise if the user clicked on a window |
| 1516 // that doesn't have the modal dialog the windows keep trying to get the focus | 1517 // that doesn't have the modal dialog the windows keep trying to get the focus |
| 1517 // from each other on Windows. http://crbug.com/141650. | 1518 // from each other on Windows. http://crbug.com/141650. |
| 1518 base::MessageLoop::current()->PostTask( | 1519 base::MessageLoop::current()->PostTask( |
| 1519 FROM_HERE, | 1520 FROM_HERE, |
| 1520 base::Bind(&BrowserView::ActivateAppModalDialog, | 1521 base::Bind(&BrowserView::ActivateAppModalDialog, |
| 1521 activate_modal_dialog_factory_.GetWeakPtr())); | 1522 activate_modal_dialog_factory_.GetWeakPtr())); |
| 1522 #endif | 1523 #endif |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2483 if (native_view->HasFocus()) { | 2484 if (native_view->HasFocus()) { |
| 2484 (contents->*method)(); | 2485 (contents->*method)(); |
| 2485 return true; | 2486 return true; |
| 2486 } | 2487 } |
| 2487 | 2488 |
| 2488 return false; | 2489 return false; |
| 2489 } | 2490 } |
| 2490 | 2491 |
| 2491 void BrowserView::ActivateAppModalDialog() const { | 2492 void BrowserView::ActivateAppModalDialog() const { |
| 2492 // If another browser is app modal, flash and activate the modal browser. | 2493 // If another browser is app modal, flash and activate the modal browser. |
| 2493 AppModalDialog* active_dialog = | 2494 app_modal_dialogs::AppModalDialog* active_dialog = |
| 2494 AppModalDialogQueue::GetInstance()->active_dialog(); | 2495 app_modal_dialogs::AppModalDialogQueue::GetInstance()->active_dialog(); |
| 2495 if (!active_dialog) | 2496 if (!active_dialog) |
| 2496 return; | 2497 return; |
| 2497 | 2498 |
| 2498 Browser* modal_browser = | 2499 Browser* modal_browser = |
| 2499 chrome::FindBrowserWithWebContents(active_dialog->web_contents()); | 2500 chrome::FindBrowserWithWebContents(active_dialog->web_contents()); |
| 2500 if (modal_browser && (browser_ != modal_browser)) { | 2501 if (modal_browser && (browser_ != modal_browser)) { |
| 2501 modal_browser->window()->FlashFrame(true); | 2502 modal_browser->window()->FlashFrame(true); |
| 2502 modal_browser->window()->Activate(); | 2503 modal_browser->window()->Activate(); |
| 2503 } | 2504 } |
| 2504 | 2505 |
| 2505 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); | 2506 app_modal_dialogs::AppModalDialogQueue::GetInstance()->ActivateModalDialog(); |
| 2506 } | 2507 } |
| 2507 | 2508 |
| 2508 int BrowserView::GetMaxTopInfoBarArrowHeight() { | 2509 int BrowserView::GetMaxTopInfoBarArrowHeight() { |
| 2509 int top_arrow_height = 0; | 2510 int top_arrow_height = 0; |
| 2510 // Only show the arrows when not in fullscreen and when there's no omnibox | 2511 // Only show the arrows when not in fullscreen and when there's no omnibox |
| 2511 // popup. | 2512 // popup. |
| 2512 if (!IsFullscreen() && | 2513 if (!IsFullscreen() && |
| 2513 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { | 2514 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { |
| 2514 gfx::Point icon_bottom( | 2515 gfx::Point icon_bottom( |
| 2515 toolbar_->location_bar()->GetLocationBarAnchorPoint()); | 2516 toolbar_->location_bar()->GetLocationBarAnchorPoint()); |
| 2516 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); | 2517 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); |
| 2517 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); | 2518 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); |
| 2518 ConvertPointToTarget(infobar_container_, this, &infobar_top); | 2519 ConvertPointToTarget(infobar_container_, this, &infobar_top); |
| 2519 top_arrow_height = infobar_top.y() - icon_bottom.y(); | 2520 top_arrow_height = infobar_top.y() - icon_bottom.y(); |
| 2520 } | 2521 } |
| 2521 return top_arrow_height; | 2522 return top_arrow_height; |
| 2522 } | 2523 } |
| OLD | NEW |