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

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

Issue 2596763003: On macOS, avoid forcible activation during Show.
Patch Set: Reword comment. Created 3 years, 12 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
« 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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
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());
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)
610 // When opening a URL from another application, macOS will activate the
611 // browser window in the case when "Open" action is used, but won't do it
612 // in the case when "Open Behind" is requested. Let's assume macOS handles
613 // the activation for us; just put the window above other browser windows.
614 frame_->ShowInactive();
615 #else
609 frame_->Activate(); 616 frame_->Activate();
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
620 // initialization that happened before this will be lost. 628 // initialization that happened before this will be lost.
621 // 629 //
622 // We really "should" restore the focus whenever the window becomes unhidden, 630 // We really "should" restore the focus whenever the window becomes unhidden,
623 // but I think initializing is the only time where this can happen where 631 // but I think initializing is the only time where this can happen where
624 // there is some focus change we need to pick up, and this is easier than 632 // there is some focus change we need to pick up, and this is easier than
625 // plumbing through an un-hide message all the way from the frame. 633 // plumbing through an un-hide message all the way from the frame.
626 // 634 //
627 // If we do find there are cases where we need to restore the focus on show, 635 // If we do find there are cases where we need to restore the focus on show,
628 // that should be added and this should be removed. 636 // that should be added and this should be removed.
629 RestoreFocus(); 637 RestoreFocus();
630 638
631 frame_->Show(); 639 frame_->Show();
tapted 2017/01/03 03:27:06 This isn't quite right either. If Chrome has been
sky 2017/01/03 16:38:01 Is the problem that there are two many random plac
632 640
633 force_location_bar_focus_ = false; 641 force_location_bar_focus_ = false;
634 642
635 browser()->OnWindowDidShow(); 643 browser()->OnWindowDidShow();
636 644
637 chrome::MaybeShowInvertBubbleView(this); 645 chrome::MaybeShowInvertBubbleView(this);
638 } 646 }
639 647
640 void BrowserView::ShowInactive() { 648 void BrowserView::ShowInactive() {
641 if (!frame_->IsVisible()) 649 if (!frame_->IsVisible())
(...skipping 1943 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