| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 layout_mode_button_ = static_cast<chromeos::LayoutModeButton*>(view); | 148 layout_mode_button_ = static_cast<chromeos::LayoutModeButton*>(view); |
| 149 break; | 149 break; |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 | 152 |
| 153 // In the normal and the compact navigation bar mode, ChromeOS | 153 // In the normal and the compact navigation bar mode, ChromeOS |
| 154 // lays out compact navigation buttons and status views in the title | 154 // lays out compact navigation buttons and status views in the title |
| 155 // area. See Layout | 155 // area. See Layout |
| 156 virtual int LayoutTabStripRegion() OVERRIDE { | 156 virtual int LayoutTabStripRegion() OVERRIDE { |
| 157 if (browser_view_->IsFullscreen() || !browser_view_->IsTabStripVisible()) { | 157 if (browser_view_->IsFullscreen() || !browser_view_->IsTabStripVisible()) { |
| 158 status_area_->SetVisible(false); | 158 if (status_area_) { |
| 159 UpdateStatusAreaBoundsProperty(); | 159 status_area_->SetVisible(false); |
| 160 UpdateStatusAreaBoundsProperty(); |
| 161 } |
| 160 tabstrip_->SetVisible(false); | 162 tabstrip_->SetVisible(false); |
| 161 tabstrip_->SetBounds(0, 0, 0, 0); | 163 tabstrip_->SetBounds(0, 0, 0, 0); |
| 162 layout_mode_button_->SetVisible(false); | 164 layout_mode_button_->SetVisible(false); |
| 163 layout_mode_button_->SetBounds(0, 0, 0, 0); | 165 layout_mode_button_->SetBounds(0, 0, 0, 0); |
| 164 return 0; | 166 return 0; |
| 165 } | 167 } |
| 166 | 168 |
| 167 gfx::Rect tabstrip_bounds( | 169 gfx::Rect tabstrip_bounds( |
| 168 browser_view_->frame()->GetBoundsForTabStrip(tabstrip_)); | 170 browser_view_->frame()->GetBoundsForTabStrip(tabstrip_)); |
| 169 gfx::Point tabstrip_origin = tabstrip_bounds.origin(); | 171 gfx::Point tabstrip_origin = tabstrip_bounds.origin(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 189 | 191 |
| 190 private: | 192 private: |
| 191 chromeos::BrowserView* chromeos_browser_view() { | 193 chromeos::BrowserView* chromeos_browser_view() { |
| 192 return static_cast<chromeos::BrowserView*>(browser_view_); | 194 return static_cast<chromeos::BrowserView*>(browser_view_); |
| 193 } | 195 } |
| 194 | 196 |
| 195 // Tests if the point is on one of views that are within the | 197 // Tests if the point is on one of views that are within the |
| 196 // considered title bar area of client view. | 198 // considered title bar area of client view. |
| 197 bool IsPointInViewsInTitleArea(const gfx::Point& point) | 199 bool IsPointInViewsInTitleArea(const gfx::Point& point) |
| 198 const { | 200 const { |
| 199 gfx::Point point_in_status_area_coords(point); | 201 if (status_area_) { |
| 200 views::View::ConvertPointToView(browser_view_, status_area_, | 202 gfx::Point point_in_status_area_coords(point); |
| 201 &point_in_status_area_coords); | 203 views::View::ConvertPointToView(browser_view_, status_area_, |
| 202 if (status_area_->HitTest(point_in_status_area_coords)) | 204 &point_in_status_area_coords); |
| 203 return true; | 205 if (status_area_->HitTest(point_in_status_area_coords)) |
| 204 | 206 return true; |
| 207 } |
| 205 gfx::Point point_in_layout_mode_button_coords(point); | 208 gfx::Point point_in_layout_mode_button_coords(point); |
| 206 views::View::ConvertPointToView(browser_view_, layout_mode_button_, | 209 views::View::ConvertPointToView(browser_view_, layout_mode_button_, |
| 207 &point_in_layout_mode_button_coords); | 210 &point_in_layout_mode_button_coords); |
| 208 if (layout_mode_button_->HitTest(point_in_layout_mode_button_coords)) | 211 if (layout_mode_button_->HitTest(point_in_layout_mode_button_coords)) |
| 209 return true; | 212 return true; |
| 210 | 213 |
| 211 return false; | 214 return false; |
| 212 } | 215 } |
| 213 | 216 |
| 214 // Lays out tabstrip, status area, and layout mode button in the title bar | 217 // Lays out tabstrip, status area, and layout mode button in the title bar |
| 215 // area (given by |bounds|). | 218 // area (given by |bounds|). |
| 216 int LayoutTitlebarComponents(const gfx::Rect& bounds) { | 219 int LayoutTitlebarComponents(const gfx::Rect& bounds) { |
| 217 if (bounds.IsEmpty()) | 220 if (bounds.IsEmpty()) |
| 218 return 0; | 221 return 0; |
| 219 | 222 |
| 220 const bool show_layout_mode_button = | 223 const bool show_layout_mode_button = |
| 221 chromeos_browser_view()->should_show_layout_mode_button(); | 224 chromeos_browser_view()->should_show_layout_mode_button(); |
| 222 | 225 |
| 223 tabstrip_->SetVisible(true); | 226 tabstrip_->SetVisible(true); |
| 224 status_area_->SetVisible( | 227 if (status_area_) { |
| 225 !chromeos_browser_view()->has_hide_status_area_property()); | 228 status_area_->SetVisible( |
| 229 !chromeos_browser_view()->has_hide_status_area_property()); |
| 230 } |
| 226 layout_mode_button_->SetVisible(show_layout_mode_button); | 231 layout_mode_button_->SetVisible(show_layout_mode_button); |
| 227 | 232 |
| 228 const gfx::Size layout_mode_button_size = | 233 const gfx::Size layout_mode_button_size = |
| 229 layout_mode_button_->GetPreferredSize(); | 234 layout_mode_button_->GetPreferredSize(); |
| 230 layout_mode_button_->SetBounds( | 235 layout_mode_button_->SetBounds( |
| 231 bounds.right() - layout_mode_button_size.width(), | 236 bounds.right() - layout_mode_button_size.width(), |
| 232 bounds.y(), | 237 bounds.y(), |
| 233 layout_mode_button_size.width(), | 238 layout_mode_button_size.width(), |
| 234 layout_mode_button_size.height()); | 239 layout_mode_button_size.height()); |
| 235 | 240 |
| 236 // Lay out status area after tab strip and before layout mode button (if | 241 if (status_area_) { |
| 237 // shown). | 242 // Lay out status area after tab strip and before layout mode button (if |
| 238 gfx::Size status_size = status_area_->GetPreferredSize(); | 243 // shown). |
| 239 const int status_right = | 244 gfx::Size status_size = status_area_->GetPreferredSize(); |
| 240 show_layout_mode_button ? | 245 const int status_right = |
| 241 layout_mode_button_->bounds().x() : | 246 show_layout_mode_button ? |
| 242 bounds.right(); | 247 layout_mode_button_->bounds().x() : |
| 243 status_area_->SetBounds( | 248 bounds.right(); |
| 244 status_right - status_size.width(), | 249 status_area_->SetBounds( |
| 245 bounds.y() + kStatusAreaVerticalAdjustment, | 250 status_right - status_size.width(), |
| 246 status_size.width(), | 251 bounds.y() + kStatusAreaVerticalAdjustment, |
| 247 status_size.height()); | 252 status_size.width(), |
| 248 UpdateStatusAreaBoundsProperty(); | 253 status_size.height()); |
| 254 UpdateStatusAreaBoundsProperty(); |
| 255 } |
| 249 tabstrip_->SetBounds(bounds.x(), bounds.y(), | 256 tabstrip_->SetBounds(bounds.x(), bounds.y(), |
| 250 std::max(0, status_area_->bounds().x() - bounds.x()), | 257 std::max(0, status_area_->bounds().x() - bounds.x()), |
| 251 bounds.height()); | 258 bounds.height()); |
| 252 return bounds.bottom(); | 259 return bounds.bottom(); |
| 253 } | 260 } |
| 254 | 261 |
| 255 // Updates |status_area_bounds_for_property_| based on the current bounds and | 262 // Updates |status_area_bounds_for_property_| based on the current bounds and |
| 256 // calls WmIpc::SetStatusBoundsProperty() if it changed. | 263 // calls WmIpc::SetStatusBoundsProperty() if it changed. |
| 257 void UpdateStatusAreaBoundsProperty() { | 264 void UpdateStatusAreaBoundsProperty() { |
| 265 if (!status_area_) |
| 266 return; |
| 258 gfx::Rect current_bounds; | 267 gfx::Rect current_bounds; |
| 259 if (status_area_->IsVisible()) { | 268 if (status_area_->IsVisible()) { |
| 260 gfx::Rect translated_bounds = | 269 gfx::Rect translated_bounds = |
| 261 status_area_->parent()->ConvertRectToWidget(status_area_->bounds()); | 270 status_area_->parent()->ConvertRectToWidget(status_area_->bounds()); |
| 262 // To avoid a dead zone across the top of the screen, | 271 // To avoid a dead zone across the top of the screen, |
| 263 // StatusAreaButton::HitTest() accepts clicks in the area between the top | 272 // StatusAreaButton::HitTest() accepts clicks in the area between the top |
| 264 // of its own bounds and the top of its parent view. Make the bounds that | 273 // of its own bounds and the top of its parent view. Make the bounds that |
| 265 // we report match. | 274 // we report match. |
| 266 current_bounds.SetRect( | 275 current_bounds.SetRect( |
| 267 translated_bounds.x(), | 276 translated_bounds.x(), |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 WmIpc::instance()->SetWindowType( | 391 WmIpc::instance()->SetWindowType( |
| 383 GTK_WIDGET(frame()->GetNativeWindow()), | 392 GTK_WIDGET(frame()->GetNativeWindow()), |
| 384 WM_IPC_WINDOW_CHROME_TOPLEVEL, | 393 WM_IPC_WINDOW_CHROME_TOPLEVEL, |
| 385 ¶ms); | 394 ¶ms); |
| 386 #endif | 395 #endif |
| 387 } | 396 } |
| 388 } | 397 } |
| 389 | 398 |
| 390 void BrowserView::FocusChromeOSStatus() { | 399 void BrowserView::FocusChromeOSStatus() { |
| 391 SaveFocusedView(); | 400 SaveFocusedView(); |
| 392 status_area_->SetPaneFocus(last_focused_view_storage_id(), NULL); | 401 if (status_area_) |
| 402 status_area_->SetPaneFocus(last_focused_view_storage_id(), NULL); |
| 393 } | 403 } |
| 394 | 404 |
| 395 views::LayoutManager* BrowserView::CreateLayoutManager() const { | 405 views::LayoutManager* BrowserView::CreateLayoutManager() const { |
| 396 return new BrowserViewLayout(); | 406 return new BrowserViewLayout(); |
| 397 } | 407 } |
| 398 | 408 |
| 399 void BrowserView::ChildPreferredSizeChanged(View* child) { | 409 void BrowserView::ChildPreferredSizeChanged(View* child) { |
| 400 Layout(); | 410 Layout(); |
| 401 } | 411 } |
| 402 | 412 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 // StatusAreaButton::Delegate overrides. | 509 // StatusAreaButton::Delegate overrides. |
| 500 | 510 |
| 501 bool BrowserView::ShouldExecuteStatusAreaCommand( | 511 bool BrowserView::ShouldExecuteStatusAreaCommand( |
| 502 const views::View* button_view, int command_id) const { | 512 const views::View* button_view, int command_id) const { |
| 503 return true; | 513 return true; |
| 504 } | 514 } |
| 505 | 515 |
| 506 void BrowserView::ExecuteStatusAreaCommand( | 516 void BrowserView::ExecuteStatusAreaCommand( |
| 507 const views::View* button_view, int command_id) { | 517 const views::View* button_view, int command_id) { |
| 508 switch (command_id) { | 518 switch (command_id) { |
| 509 case StatusAreaViewChromeos::SHOW_NETWORK_OPTIONS: | 519 case StatusAreaButton::Delegate::SHOW_NETWORK_OPTIONS: |
| 510 browser()->OpenInternetOptionsDialog(); | 520 browser()->OpenInternetOptionsDialog(); |
| 511 break; | 521 break; |
| 512 case StatusAreaViewChromeos::SHOW_LANGUAGE_OPTIONS: | 522 case StatusAreaButton::Delegate::SHOW_LANGUAGE_OPTIONS: |
| 513 browser()->OpenLanguageOptionsDialog(); | 523 browser()->OpenLanguageOptionsDialog(); |
| 514 break; | 524 break; |
| 515 case StatusAreaViewChromeos::SHOW_SYSTEM_OPTIONS: | 525 case StatusAreaButton::Delegate::SHOW_SYSTEM_OPTIONS: |
| 516 browser()->OpenLanguageOptionsDialog(); | 526 browser()->OpenSystemOptionsDialog(); |
| 517 break; | 527 break; |
| 518 default: | 528 default: |
| 519 NOTREACHED(); | 529 NOTREACHED(); |
| 520 } | 530 } |
| 521 } | 531 } |
| 522 | 532 |
| 523 gfx::Font BrowserView::GetStatusAreaFont(const gfx::Font& font) const { | 533 gfx::Font BrowserView::GetStatusAreaFont(const gfx::Font& font) const { |
| 524 return font.DeriveFont(0, gfx::Font::BOLD); | 534 return font.DeriveFont(0, gfx::Font::BOLD); |
| 525 } | 535 } |
| 526 | 536 |
| 527 StatusAreaButton::TextStyle BrowserView::GetStatusAreaTextStyle() const { | 537 StatusAreaButton::TextStyle BrowserView::GetStatusAreaTextStyle() const { |
| 528 ThemeService* theme_service = | 538 ThemeService* theme_service = |
| 529 ThemeServiceFactory::GetForProfile(browser()->profile()); | 539 ThemeServiceFactory::GetForProfile(browser()->profile()); |
| 530 | 540 |
| 531 if (!theme_service->UsingDefaultTheme()) | 541 if (!theme_service->UsingDefaultTheme()) |
| 532 return StatusAreaButton::WHITE_HALOED; | 542 return StatusAreaButton::WHITE_HALOED; |
| 533 | 543 |
| 534 return IsOffTheRecord() ? | 544 return IsOffTheRecord() ? |
| 535 StatusAreaButton::WHITE_PLAIN : StatusAreaButton::GRAY_EMBOSSED; | 545 StatusAreaButton::WHITE_PLAIN : StatusAreaButton::GRAY_EMBOSSED; |
| 536 } | 546 } |
| 537 | 547 |
| 538 void BrowserView::ButtonVisibilityChanged(views::View* button_view) { | 548 void BrowserView::ButtonVisibilityChanged(views::View* button_view) { |
| 539 status_area_->UpdateButtonVisibility(); | 549 if (status_area_) |
| 550 status_area_->UpdateButtonVisibility(); |
| 540 } | 551 } |
| 541 | 552 |
| 542 // BrowserView, MessageLoopForUI::Observer implementation. | 553 // BrowserView, MessageLoopForUI::Observer implementation. |
| 543 | 554 |
| 544 #if defined(TOUCH_UI) || defined(USE_AURA) | 555 #if defined(TOUCH_UI) || defined(USE_AURA) |
| 545 base::EventStatus BrowserView::WillProcessEvent( | 556 base::EventStatus BrowserView::WillProcessEvent( |
| 546 const base::NativeEvent& event) OVERRIDE { | 557 const base::NativeEvent& event) OVERRIDE { |
| 547 return base::EVENT_CONTINUE; | 558 return base::EVENT_CONTINUE; |
| 548 } | 559 } |
| 549 | 560 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 569 } | 580 } |
| 570 } | 581 } |
| 571 } | 582 } |
| 572 #endif | 583 #endif |
| 573 | 584 |
| 574 // BrowserView protected: | 585 // BrowserView protected: |
| 575 | 586 |
| 576 void BrowserView::GetAccessiblePanes( | 587 void BrowserView::GetAccessiblePanes( |
| 577 std::vector<AccessiblePaneView*>* panes) { | 588 std::vector<AccessiblePaneView*>* panes) { |
| 578 ::BrowserView::GetAccessiblePanes(panes); | 589 ::BrowserView::GetAccessiblePanes(panes); |
| 579 panes->push_back(status_area_); | 590 if (status_area_) |
| 591 panes->push_back(status_area_); |
| 580 } | 592 } |
| 581 | 593 |
| 582 // BrowserView private. | 594 // BrowserView private. |
| 583 | 595 |
| 584 void BrowserView::InitSystemMenu() { | 596 void BrowserView::InitSystemMenu() { |
| 585 views::MenuItemView* menu = | 597 views::MenuItemView* menu = |
| 586 new views::MenuItemView(system_menu_delegate_.get()); | 598 new views::MenuItemView(system_menu_delegate_.get()); |
| 587 // MenuRunner takes ownership of menu. | 599 // MenuRunner takes ownership of menu. |
| 588 system_menu_runner_.reset(new views::MenuRunner(menu)); | 600 system_menu_runner_.reset(new views::MenuRunner(menu)); |
| 589 menu->AppendDelegateMenuItem(IDC_RESTORE_TAB); | 601 menu->AppendDelegateMenuItem(IDC_RESTORE_TAB); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 641 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 630 // Create a browser view for chromeos. | 642 // Create a browser view for chromeos. |
| 631 BrowserView* view; | 643 BrowserView* view; |
| 632 if (browser->is_type_popup() || browser->is_type_panel()) | 644 if (browser->is_type_popup() || browser->is_type_panel()) |
| 633 view = new chromeos::PanelBrowserView(browser); | 645 view = new chromeos::PanelBrowserView(browser); |
| 634 else | 646 else |
| 635 view = new chromeos::BrowserView(browser); | 647 view = new chromeos::BrowserView(browser); |
| 636 (new BrowserFrame(view))->InitBrowserFrame(); | 648 (new BrowserFrame(view))->InitBrowserFrame(); |
| 637 return view; | 649 return view; |
| 638 } | 650 } |
| OLD | NEW |