OLD | NEW |
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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 // static | 532 // static |
533 BrowserView* BrowserView::GetBrowserViewForBrowser(const Browser* browser) { | 533 BrowserView* BrowserView::GetBrowserViewForBrowser(const Browser* browser) { |
534 return static_cast<BrowserView*>(browser->window()); | 534 return static_cast<BrowserView*>(browser->window()); |
535 } | 535 } |
536 | 536 |
537 void BrowserView::InitStatusBubble() { | 537 void BrowserView::InitStatusBubble() { |
538 status_bubble_.reset(new StatusBubbleViews(contents_web_view_)); | 538 status_bubble_.reset(new StatusBubbleViews(contents_web_view_)); |
539 contents_web_view_->SetStatusBubble(status_bubble_.get()); | 539 contents_web_view_->SetStatusBubble(status_bubble_.get()); |
540 } | 540 } |
541 | 541 |
542 void BrowserView::InitPermissionBubbleView() { | |
543 std::string languages = | |
544 browser_->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages); | |
545 permission_bubble_view_.reset(new PermissionBubbleViewViews( | |
546 GetLocationBarView()->location_icon_view(), languages)); | |
547 } | |
548 | |
549 gfx::Rect BrowserView::GetToolbarBounds() const { | 542 gfx::Rect BrowserView::GetToolbarBounds() const { |
550 gfx::Rect toolbar_bounds(toolbar_->bounds()); | 543 gfx::Rect toolbar_bounds(toolbar_->bounds()); |
551 if (toolbar_bounds.IsEmpty()) | 544 if (toolbar_bounds.IsEmpty()) |
552 return toolbar_bounds; | 545 return toolbar_bounds; |
553 // The apparent toolbar edges are outside the "real" toolbar edges. | 546 // The apparent toolbar edges are outside the "real" toolbar edges. |
554 toolbar_bounds.Inset(-views::NonClientFrameView::kClientEdgeThickness, 0); | 547 toolbar_bounds.Inset(-views::NonClientFrameView::kClientEdgeThickness, 0); |
555 return toolbar_bounds; | 548 return toolbar_bounds; |
556 } | 549 } |
557 | 550 |
558 gfx::Rect BrowserView::GetFindBarBoundingBox() const { | 551 gfx::Rect BrowserView::GetFindBarBoundingBox() const { |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 840 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
848 } | 841 } |
849 | 842 |
850 infobar_container_->ChangeInfoBarManager( | 843 infobar_container_->ChangeInfoBarManager( |
851 InfoBarService::FromWebContents(new_contents)); | 844 InfoBarService::FromWebContents(new_contents)); |
852 | 845 |
853 if (old_contents && PermissionBubbleManager::FromWebContents(old_contents)) | 846 if (old_contents && PermissionBubbleManager::FromWebContents(old_contents)) |
854 PermissionBubbleManager::FromWebContents(old_contents)->SetView(nullptr); | 847 PermissionBubbleManager::FromWebContents(old_contents)->SetView(nullptr); |
855 | 848 |
856 if (new_contents && PermissionBubbleManager::FromWebContents(new_contents)) { | 849 if (new_contents && PermissionBubbleManager::FromWebContents(new_contents)) { |
| 850 if (!permission_bubble_.get()) |
| 851 permission_bubble_.reset(new PermissionBubbleViewViews(browser_.get())); |
| 852 |
857 PermissionBubbleManager::FromWebContents(new_contents)->SetView( | 853 PermissionBubbleManager::FromWebContents(new_contents)->SetView( |
858 permission_bubble_view_.get()); | 854 permission_bubble_.get()); |
859 } | 855 } |
860 | 856 |
861 UpdateUIForContents(new_contents); | 857 UpdateUIForContents(new_contents); |
862 | 858 |
863 // Layout for DevTools _before_ setting the both main and devtools WebContents | 859 // Layout for DevTools _before_ setting the both main and devtools WebContents |
864 // to avoid toggling the size of any of them. | 860 // to avoid toggling the size of any of them. |
865 UpdateDevToolsForContents(new_contents, !change_tab_contents); | 861 UpdateDevToolsForContents(new_contents, !change_tab_contents); |
866 | 862 |
867 if (change_tab_contents) { | 863 if (change_tab_contents) { |
868 web_contents_close_handler_->ActiveTabChanged(); | 864 web_contents_close_handler_->ActiveTabChanged(); |
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2033 browser_->tab_strip_model()); | 2029 browser_->tab_strip_model()); |
2034 tabstrip_ = new TabStrip(tabstrip_controller); | 2030 tabstrip_ = new TabStrip(tabstrip_controller); |
2035 top_container_->AddChildView(tabstrip_); | 2031 top_container_->AddChildView(tabstrip_); |
2036 tabstrip_controller->InitFromModel(tabstrip_); | 2032 tabstrip_controller->InitFromModel(tabstrip_); |
2037 | 2033 |
2038 toolbar_ = new ToolbarView(browser_.get()); | 2034 toolbar_ = new ToolbarView(browser_.get()); |
2039 top_container_->AddChildView(toolbar_); | 2035 top_container_->AddChildView(toolbar_); |
2040 toolbar_->Init(); | 2036 toolbar_->Init(); |
2041 | 2037 |
2042 InitStatusBubble(); | 2038 InitStatusBubble(); |
2043 InitPermissionBubbleView(); | |
2044 | 2039 |
2045 // Create do-nothing view for the sake of controlling the z-order of the find | 2040 // Create do-nothing view for the sake of controlling the z-order of the find |
2046 // bar widget. | 2041 // bar widget. |
2047 find_bar_host_view_ = new View(); | 2042 find_bar_host_view_ = new View(); |
2048 AddChildView(find_bar_host_view_); | 2043 AddChildView(find_bar_host_view_); |
2049 | 2044 |
2050 immersive_mode_controller_->Init(this); | 2045 immersive_mode_controller_->Init(this); |
2051 | 2046 |
2052 BrowserViewLayout* browser_view_layout = new BrowserViewLayout; | 2047 BrowserViewLayout* browser_view_layout = new BrowserViewLayout; |
2053 browser_view_layout->Init(new BrowserViewLayoutDelegateImpl(this), | 2048 browser_view_layout->Init(new BrowserViewLayoutDelegateImpl(this), |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2284 } | 2279 } |
2285 | 2280 |
2286 // Undo our anti-jankiness hacks and force a re-layout. We also need to | 2281 // Undo our anti-jankiness hacks and force a re-layout. We also need to |
2287 // recompute the height of the infobar top arrow because toggling in and out | 2282 // recompute the height of the infobar top arrow because toggling in and out |
2288 // of fullscreen changes it. Calling ToolbarSizeChanged() will do both these | 2283 // of fullscreen changes it. Calling ToolbarSizeChanged() will do both these |
2289 // things since it computes the arrow height directly and forces a layout | 2284 // things since it computes the arrow height directly and forces a layout |
2290 // indirectly via UpdateUIForContents(). Reset |in_process_fullscreen_| in | 2285 // indirectly via UpdateUIForContents(). Reset |in_process_fullscreen_| in |
2291 // order to let the layout occur. | 2286 // order to let the layout occur. |
2292 in_process_fullscreen_ = false; | 2287 in_process_fullscreen_ = false; |
2293 ToolbarSizeChanged(false); | 2288 ToolbarSizeChanged(false); |
| 2289 |
| 2290 if (permission_bubble_.get()) |
| 2291 permission_bubble_->UpdateAnchorPosition(); |
2294 } | 2292 } |
2295 | 2293 |
2296 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const { | 2294 bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const { |
2297 // Kiosk mode needs the whole screen, and if we're not in an Ash desktop | 2295 // Kiosk mode needs the whole screen, and if we're not in an Ash desktop |
2298 // immersive fullscreen doesn't exist. | 2296 // immersive fullscreen doesn't exist. |
2299 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) || | 2297 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) || |
2300 browser()->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) { | 2298 browser()->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) { |
2301 return false; | 2299 return false; |
2302 } | 2300 } |
2303 | 2301 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2604 return immersive_mode_controller()->IsEnabled(); | 2602 return immersive_mode_controller()->IsEnabled(); |
2605 } | 2603 } |
2606 | 2604 |
2607 views::Widget* BrowserView::GetBubbleAssociatedWidget() { | 2605 views::Widget* BrowserView::GetBubbleAssociatedWidget() { |
2608 return GetWidget(); | 2606 return GetWidget(); |
2609 } | 2607 } |
2610 | 2608 |
2611 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { | 2609 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { |
2612 return top_container_->GetBoundsInScreen(); | 2610 return top_container_->GetBoundsInScreen(); |
2613 } | 2611 } |
OLD | NEW |