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/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/themes/theme_service.h" | 9 #include "chrome/browser/themes/theme_service.h" |
10 #include "chrome/browser/ui/panels/panel.h" | 10 #include "chrome/browser/ui/panels/panel.h" |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 BrowserNonClientFrameView::OnMouseCaptureLost(); | 431 BrowserNonClientFrameView::OnMouseCaptureLost(); |
432 } | 432 } |
433 | 433 |
434 void PanelBrowserFrameView::ButtonPressed(views::Button* sender, | 434 void PanelBrowserFrameView::ButtonPressed(views::Button* sender, |
435 const views::Event& event) { | 435 const views::Event& event) { |
436 if (sender == close_button_) | 436 if (sender == close_button_) |
437 frame_->Close(); | 437 frame_->Close(); |
438 } | 438 } |
439 | 439 |
440 void PanelBrowserFrameView::RunMenu(View* source, const gfx::Point& pt) { | 440 void PanelBrowserFrameView::RunMenu(View* source, const gfx::Point& pt) { |
441 EnsureSettingsMenuCreated(); | 441 if (!EnsureSettingsMenuCreated()) |
| 442 return; |
442 | 443 |
443 DCHECK_EQ(settings_button_, source); | 444 DCHECK_EQ(settings_button_, source); |
444 gfx::Point screen_point; | 445 gfx::Point screen_point; |
445 views::View::ConvertPointToScreen(source, &screen_point); | 446 views::View::ConvertPointToScreen(source, &screen_point); |
446 if (settings_menu_runner_.RunMenuAt(source->GetWidget(), | 447 if (settings_menu_runner_.RunMenuAt(source->GetWidget(), |
447 settings_button_, gfx::Rect(screen_point, source->size()), | 448 settings_button_, gfx::Rect(screen_point, source->size()), |
448 views::MenuItemView::TOPRIGHT, views::MenuRunner::HAS_MNEMONICS) == | 449 views::MenuItemView::TOPRIGHT, views::MenuRunner::HAS_MNEMONICS) == |
449 views::MenuRunner::MENU_DELETED) | 450 views::MenuRunner::MENU_DELETED) |
450 return; | 451 return; |
451 } | 452 } |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 void PanelBrowserFrameView::UpdateSettingsButtonVisibility( | 731 void PanelBrowserFrameView::UpdateSettingsButtonVisibility( |
731 bool focused, bool cursor_in_view) { | 732 bool focused, bool cursor_in_view) { |
732 is_settings_button_visible_ = focused || cursor_in_view; | 733 is_settings_button_visible_ = focused || cursor_in_view; |
733 settings_button_->SetVisible(is_settings_button_visible_); | 734 settings_button_->SetVisible(is_settings_button_visible_); |
734 } | 735 } |
735 | 736 |
736 const Extension* PanelBrowserFrameView::GetExtension() const { | 737 const Extension* PanelBrowserFrameView::GetExtension() const { |
737 return Panel::GetExtension(browser_view_->browser()); | 738 return Panel::GetExtension(browser_view_->browser()); |
738 } | 739 } |
739 | 740 |
740 void PanelBrowserFrameView::EnsureSettingsMenuCreated() { | 741 bool PanelBrowserFrameView::EnsureSettingsMenuCreated() { |
741 if (settings_menu_contents_.GetItemCount()) | 742 if (settings_menu_contents_.GetItemCount()) |
742 return; | 743 return true; |
743 | 744 |
744 const Extension* extension = GetExtension(); | 745 const Extension* extension = GetExtension(); |
745 if (!extension) | 746 if (!extension) |
746 return; | 747 return false; |
747 | 748 |
748 settings_menu_contents_.AddItem( | 749 settings_menu_contents_.AddItem( |
749 COMMAND_NAME, UTF8ToUTF16(extension->name())); | 750 COMMAND_NAME, UTF8ToUTF16(extension->name())); |
750 settings_menu_contents_.AddSeparator(); | 751 settings_menu_contents_.AddSeparator(); |
751 settings_menu_contents_.AddItem( | 752 settings_menu_contents_.AddItem( |
752 COMMAND_CONFIGURE, l10n_util::GetStringUTF16(IDS_EXTENSIONS_OPTIONS)); | 753 COMMAND_CONFIGURE, l10n_util::GetStringUTF16(IDS_EXTENSIONS_OPTIONS)); |
753 settings_menu_contents_.AddItem( | 754 settings_menu_contents_.AddItem( |
754 COMMAND_DISABLE, l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE)); | 755 COMMAND_DISABLE, l10n_util::GetStringUTF16(IDS_EXTENSIONS_DISABLE)); |
755 settings_menu_contents_.AddItem( | 756 settings_menu_contents_.AddItem( |
756 COMMAND_UNINSTALL, l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL)); | 757 COMMAND_UNINSTALL, l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL)); |
757 settings_menu_contents_.AddSeparator(); | 758 settings_menu_contents_.AddSeparator(); |
758 settings_menu_contents_.AddItem( | 759 settings_menu_contents_.AddItem( |
759 COMMAND_MANAGE, l10n_util::GetStringUTF16(IDS_MANAGE_EXTENSIONS)); | 760 COMMAND_MANAGE, l10n_util::GetStringUTF16(IDS_MANAGE_EXTENSIONS)); |
760 | 761 |
761 settings_menu_adapter_.BuildMenu(settings_menu_); | 762 settings_menu_adapter_.BuildMenu(settings_menu_); |
| 763 return true; |
762 } | 764 } |
OLD | NEW |