| 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 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 ExclusiveAccessBubbleType bubble_type) { | 975 ExclusiveAccessBubbleType bubble_type) { |
| 976 // Immersive mode has no exit bubble because it has a visible strip at the | 976 // Immersive mode has no exit bubble because it has a visible strip at the |
| 977 // top that gives the user a hover target. | 977 // top that gives the user a hover target. |
| 978 // TODO(jamescook): Figure out what to do with mouse-lock. | 978 // TODO(jamescook): Figure out what to do with mouse-lock. |
| 979 if (bubble_type == EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE || | 979 if (bubble_type == EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE || |
| 980 ShouldUseImmersiveFullscreenForUrl(url)) { | 980 ShouldUseImmersiveFullscreenForUrl(url)) { |
| 981 exclusive_access_bubble_.reset(); | 981 exclusive_access_bubble_.reset(); |
| 982 return; | 982 return; |
| 983 } | 983 } |
| 984 | 984 |
| 985 if (exclusive_access_bubble_) { |
| 986 exclusive_access_bubble_->UpdateContent(url, bubble_type); |
| 987 return; |
| 988 } |
| 989 |
| 985 // Hide the backspace shortcut bubble, to avoid overlapping. | 990 // Hide the backspace shortcut bubble, to avoid overlapping. |
| 986 new_back_shortcut_bubble_.reset(); | 991 new_back_shortcut_bubble_.reset(); |
| 987 | 992 |
| 988 if (exclusive_access_bubble_) { | 993 exclusive_access_bubble_.reset( |
| 989 exclusive_access_bubble_->UpdateContent(url, bubble_type); | 994 new ExclusiveAccessBubbleViews(this, url, bubble_type)); |
| 990 } else { | |
| 991 exclusive_access_bubble_.reset( | |
| 992 new ExclusiveAccessBubbleViews(this, url, bubble_type)); | |
| 993 } | |
| 994 } | 995 } |
| 995 | 996 |
| 996 void BrowserView::OnExclusiveAccessUserInput() { | 997 void BrowserView::OnExclusiveAccessUserInput() { |
| 997 if (exclusive_access_bubble_.get()) | 998 if (exclusive_access_bubble_.get()) |
| 998 exclusive_access_bubble_->OnUserInput(); | 999 exclusive_access_bubble_->OnUserInput(); |
| 999 } | 1000 } |
| 1000 | 1001 |
| 1001 bool BrowserView::ShouldHideUIForFullscreen() const { | 1002 bool BrowserView::ShouldHideUIForFullscreen() const { |
| 1002 // Immersive mode needs UI for the slide-down top panel. | 1003 // Immersive mode needs UI for the slide-down top panel. |
| 1003 if (immersive_mode_controller_->IsEnabled()) | 1004 if (immersive_mode_controller_->IsEnabled()) |
| 1004 return false; | 1005 return false; |
| 1005 | 1006 |
| 1006 return IsFullscreen(); | 1007 return IsFullscreen(); |
| 1007 } | 1008 } |
| 1008 | 1009 |
| 1009 bool BrowserView::IsFullscreen() const { | 1010 bool BrowserView::IsFullscreen() const { |
| 1010 return frame_->IsFullscreen(); | 1011 return frame_->IsFullscreen(); |
| 1011 } | 1012 } |
| 1012 | 1013 |
| 1013 bool BrowserView::IsFullscreenBubbleVisible() const { | 1014 bool BrowserView::IsFullscreenBubbleVisible() const { |
| 1014 return exclusive_access_bubble_ != nullptr; | 1015 return exclusive_access_bubble_ != nullptr; |
| 1015 } | 1016 } |
| 1016 | 1017 |
| 1017 void BrowserView::ShowNewBackShortcutBubble(bool forward) { | 1018 void BrowserView::MaybeShowNewBackShortcutBubble(bool forward) { |
| 1018 // Hide the exclusive access bubble, to avoid overlapping. | 1019 if (!new_back_shortcut_bubble_ || !new_back_shortcut_bubble_->IsVisible()) { |
| 1019 exclusive_access_bubble_.reset(); | 1020 // Show the bubble at most five times. |
| 1021 PrefService* prefs = browser_->profile()->GetPrefs(); |
| 1022 int shown_count = prefs->GetInteger(prefs::kBackShortcutBubbleShownCount); |
| 1023 constexpr int kMaxShownCount = 5; |
| 1024 if (shown_count >= kMaxShownCount) |
| 1025 return; |
| 1020 | 1026 |
| 1027 // Only show the bubble when the user presses a shortcut twice within three |
| 1028 // seconds. |
| 1029 const base::TimeTicks now = base::TimeTicks::Now(); |
| 1030 constexpr base::TimeDelta kRepeatWindow = base::TimeDelta::FromSeconds(3); |
| 1031 if (last_back_shortcut_press_time_.is_null() || |
| 1032 ((now - last_back_shortcut_press_time_) > kRepeatWindow)) { |
| 1033 last_back_shortcut_press_time_ = now; |
| 1034 return; |
| 1035 } |
| 1036 |
| 1037 // Hide the exclusive access bubble, to avoid overlapping. |
| 1038 exclusive_access_bubble_.reset(); |
| 1039 |
| 1040 new_back_shortcut_bubble_.reset(new NewBackShortcutBubble(this)); |
| 1041 prefs->SetInteger(prefs::kBackShortcutBubbleShownCount, shown_count + 1); |
| 1042 last_back_shortcut_press_time_ = base::TimeTicks(); |
| 1043 } |
| 1044 |
| 1045 new_back_shortcut_bubble_->UpdateContent(forward); |
| 1046 } |
| 1047 |
| 1048 void BrowserView::HideNewBackShortcutBubble() { |
| 1021 if (new_back_shortcut_bubble_) | 1049 if (new_back_shortcut_bubble_) |
| 1022 new_back_shortcut_bubble_->UpdateContent(forward); | 1050 new_back_shortcut_bubble_->Hide(); |
| 1023 else | |
| 1024 new_back_shortcut_bubble_.reset(new NewBackShortcutBubble(this, forward)); | |
| 1025 } | 1051 } |
| 1026 | 1052 |
| 1027 void BrowserView::RestoreFocus() { | 1053 void BrowserView::RestoreFocus() { |
| 1028 WebContents* selected_web_contents = GetActiveWebContents(); | 1054 WebContents* selected_web_contents = GetActiveWebContents(); |
| 1029 if (selected_web_contents) | 1055 if (selected_web_contents) |
| 1030 selected_web_contents->RestoreFocus(); | 1056 selected_web_contents->RestoreFocus(); |
| 1031 } | 1057 } |
| 1032 | 1058 |
| 1033 void BrowserView::FullscreenStateChanged() { | 1059 void BrowserView::FullscreenStateChanged() { |
| 1034 CHECK(!IsFullscreen()); | 1060 CHECK(!IsFullscreen()); |
| (...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2642 } | 2668 } |
| 2643 | 2669 |
| 2644 extensions::ActiveTabPermissionGranter* | 2670 extensions::ActiveTabPermissionGranter* |
| 2645 BrowserView::GetActiveTabPermissionGranter() { | 2671 BrowserView::GetActiveTabPermissionGranter() { |
| 2646 content::WebContents* web_contents = GetActiveWebContents(); | 2672 content::WebContents* web_contents = GetActiveWebContents(); |
| 2647 if (!web_contents) | 2673 if (!web_contents) |
| 2648 return nullptr; | 2674 return nullptr; |
| 2649 return extensions::TabHelper::FromWebContents(web_contents) | 2675 return extensions::TabHelper::FromWebContents(web_contents) |
| 2650 ->active_tab_permission_granter(); | 2676 ->active_tab_permission_granter(); |
| 2651 } | 2677 } |
| OLD | NEW |