| 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/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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 Layout(); | 351 Layout(); |
| 352 } | 352 } |
| 353 | 353 |
| 354 bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const { | 354 bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const { |
| 355 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeosFrame)) { | 355 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeosFrame)) { |
| 356 // Typically we don't request a full screen size. This means we'll request a | 356 // Typically we don't request a full screen size. This means we'll request a |
| 357 // non-full screen size, layout/paint at that size, then the window manager | 357 // non-full screen size, layout/paint at that size, then the window manager |
| 358 // will snap us to full screen size. This results in an ugly | 358 // will snap us to full screen size. This results in an ugly |
| 359 // resize/paint. To avoid this we always request a full screen size. | 359 // resize/paint. To avoid this we always request a full screen size. |
| 360 *bounds = views::Screen::GetMonitorWorkAreaNearestWindow( | 360 *bounds = views::Screen::GetMonitorWorkAreaNearestWindow( |
| 361 GTK_WIDGET(GetWindow()->GetNativeWindow())); | 361 GTK_WIDGET(GetWidget()->GetNativeWindow())); |
| 362 return true; | 362 return true; |
| 363 } | 363 } |
| 364 return ::BrowserView::GetSavedWindowBounds(bounds); | 364 return ::BrowserView::GetSavedWindowBounds(bounds); |
| 365 } | 365 } |
| 366 | 366 |
| 367 void BrowserView::Cut() { | 367 void BrowserView::Cut() { |
| 368 gtk_util::DoCut(this); | 368 gtk_util::DoCut(this); |
| 369 } | 369 } |
| 370 | 370 |
| 371 void BrowserView::Copy() { | 371 void BrowserView::Copy() { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 400 // Only show context menu if point is in unobscured parts of browser, i.e. | 400 // Only show context menu if point is in unobscured parts of browser, i.e. |
| 401 // if NonClientHitTest returns : | 401 // if NonClientHitTest returns : |
| 402 // - HTCAPTION: in title bar or unobscured part of tabstrip | 402 // - HTCAPTION: in title bar or unobscured part of tabstrip |
| 403 // - HTNOWHERE: as the name implies. | 403 // - HTNOWHERE: as the name implies. |
| 404 gfx::Point point_in_parent_coords(p); | 404 gfx::Point point_in_parent_coords(p); |
| 405 views::View::ConvertPointToView(NULL, parent(), &point_in_parent_coords); | 405 views::View::ConvertPointToView(NULL, parent(), &point_in_parent_coords); |
| 406 int hit_test = NonClientHitTest(point_in_parent_coords); | 406 int hit_test = NonClientHitTest(point_in_parent_coords); |
| 407 if (hit_test == HTCAPTION || hit_test == HTNOWHERE) { | 407 if (hit_test == HTCAPTION || hit_test == HTNOWHERE) { |
| 408 // rebuild menu so it reflects current application state | 408 // rebuild menu so it reflects current application state |
| 409 InitSystemMenu(); | 409 InitSystemMenu(); |
| 410 system_menu_->RunMenuAt(source->GetWindow()->GetNativeWindow(), NULL, | 410 system_menu_->RunMenuAt(source->GetWidget()->GetNativeWindow(), NULL, |
| 411 gfx::Rect(p, gfx::Size(0,0)), | 411 gfx::Rect(p, gfx::Size(0,0)), |
| 412 views::MenuItemView::TOPLEFT, | 412 views::MenuItemView::TOPLEFT, |
| 413 true); | 413 true); |
| 414 } | 414 } |
| 415 } | 415 } |
| 416 | 416 |
| 417 // BrowserView, views::MenuListener implementation. | 417 // BrowserView, views::MenuListener implementation. |
| 418 void BrowserView::OnMenuOpened() { | 418 void BrowserView::OnMenuOpened() { |
| 419 // Save the focused widget before wrench menu opens. | 419 // Save the focused widget before wrench menu opens. |
| 420 saved_focused_widget_ = gtk_window_get_focus(GetNativeHandle()); | 420 saved_focused_widget_ = gtk_window_get_focus(GetNativeHandle()); |
| 421 } | 421 } |
| 422 | 422 |
| 423 // BrowserView, StatusAreaHost implementation. | 423 // BrowserView, StatusAreaHost implementation. |
| 424 | 424 |
| 425 Profile* BrowserView::GetProfile() const { | 425 Profile* BrowserView::GetProfile() const { |
| 426 return browser()->profile(); | 426 return browser()->profile(); |
| 427 } | 427 } |
| 428 | 428 |
| 429 gfx::NativeWindow BrowserView::GetNativeWindow() const { | 429 gfx::NativeWindow BrowserView::GetNativeWindow() const { |
| 430 return GetWindow()->GetNativeWindow(); | 430 return GetWidget()->GetNativeWindow(); |
| 431 } | 431 } |
| 432 | 432 |
| 433 bool BrowserView::ShouldOpenButtonOptions( | 433 bool BrowserView::ShouldOpenButtonOptions( |
| 434 const views::View* button_view) const { | 434 const views::View* button_view) const { |
| 435 return true; | 435 return true; |
| 436 } | 436 } |
| 437 | 437 |
| 438 void BrowserView::ExecuteBrowserCommand(int id) const { | 438 void BrowserView::ExecuteBrowserCommand(int id) const { |
| 439 browser()->ExecuteCommand(id); | 439 browser()->ExecuteCommand(id); |
| 440 } | 440 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 489 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 490 // Create a browser view for chromeos. | 490 // Create a browser view for chromeos. |
| 491 BrowserView* view; | 491 BrowserView* view; |
| 492 if (browser->is_type_popup() || browser->is_type_panel()) | 492 if (browser->is_type_popup() || browser->is_type_panel()) |
| 493 view = new chromeos::PanelBrowserView(browser); | 493 view = new chromeos::PanelBrowserView(browser); |
| 494 else | 494 else |
| 495 view = new chromeos::BrowserView(browser); | 495 view = new chromeos::BrowserView(browser); |
| 496 (new BrowserFrame(view))->InitBrowserFrame(); | 496 (new BrowserFrame(view))->InitBrowserFrame(); |
| 497 return view; | 497 return view; |
| 498 } | 498 } |
| OLD | NEW |