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_view_.get()) { | |
851 permission_bubble_view_.reset( | |
msw
2015/03/18 18:30:09
optional nit: rename the member to |permission_bub
hcarmona
2015/03/18 23:50:39
Done.
| |
852 new PermissionBubbleViewViews(browser_.get())); | |
853 } | |
854 | |
857 PermissionBubbleManager::FromWebContents(new_contents)->SetView( | 855 PermissionBubbleManager::FromWebContents(new_contents)->SetView( |
858 permission_bubble_view_.get()); | 856 permission_bubble_view_.get()); |
859 } | 857 } |
860 | 858 |
861 UpdateUIForContents(new_contents); | 859 UpdateUIForContents(new_contents); |
862 | 860 |
863 // Layout for DevTools _before_ setting the both main and devtools WebContents | 861 // Layout for DevTools _before_ setting the both main and devtools WebContents |
864 // to avoid toggling the size of any of them. | 862 // to avoid toggling the size of any of them. |
865 UpdateDevToolsForContents(new_contents, !change_tab_contents); | 863 UpdateDevToolsForContents(new_contents, !change_tab_contents); |
866 | 864 |
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2033 browser_->tab_strip_model()); | 2031 browser_->tab_strip_model()); |
2034 tabstrip_ = new TabStrip(tabstrip_controller); | 2032 tabstrip_ = new TabStrip(tabstrip_controller); |
2035 top_container_->AddChildView(tabstrip_); | 2033 top_container_->AddChildView(tabstrip_); |
2036 tabstrip_controller->InitFromModel(tabstrip_); | 2034 tabstrip_controller->InitFromModel(tabstrip_); |
2037 | 2035 |
2038 toolbar_ = new ToolbarView(browser_.get()); | 2036 toolbar_ = new ToolbarView(browser_.get()); |
2039 top_container_->AddChildView(toolbar_); | 2037 top_container_->AddChildView(toolbar_); |
2040 toolbar_->Init(); | 2038 toolbar_->Init(); |
2041 | 2039 |
2042 InitStatusBubble(); | 2040 InitStatusBubble(); |
2043 InitPermissionBubbleView(); | |
2044 | 2041 |
2045 // Create do-nothing view for the sake of controlling the z-order of the find | 2042 // Create do-nothing view for the sake of controlling the z-order of the find |
2046 // bar widget. | 2043 // bar widget. |
2047 find_bar_host_view_ = new View(); | 2044 find_bar_host_view_ = new View(); |
2048 AddChildView(find_bar_host_view_); | 2045 AddChildView(find_bar_host_view_); |
2049 | 2046 |
2050 immersive_mode_controller_->Init(this); | 2047 immersive_mode_controller_->Init(this); |
2051 | 2048 |
2052 BrowserViewLayout* browser_view_layout = new BrowserViewLayout; | 2049 BrowserViewLayout* browser_view_layout = new BrowserViewLayout; |
2053 browser_view_layout->Init(new BrowserViewLayoutDelegateImpl(this), | 2050 browser_view_layout->Init(new BrowserViewLayoutDelegateImpl(this), |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2604 return immersive_mode_controller()->IsEnabled(); | 2601 return immersive_mode_controller()->IsEnabled(); |
2605 } | 2602 } |
2606 | 2603 |
2607 views::Widget* BrowserView::GetBubbleAssociatedWidget() { | 2604 views::Widget* BrowserView::GetBubbleAssociatedWidget() { |
2608 return GetWidget(); | 2605 return GetWidget(); |
2609 } | 2606 } |
2610 | 2607 |
2611 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { | 2608 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { |
2612 return top_container_->GetBoundsInScreen(); | 2609 return top_container_->GetBoundsInScreen(); |
2613 } | 2610 } |
OLD | NEW |