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> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
14 #include "chrome/browser/chromeos/frame/layout_mode_button.h" | 14 #include "chrome/browser/chromeos/frame/layout_mode_button.h" |
15 #include "chrome/browser/chromeos/frame/panel_browser_view.h" | 15 #include "chrome/browser/chromeos/frame/panel_browser_view.h" |
16 #include "chrome/browser/chromeos/status/input_method_menu_button.h" | 16 #include "chrome/browser/chromeos/status/input_method_menu_button.h" |
17 #include "chrome/browser/chromeos/status/network_menu_button.h" | 17 #include "chrome/browser/chromeos/status/network_menu_button.h" |
18 #include "chrome/browser/chromeos/status/status_area_button.h" | 18 #include "chrome/browser/chromeos/status/status_area_button.h" |
19 #include "chrome/browser/chromeos/status/status_area_view.h" | 19 #include "chrome/browser/chromeos/status/status_area_view_chromeos.h" |
20 #include "chrome/browser/chromeos/system/runtime_environment.h" | 20 #include "chrome/browser/chromeos/system/runtime_environment.h" |
21 #include "chrome/browser/chromeos/view_ids.h" | 21 #include "chrome/browser/chromeos/view_ids.h" |
22 #include "chrome/browser/themes/theme_service.h" | 22 #include "chrome/browser/themes/theme_service.h" |
23 #include "chrome/browser/themes/theme_service_factory.h" | 23 #include "chrome/browser/themes/theme_service_factory.h" |
24 #include "chrome/browser/ui/gtk/gtk_util.h" | 24 #include "chrome/browser/ui/gtk/gtk_util.h" |
25 #include "chrome/browser/ui/views/frame/browser_view.h" | 25 #include "chrome/browser/ui/views/frame/browser_view.h" |
26 #include "chrome/browser/ui/views/frame/browser_view_layout.h" | 26 #include "chrome/browser/ui/views/frame/browser_view_layout.h" |
27 #include "chrome/browser/ui/views/tabs/tab.h" | 27 #include "chrome/browser/ui/views/tabs/tab.h" |
28 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 28 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
29 #include "chrome/browser/ui/views/theme_background.h" | 29 #include "chrome/browser/ui/views/theme_background.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 status_area_ = NULL; | 135 status_area_ = NULL; |
136 layout_mode_button_ = NULL; | 136 layout_mode_button_ = NULL; |
137 ::BrowserViewLayout::Installed(host); | 137 ::BrowserViewLayout::Installed(host); |
138 } | 138 } |
139 | 139 |
140 void ViewAdded(views::View* host, | 140 void ViewAdded(views::View* host, |
141 views::View* view) { | 141 views::View* view) { |
142 ::BrowserViewLayout::ViewAdded(host, view); | 142 ::BrowserViewLayout::ViewAdded(host, view); |
143 switch (view->id()) { | 143 switch (view->id()) { |
144 case VIEW_ID_STATUS_AREA: | 144 case VIEW_ID_STATUS_AREA: |
145 status_area_ = static_cast<chromeos::StatusAreaView*>(view); | 145 status_area_ = static_cast<chromeos::StatusAreaViewChromeos*>(view); |
146 break; | 146 break; |
147 case VIEW_ID_LAYOUT_MODE_BUTTON: | 147 case VIEW_ID_LAYOUT_MODE_BUTTON: |
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 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 if (status_area_bounds_for_property_ != current_bounds) { | 273 if (status_area_bounds_for_property_ != current_bounds) { |
274 status_area_bounds_for_property_ = current_bounds; | 274 status_area_bounds_for_property_ = current_bounds; |
275 #if defined(TOOLKIT_USES_GTK) | 275 #if defined(TOOLKIT_USES_GTK) |
276 WmIpc::instance()->SetStatusBoundsProperty( | 276 WmIpc::instance()->SetStatusBoundsProperty( |
277 GTK_WIDGET(chromeos_browser_view()->frame()->GetNativeWindow()), | 277 GTK_WIDGET(chromeos_browser_view()->frame()->GetNativeWindow()), |
278 status_area_bounds_for_property_); | 278 status_area_bounds_for_property_); |
279 #endif | 279 #endif |
280 } | 280 } |
281 } | 281 } |
282 | 282 |
283 chromeos::StatusAreaView* status_area_; | 283 chromeos::StatusAreaViewChromeos* status_area_; |
284 chromeos::LayoutModeButton* layout_mode_button_; | 284 chromeos::LayoutModeButton* layout_mode_button_; |
285 | 285 |
286 // Most-recently-set bounds for the _CHROME_STATUS_BOUNDS property. | 286 // Most-recently-set bounds for the _CHROME_STATUS_BOUNDS property. |
287 // Empty if |status_area_| isn't visible. Tracked here so we don't update the | 287 // Empty if |status_area_| isn't visible. Tracked here so we don't update the |
288 // property needlessly on no-op relayouts. | 288 // property needlessly on no-op relayouts. |
289 gfx::Rect status_area_bounds_for_property_; | 289 gfx::Rect status_area_bounds_for_property_; |
290 | 290 |
291 DISALLOW_COPY_AND_ASSIGN(BrowserViewLayout); | 291 DISALLOW_COPY_AND_ASSIGN(BrowserViewLayout); |
292 }; | 292 }; |
293 | 293 |
(...skipping 23 matching lines...) Expand all Loading... |
317 if (toolbar()) | 317 if (toolbar()) |
318 toolbar()->RemoveMenuListener(this); | 318 toolbar()->RemoveMenuListener(this); |
319 MessageLoopForUI::current()->RemoveObserver(this); | 319 MessageLoopForUI::current()->RemoveObserver(this); |
320 BrowserList::RemoveObserver(this); | 320 BrowserList::RemoveObserver(this); |
321 } | 321 } |
322 | 322 |
323 // BrowserView, ::BrowserView overrides: | 323 // BrowserView, ::BrowserView overrides: |
324 | 324 |
325 void BrowserView::Init() { | 325 void BrowserView::Init() { |
326 ::BrowserView::Init(); | 326 ::BrowserView::Init(); |
327 status_area_ = new StatusAreaView(this); | 327 status_area_ = new StatusAreaViewChromeos(); |
| 328 status_area_->Init(this, StatusAreaViewChromeos::BROWSER_MODE); |
328 status_area_->set_id(VIEW_ID_STATUS_AREA); | 329 status_area_->set_id(VIEW_ID_STATUS_AREA); |
329 AddChildView(status_area_); | 330 AddChildView(status_area_); |
330 status_area_->Init(); | |
331 | 331 |
332 layout_mode_button_ = new LayoutModeButton(); | 332 layout_mode_button_ = new LayoutModeButton(); |
333 layout_mode_button_->set_id(VIEW_ID_LAYOUT_MODE_BUTTON); | 333 layout_mode_button_->set_id(VIEW_ID_LAYOUT_MODE_BUTTON); |
334 AddChildView(layout_mode_button_); | 334 AddChildView(layout_mode_button_); |
335 layout_mode_button_->Init(); | 335 layout_mode_button_->Init(); |
336 | 336 |
337 frame()->non_client_view()->set_context_menu_controller(this); | 337 frame()->non_client_view()->set_context_menu_controller(this); |
338 | 338 |
339 // Listen to wrench menu opens. | 339 // Listen to wrench menu opens. |
340 if (toolbar()) | 340 if (toolbar()) |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 Layout(); | 489 Layout(); |
490 } | 490 } |
491 | 491 |
492 void BrowserView::OnBrowserRemoved(const Browser* browser) { | 492 void BrowserView::OnBrowserRemoved(const Browser* browser) { |
493 const bool was_showing = should_show_layout_mode_button_; | 493 const bool was_showing = should_show_layout_mode_button_; |
494 UpdateLayoutModeButtonVisibility(); | 494 UpdateLayoutModeButtonVisibility(); |
495 if (should_show_layout_mode_button_ != was_showing) | 495 if (should_show_layout_mode_button_ != was_showing) |
496 Layout(); | 496 Layout(); |
497 } | 497 } |
498 | 498 |
499 // BrowserView, StatusAreaHost implementation. | 499 // StatusAreaButton::Delegate overrides. |
500 | 500 |
501 Profile* BrowserView::GetProfile() const { | 501 bool BrowserView::ShouldExecuteStatusAreaCommand( |
502 return browser()->profile(); | 502 const views::View* button_view, int command_id) const { |
503 } | |
504 | |
505 gfx::NativeWindow BrowserView::GetNativeWindow() const { | |
506 return GetWidget()->GetNativeWindow(); | |
507 } | |
508 | |
509 bool BrowserView::ShouldOpenButtonOptions( | |
510 const views::View* button_view) const { | |
511 return true; | 503 return true; |
512 } | 504 } |
513 | 505 |
514 void BrowserView::ExecuteBrowserCommand(int id) const { | 506 void BrowserView::ExecuteStatusAreaCommand( |
515 browser()->ExecuteCommand(id); | 507 const views::View* button_view, int command_id) { |
516 } | 508 switch (command_id) { |
517 | 509 case StatusAreaViewChromeos::SHOW_NETWORK_OPTIONS: |
518 void BrowserView::OpenButtonOptions(const views::View* button_view) { | 510 browser()->OpenInternetOptionsDialog(); |
519 if (button_view == status_area_->network_view()) { | 511 break; |
520 browser()->OpenInternetOptionsDialog(); | 512 case StatusAreaViewChromeos::SHOW_LANGUAGE_OPTIONS: |
521 } else if (button_view == status_area_->input_method_view()) { | 513 browser()->OpenLanguageOptionsDialog(); |
522 browser()->OpenLanguageOptionsDialog(); | 514 break; |
523 } else { | 515 case StatusAreaViewChromeos::SHOW_SYSTEM_OPTIONS: |
524 browser()->OpenSystemOptionsDialog(); | 516 browser()->OpenLanguageOptionsDialog(); |
| 517 break; |
| 518 default: |
| 519 NOTREACHED(); |
525 } | 520 } |
526 } | 521 } |
527 | 522 |
528 StatusAreaHost::ScreenMode BrowserView::GetScreenMode() const { | 523 gfx::Font BrowserView::GetStatusAreaFont(const gfx::Font& font) const { |
529 return kBrowserMode; | 524 return font.DeriveFont(0, gfx::Font::BOLD); |
530 } | 525 } |
531 | 526 |
532 StatusAreaHost::TextStyle BrowserView::GetTextStyle() const { | 527 StatusAreaButton::TextStyle BrowserView::GetStatusAreaTextStyle() const { |
533 ThemeService* theme_service = | 528 ThemeService* theme_service = |
534 ThemeServiceFactory::GetForProfile(GetProfile()); | 529 ThemeServiceFactory::GetForProfile(browser()->profile()); |
535 | 530 |
536 if (!theme_service->UsingDefaultTheme()) | 531 if (!theme_service->UsingDefaultTheme()) |
537 return StatusAreaHost::kWhiteHaloed; | 532 return StatusAreaButton::WHITE_HALOED; |
538 | 533 |
539 return IsOffTheRecord() ? | 534 return IsOffTheRecord() ? |
540 StatusAreaHost::kWhitePlain : StatusAreaHost::kGrayEmbossed; | 535 StatusAreaButton::WHITE_PLAIN : StatusAreaButton::GRAY_EMBOSSED; |
541 } | 536 } |
542 | 537 |
543 void BrowserView::ButtonVisibilityChanged(views::View* button_view) { | 538 void BrowserView::ButtonVisibilityChanged(views::View* button_view) { |
544 status_area_->ButtonVisibilityChanged(button_view); | 539 status_area_->UpdateButtonVisibility(); |
545 } | 540 } |
546 | 541 |
547 // BrowserView, MessageLoopForUI::Observer implementation. | 542 // BrowserView, MessageLoopForUI::Observer implementation. |
| 543 |
548 #if defined(TOUCH_UI) || defined(USE_AURA) | 544 #if defined(TOUCH_UI) || defined(USE_AURA) |
549 base::EventStatus BrowserView::WillProcessEvent( | 545 base::EventStatus BrowserView::WillProcessEvent( |
550 const base::NativeEvent& event) OVERRIDE { | 546 const base::NativeEvent& event) OVERRIDE { |
551 return base::EVENT_CONTINUE; | 547 return base::EVENT_CONTINUE; |
552 } | 548 } |
553 | 549 |
554 void BrowserView::DidProcessEvent(const base::NativeEvent& event) OVERRIDE { | 550 void BrowserView::DidProcessEvent(const base::NativeEvent& event) OVERRIDE { |
555 // TODO(oshima): On Aura, WM should notify chrome someshow. | 551 // TODO(oshima): On Aura, WM should notify chrome someshow. |
556 } | 552 } |
557 #else | 553 #else |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 629 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
634 // Create a browser view for chromeos. | 630 // Create a browser view for chromeos. |
635 BrowserView* view; | 631 BrowserView* view; |
636 if (browser->is_type_popup() || browser->is_type_panel()) | 632 if (browser->is_type_popup() || browser->is_type_panel()) |
637 view = new chromeos::PanelBrowserView(browser); | 633 view = new chromeos::PanelBrowserView(browser); |
638 else | 634 else |
639 view = new chromeos::BrowserView(browser); | 635 view = new chromeos::BrowserView(browser); |
640 (new BrowserFrame(view))->InitBrowserFrame(); | 636 (new BrowserFrame(view))->InitBrowserFrame(); |
641 return view; | 637 return view; |
642 } | 638 } |
OLD | NEW |