| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/gtk/location_bar_view_gtk.h" | 5 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1675 DCHECK_EQ(type, chrome::NOTIFICATION_WINDOW_CLOSED); | 1675 DCHECK_EQ(type, chrome::NOTIFICATION_WINDOW_CLOSED); |
| 1676 DisconnectPageActionAccelerator(); | 1676 DisconnectPageActionAccelerator(); |
| 1677 } | 1677 } |
| 1678 | 1678 |
| 1679 void LocationBarViewGtk::EnabledStateChangedForCommand(int id, bool enabled) { | 1679 void LocationBarViewGtk::EnabledStateChangedForCommand(int id, bool enabled) { |
| 1680 DCHECK_EQ(id, IDC_CHROME_TO_MOBILE_PAGE); | 1680 DCHECK_EQ(id, IDC_CHROME_TO_MOBILE_PAGE); |
| 1681 if (enabled != gtk_widget_get_visible(chrome_to_mobile_view_.get())) | 1681 if (enabled != gtk_widget_get_visible(chrome_to_mobile_view_.get())) |
| 1682 UpdateChromeToMobileIcon(); | 1682 UpdateChromeToMobileIcon(); |
| 1683 } | 1683 } |
| 1684 | 1684 |
| 1685 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( | 1685 bool LocationBarViewGtk::PageActionViewGtk::ShowPopup() { |
| 1686 ExtensionAction* action) { | |
| 1687 ShowPopup(true); | |
| 1688 } | |
| 1689 | |
| 1690 bool LocationBarViewGtk::PageActionViewGtk::ShowPopup(bool devtools) { | |
| 1691 if (!page_action_->HasPopup(current_tab_id_)) | 1686 if (!page_action_->HasPopup(current_tab_id_)) |
| 1692 return false; | 1687 return false; |
| 1693 | 1688 |
| 1694 ExtensionPopupGtk::Show( | 1689 ExtensionPopupGtk::Show( |
| 1695 page_action_->GetPopupUrl(current_tab_id_), | 1690 page_action_->GetPopupUrl(current_tab_id_), |
| 1696 owner_->browser_, | 1691 owner_->browser_, |
| 1697 event_box_.get(), | 1692 event_box_.get()); |
| 1698 devtools); | |
| 1699 return true; | 1693 return true; |
| 1700 } | 1694 } |
| 1701 | 1695 |
| 1702 void LocationBarViewGtk::PageActionViewGtk::ConnectPageActionAccelerator() { | 1696 void LocationBarViewGtk::PageActionViewGtk::ConnectPageActionAccelerator() { |
| 1703 const ExtensionSet* extensions = owner_->browser()->profile()-> | 1697 const ExtensionSet* extensions = owner_->browser()->profile()-> |
| 1704 GetExtensionService()->extensions(); | 1698 GetExtensionService()->extensions(); |
| 1705 const Extension* extension = | 1699 const Extension* extension = |
| 1706 extensions->GetByID(page_action_->extension_id()); | 1700 extensions->GetByID(page_action_->extension_id()); |
| 1707 window_ = owner_->browser()->window()->GetNativeHandle(); | 1701 window_ = owner_->browser()->window()->GetNativeHandle(); |
| 1708 | 1702 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1745 accel_group_ = NULL; | 1739 accel_group_ = NULL; |
| 1746 keybinding_.reset(NULL); | 1740 keybinding_.reset(NULL); |
| 1747 } | 1741 } |
| 1748 } | 1742 } |
| 1749 | 1743 |
| 1750 gboolean LocationBarViewGtk::PageActionViewGtk::OnButtonPressed( | 1744 gboolean LocationBarViewGtk::PageActionViewGtk::OnButtonPressed( |
| 1751 GtkWidget* sender, | 1745 GtkWidget* sender, |
| 1752 GdkEventButton* event) { | 1746 GdkEventButton* event) { |
| 1753 Profile* profile = owner_->browser()->profile(); | 1747 Profile* profile = owner_->browser()->profile(); |
| 1754 if (event->button != 3) { | 1748 if (event->button != 3) { |
| 1755 if (!ShowPopup(false)) { | 1749 if (!ShowPopup()) { |
| 1756 ExtensionService* service = profile->GetExtensionService(); | 1750 ExtensionService* service = profile->GetExtensionService(); |
| 1757 service->browser_event_router()->PageActionExecuted(profile, | 1751 service->browser_event_router()->PageActionExecuted(profile, |
| 1758 page_action_->extension_id(), page_action_->id(), current_tab_id_, | 1752 page_action_->extension_id(), page_action_->id(), current_tab_id_, |
| 1759 current_url_.spec(), event->button); | 1753 current_url_.spec(), event->button); |
| 1760 } | 1754 } |
| 1761 } else { | 1755 } else { |
| 1762 const Extension* extension = profile->GetExtensionService()-> | 1756 const Extension* extension = profile->GetExtensionService()-> |
| 1763 GetExtensionById(page_action()->extension_id(), false); | 1757 GetExtensionById(page_action()->extension_id(), false); |
| 1764 | 1758 |
| 1765 if (extension->ShowConfigureContextMenus()) { | 1759 if (extension->ShowConfigureContextMenus()) { |
| 1766 context_menu_model_ = | 1760 context_menu_model_ = |
| 1767 new ExtensionContextMenuModel(extension, owner_->browser_, this); | 1761 new ExtensionContextMenuModel(extension, owner_->browser_); |
| 1768 context_menu_.reset( | 1762 context_menu_.reset( |
| 1769 new MenuGtk(NULL, context_menu_model_.get())); | 1763 new MenuGtk(NULL, context_menu_model_.get())); |
| 1770 context_menu_->PopupForWidget(sender, event->button, event->time); | 1764 context_menu_->PopupForWidget(sender, event->button, event->time); |
| 1771 } | 1765 } |
| 1772 } | 1766 } |
| 1773 | 1767 |
| 1774 return TRUE; | 1768 return TRUE; |
| 1775 } | 1769 } |
| 1776 | 1770 |
| 1777 gboolean LocationBarViewGtk::PageActionViewGtk::OnExposeEvent( | 1771 gboolean LocationBarViewGtk::PageActionViewGtk::OnExposeEvent( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1809 GdkModifierType modifier, | 1803 GdkModifierType modifier, |
| 1810 void* user_data) { | 1804 void* user_data) { |
| 1811 PageActionViewGtk* view = static_cast<PageActionViewGtk*>(user_data); | 1805 PageActionViewGtk* view = static_cast<PageActionViewGtk*>(user_data); |
| 1812 if (!gtk_widget_get_visible(view->widget())) | 1806 if (!gtk_widget_get_visible(view->widget())) |
| 1813 return FALSE; | 1807 return FALSE; |
| 1814 | 1808 |
| 1815 GdkEventButton event = {}; | 1809 GdkEventButton event = {}; |
| 1816 event.button = 1; | 1810 event.button = 1; |
| 1817 return view->OnButtonPressed(view->widget(), &event); | 1811 return view->OnButtonPressed(view->widget(), &event); |
| 1818 } | 1812 } |
| OLD | NEW |