| 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 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 ExclusiveAccessBubbleType bubble_type) { | 951 ExclusiveAccessBubbleType bubble_type) { |
| 952 // Immersive mode has no exit bubble because it has a visible strip at the | 952 // Immersive mode has no exit bubble because it has a visible strip at the |
| 953 // top that gives the user a hover target. | 953 // top that gives the user a hover target. |
| 954 // TODO(jamescook): Figure out what to do with mouse-lock. | 954 // TODO(jamescook): Figure out what to do with mouse-lock. |
| 955 if (bubble_type == EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE || | 955 if (bubble_type == EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE || |
| 956 ShouldUseImmersiveFullscreenForUrl(url)) { | 956 ShouldUseImmersiveFullscreenForUrl(url)) { |
| 957 exclusive_access_bubble_.reset(); | 957 exclusive_access_bubble_.reset(); |
| 958 return; | 958 return; |
| 959 } | 959 } |
| 960 | 960 |
| 961 if (exclusive_access_bubble_) { |
| 962 exclusive_access_bubble_->UpdateContent(url, bubble_type); |
| 963 return; |
| 964 } |
| 965 |
| 961 // Hide the backspace shortcut bubble, to avoid overlapping. | 966 // Hide the backspace shortcut bubble, to avoid overlapping. |
| 962 new_back_shortcut_bubble_.reset(); | 967 new_back_shortcut_bubble_.reset(); |
| 963 | 968 |
| 964 if (exclusive_access_bubble_) { | 969 exclusive_access_bubble_.reset( |
| 965 exclusive_access_bubble_->UpdateContent(url, bubble_type); | 970 new ExclusiveAccessBubbleViews(this, url, bubble_type)); |
| 966 } else { | |
| 967 exclusive_access_bubble_.reset( | |
| 968 new ExclusiveAccessBubbleViews(this, url, bubble_type)); | |
| 969 } | |
| 970 } | 971 } |
| 971 | 972 |
| 972 void BrowserView::OnExclusiveAccessUserInput() { | 973 void BrowserView::OnExclusiveAccessUserInput() { |
| 973 if (exclusive_access_bubble_.get()) | 974 if (exclusive_access_bubble_.get()) |
| 974 exclusive_access_bubble_->OnUserInput(); | 975 exclusive_access_bubble_->OnUserInput(); |
| 975 } | 976 } |
| 976 | 977 |
| 977 bool BrowserView::ShouldHideUIForFullscreen() const { | 978 bool BrowserView::ShouldHideUIForFullscreen() const { |
| 978 // Immersive mode needs UI for the slide-down top panel. | 979 // Immersive mode needs UI for the slide-down top panel. |
| 979 if (immersive_mode_controller_->IsEnabled()) | 980 if (immersive_mode_controller_->IsEnabled()) |
| 980 return false; | 981 return false; |
| 981 | 982 |
| 982 return IsFullscreen(); | 983 return IsFullscreen(); |
| 983 } | 984 } |
| 984 | 985 |
| 985 bool BrowserView::IsFullscreen() const { | 986 bool BrowserView::IsFullscreen() const { |
| 986 return frame_->IsFullscreen(); | 987 return frame_->IsFullscreen(); |
| 987 } | 988 } |
| 988 | 989 |
| 989 bool BrowserView::IsFullscreenBubbleVisible() const { | 990 bool BrowserView::IsFullscreenBubbleVisible() const { |
| 990 return exclusive_access_bubble_ != nullptr; | 991 return exclusive_access_bubble_ != nullptr; |
| 991 } | 992 } |
| 992 | 993 |
| 993 void BrowserView::ShowNewBackShortcutBubble(bool forward) { | 994 void BrowserView::MaybeShowNewBackShortcutBubble(bool forward) { |
| 994 // Hide the exclusive access bubble, to avoid overlapping. | 995 if (!new_back_shortcut_bubble_ || !new_back_shortcut_bubble_->IsVisible()) { |
| 995 exclusive_access_bubble_.reset(); | 996 PrefService* prefs = browser_->profile()->GetPrefs(); |
| 997 int shown_count = prefs->GetInteger(prefs::kBackShortcutBubbleShownCount); |
| 998 constexpr int kMaxShownCount = 5; |
| 999 if (shown_count >= kMaxShownCount) |
| 1000 return; |
| 996 | 1001 |
| 1002 const base::TimeTicks now = base::TimeTicks::Now(); |
| 1003 constexpr base::TimeDelta kRepeatWindow = base::TimeDelta::FromSeconds(3); |
| 1004 if (last_back_shortcut_press_time_.is_null() || |
| 1005 ((now - last_back_shortcut_press_time_) > kRepeatWindow)) { |
| 1006 last_back_shortcut_press_time_ = now; |
| 1007 return; |
| 1008 } |
| 1009 |
| 1010 // Hide the exclusive access bubble, to avoid overlapping. |
| 1011 exclusive_access_bubble_.reset(); |
| 1012 |
| 1013 new_back_shortcut_bubble_.reset(new NewBackShortcutBubble(this)); |
| 1014 prefs->SetInteger(prefs::kBackShortcutBubbleShownCount, shown_count + 1); |
| 1015 last_back_shortcut_press_time_ = base::TimeTicks(); |
| 1016 } |
| 1017 |
| 1018 new_back_shortcut_bubble_->UpdateContent(forward); |
| 1019 } |
| 1020 |
| 1021 void BrowserView::HideNewBackShortcutBubble() { |
| 997 if (new_back_shortcut_bubble_) | 1022 if (new_back_shortcut_bubble_) |
| 998 new_back_shortcut_bubble_->UpdateContent(forward); | 1023 new_back_shortcut_bubble_->Hide(); |
| 999 else | |
| 1000 new_back_shortcut_bubble_.reset(new NewBackShortcutBubble(this, forward)); | |
| 1001 } | 1024 } |
| 1002 | 1025 |
| 1003 void BrowserView::RestoreFocus() { | 1026 void BrowserView::RestoreFocus() { |
| 1004 WebContents* selected_web_contents = GetActiveWebContents(); | 1027 WebContents* selected_web_contents = GetActiveWebContents(); |
| 1005 if (selected_web_contents) | 1028 if (selected_web_contents) |
| 1006 selected_web_contents->RestoreFocus(); | 1029 selected_web_contents->RestoreFocus(); |
| 1007 } | 1030 } |
| 1008 | 1031 |
| 1009 void BrowserView::FullscreenStateChanged() { | 1032 void BrowserView::FullscreenStateChanged() { |
| 1010 CHECK(!IsFullscreen()); | 1033 CHECK(!IsFullscreen()); |
| (...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2627 } | 2650 } |
| 2628 | 2651 |
| 2629 extensions::ActiveTabPermissionGranter* | 2652 extensions::ActiveTabPermissionGranter* |
| 2630 BrowserView::GetActiveTabPermissionGranter() { | 2653 BrowserView::GetActiveTabPermissionGranter() { |
| 2631 content::WebContents* web_contents = GetActiveWebContents(); | 2654 content::WebContents* web_contents = GetActiveWebContents(); |
| 2632 if (!web_contents) | 2655 if (!web_contents) |
| 2633 return nullptr; | 2656 return nullptr; |
| 2634 return extensions::TabHelper::FromWebContents(web_contents) | 2657 return extensions::TabHelper::FromWebContents(web_contents) |
| 2635 ->active_tab_permission_granter(); | 2658 ->active_tab_permission_granter(); |
| 2636 } | 2659 } |
| OLD | NEW |