| 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 <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" | 34 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" |
| 35 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 36 #include "ui/base/models/simple_menu_model.h" | 36 #include "ui/base/models/simple_menu_model.h" |
| 37 #include "ui/base/theme_provider.h" | 37 #include "ui/base/theme_provider.h" |
| 38 #include "ui/gfx/canvas.h" | 38 #include "ui/gfx/canvas.h" |
| 39 #include "ui/gfx/screen.h" | 39 #include "ui/gfx/screen.h" |
| 40 #include "views/controls/button/button.h" | 40 #include "views/controls/button/button.h" |
| 41 #include "views/controls/button/image_button.h" | 41 #include "views/controls/button/image_button.h" |
| 42 #include "views/controls/menu/menu_delegate.h" | 42 #include "views/controls/menu/menu_delegate.h" |
| 43 #include "views/controls/menu/menu_item_view.h" | 43 #include "views/controls/menu/menu_item_view.h" |
| 44 #include "views/controls/menu/menu_runner.h" |
| 44 #include "views/widget/root_view.h" | 45 #include "views/widget/root_view.h" |
| 45 #include "views/widget/widget.h" | 46 #include "views/widget/widget.h" |
| 46 #include "views/window/hit_test.h" | 47 #include "views/window/hit_test.h" |
| 47 | 48 |
| 48 namespace { | 49 namespace { |
| 49 | 50 |
| 50 // Amount to offset the toolbar by when vertical tabs are enabled. | 51 // Amount to offset the toolbar by when vertical tabs are enabled. |
| 51 const int kVerticalTabStripToolbarOffset = 2; | 52 const int kVerticalTabStripToolbarOffset = 2; |
| 52 // Amount to tweak the position of the status area to get it to look right. | 53 // Amount to tweak the position of the status area to get it to look right. |
| 53 const int kStatusAreaVerticalAdjustment = -1; | 54 const int kStatusAreaVerticalAdjustment = -1; |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 // Only show context menu if point is in unobscured parts of browser, i.e. | 505 // Only show context menu if point is in unobscured parts of browser, i.e. |
| 505 // if NonClientHitTest returns : | 506 // if NonClientHitTest returns : |
| 506 // - HTCAPTION: in title bar or unobscured part of tabstrip | 507 // - HTCAPTION: in title bar or unobscured part of tabstrip |
| 507 // - HTNOWHERE: as the name implies. | 508 // - HTNOWHERE: as the name implies. |
| 508 gfx::Point point_in_parent_coords(p); | 509 gfx::Point point_in_parent_coords(p); |
| 509 views::View::ConvertPointToView(NULL, parent(), &point_in_parent_coords); | 510 views::View::ConvertPointToView(NULL, parent(), &point_in_parent_coords); |
| 510 int hit_test = NonClientHitTest(point_in_parent_coords); | 511 int hit_test = NonClientHitTest(point_in_parent_coords); |
| 511 if (hit_test == HTCAPTION || hit_test == HTNOWHERE) { | 512 if (hit_test == HTCAPTION || hit_test == HTNOWHERE) { |
| 512 // rebuild menu so it reflects current application state | 513 // rebuild menu so it reflects current application state |
| 513 InitSystemMenu(); | 514 InitSystemMenu(); |
| 514 system_menu_->RunMenuAt(source->GetWidget(), NULL, | 515 if (system_menu_runner_->RunMenuAt(source->GetWidget(), NULL, |
| 515 gfx::Rect(p, gfx::Size(0,0)), | 516 gfx::Rect(p, gfx::Size(0,0)), views::MenuItemView::TOPLEFT, |
| 516 views::MenuItemView::TOPLEFT, | 517 views::MenuRunner::HAS_MNEMONICS) == |
| 517 true); | 518 views::MenuRunner::MENU_DELETED) |
| 519 return; |
| 518 } | 520 } |
| 519 } | 521 } |
| 520 | 522 |
| 521 // BrowserView, views::MenuListener implementation. | 523 // BrowserView, views::MenuListener implementation. |
| 522 void BrowserView::OnMenuOpened() { | 524 void BrowserView::OnMenuOpened() { |
| 523 // Save the focused widget before wrench menu opens. | 525 // Save the focused widget before wrench menu opens. |
| 524 saved_focused_widget_ = gtk_window_get_focus(GetNativeHandle()); | 526 saved_focused_widget_ = gtk_window_get_focus(GetNativeHandle()); |
| 525 } | 527 } |
| 526 | 528 |
| 527 // BrowserView, BrowserList::Observer implementation. | 529 // BrowserView, BrowserList::Observer implementation. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 | 615 |
| 614 void BrowserView::GetAccessiblePanes( | 616 void BrowserView::GetAccessiblePanes( |
| 615 std::vector<AccessiblePaneView*>* panes) { | 617 std::vector<AccessiblePaneView*>* panes) { |
| 616 ::BrowserView::GetAccessiblePanes(panes); | 618 ::BrowserView::GetAccessiblePanes(panes); |
| 617 panes->push_back(status_area_); | 619 panes->push_back(status_area_); |
| 618 } | 620 } |
| 619 | 621 |
| 620 // BrowserView private. | 622 // BrowserView private. |
| 621 | 623 |
| 622 void BrowserView::InitSystemMenu() { | 624 void BrowserView::InitSystemMenu() { |
| 623 system_menu_.reset(new views::MenuItemView(system_menu_delegate_.get())); | 625 views::MenuItemView* menu = |
| 624 system_menu_->AppendDelegateMenuItem(IDC_RESTORE_TAB); | 626 new views::MenuItemView(system_menu_delegate_.get()); |
| 625 | 627 // MenuRunner takes ownership of menu. |
| 626 system_menu_->AppendMenuItemWithLabel( | 628 system_menu_runner_.reset(new views::MenuRunner(menu)); |
| 629 menu->AppendDelegateMenuItem(IDC_RESTORE_TAB); |
| 630 menu->AppendMenuItemWithLabel( |
| 627 IDC_NEW_TAB, | 631 IDC_NEW_TAB, |
| 628 UTF16ToWide(l10n_util::GetStringUTF16(IDS_NEW_TAB))); | 632 UTF16ToWide(l10n_util::GetStringUTF16(IDS_NEW_TAB))); |
| 629 system_menu_->AppendSeparator(); | 633 menu->AppendSeparator(); |
| 630 system_menu_->AppendMenuItemWithLabel( | 634 menu->AppendMenuItemWithLabel( |
| 631 IDC_TASK_MANAGER, | 635 IDC_TASK_MANAGER, |
| 632 UTF16ToWide(l10n_util::GetStringUTF16(IDS_TASK_MANAGER))); | 636 UTF16ToWide(l10n_util::GetStringUTF16(IDS_TASK_MANAGER))); |
| 633 } | 637 } |
| 634 | 638 |
| 635 void BrowserView::FetchHideStatusAreaProperty() { | 639 void BrowserView::FetchHideStatusAreaProperty() { |
| 636 std::set<WmIpc::AtomType> state_atoms; | 640 std::set<WmIpc::AtomType> state_atoms; |
| 637 if (WmIpc::instance()->GetWindowState( | 641 if (WmIpc::instance()->GetWindowState( |
| 638 GTK_WIDGET(frame()->GetNativeWindow()), &state_atoms)) { | 642 GTK_WIDGET(frame()->GetNativeWindow()), &state_atoms)) { |
| 639 if (state_atoms.count(WmIpc::ATOM_CHROME_STATE_STATUS_HIDDEN)) { | 643 if (state_atoms.count(WmIpc::ATOM_CHROME_STATE_STATUS_HIDDEN)) { |
| 640 has_hide_status_area_property_ = true; | 644 has_hide_status_area_property_ = true; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 665 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 669 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 666 // Create a browser view for chromeos. | 670 // Create a browser view for chromeos. |
| 667 BrowserView* view; | 671 BrowserView* view; |
| 668 if (browser->is_type_popup() || browser->is_type_panel()) | 672 if (browser->is_type_popup() || browser->is_type_panel()) |
| 669 view = new chromeos::PanelBrowserView(browser); | 673 view = new chromeos::PanelBrowserView(browser); |
| 670 else | 674 else |
| 671 view = new chromeos::BrowserView(browser); | 675 view = new chromeos::BrowserView(browser); |
| 672 (new BrowserFrame(view))->InitBrowserFrame(); | 676 (new BrowserFrame(view))->InitBrowserFrame(); |
| 673 return view; | 677 return view; |
| 674 } | 678 } |
| OLD | NEW |