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 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1495 gboolean LocationBarViewGtk::OnChromeToMobileButtonPress( | 1495 gboolean LocationBarViewGtk::OnChromeToMobileButtonPress( |
1496 GtkWidget* widget, | 1496 GtkWidget* widget, |
1497 GdkEventButton* event) { | 1497 GdkEventButton* event) { |
1498 if (event->button == 1) { | 1498 if (event->button == 1) { |
1499 chrome::ExecuteCommand(browser_, IDC_CHROME_TO_MOBILE_PAGE); | 1499 chrome::ExecuteCommand(browser_, IDC_CHROME_TO_MOBILE_PAGE); |
1500 return TRUE; | 1500 return TRUE; |
1501 } | 1501 } |
1502 return FALSE; | 1502 return FALSE; |
1503 } | 1503 } |
1504 | 1504 |
1505 void LocationBarViewGtk::ShowZoomBubble() { | 1505 void LocationBarViewGtk::ShowZoomBubble(int zoom_percent) { |
1506 if (!zoom_.get() || toolbar_model_->input_in_progress()) | 1506 if (!zoom_.get() || toolbar_model_->input_in_progress()) |
1507 return; | 1507 return; |
1508 | 1508 |
1509 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), true); | 1509 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), true); |
1510 } | 1510 } |
1511 | 1511 |
1512 void LocationBarViewGtk::ShowStarBubble(const GURL& url, | 1512 void LocationBarViewGtk::ShowStarBubble(const GURL& url, |
1513 bool newly_bookmarked) { | 1513 bool newly_bookmarked) { |
1514 if (!star_.get()) | 1514 if (!star_.get()) |
1515 return; | 1515 return; |
1516 | 1516 |
1517 BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), url, | 1517 BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), url, |
1518 newly_bookmarked); | 1518 newly_bookmarked); |
1519 } | 1519 } |
1520 | 1520 |
1521 void LocationBarViewGtk::ShowChromeToMobileBubble() { | 1521 void LocationBarViewGtk::ShowChromeToMobileBubble() { |
1522 ChromeToMobileBubbleGtk::Show(GTK_IMAGE(chrome_to_mobile_image_), browser_); | 1522 ChromeToMobileBubbleGtk::Show(GTK_IMAGE(chrome_to_mobile_image_), browser_); |
1523 } | 1523 } |
1524 | 1524 |
| 1525 void LocationBarViewGtk::SetZoomIconTooltipPercent(int zoom_percent) { |
| 1526 UpdateZoomIcon(); |
| 1527 } |
| 1528 |
| 1529 void LocationBarViewGtk::SetZoomIconState( |
| 1530 ZoomController::ZoomIconState zoom_icon_state) { |
| 1531 UpdateZoomIcon(); |
| 1532 } |
| 1533 |
1525 void LocationBarViewGtk::SetStarred(bool starred) { | 1534 void LocationBarViewGtk::SetStarred(bool starred) { |
1526 if (starred == starred_) | 1535 if (starred == starred_) |
1527 return; | 1536 return; |
1528 | 1537 |
1529 starred_ = starred; | 1538 starred_ = starred; |
1530 UpdateStarIcon(); | 1539 UpdateStarIcon(); |
1531 } | 1540 } |
1532 | 1541 |
1533 void LocationBarViewGtk::ZoomChangedForActiveTab(bool can_show_bubble) { | |
1534 UpdateZoomIcon(); | |
1535 | |
1536 // TODO(dbeam): don't show bubble if the wrench menu is showing. | |
1537 if (can_show_bubble && gtk_widget_get_visible(zoom_.get())) | |
1538 ShowZoomBubble(); | |
1539 } | |
1540 | |
1541 void LocationBarViewGtk::UpdateZoomIcon() { | 1542 void LocationBarViewGtk::UpdateZoomIcon() { |
1542 TabContents* tab_contents = GetTabContents(); | 1543 if (!zoom_.get() || !GetWebContents()) |
1543 if (!zoom_.get() || !tab_contents) | |
1544 return; | 1544 return; |
1545 | 1545 |
1546 ZoomController* zoom_controller = tab_contents->zoom_controller(); | 1546 const ZoomController* zc = TabContents::FromWebContents( |
1547 if (!zoom_controller || zoom_controller->IsAtDefaultZoom() || | 1547 GetWebContents())->zoom_controller(); |
1548 toolbar_model_->input_in_progress()) { | 1548 |
| 1549 if (toolbar_model_->input_in_progress() || |
| 1550 zc->zoom_icon_state() == ZoomController::NONE) { |
1549 gtk_widget_hide(zoom_.get()); | 1551 gtk_widget_hide(zoom_.get()); |
1550 ZoomBubbleGtk::Close(); | 1552 ZoomBubbleGtk::Close(); |
1551 return; | 1553 return; |
1552 } | 1554 } |
1553 | 1555 |
1554 const int zoom_resource = zoom_controller->GetResourceForZoomLevel(); | 1556 gtk_widget_show(zoom_.get()); |
| 1557 int zoom_resource = zc->zoom_icon_state() == ZoomController::ZOOM_PLUS_ICON ? |
| 1558 IDR_ZOOM_PLUS : IDR_ZOOM_MINUS; |
1555 gtk_image_set_from_pixbuf(GTK_IMAGE(zoom_image_), | 1559 gtk_image_set_from_pixbuf(GTK_IMAGE(zoom_image_), |
1556 theme_service_->GetImageNamed(zoom_resource)->ToGdkPixbuf()); | 1560 theme_service_->GetImageNamed(zoom_resource)->ToGdkPixbuf()); |
1557 | 1561 |
1558 string16 tooltip = l10n_util::GetStringFUTF16Int( | 1562 string16 tooltip = l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, |
1559 IDS_TOOLTIP_ZOOM, zoom_controller->zoom_percent()); | 1563 zc->zoom_percent()); |
1560 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str()); | 1564 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str()); |
1561 | |
1562 gtk_widget_show(zoom_.get()); | |
1563 } | 1565 } |
1564 | 1566 |
1565 void LocationBarViewGtk::UpdateStarIcon() { | 1567 void LocationBarViewGtk::UpdateStarIcon() { |
1566 if (!star_.get()) | 1568 if (!star_.get()) |
1567 return; | 1569 return; |
1568 bool star_enabled = !toolbar_model_->input_in_progress() && | 1570 bool star_enabled = !toolbar_model_->input_in_progress() && |
1569 edit_bookmarks_enabled_.GetValue(); | 1571 edit_bookmarks_enabled_.GetValue(); |
1570 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); | 1572 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); |
1571 if (star_enabled) { | 1573 if (star_enabled) { |
1572 gtk_widget_show_all(star_.get()); | 1574 gtk_widget_show_all(star_.get()); |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2133 } | 2135 } |
2134 | 2136 |
2135 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( | 2137 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( |
2136 ExtensionAction* action) { | 2138 ExtensionAction* action) { |
2137 ExtensionPopupGtk::Show( | 2139 ExtensionPopupGtk::Show( |
2138 action->GetPopupUrl(current_tab_id_), | 2140 action->GetPopupUrl(current_tab_id_), |
2139 owner_->browser_, | 2141 owner_->browser_, |
2140 event_box_.get(), | 2142 event_box_.get(), |
2141 ExtensionPopupGtk::SHOW_AND_INSPECT); | 2143 ExtensionPopupGtk::SHOW_AND_INSPECT); |
2142 } | 2144 } |
OLD | NEW |