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

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

Issue 1785643002: Update avatar icon when nonclient frame view is added to view hierarchy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More consistent calling of GetNativeWindow() Created 4 years, 9 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 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 return profiles::IsRegularOrGuestSession(browser_.get()); 620 return profiles::IsRegularOrGuestSession(browser_.get());
621 } 621 }
622 622
623 bool BrowserView::ShouldShowAvatar() const { 623 bool BrowserView::ShouldShowAvatar() const {
624 #if defined(OS_CHROMEOS) 624 #if defined(OS_CHROMEOS)
625 if (!browser_->is_type_tabbed() && !browser_->is_app()) 625 if (!browser_->is_type_tabbed() && !browser_->is_app())
626 return false; 626 return false;
627 // Don't show incognito avatar in the guest session. 627 // Don't show incognito avatar in the guest session.
628 if (IsOffTheRecord() && !IsGuestSession()) 628 if (IsOffTheRecord() && !IsGuestSession())
629 return true; 629 return true;
630 // This function is called via BrowserNonClientFrameView::UpdateAvatarInfo 630 return chrome::MultiUserWindowManager::ShouldShowAvatar(GetNativeWindow());
631 // during the creation of the BrowserWindow, so browser->window() will not
632 // yet be set. In this case we can safely return false.
633 if (!browser_->window())
634 return false;
635 return chrome::MultiUserWindowManager::ShouldShowAvatar(
636 browser_->window()->GetNativeWindow());
637 #else 631 #else
638 if (!IsBrowserTypeNormal()) 632 if (!IsBrowserTypeNormal())
639 return false; 633 return false;
640 if (IsOffTheRecord()) // Desktop guest is incognito and needs avatar. 634 if (IsOffTheRecord()) // Desktop guest is incognito and needs avatar.
641 return true; 635 return true;
642 // Tests may not have a profile manager. 636 // Tests may not have a profile manager.
643 if (!g_browser_process->profile_manager()) 637 if (!g_browser_process->profile_manager())
644 return false; 638 return false;
645 ProfileAttributesEntry* entry; 639 ProfileAttributesEntry* entry;
646 if (!g_browser_process->profile_manager()->GetProfileAttributesStorage(). 640 if (!g_browser_process->profile_manager()->GetProfileAttributesStorage().
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 return false; 758 return false;
765 } 759 }
766 760
767 void BrowserView::SetAlwaysOnTop(bool always_on_top) { 761 void BrowserView::SetAlwaysOnTop(bool always_on_top) {
768 // Not implemented for browser windows. 762 // Not implemented for browser windows.
769 NOTIMPLEMENTED(); 763 NOTIMPLEMENTED();
770 } 764 }
771 765
772 gfx::NativeWindow BrowserView::GetNativeWindow() const { 766 gfx::NativeWindow BrowserView::GetNativeWindow() const {
773 // While the browser destruction is going on, the widget can already be gone, 767 // While the browser destruction is going on, the widget can already be gone,
774 // but utility functions like FindBrowserWithWindow will come here and crash. 768 // but utility functions like FindBrowserWithWindow will still call this.
775 // We short circuit therefore. 769 return GetWidget() ? GetWidget()->GetNativeWindow() : nullptr;
776 if (!GetWidget())
777 return nullptr;
778 return GetWidget()->GetTopLevelWidget()->GetNativeWindow();
779 } 770 }
780 771
781 StatusBubble* BrowserView::GetStatusBubble() { 772 StatusBubble* BrowserView::GetStatusBubble() {
782 return status_bubble_.get(); 773 return status_bubble_.get();
783 } 774 }
784 775
785 namespace { 776 namespace {
786 // Only used by ToolbarSizeChanged() below, but placed here because template 777 // Only used by ToolbarSizeChanged() below, but placed here because template
787 // arguments (to base::AutoReset<>) must have external linkage. 778 // arguments (to base::AutoReset<>) must have external linkage.
788 enum CallState { NORMAL, REENTRANT, REENTRANT_FORCE_FAST_RESIZE }; 779 enum CallState { NORMAL, REENTRANT, REENTRANT_FORCE_FAST_RESIZE };
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 } 1241 }
1251 1242
1252 gfx::Rect BrowserView::GetRootWindowResizerRect() const { 1243 gfx::Rect BrowserView::GetRootWindowResizerRect() const {
1253 // Views does not support resizer rects because they caused page cycler 1244 // Views does not support resizer rects because they caused page cycler
1254 // performance regressions when they were added. See crrev.com/9654 1245 // performance regressions when they were added. See crrev.com/9654
1255 return gfx::Rect(); 1246 return gfx::Rect();
1256 } 1247 }
1257 1248
1258 void BrowserView::ConfirmAddSearchProvider(TemplateURL* template_url, 1249 void BrowserView::ConfirmAddSearchProvider(TemplateURL* template_url,
1259 Profile* profile) { 1250 Profile* profile) {
1260 chrome::EditSearchEngine(GetWidget()->GetNativeWindow(), template_url, 1251 chrome::EditSearchEngine(GetNativeWindow(), template_url, nullptr, profile);
1261 nullptr, profile);
1262 } 1252 }
1263 1253
1264 void BrowserView::ShowUpdateChromeDialog() { 1254 void BrowserView::ShowUpdateChromeDialog() {
1265 UpdateRecommendedMessageBox::Show(GetWidget()->GetNativeWindow()); 1255 UpdateRecommendedMessageBox::Show(GetNativeWindow());
1266 } 1256 }
1267 1257
1268 void BrowserView::ShowBookmarkBubble(const GURL& url, bool already_bookmarked) { 1258 void BrowserView::ShowBookmarkBubble(const GURL& url, bool already_bookmarked) {
1269 scoped_ptr<BubbleSyncPromoDelegate> delegate; 1259 scoped_ptr<BubbleSyncPromoDelegate> delegate;
1270 delegate.reset(new BookmarkBubbleSignInDelegate(browser_.get())); 1260 delegate.reset(new BookmarkBubbleSignInDelegate(browser_.get()));
1271 1261
1272 views::View* anchor_view = GetToolbarView()->GetBookmarkBubbleAnchor(); 1262 views::View* anchor_view = GetToolbarView()->GetBookmarkBubbleAnchor();
1273 views::Widget* bubble_widget = BookmarkBubbleView::ShowBubble( 1263 views::Widget* bubble_widget = BookmarkBubbleView::ShowBubble(
1274 anchor_view, gfx::Rect(), nullptr, bookmark_bar_view_.get(), 1264 anchor_view, gfx::Rect(), nullptr, bookmark_bar_view_.get(),
1275 std::move(delegate), browser_->profile(), url, already_bookmarked); 1265 std::move(delegate), browser_->profile(), url, already_bookmarked);
(...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after
2711 } 2701 }
2712 2702
2713 extensions::ActiveTabPermissionGranter* 2703 extensions::ActiveTabPermissionGranter*
2714 BrowserView::GetActiveTabPermissionGranter() { 2704 BrowserView::GetActiveTabPermissionGranter() {
2715 content::WebContents* web_contents = GetActiveWebContents(); 2705 content::WebContents* web_contents = GetActiveWebContents();
2716 if (!web_contents) 2706 if (!web_contents)
2717 return nullptr; 2707 return nullptr;
2718 return extensions::TabHelper::FromWebContents(web_contents) 2708 return extensions::TabHelper::FromWebContents(web_contents)
2719 ->active_tab_permission_granter(); 2709 ->active_tab_permission_granter();
2720 } 2710 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698