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()) |
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 } | |
1587 | 1581 |
1588 #if defined(USE_AURA) && defined(OS_CHROMEOS) | 1582 #if defined(USE_AURA) && defined(OS_CHROMEOS) |
1589 // On Aura window manager controls all windows so settings focus via PostTask | 1583 // 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. | 1584 // will make only worse because posted task will keep trying to steal focus. |
1591 queue->ActivateModalDialog(); | 1585 BrowserModalDialogList::GetInstance()->ActivateModalDialog(browser_.get()); |
1592 #else | 1586 #else |
1593 // If another browser is app modal, flash and activate the modal browser. This | 1587 // 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 | 1588 // 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 | 1589 // 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. | 1590 // from each other on Windows. http://crbug.com/141650. |
1597 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1591 base::ThreadTaskRunnerHandle::Get()->PostTask( |
1598 FROM_HERE, base::BindOnce(&BrowserView::ActivateAppModalDialog, | 1592 FROM_HERE, base::BindOnce(&BrowserView::ActivateAppModalDialog, |
1599 activate_modal_dialog_factory_.GetWeakPtr())); | 1593 activate_modal_dialog_factory_.GetWeakPtr())); |
1600 #endif | 1594 #endif |
1601 return false; | 1595 return false; |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2588 content::RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView(); | 2582 content::RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView(); |
2589 if (!rwhv || !rwhv->HasFocus()) | 2583 if (!rwhv || !rwhv->HasFocus()) |
2590 return false; | 2584 return false; |
2591 // Calling |method| rather than using a fake key event is important since a | 2585 // Calling |method| rather than using a fake key event is important since a |
2592 // fake event might be consumed by the web content. | 2586 // fake event might be consumed by the web content. |
2593 (contents->*method)(); | 2587 (contents->*method)(); |
2594 return true; | 2588 return true; |
2595 } | 2589 } |
2596 | 2590 |
2597 void BrowserView::ActivateAppModalDialog() const { | 2591 void BrowserView::ActivateAppModalDialog() const { |
2598 // If another browser is app modal, flash and activate the modal browser. | 2592 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 } | 2593 } |
2613 | 2594 |
2614 int BrowserView::GetMaxTopInfoBarArrowHeight() { | 2595 int BrowserView::GetMaxTopInfoBarArrowHeight() { |
2615 int top_arrow_height = 0; | 2596 int top_arrow_height = 0; |
2616 // Only show the arrows when not in fullscreen and when there's no omnibox | 2597 // Only show the arrows when not in fullscreen and when there's no omnibox |
2617 // popup. | 2598 // popup. |
2618 if (!IsFullscreen() && | 2599 if (!IsFullscreen() && |
2619 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { | 2600 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { |
2620 gfx::Point icon_bottom(toolbar_->location_bar()->GetInfoBarAnchorPoint()); | 2601 gfx::Point icon_bottom(toolbar_->location_bar()->GetInfoBarAnchorPoint()); |
2621 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); | 2602 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2692 } | 2673 } |
2693 | 2674 |
2694 extensions::ActiveTabPermissionGranter* | 2675 extensions::ActiveTabPermissionGranter* |
2695 BrowserView::GetActiveTabPermissionGranter() { | 2676 BrowserView::GetActiveTabPermissionGranter() { |
2696 content::WebContents* web_contents = GetActiveWebContents(); | 2677 content::WebContents* web_contents = GetActiveWebContents(); |
2697 if (!web_contents) | 2678 if (!web_contents) |
2698 return nullptr; | 2679 return nullptr; |
2699 return extensions::TabHelper::FromWebContents(web_contents) | 2680 return extensions::TabHelper::FromWebContents(web_contents) |
2700 ->active_tab_permission_granter(); | 2681 ->active_tab_permission_granter(); |
2701 } | 2682 } |
OLD | NEW |