Chromium Code Reviews| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 #include "chrome/browser/ui/browser_list.h" | 54 #include "chrome/browser/ui/browser_list.h" |
| 55 #include "chrome/browser/ui/browser_window_state.h" | 55 #include "chrome/browser/ui/browser_window_state.h" |
| 56 #include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h" | 56 #include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h" |
| 57 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 57 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
| 58 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 58 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 59 #include "chrome/browser/ui/view_ids.h" | 59 #include "chrome/browser/ui/view_ids.h" |
| 60 #include "chrome/browser/ui/views/accelerator_table.h" | 60 #include "chrome/browser/ui/views/accelerator_table.h" |
| 61 #include "chrome/browser/ui/views/accessibility/invert_bubble_view.h" | 61 #include "chrome/browser/ui/views/accessibility/invert_bubble_view.h" |
| 62 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | 62 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
| 63 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" | 63 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" |
| 64 #include "chrome/browser/ui/views/browser_modal_dialog.h" | |
| 64 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" | 65 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" |
| 65 #include "chrome/browser/ui/views/download/download_shelf_view.h" | 66 #include "chrome/browser/ui/views/download/download_shelf_view.h" |
| 66 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" | 67 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" |
| 67 #include "chrome/browser/ui/views/extensions/bookmark_app_confirmation_view.h" | 68 #include "chrome/browser/ui/views/extensions/bookmark_app_confirmation_view.h" |
| 68 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" | 69 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" |
| 69 #include "chrome/browser/ui/views/find_bar_host.h" | 70 #include "chrome/browser/ui/views/find_bar_host.h" |
| 70 #include "chrome/browser/ui/views/frame/browser_view_layout.h" | 71 #include "chrome/browser/ui/views/frame/browser_view_layout.h" |
| 71 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" | 72 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" |
| 72 #include "chrome/browser/ui/views/frame/contents_layout_manager.h" | 73 #include "chrome/browser/ui/views/frame/contents_layout_manager.h" |
| 73 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | 74 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 96 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 97 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
| 97 #include "chrome/common/chrome_switches.h" | 98 #include "chrome/common/chrome_switches.h" |
| 98 #include "chrome/common/extensions/command.h" | 99 #include "chrome/common/extensions/command.h" |
| 99 #include "chrome/common/features.h" | 100 #include "chrome/common/features.h" |
| 100 #include "chrome/common/pref_names.h" | 101 #include "chrome/common/pref_names.h" |
| 101 #include "chrome/common/url_constants.h" | 102 #include "chrome/common/url_constants.h" |
| 102 #include "chrome/grit/chromium_strings.h" | 103 #include "chrome/grit/chromium_strings.h" |
| 103 #include "chrome/grit/generated_resources.h" | 104 #include "chrome/grit/generated_resources.h" |
| 104 #include "chrome/grit/locale_settings.h" | 105 #include "chrome/grit/locale_settings.h" |
| 105 #include "chrome/grit/theme_resources.h" | 106 #include "chrome/grit/theme_resources.h" |
| 106 #include "components/app_modal/app_modal_dialog.h" | |
| 107 #include "components/app_modal/app_modal_dialog_queue.h" | |
| 108 #include "components/app_modal/native_app_modal_dialog.h" | |
| 109 #include "components/omnibox/browser/omnibox_popup_model.h" | 107 #include "components/omnibox/browser/omnibox_popup_model.h" |
| 110 #include "components/omnibox/browser/omnibox_popup_view.h" | 108 #include "components/omnibox/browser/omnibox_popup_view.h" |
| 111 #include "components/omnibox/browser/omnibox_view.h" | 109 #include "components/omnibox/browser/omnibox_view.h" |
| 112 #include "components/prefs/pref_service.h" | 110 #include "components/prefs/pref_service.h" |
| 113 #include "components/sessions/core/tab_restore_service.h" | 111 #include "components/sessions/core/tab_restore_service.h" |
| 114 #include "components/signin/core/common/profile_management_switches.h" | 112 #include "components/signin/core/common/profile_management_switches.h" |
| 115 #include "components/translate/core/browser/language_state.h" | 113 #include "components/translate/core/browser/language_state.h" |
| 116 #include "content/public/browser/download_manager.h" | 114 #include "content/public/browser/download_manager.h" |
| 117 #include "content/public/browser/keyboard_event_processing_result.h" | 115 #include "content/public/browser/keyboard_event_processing_result.h" |
| 118 #include "content/public/browser/notification_service.h" | 116 #include "content/public/browser/notification_service.h" |
| (...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1571 | 1569 |
| 1572 bool BrowserView::CanMaximize() const { | 1570 bool BrowserView::CanMaximize() const { |
| 1573 return true; | 1571 return true; |
| 1574 } | 1572 } |
| 1575 | 1573 |
| 1576 bool BrowserView::CanMinimize() const { | 1574 bool BrowserView::CanMinimize() const { |
| 1577 return true; | 1575 return true; |
| 1578 } | 1576 } |
| 1579 | 1577 |
| 1580 bool BrowserView::CanActivate() const { | 1578 bool BrowserView::CanActivate() const { |
| 1581 app_modal::AppModalDialogQueue* queue = | 1579 if (!BrowserModalDialogList::GetInstance()->IsShowing()) { |
|
sky
2017/05/17 18:03:18
no {}
zmin
2017/05/18 03:31:18
Done.
| |
| 1582 app_modal::AppModalDialogQueue::GetInstance(); | |
| 1583 if (!queue->active_dialog() || !queue->active_dialog()->native_dialog() || | |
| 1584 !queue->active_dialog()->native_dialog()->IsShowing()) { | |
| 1585 return true; | 1580 return true; |
| 1586 } | 1581 } |
| 1587 | 1582 |
| 1588 #if defined(USE_AURA) && defined(OS_CHROMEOS) | 1583 #if defined(USE_AURA) && defined(OS_CHROMEOS) |
| 1589 // On Aura window manager controls all windows so settings focus via PostTask | 1584 // On Aura window manager controls all windows so settings focus via PostTask |
| 1590 // will make only worse because posted task will keep trying to steal focus. | 1585 // will make only worse because posted task will keep trying to steal focus. |
| 1591 queue->ActivateModalDialog(); | 1586 BrowserModalDialogList::GetInstance()->ActivateModalDialog(browser_.get()); |
| 1592 #else | 1587 #else |
| 1593 // If another browser is app modal, flash and activate the modal browser. This | 1588 // If another browser is app modal, flash and activate the modal browser. This |
| 1594 // has to be done in a post task, otherwise if the user clicked on a window | 1589 // has to be done in a post task, otherwise if the user clicked on a window |
| 1595 // that doesn't have the modal dialog the windows keep trying to get the focus | 1590 // that doesn't have the modal dialog the windows keep trying to get the focus |
| 1596 // from each other on Windows. http://crbug.com/141650. | 1591 // from each other on Windows. http://crbug.com/141650. |
| 1597 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1592 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1598 FROM_HERE, base::BindOnce(&BrowserView::ActivateAppModalDialog, | 1593 FROM_HERE, base::BindOnce(&BrowserView::ActivateAppModalDialog, |
| 1599 activate_modal_dialog_factory_.GetWeakPtr())); | 1594 activate_modal_dialog_factory_.GetWeakPtr())); |
| 1600 #endif | 1595 #endif |
| 1601 return false; | 1596 return false; |
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2588 content::RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView(); | 2583 content::RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView(); |
| 2589 if (!rwhv || !rwhv->HasFocus()) | 2584 if (!rwhv || !rwhv->HasFocus()) |
| 2590 return false; | 2585 return false; |
| 2591 // Calling |method| rather than using a fake key event is important since a | 2586 // Calling |method| rather than using a fake key event is important since a |
| 2592 // fake event might be consumed by the web content. | 2587 // fake event might be consumed by the web content. |
| 2593 (contents->*method)(); | 2588 (contents->*method)(); |
| 2594 return true; | 2589 return true; |
| 2595 } | 2590 } |
| 2596 | 2591 |
| 2597 void BrowserView::ActivateAppModalDialog() const { | 2592 void BrowserView::ActivateAppModalDialog() const { |
| 2598 // If another browser is app modal, flash and activate the modal browser. | 2593 BrowserModalDialogList::GetInstance()->ActivateModalDialog(browser_.get()); |
| 2599 app_modal::AppModalDialog* active_dialog = | |
| 2600 app_modal::AppModalDialogQueue::GetInstance()->active_dialog(); | |
| 2601 if (!active_dialog) | |
| 2602 return; | |
| 2603 | |
| 2604 Browser* modal_browser = | |
| 2605 chrome::FindBrowserWithWebContents(active_dialog->web_contents()); | |
| 2606 if (modal_browser && (browser_.get() != modal_browser)) { | |
| 2607 modal_browser->window()->FlashFrame(true); | |
| 2608 modal_browser->window()->Activate(); | |
| 2609 } | |
| 2610 | |
| 2611 app_modal::AppModalDialogQueue::GetInstance()->ActivateModalDialog(); | |
| 2612 } | 2594 } |
| 2613 | 2595 |
| 2614 int BrowserView::GetMaxTopInfoBarArrowHeight() { | 2596 int BrowserView::GetMaxTopInfoBarArrowHeight() { |
| 2615 int top_arrow_height = 0; | 2597 int top_arrow_height = 0; |
| 2616 // Only show the arrows when not in fullscreen and when there's no omnibox | 2598 // Only show the arrows when not in fullscreen and when there's no omnibox |
| 2617 // popup. | 2599 // popup. |
| 2618 if (!IsFullscreen() && | 2600 if (!IsFullscreen() && |
| 2619 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { | 2601 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { |
| 2620 gfx::Point icon_bottom(toolbar_->location_bar()->GetInfoBarAnchorPoint()); | 2602 gfx::Point icon_bottom(toolbar_->location_bar()->GetInfoBarAnchorPoint()); |
| 2621 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); | 2603 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2692 } | 2674 } |
| 2693 | 2675 |
| 2694 extensions::ActiveTabPermissionGranter* | 2676 extensions::ActiveTabPermissionGranter* |
| 2695 BrowserView::GetActiveTabPermissionGranter() { | 2677 BrowserView::GetActiveTabPermissionGranter() { |
| 2696 content::WebContents* web_contents = GetActiveWebContents(); | 2678 content::WebContents* web_contents = GetActiveWebContents(); |
| 2697 if (!web_contents) | 2679 if (!web_contents) |
| 2698 return nullptr; | 2680 return nullptr; |
| 2699 return extensions::TabHelper::FromWebContents(web_contents) | 2681 return extensions::TabHelper::FromWebContents(web_contents) |
| 2700 ->active_tab_permission_granter(); | 2682 ->active_tab_permission_granter(); |
| 2701 } | 2683 } |
| OLD | NEW |