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

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 617543002: Disable overscroll on Windows machines w/o touchscreen (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unwanted changes. Created 6 years, 2 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/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #endif // defined(OS_WIN) 10 #endif // defined(OS_WIN)
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 #include "chrome/browser/ui/browser_finder.h" 99 #include "chrome/browser/ui/browser_finder.h"
100 #include "chrome/browser/ui/browser_instant_controller.h" 100 #include "chrome/browser/ui/browser_instant_controller.h"
101 #include "chrome/browser/ui/browser_iterator.h" 101 #include "chrome/browser/ui/browser_iterator.h"
102 #include "chrome/browser/ui/browser_list.h" 102 #include "chrome/browser/ui/browser_list.h"
103 #include "chrome/browser/ui/browser_navigator.h" 103 #include "chrome/browser/ui/browser_navigator.h"
104 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" 104 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h"
105 #include "chrome/browser/ui/browser_tab_strip_model_delegate.h" 105 #include "chrome/browser/ui/browser_tab_strip_model_delegate.h"
106 #include "chrome/browser/ui/browser_tabstrip.h" 106 #include "chrome/browser/ui/browser_tabstrip.h"
107 #include "chrome/browser/ui/browser_toolbar_model_delegate.h" 107 #include "chrome/browser/ui/browser_toolbar_model_delegate.h"
108 #include "chrome/browser/ui/browser_ui_prefs.h" 108 #include "chrome/browser/ui/browser_ui_prefs.h"
109 #include "chrome/browser/ui/browser_util.h"
109 #include "chrome/browser/ui/browser_window.h" 110 #include "chrome/browser/ui/browser_window.h"
110 #include "chrome/browser/ui/chrome_pages.h" 111 #include "chrome/browser/ui/chrome_pages.h"
111 #include "chrome/browser/ui/chrome_select_file_policy.h" 112 #include "chrome/browser/ui/chrome_select_file_policy.h"
112 #include "chrome/browser/ui/fast_unload_controller.h" 113 #include "chrome/browser/ui/fast_unload_controller.h"
113 #include "chrome/browser/ui/find_bar/find_bar.h" 114 #include "chrome/browser/ui/find_bar/find_bar.h"
114 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 115 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
115 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 116 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
116 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" 117 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
117 #include "chrome/browser/ui/global_error/global_error.h" 118 #include "chrome/browser/ui/global_error/global_error.h"
118 #include "chrome/browser/ui/global_error/global_error_service.h" 119 #include "chrome/browser/ui/global_error/global_error_service.h"
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 base::string16 title; 571 base::string16 title;
571 572
572 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the 573 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the
573 // window during the window's creation (before tabs have been added). 574 // window during the window's creation (before tabs have been added).
574 if (contents) { 575 if (contents) {
575 // Streamlined hosted apps use the host instead of the title. 576 // Streamlined hosted apps use the host instead of the title.
576 if (is_app() && extensions::util::IsStreamlinedHostedAppsEnabled()) 577 if (is_app() && extensions::util::IsStreamlinedHostedAppsEnabled())
577 return base::UTF8ToUTF16(contents->GetURL().host()); 578 return base::UTF8ToUTF16(contents->GetURL().host());
578 579
579 title = contents->GetTitle(); 580 title = contents->GetTitle();
580 FormatTitleForDisplay(&title); 581 BrowserUtil::FormatTitleForDisplay(&title);
581 } 582 }
582 if (title.empty()) 583 if (title.empty())
583 title = CoreTabHelper::GetDefaultTitle(); 584 title = CoreTabHelper::GetDefaultTitle();
584 585
585 #if defined(OS_MACOSX) 586 #if defined(OS_MACOSX)
586 // On Mac, we don't want to suffix the page title with 587 // On Mac, we don't want to suffix the page title with
587 // the application name. 588 // the application name.
588 return title; 589 return title;
589 #elif defined(USE_ASH) 590 #elif defined(USE_ASH)
590 // On Ash, we don't want to suffix the page title with the application name, 591 // On Ash, we don't want to suffix the page title with the application name,
591 // but on Windows, where USE_ASH can also be true, we still want the prefix 592 // but on Windows, where USE_ASH can also be true, we still want the prefix
592 // on desktop. 593 // on desktop.
593 if (host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) 594 if (host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH)
594 return title; 595 return title;
595 #endif 596 #endif
596 // Don't append the app name to window titles on app frames and app popups 597 // Don't append the app name to window titles on app frames and app popups
597 return is_app() ? 598 return is_app() ?
598 title : 599 title :
599 l10n_util::GetStringFUTF16(IDS_BROWSER_WINDOW_TITLE_FORMAT, title); 600 l10n_util::GetStringFUTF16(IDS_BROWSER_WINDOW_TITLE_FORMAT, title);
600 } 601 }
601 602
602 // static
603 void Browser::FormatTitleForDisplay(base::string16* title) {
604 size_t current_index = 0;
605 size_t match_index;
606 while ((match_index = title->find(L'\n', current_index)) !=
607 base::string16::npos) {
608 title->replace(match_index, 1, base::string16());
609 current_index = match_index;
610 }
611 }
612
613 /////////////////////////////////////////////////////////////////////////////// 603 ///////////////////////////////////////////////////////////////////////////////
614 // Browser, OnBeforeUnload handling: 604 // Browser, OnBeforeUnload handling:
615 605
616 bool Browser::ShouldCloseWindow() { 606 bool Browser::ShouldCloseWindow() {
617 if (!CanCloseWithInProgressDownloads()) 607 if (!CanCloseWithInProgressDownloads())
618 return false; 608 return false;
619 609
620 if (IsFastTabUnloadEnabled()) 610 if (IsFastTabUnloadEnabled())
621 return fast_unload_controller_->ShouldCloseWindow(); 611 return fast_unload_controller_->ShouldCloseWindow();
622 return unload_controller_->ShouldCloseWindow(); 612 return unload_controller_->ShouldCloseWindow();
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 // still present. 1110 // still present.
1121 base::MessageLoop::current()->PostTask( 1111 base::MessageLoop::current()->PostTask(
1122 FROM_HERE, base::Bind(&Browser::CloseFrame, weak_factory_.GetWeakPtr())); 1112 FROM_HERE, base::Bind(&Browser::CloseFrame, weak_factory_.GetWeakPtr()));
1123 1113
1124 // Instant may have visible WebContents that need to be detached before the 1114 // Instant may have visible WebContents that need to be detached before the
1125 // window system closes. 1115 // window system closes.
1126 instant_controller_.reset(); 1116 instant_controller_.reset();
1127 } 1117 }
1128 1118
1129 bool Browser::CanOverscrollContent() const { 1119 bool Browser::CanOverscrollContent() const {
1130 #if defined(USE_AURA) 1120 if (!BrowserUtil::IsOverscrollEnabledOnPlatform())
1121 return false;
1122
1131 const std::string value = CommandLine::ForCurrentProcess()-> 1123 const std::string value = CommandLine::ForCurrentProcess()->
1132 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation); 1124 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation);
1133 bool overscroll_enabled = value != "0"; 1125 bool overscroll_enabled = value != "0";
1134 if (!overscroll_enabled) 1126 if (!overscroll_enabled)
1135 return false; 1127 return false;
1136 if (is_app() || is_devtools() || !is_type_tabbed()) 1128 if (is_app() || is_devtools() || !is_type_tabbed())
1137 return false; 1129 return false;
1138 1130
1139 // The detached bookmark bar has appearance of floating above the 1131 // The detached bookmark bar has appearance of floating above the
1140 // web-contents. This does not play nicely with overscroll navigation 1132 // web-contents. This does not play nicely with overscroll navigation
1141 // gestures. So disable overscroll navigation when the bookmark bar is in the 1133 // gestures. So disable overscroll navigation when the bookmark bar is in the
1142 // detached state and the overscroll effect moves the layers. 1134 // detached state and the overscroll effect moves the layers.
1143 if (value == "1" && bookmark_bar_state_ == BookmarkBar::DETACHED) 1135 if (value == "1" && bookmark_bar_state_ == BookmarkBar::DETACHED)
1144 return false; 1136 return false;
1145 return true; 1137 return true;
1146 #else
1147 return false;
1148 #endif
1149 } 1138 }
1150 1139
1151 bool Browser::ShouldPreserveAbortedURLs(WebContents* source) { 1140 bool Browser::ShouldPreserveAbortedURLs(WebContents* source) {
1152 // Allow failed URLs to stick around in the omnibox on the NTP, but not when 1141 // Allow failed URLs to stick around in the omnibox on the NTP, but not when
1153 // other pages have committed. 1142 // other pages have committed.
1154 Profile* profile = Profile::FromBrowserContext(source->GetBrowserContext()); 1143 Profile* profile = Profile::FromBrowserContext(source->GetBrowserContext());
1155 if (!profile || !source->GetController().GetLastCommittedEntry()) 1144 if (!profile || !source->GetController().GetLastCommittedEntry())
1156 return false; 1145 return false;
1157 GURL committed_url(source->GetController().GetLastCommittedEntry()->GetURL()); 1146 GURL committed_url(source->GetController().GetLastCommittedEntry()->GetURL());
1158 return chrome::IsNTPURL(committed_url, profile); 1147 return chrome::IsNTPURL(committed_url, profile);
(...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after
2476 if (contents && !allow_js_access) { 2465 if (contents && !allow_js_access) {
2477 contents->web_contents()->GetController().LoadURL( 2466 contents->web_contents()->GetController().LoadURL(
2478 target_url, 2467 target_url,
2479 content::Referrer(), 2468 content::Referrer(),
2480 ui::PAGE_TRANSITION_LINK, 2469 ui::PAGE_TRANSITION_LINK,
2481 std::string()); // No extra headers. 2470 std::string()); // No extra headers.
2482 } 2471 }
2483 2472
2484 return contents != NULL; 2473 return contents != NULL;
2485 } 2474 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698