Chromium Code Reviews| 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 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
| 13 #include "chrome/browser/chromeos/frame/panel_browser_view.h" | 13 #include "chrome/browser/chromeos/frame/panel_browser_view.h" |
| 14 #include "chrome/browser/chromeos/status/input_method_menu_button.h" | 14 #include "chrome/browser/chromeos/status/input_method_menu_button.h" |
| 15 #include "chrome/browser/chromeos/status/network_menu_button.h" | 15 #include "chrome/browser/chromeos/status/network_menu_button.h" |
| 16 #include "chrome/browser/chromeos/status/status_area_button.h" | 16 #include "chrome/browser/chromeos/status/status_area_button.h" |
| 17 #include "chrome/browser/chromeos/status/status_area_view.h" | 17 #include "chrome/browser/chromeos/status/status_area_view.h" |
| 18 #include "chrome/browser/chromeos/view_ids.h" | 18 #include "chrome/browser/chromeos/view_ids.h" |
| 19 #include "chrome/browser/chromeos/wm_ipc.h" | 19 #include "chrome/browser/chromeos/wm_ipc.h" |
| 20 #include "chrome/browser/ui/gtk/gtk_util.h" | 20 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 21 #include "chrome/browser/ui/views/frame/browser_frame_gtk.h" | 21 #include "chrome/browser/ui/views/frame/browser_frame_gtk.h" |
| 22 #include "chrome/browser/ui/views/frame/browser_view.h" | 22 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 23 #include "chrome/browser/ui/views/frame/browser_view_layout.h" | 23 #include "chrome/browser/ui/views/frame/browser_view_layout.h" |
| 24 #include "chrome/browser/ui/views/tabs/tab.h" | 24 #include "chrome/browser/ui/views/tabs/tab.h" |
| 25 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 25 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 26 #include "chrome/browser/ui/views/theme_background.h" | 26 #include "chrome/browser/ui/views/theme_background.h" |
| 27 #include "chrome/browser/ui/views/toolbar_view.h" | 27 #include "chrome/browser/ui/views/toolbar_view.h" |
| 28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 29 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 30 #include "grit/theme_resources_standard.h" | |
| 30 #include "third_party/cros/chromeos_wm_ipc_enums.h" | 31 #include "third_party/cros/chromeos_wm_ipc_enums.h" |
| 31 #include "ui/base/models/simple_menu_model.h" | 32 #include "ui/base/models/simple_menu_model.h" |
| 33 #include "ui/base/theme_provider.h" | |
| 32 #include "ui/gfx/canvas.h" | 34 #include "ui/gfx/canvas.h" |
| 33 #include "views/controls/button/button.h" | 35 #include "views/controls/button/button.h" |
| 34 #include "views/controls/button/image_button.h" | 36 #include "views/controls/button/image_button.h" |
| 35 #include "views/controls/menu/menu_2.h" | 37 #include "views/controls/menu/menu_2.h" |
| 36 #include "views/screen.h" | 38 #include "views/screen.h" |
| 37 #include "views/widget/root_view.h" | 39 #include "views/widget/root_view.h" |
| 38 #include "views/window/hit_test.h" | 40 #include "views/window/hit_test.h" |
| 39 #include "views/window/window.h" | 41 #include "views/window/window.h" |
| 40 | 42 |
| 41 namespace { | 43 namespace { |
| 42 | 44 |
| 43 // Amount to offset the toolbar by when vertical tabs are enabled. | 45 // Amount to offset the toolbar by when vertical tabs are enabled. |
| 44 const int kVerticalTabStripToolbarOffset = 2; | 46 const int kVerticalTabStripToolbarOffset = 2; |
| 47 // Amount to tweak the position of the status area to get it to look right. | |
| 48 const int kStatusAreaVerticalAdjustment = -1; | |
| 49 | |
| 45 // If a popup window is larger than this fraction of the screen, create a tab. | 50 // If a popup window is larger than this fraction of the screen, create a tab. |
| 46 const float kPopupMaxWidthFactor = 0.5; | 51 const float kPopupMaxWidthFactor = 0.5; |
| 47 const float kPopupMaxHeightFactor = 0.6; | 52 const float kPopupMaxHeightFactor = 0.6; |
| 48 | 53 |
| 49 } // namespace | 54 } // namespace |
| 50 | 55 |
| 51 namespace chromeos { | 56 namespace chromeos { |
| 52 | 57 |
| 53 // LayoutManager for BrowserView, which layouts extra components such as | 58 // LayoutManager for BrowserView, which layouts extra components such as |
| 54 // the status views as follows: | 59 // the status views as follows: |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 // |bounds|). | 195 // |bounds|). |
| 191 int LayoutTitlebarComponents(const gfx::Rect& bounds) { | 196 int LayoutTitlebarComponents(const gfx::Rect& bounds) { |
| 192 if (bounds.IsEmpty()) | 197 if (bounds.IsEmpty()) |
| 193 return 0; | 198 return 0; |
| 194 | 199 |
| 195 tabstrip_->SetVisible(true); | 200 tabstrip_->SetVisible(true); |
| 196 status_area_->SetVisible(true); | 201 status_area_->SetVisible(true); |
| 197 | 202 |
| 198 // Layout status area after tab strip. | 203 // Layout status area after tab strip. |
| 199 gfx::Size status_size = status_area_->GetPreferredSize(); | 204 gfx::Size status_size = status_area_->GetPreferredSize(); |
| 200 status_area_->SetBounds(bounds.right() - status_size.width(), bounds.y(), | 205 status_area_->SetBounds( |
| 201 status_size.width(), status_size.height()); | 206 bounds.right() - status_size.width(), |
| 207 bounds.y() + kStatusAreaVerticalAdjustment, | |
| 208 status_size.width(), | |
| 209 status_size.height()); | |
| 202 tabstrip_->SetBounds(bounds.x(), bounds.y(), | 210 tabstrip_->SetBounds(bounds.x(), bounds.y(), |
| 203 std::max(0, status_area_->bounds().x() - bounds.x()), | 211 std::max(0, status_area_->bounds().x() - bounds.x()), |
| 204 bounds.height()); | 212 bounds.height()); |
| 205 return bounds.bottom(); | 213 return bounds.bottom(); |
| 206 } | 214 } |
| 207 | 215 |
| 208 chromeos::StatusAreaView* status_area_; | 216 chromeos::StatusAreaView* status_area_; |
| 209 | 217 |
| 210 DISALLOW_COPY_AND_ASSIGN(BrowserViewLayout); | 218 DISALLOW_COPY_AND_ASSIGN(BrowserViewLayout); |
| 211 }; | 219 }; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 browser()->OpenLanguageOptionsDialog(); | 388 browser()->OpenLanguageOptionsDialog(); |
| 381 } else { | 389 } else { |
| 382 browser()->OpenSystemOptionsDialog(); | 390 browser()->OpenSystemOptionsDialog(); |
| 383 } | 391 } |
| 384 } | 392 } |
| 385 | 393 |
| 386 StatusAreaHost::ScreenMode BrowserView::GetScreenMode() const { | 394 StatusAreaHost::ScreenMode BrowserView::GetScreenMode() const { |
| 387 return kBrowserMode; | 395 return kBrowserMode; |
| 388 } | 396 } |
| 389 | 397 |
| 398 StatusAreaHost::TextStyle BrowserView::GetTextStyle() const { | |
| 399 ui::ThemeProvider* tp = GetThemeProvider(); | |
| 400 return tp->HasCustomImage(IDR_THEME_FRAME) ? | |
| 401 StatusAreaHost::kWhiteHaloed : IsOffTheRecord() ? | |
|
sky
2011/05/02 14:26:27
Oi. Can you use () around the first conditional to
| |
| 402 StatusAreaHost::kWhitePlain : StatusAreaHost::kGrayEmbossed; | |
| 403 } | |
| 404 | |
| 390 //////////////////////////////////////////////////////////////////////////////// | 405 //////////////////////////////////////////////////////////////////////////////// |
| 391 // BrowserView protected: | 406 // BrowserView protected: |
| 392 | 407 |
| 393 void BrowserView::GetAccessiblePanes( | 408 void BrowserView::GetAccessiblePanes( |
| 394 std::vector<AccessiblePaneView*>* panes) { | 409 std::vector<AccessiblePaneView*>* panes) { |
| 395 ::BrowserView::GetAccessiblePanes(panes); | 410 ::BrowserView::GetAccessiblePanes(panes); |
| 396 panes->push_back(status_area_); | 411 panes->push_back(status_area_); |
| 397 } | 412 } |
| 398 | 413 |
| 399 //////////////////////////////////////////////////////////////////////////////// | 414 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 416 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 431 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 417 // Create a browser view for chromeos. | 432 // Create a browser view for chromeos. |
| 418 BrowserView* view; | 433 BrowserView* view; |
| 419 if (browser->type() & Browser::TYPE_POPUP) | 434 if (browser->type() & Browser::TYPE_POPUP) |
| 420 view = new chromeos::PanelBrowserView(browser); | 435 view = new chromeos::PanelBrowserView(browser); |
| 421 else | 436 else |
| 422 view = new chromeos::BrowserView(browser); | 437 view = new chromeos::BrowserView(browser); |
| 423 BrowserFrame::Create(view, browser->profile()); | 438 BrowserFrame::Create(view, browser->profile()); |
| 424 return view; | 439 return view; |
| 425 } | 440 } |
| OLD | NEW |