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

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

Issue 2596763003: On macOS, avoid forcible activation during Show.
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 594
595 void BrowserView::Show() { 595 void BrowserView::Show() {
596 #if !defined(OS_WIN) && !defined(USE_ASH) 596 #if !defined(OS_WIN) && !defined(USE_ASH)
597 // The Browser associated with this browser window must become the active 597 // The Browser associated with this browser window must become the active
598 // browser at the time |Show()| is called. This is the natural behavior under 598 // browser at the time |Show()| is called. This is the natural behavior under
599 // Windows and Ash, but other platforms will not trigger 599 // Windows and Ash, but other platforms will not trigger
600 // OnWidgetActivationChanged() until we return to the runloop. Therefore any 600 // OnWidgetActivationChanged() until we return to the runloop. Therefore any
601 // calls to Browser::GetLastActive() will return the wrong result if we do not 601 // calls to Browser::GetLastActive() will return the wrong result if we do not
602 // explicitly set it here. 602 // explicitly set it here.
603 // A similar block also appears in BrowserWindowCocoa::Show(). 603 // A similar block also appears in BrowserWindowCocoa::Show().
604 BrowserList::SetLastActive(browser()); 604 BrowserList::SetLastActive(browser());
Peter Kasting 2016/12/22 00:38:42 Is it inconsistent that we SetLastActive() a windo
tapted 2017/01/03 03:27:06 Please respond to comments on the code itself usin
605 #endif 605 #endif
606 606
607 // If the window is already visible, just activate it. 607 // If the window is already visible, just activate it.
608 if (frame_->IsVisible()) { 608 if (frame_->IsVisible()) {
609 #if !defined(OS_MACOSX)
Peter Kasting 2016/12/22 00:38:42 Nit: Remove "!" and reverse arms, so "else" doesn'
609 frame_->Activate(); 610 frame_->Activate();
611 #else
612 // When opening a URL from other application, macOS will activate browser
Peter Kasting 2016/12/22 00:38:42 Nit: other -> another, browser -> the browser
613 // window in case when "Open" action is used, but won't do it in case when
Peter Kasting 2016/12/22 00:38:42 Nit: in case -> in the case (2x)
614 // "Open Behind" is requested. Let's assume macOS handles the activation
615 // for us, just put the window above other browser windows.
Peter Kasting 2016/12/22 00:38:42 Nit: , -> ;
616 frame_->ShowInactive();
617 #endif
610 return; 618 return;
611 } 619 }
612 620
613 // Showing the window doesn't make the browser window active right away. 621 // Showing the window doesn't make the browser window active right away.
614 // This can cause SetFocusToLocationBar() to skip setting focus to the 622 // This can cause SetFocusToLocationBar() to skip setting focus to the
615 // location bar. To avoid this we explicilty let SetFocusToLocationBar() 623 // location bar. To avoid this we explicilty let SetFocusToLocationBar()
616 // know that it's ok to steal focus. 624 // know that it's ok to steal focus.
617 force_location_bar_focus_ = true; 625 force_location_bar_focus_ = true;
618 626
619 // Setting the focus doesn't work when the window is invisible, so any focus 627 // Setting the focus doesn't work when the window is invisible, so any focus
(...skipping 1965 matching lines...) Expand 10 before | Expand all | Expand 10 after
2585 } 2593 }
2586 2594
2587 extensions::ActiveTabPermissionGranter* 2595 extensions::ActiveTabPermissionGranter*
2588 BrowserView::GetActiveTabPermissionGranter() { 2596 BrowserView::GetActiveTabPermissionGranter() {
2589 content::WebContents* web_contents = GetActiveWebContents(); 2597 content::WebContents* web_contents = GetActiveWebContents();
2590 if (!web_contents) 2598 if (!web_contents)
2591 return nullptr; 2599 return nullptr;
2592 return extensions::TabHelper::FromWebContents(web_contents) 2600 return extensions::TabHelper::FromWebContents(web_contents)
2593 ->active_tab_permission_granter(); 2601 ->active_tab_permission_granter();
2594 } 2602 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698