Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 2041293002: Add heuristics to limit showing of new backspace UI bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // Show the bubble at most five times.
997 PrefService* prefs = browser_->profile()->GetPrefs();
998 int shown_count = prefs->GetInteger(prefs::kBackShortcutBubbleShownCount);
999 constexpr int kMaxShownCount = 5;
1000 if (shown_count >= kMaxShownCount)
1001 return;
996 1002
1003 // Only show the bubble when the user presses a shortcut twice within three
1004 // seconds.
1005 const base::TimeTicks now = base::TimeTicks::Now();
1006 constexpr base::TimeDelta kRepeatWindow = base::TimeDelta::FromSeconds(3);
1007 if (last_back_shortcut_press_time_.is_null() ||
1008 ((now - last_back_shortcut_press_time_) > kRepeatWindow)) {
1009 last_back_shortcut_press_time_ = now;
1010 return;
1011 }
1012
1013 // Hide the exclusive access bubble, to avoid overlapping.
1014 exclusive_access_bubble_.reset();
1015
1016 new_back_shortcut_bubble_.reset(new NewBackShortcutBubble(this));
1017 prefs->SetInteger(prefs::kBackShortcutBubbleShownCount, shown_count + 1);
1018 last_back_shortcut_press_time_ = base::TimeTicks();
1019 }
1020
1021 new_back_shortcut_bubble_->UpdateContent(forward);
1022 }
1023
1024 void BrowserView::HideNewBackShortcutBubble() {
997 if (new_back_shortcut_bubble_) 1025 if (new_back_shortcut_bubble_)
998 new_back_shortcut_bubble_->UpdateContent(forward); 1026 new_back_shortcut_bubble_->Hide();
999 else
1000 new_back_shortcut_bubble_.reset(new NewBackShortcutBubble(this, forward));
1001 } 1027 }
1002 1028
1003 void BrowserView::RestoreFocus() { 1029 void BrowserView::RestoreFocus() {
1004 WebContents* selected_web_contents = GetActiveWebContents(); 1030 WebContents* selected_web_contents = GetActiveWebContents();
1005 if (selected_web_contents) 1031 if (selected_web_contents)
1006 selected_web_contents->RestoreFocus(); 1032 selected_web_contents->RestoreFocus();
1007 } 1033 }
1008 1034
1009 void BrowserView::FullscreenStateChanged() { 1035 void BrowserView::FullscreenStateChanged() {
1010 CHECK(!IsFullscreen()); 1036 CHECK(!IsFullscreen());
(...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after
2627 } 2653 }
2628 2654
2629 extensions::ActiveTabPermissionGranter* 2655 extensions::ActiveTabPermissionGranter*
2630 BrowserView::GetActiveTabPermissionGranter() { 2656 BrowserView::GetActiveTabPermissionGranter() {
2631 content::WebContents* web_contents = GetActiveWebContents(); 2657 content::WebContents* web_contents = GetActiveWebContents();
2632 if (!web_contents) 2658 if (!web_contents)
2633 return nullptr; 2659 return nullptr;
2634 return extensions::TabHelper::FromWebContents(web_contents) 2660 return extensions::TabHelper::FromWebContents(web_contents)
2635 ->active_tab_permission_granter(); 2661 ->active_tab_permission_granter();
2636 } 2662 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | chrome/browser/ui/views/new_back_shortcut_bubble.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698