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

Side by Side Diff: chrome/browser/chromeos/frame/browser_view.cc

Issue 6881073: Cleanup popup related browser navigation code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Popup tests for ChromeOS. Created 9 years, 8 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 | Annotate | Revision Log
OLDNEW
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/chromeos/frame/browser_view.h" 5 #include "chrome/browser/chromeos/frame/browser_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 24 matching lines...) Expand all
35 #include "views/controls/menu/menu_2.h" 35 #include "views/controls/menu/menu_2.h"
36 #include "views/screen.h" 36 #include "views/screen.h"
37 #include "views/widget/root_view.h" 37 #include "views/widget/root_view.h"
38 #include "views/window/hit_test.h" 38 #include "views/window/hit_test.h"
39 #include "views/window/window.h" 39 #include "views/window/window.h"
40 40
41 namespace { 41 namespace {
42 42
43 // Amount to offset the toolbar by when vertical tabs are enabled. 43 // Amount to offset the toolbar by when vertical tabs are enabled.
44 const int kVerticalTabStripToolbarOffset = 2; 44 const int kVerticalTabStripToolbarOffset = 2;
45 // If a popup window is larger than this fraction of the screen, create a tab.
46 const float kPopupMaxWidthFactor = 0.5;
47 const float kPopupMaxHeightFactor = 0.6;
45 48
46 } // namespace 49 } // namespace
47 50
48 namespace chromeos { 51 namespace chromeos {
49 52
50 // LayoutManager for BrowserView, which layouts extra components such as 53 // LayoutManager for BrowserView, which layouts extra components such as
51 // the status views as follows: 54 // the status views as follows:
52 // ____ __ __ 55 // ____ __ __
53 // / \ \ \ [StatusArea] 56 // / \ \ \ [StatusArea]
54 // 57 //
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 311 }
309 312
310 void BrowserView::Copy() { 313 void BrowserView::Copy() {
311 gtk_util::DoCopy(this); 314 gtk_util::DoCopy(this);
312 } 315 }
313 316
314 void BrowserView::Paste() { 317 void BrowserView::Paste() {
315 gtk_util::DoPaste(this); 318 gtk_util::DoPaste(this);
316 } 319 }
317 320
321 void BrowserView::AdjustNavigateParams(browser::NavigateParams* params) {
322 if (params->disposition == NEW_POPUP) {
323 // If the popup is larger than a given fraction of the screen, turn it into
324 // a foreground tab. Also check for width or height == 0, which indicate
325 // a tab sized popup window.
326 GdkScreen* screen = gdk_screen_get_default();
327 int max_width = gdk_screen_get_width(screen) * kPopupMaxWidthFactor;
328 int max_height = gdk_screen_get_height(screen) * kPopupMaxHeightFactor;
329 if (params->window_bounds.width() > max_width ||
330 params->window_bounds.width() == 0 ||
331 params->window_bounds.height() > max_height ||
332 params->window_bounds.height() == 0) {
333 params->disposition = NEW_FOREGROUND_TAB;
334 }
335 }
336 }
337
318 // views::ContextMenuController overrides. 338 // views::ContextMenuController overrides.
319 void BrowserView::ShowContextMenuForView(views::View* source, 339 void BrowserView::ShowContextMenuForView(views::View* source,
320 const gfx::Point& p, 340 const gfx::Point& p,
321 bool is_mouse_gesture) { 341 bool is_mouse_gesture) {
322 // Only show context menu if point is in unobscured parts of browser, i.e. 342 // Only show context menu if point is in unobscured parts of browser, i.e.
323 // if NonClientHitTest returns : 343 // if NonClientHitTest returns :
324 // - HTCAPTION: in title bar or unobscured part of tabstrip 344 // - HTCAPTION: in title bar or unobscured part of tabstrip
325 // - HTNOWHERE: as the name implies. 345 // - HTNOWHERE: as the name implies.
326 gfx::Point point_in_parent_coords(p); 346 gfx::Point point_in_parent_coords(p);
327 views::View::ConvertPointToView(NULL, parent(), &point_in_parent_coords); 347 views::View::ConvertPointToView(NULL, parent(), &point_in_parent_coords);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { 416 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
397 // Create a browser view for chromeos. 417 // Create a browser view for chromeos.
398 BrowserView* view; 418 BrowserView* view;
399 if (browser->type() & Browser::TYPE_POPUP) 419 if (browser->type() & Browser::TYPE_POPUP)
400 view = new chromeos::PanelBrowserView(browser); 420 view = new chromeos::PanelBrowserView(browser);
401 else 421 else
402 view = new chromeos::BrowserView(browser); 422 view = new chromeos::BrowserView(browser);
403 BrowserFrame::Create(view, browser->profile()); 423 BrowserFrame::Create(view, browser->profile());
404 return view; 424 return view;
405 } 425 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698