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/ui/panels/panel_browser_frame_view.h" | 5 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" |
6 | 6 |
7 #include "chrome/browser/themes/theme_service.h" | 7 #include "chrome/browser/themes/theme_service.h" |
| 8 #include "chrome/browser/ui/panels/about_panel_bubble.h" |
8 #include "chrome/browser/ui/panels/panel.h" | 9 #include "chrome/browser/ui/panels/panel.h" |
9 #include "chrome/browser/ui/panels/panel_browser_view.h" | 10 #include "chrome/browser/ui/panels/panel_browser_view.h" |
10 #include "chrome/browser/ui/panels/panel_manager.h" | 11 #include "chrome/browser/ui/panels/panel_manager.h" |
11 #include "content/browser/tab_contents/tab_contents.h" | 12 #include "content/browser/tab_contents/tab_contents.h" |
12 #include "grit/app_resources.h" | 13 #include "grit/app_resources.h" |
13 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
14 #include "grit/theme_resources.h" | 15 #include "grit/theme_resources.h" |
15 #include "grit/theme_resources_standard.h" | 16 #include "grit/theme_resources_standard.h" |
16 #include "third_party/skia/include/effects/SkGradientShader.h" | 17 #include "third_party/skia/include/effects/SkGradientShader.h" |
17 #include "ui/base/accessibility/accessible_view_state.h" | 18 #include "ui/base/accessibility/accessible_view_state.h" |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 CreateOrUpdateOptionsMenu(); | 348 CreateOrUpdateOptionsMenu(); |
348 options_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); | 349 options_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); |
349 } | 350 } |
350 | 351 |
351 bool PanelBrowserFrameView::IsCommandIdChecked(int command_id) const { | 352 bool PanelBrowserFrameView::IsCommandIdChecked(int command_id) const { |
352 // Nothing in the menu is checked. | 353 // Nothing in the menu is checked. |
353 return false; | 354 return false; |
354 } | 355 } |
355 | 356 |
356 bool PanelBrowserFrameView::IsCommandIdEnabled(int command_id) const { | 357 bool PanelBrowserFrameView::IsCommandIdEnabled(int command_id) const { |
357 // All the menu options are always enabled. | 358 // If the panel originator is not provided, disable "About this panel". |
| 359 // Currently this is not possible. |
| 360 if (command_id == COMMAND_ABOUT && !browser_view_->panel()->originator()) { |
| 361 NOTREACHED(); |
| 362 return false; |
| 363 } |
358 return true; | 364 return true; |
359 } | 365 } |
360 | 366 |
361 bool PanelBrowserFrameView::GetAcceleratorForCommandId( | 367 bool PanelBrowserFrameView::GetAcceleratorForCommandId( |
362 int command_id, ui::Accelerator* accelerator) { | 368 int command_id, ui::Accelerator* accelerator) { |
363 return false; | 369 return false; |
364 } | 370 } |
365 | 371 |
366 void PanelBrowserFrameView::ExecuteCommand(int command_id) { | 372 void PanelBrowserFrameView::ExecuteCommand(int command_id) { |
367 switch (command_id) { | 373 switch (command_id) { |
368 case COMMAND_MINIMIZE_ALL: | 374 case COMMAND_MINIMIZE_ALL: |
369 browser_view_->panel()->manager()->MinimizeAll(); | 375 browser_view_->panel()->manager()->MinimizeAll(); |
370 break; | 376 break; |
371 case COMMAND_RESTORE_ALL: | 377 case COMMAND_RESTORE_ALL: |
372 browser_view_->panel()->manager()->RestoreAll(); | 378 browser_view_->panel()->manager()->RestoreAll(); |
373 break; | 379 break; |
374 case COMMAND_CLOSE_ALL: | 380 case COMMAND_CLOSE_ALL: |
375 browser_view_->panel()->manager()->RemoveAllActive(); | 381 browser_view_->panel()->manager()->RemoveAllActive(); |
376 break; | 382 break; |
377 case COMMAND_ABOUT: | 383 case COMMAND_ABOUT: { |
378 NOTIMPLEMENTED(); | 384 gfx::Point origin(options_button_->bounds().origin()); |
| 385 views::View::ConvertPointToScreen(this, &origin); |
| 386 AboutPanelBubble::Show( |
| 387 GetWidget(), |
| 388 gfx::Rect(origin, options_button_->bounds().size()), |
| 389 BubbleBorder::BOTTOM_RIGHT, |
| 390 GetFaviconForTabIconView(), |
| 391 browser_view_->panel()->originator()); |
379 break; | 392 break; |
| 393 } |
380 default: | 394 default: |
381 NOTREACHED(); | 395 NOTREACHED(); |
382 break; | 396 break; |
383 } | 397 } |
384 } | 398 } |
385 | 399 |
386 bool PanelBrowserFrameView::ShouldTabIconViewAnimate() const { | 400 bool PanelBrowserFrameView::ShouldTabIconViewAnimate() const { |
387 // This function is queried during the creation of the window as the | 401 // This function is queried during the creation of the window as the |
388 // TabIconView we host is initialized, so we need to NULL check the selected | 402 // TabIconView we host is initialized, so we need to NULL check the selected |
389 // TabContents because in this condition there is not yet a selected tab. | 403 // TabContents because in this condition there is not yet a selected tab. |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 COMMAND_CLOSE_ALL, | 587 COMMAND_CLOSE_ALL, |
574 l10n_util::GetStringUTF16(IDS_PANEL_OPTIONS_MENU_CLOSE_ALL)); | 588 l10n_util::GetStringUTF16(IDS_PANEL_OPTIONS_MENU_CLOSE_ALL)); |
575 options_menu_contents_->AddSeparator(); | 589 options_menu_contents_->AddSeparator(); |
576 } | 590 } |
577 | 591 |
578 options_menu_contents_->AddItem( | 592 options_menu_contents_->AddItem( |
579 COMMAND_ABOUT, l10n_util::GetStringUTF16(IDS_PANEL_OPTIONS_MENU_ABOUT)); | 593 COMMAND_ABOUT, l10n_util::GetStringUTF16(IDS_PANEL_OPTIONS_MENU_ABOUT)); |
580 | 594 |
581 return rebuild_menu; | 595 return rebuild_menu; |
582 } | 596 } |
OLD | NEW |