| 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_layout.h" | 5 #include "chrome/browser/ui/views/frame/browser_view_layout.h" |
| 6 | 6 |
| 7 #include "base/observer_list.h" | 7 #include "base/observer_list.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 // Center horizontally over the content area, with the top overlapping the | 92 // Center horizontally over the content area, with the top overlapping the |
| 93 // browser chrome. | 93 // browser chrome. |
| 94 virtual gfx::Point GetDialogPosition(const gfx::Size& size) OVERRIDE { | 94 virtual gfx::Point GetDialogPosition(const gfx::Size& size) OVERRIDE { |
| 95 int top_y = browser_view_layout_->web_contents_modal_dialog_top_y_; | 95 int top_y = browser_view_layout_->web_contents_modal_dialog_top_y_; |
| 96 gfx::Rect content_area = | 96 gfx::Rect content_area = |
| 97 browser_view_layout_->browser_view_->GetClientAreaBounds(); | 97 browser_view_layout_->browser_view_->GetClientAreaBounds(); |
| 98 int middle_x = content_area.x() + content_area.width() / 2; | 98 int middle_x = content_area.x() + content_area.width() / 2; |
| 99 return gfx::Point(middle_x - size.width() / 2, top_y); | 99 return gfx::Point(middle_x - size.width() / 2, top_y); |
| 100 } | 100 } |
| 101 | 101 |
| 102 virtual gfx::Size GetMaximumDialogSize() OVERRIDE { |
| 103 gfx::Rect content_area = |
| 104 browser_view_layout_->contents_container_->ConvertRectToWidget( |
| 105 browser_view_layout_->contents_container_->GetLocalBounds()); |
| 106 |
| 107 gfx::Size max_dialog_size = content_area.size(); |
| 108 // Adjust for difference in alignment between the dialog top and the top of |
| 109 // the content area. |
| 110 int height_offset = content_area.y() - |
| 111 browser_view_layout_->web_contents_modal_dialog_top_y_; |
| 112 max_dialog_size.Enlarge(0, height_offset); |
| 113 return max_dialog_size; |
| 114 } |
| 115 |
| 102 // Add/remove observer. | 116 // Add/remove observer. |
| 103 virtual void AddObserver( | 117 virtual void AddObserver( |
| 104 WebContentsModalDialogHostObserver* observer) OVERRIDE { | 118 WebContentsModalDialogHostObserver* observer) OVERRIDE { |
| 105 observer_list_.AddObserver(observer); | 119 observer_list_.AddObserver(observer); |
| 106 } | 120 } |
| 107 virtual void RemoveObserver( | 121 virtual void RemoveObserver( |
| 108 WebContentsModalDialogHostObserver* observer) OVERRIDE { | 122 WebContentsModalDialogHostObserver* observer) OVERRIDE { |
| 109 observer_list_.RemoveObserver(observer); | 123 observer_list_.RemoveObserver(observer); |
| 110 } | 124 } |
| 111 | 125 |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 return bottom; | 576 return bottom; |
| 563 } | 577 } |
| 564 | 578 |
| 565 bool BrowserViewLayout::InfobarVisible() const { | 579 bool BrowserViewLayout::InfobarVisible() const { |
| 566 // Cast to a views::View to access GetPreferredSize(). | 580 // Cast to a views::View to access GetPreferredSize(). |
| 567 views::View* infobar_container = infobar_container_; | 581 views::View* infobar_container = infobar_container_; |
| 568 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. | 582 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. |
| 569 return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && | 583 return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && |
| 570 (infobar_container->GetPreferredSize().height() != 0); | 584 (infobar_container->GetPreferredSize().height() != 0); |
| 571 } | 585 } |
| OLD | NEW |