OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 #endif | 135 #endif |
136 | 136 |
137 #if defined(TOUCH_UI) | 137 #if defined(TOUCH_UI) |
138 #include "chrome/browser/ui/touch/status_bubble_touch.h" | 138 #include "chrome/browser/ui/touch/status_bubble_touch.h" |
139 #endif | 139 #endif |
140 | 140 |
141 using base::TimeDelta; | 141 using base::TimeDelta; |
142 using views::ColumnSet; | 142 using views::ColumnSet; |
143 using views::GridLayout; | 143 using views::GridLayout; |
144 | 144 |
145 namespace { | |
145 // The height of the status bubble. | 146 // The height of the status bubble. |
146 static const int kStatusBubbleHeight = 20; | 147 const int kStatusBubbleHeight = 20; |
147 // The name of a key to store on the window handle so that other code can | 148 // The name of a key to store on the window handle so that other code can |
148 // locate this object using just the handle. | 149 // locate this object using just the handle. |
149 static const char* const kBrowserViewKey = "__BROWSER_VIEW__"; | 150 const char* const kBrowserViewKey = "__BROWSER_VIEW__"; |
150 // How frequently we check for hung plugin windows. | 151 // How frequently we check for hung plugin windows. |
151 static const int kDefaultHungPluginDetectFrequency = 2000; | 152 const int kDefaultHungPluginDetectFrequency = 2000; |
152 | 153 |
153 // Minimal height of devtools pane or content pane when devtools are docked | 154 // Minimal height of devtools pane or content pane when devtools are docked |
154 // to the browser window. | 155 // to the browser window. |
155 const int kMinDevToolsHeight = 50; | 156 const int kMinDevToolsHeight = 50; |
156 const int kMinContentsHeight = 50; | 157 const int kMinContentsHeight = 50; |
157 | 158 |
159 #if defined(USE_AURA) && defined(OS_CHROMEOS) | |
160 // If a popup window is larger than this fraction of the screen, create a tab. | |
161 const float kPopupMaxWidthFactor = 0.5; | |
162 const float kPopupMaxHeightFactor = 0.6; | |
163 #endif | |
164 | |
158 // How long do we wait before we consider a window hung (in ms). | 165 // How long do we wait before we consider a window hung (in ms). |
159 static const int kDefaultPluginMessageResponseTimeout = 30000; | 166 const int kDefaultPluginMessageResponseTimeout = 30000; |
160 // The number of milliseconds between loading animation frames. | 167 // The number of milliseconds between loading animation frames. |
161 static const int kLoadingAnimationFrameTimeMs = 30; | 168 const int kLoadingAnimationFrameTimeMs = 30; |
162 // The amount of space we expect the window border to take up. | 169 // The amount of space we expect the window border to take up. |
163 static const int kWindowBorderWidth = 5; | 170 const int kWindowBorderWidth = 5; |
164 | 171 |
165 // How round the 'new tab' style bookmarks bar is. | 172 // How round the 'new tab' style bookmarks bar is. |
166 static const int kNewtabBarRoundness = 5; | 173 const int kNewtabBarRoundness = 5; |
167 // ------------ | 174 // ------------ |
168 | 175 |
176 } // namespace | |
177 | |
169 // Returned from BrowserView::GetClassName. | 178 // Returned from BrowserView::GetClassName. |
170 const char BrowserView::kViewClassName[] = "browser/ui/views/BrowserView"; | 179 const char BrowserView::kViewClassName[] = "browser/ui/views/BrowserView"; |
171 | 180 |
172 /////////////////////////////////////////////////////////////////////////////// | 181 /////////////////////////////////////////////////////////////////////////////// |
173 // BookmarkExtensionBackground, private: | 182 // BookmarkExtensionBackground, private: |
174 // This object serves as the views::Background object which is used to layout | 183 // This object serves as the views::Background object which is used to layout |
175 // and paint the bookmark bar. | 184 // and paint the bookmark bar. |
176 class BookmarkExtensionBackground : public views::Background { | 185 class BookmarkExtensionBackground : public views::Background { |
177 public: | 186 public: |
178 BookmarkExtensionBackground(BrowserView* browser_view, | 187 BookmarkExtensionBackground(BrowserView* browser_view, |
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1306 } | 1315 } |
1307 | 1316 |
1308 WindowOpenDisposition BrowserView::GetDispositionForPopupBounds( | 1317 WindowOpenDisposition BrowserView::GetDispositionForPopupBounds( |
1309 const gfx::Rect& bounds) { | 1318 const gfx::Rect& bounds) { |
1310 #if defined(USE_AURA) && defined(OS_CHROMEOS) | 1319 #if defined(USE_AURA) && defined(OS_CHROMEOS) |
1311 // If a popup is larger than a given fraction of the screen, turn it into | 1320 // If a popup is larger than a given fraction of the screen, turn it into |
1312 // a foreground tab. Also check for width or height == 0, which would | 1321 // a foreground tab. Also check for width or height == 0, which would |
1313 // indicate a tab sized popup window. | 1322 // indicate a tab sized popup window. |
1314 gfx::Size size = gfx::Screen::GetMonitorAreaNearestWindow( | 1323 gfx::Size size = gfx::Screen::GetMonitorAreaNearestWindow( |
1315 GetWidget()->GetNativeView()).size(); | 1324 GetWidget()->GetNativeView()).size(); |
1316 if (bounds.width() > size.width() || | 1325 int max_width = size.width() * kPopupMaxWidthFactor; |
1326 int max_height = size.height() * kPopupMaxHeightFactor; | |
sadrul
2011/11/22 21:40:25
Ah, my bad. When I copied over the change, I faile
| |
1327 | |
1328 if (bounds.width() > max_width || | |
1317 bounds.width() == 0 || | 1329 bounds.width() == 0 || |
1318 bounds.height() > size.height() || | 1330 bounds.height() > max_height || |
1319 bounds.height() == 0) { | 1331 bounds.height() == 0) { |
1320 return NEW_FOREGROUND_TAB; | 1332 return NEW_FOREGROUND_TAB; |
1321 } | 1333 } |
1322 #endif | 1334 #endif |
1323 return NEW_POPUP; | 1335 return NEW_POPUP; |
1324 } | 1336 } |
1325 | 1337 |
1326 FindBar* BrowserView::CreateFindBar() { | 1338 FindBar* BrowserView::CreateFindBar() { |
1327 return browser::CreateFindBar(this); | 1339 return browser::CreateFindBar(this); |
1328 } | 1340 } |
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2632 Bubble::Show(this->GetWidget(), bounds, views::BubbleBorder::TOP_RIGHT, | 2644 Bubble::Show(this->GetWidget(), bounds, views::BubbleBorder::TOP_RIGHT, |
2633 views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, | 2645 views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, |
2634 bubble_view, bubble_view); | 2646 bubble_view, bubble_view); |
2635 } | 2647 } |
2636 | 2648 |
2637 void BrowserView::ShowAvatarBubbleFromAvatarButton() { | 2649 void BrowserView::ShowAvatarBubbleFromAvatarButton() { |
2638 AvatarMenuButton* button = frame_->GetAvatarMenuButton(); | 2650 AvatarMenuButton* button = frame_->GetAvatarMenuButton(); |
2639 if (button) | 2651 if (button) |
2640 button->ShowAvatarBubble(); | 2652 button->ShowAvatarBubble(); |
2641 } | 2653 } |
OLD | NEW |