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 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 gboolean LocationBarViewGtk::OnChromeToMobileButtonPress( | 1412 gboolean LocationBarViewGtk::OnChromeToMobileButtonPress( |
1413 GtkWidget* widget, | 1413 GtkWidget* widget, |
1414 GdkEventButton* event) { | 1414 GdkEventButton* event) { |
1415 if (event->button == 1) { | 1415 if (event->button == 1) { |
1416 chrome::ExecuteCommand(browser_, IDC_CHROME_TO_MOBILE_PAGE); | 1416 chrome::ExecuteCommand(browser_, IDC_CHROME_TO_MOBILE_PAGE); |
1417 return TRUE; | 1417 return TRUE; |
1418 } | 1418 } |
1419 return FALSE; | 1419 return FALSE; |
1420 } | 1420 } |
1421 | 1421 |
1422 void LocationBarViewGtk::ShowZoomBubble(int zoom_percent) { | 1422 void LocationBarViewGtk::ShowZoomBubble() { |
1423 if (!zoom_.get() || toolbar_model_->input_in_progress()) | 1423 if (!zoom_.get() || toolbar_model_->input_in_progress()) |
1424 return; | 1424 return; |
1425 | 1425 |
1426 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), true); | 1426 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), true); |
1427 } | 1427 } |
1428 | 1428 |
1429 void LocationBarViewGtk::ShowStarBubble(const GURL& url, | 1429 void LocationBarViewGtk::ShowStarBubble(const GURL& url, |
1430 bool newly_bookmarked) { | 1430 bool newly_bookmarked) { |
1431 if (!star_.get()) | 1431 if (!star_.get()) |
1432 return; | 1432 return; |
1433 | 1433 |
1434 BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), url, | 1434 BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), url, |
1435 newly_bookmarked); | 1435 newly_bookmarked); |
1436 } | 1436 } |
1437 | 1437 |
1438 void LocationBarViewGtk::ShowChromeToMobileBubble() { | 1438 void LocationBarViewGtk::ShowChromeToMobileBubble() { |
1439 ChromeToMobileBubbleGtk::Show(GTK_IMAGE(chrome_to_mobile_image_), browser_); | 1439 ChromeToMobileBubbleGtk::Show(GTK_IMAGE(chrome_to_mobile_image_), browser_); |
1440 } | 1440 } |
1441 | 1441 |
1442 void LocationBarViewGtk::SetZoomIconTooltipPercent(int zoom_percent) { | |
1443 UpdateZoomIcon(); | |
1444 } | |
1445 | |
1446 void LocationBarViewGtk::SetZoomIconState( | |
1447 ZoomController::ZoomIconState zoom_icon_state) { | |
1448 UpdateZoomIcon(); | |
1449 } | |
1450 | |
1451 void LocationBarViewGtk::SetStarred(bool starred) { | 1442 void LocationBarViewGtk::SetStarred(bool starred) { |
1452 if (starred == starred_) | 1443 if (starred == starred_) |
1453 return; | 1444 return; |
1454 | 1445 |
1455 starred_ = starred; | 1446 starred_ = starred; |
1456 UpdateStarIcon(); | 1447 UpdateStarIcon(); |
1457 } | 1448 } |
1458 | 1449 |
| 1450 void LocationBarViewGtk::ZoomChangedForActiveTab(bool can_show_bubble) { |
| 1451 UpdateZoomIcon(); |
| 1452 |
| 1453 // TODO(dbeam): don't show bubble if the wrench menu is showing. |
| 1454 if (can_show_bubble && gtk_widget_get_visible(zoom_.get())) |
| 1455 ShowZoomBubble(); |
| 1456 } |
| 1457 |
1459 void LocationBarViewGtk::UpdateZoomIcon() { | 1458 void LocationBarViewGtk::UpdateZoomIcon() { |
1460 if (!zoom_.get() || !GetWebContents()) | 1459 TabContents* tab_contents = GetTabContents(); |
| 1460 if (!zoom_.get() || !tab_contents) |
1461 return; | 1461 return; |
1462 | 1462 |
1463 const ZoomController* zc = TabContents::FromWebContents( | 1463 ZoomController* zoom_controller = tab_contents->zoom_controller(); |
1464 GetWebContents())->zoom_controller(); | 1464 if (!zoom_controller || zoom_controller->IsAtDefaultZoom() || |
1465 | 1465 toolbar_model_->input_in_progress()) { |
1466 if (toolbar_model_->input_in_progress() || | |
1467 zc->zoom_icon_state() == ZoomController::NONE) { | |
1468 gtk_widget_hide(zoom_.get()); | 1466 gtk_widget_hide(zoom_.get()); |
1469 ZoomBubbleGtk::Close(); | 1467 ZoomBubbleGtk::Close(); |
1470 return; | 1468 return; |
1471 } | 1469 } |
1472 | 1470 |
1473 gtk_widget_show(zoom_.get()); | 1471 const int zoom_resource = zoom_controller->GetResourceForZoomLevel(); |
1474 int zoom_resource = zc->zoom_icon_state() == ZoomController::ZOOM_PLUS_ICON ? | |
1475 IDR_ZOOM_PLUS : IDR_ZOOM_MINUS; | |
1476 gtk_image_set_from_pixbuf(GTK_IMAGE(zoom_image_), | 1472 gtk_image_set_from_pixbuf(GTK_IMAGE(zoom_image_), |
1477 theme_service_->GetImageNamed(zoom_resource)->ToGdkPixbuf()); | 1473 theme_service_->GetImageNamed(zoom_resource)->ToGdkPixbuf()); |
1478 | 1474 |
1479 string16 tooltip = l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, | 1475 string16 tooltip = l10n_util::GetStringFUTF16Int( |
1480 zc->zoom_percent()); | 1476 IDS_TOOLTIP_ZOOM, zoom_controller->zoom_percent()); |
1481 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str()); | 1477 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str()); |
| 1478 |
| 1479 gtk_widget_show(zoom_.get()); |
1482 } | 1480 } |
1483 | 1481 |
1484 void LocationBarViewGtk::UpdateStarIcon() { | 1482 void LocationBarViewGtk::UpdateStarIcon() { |
1485 if (!star_.get()) | 1483 if (!star_.get()) |
1486 return; | 1484 return; |
1487 bool star_enabled = !toolbar_model_->input_in_progress() && | 1485 bool star_enabled = !toolbar_model_->input_in_progress() && |
1488 edit_bookmarks_enabled_.GetValue(); | 1486 edit_bookmarks_enabled_.GetValue(); |
1489 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); | 1487 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); |
1490 if (star_enabled) { | 1488 if (star_enabled) { |
1491 gtk_widget_show_all(star_.get()); | 1489 gtk_widget_show_all(star_.get()); |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2052 } | 2050 } |
2053 | 2051 |
2054 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( | 2052 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( |
2055 ExtensionAction* action) { | 2053 ExtensionAction* action) { |
2056 ExtensionPopupGtk::Show( | 2054 ExtensionPopupGtk::Show( |
2057 action->GetPopupUrl(current_tab_id_), | 2055 action->GetPopupUrl(current_tab_id_), |
2058 owner_->browser_, | 2056 owner_->browser_, |
2059 event_box_.get(), | 2057 event_box_.get(), |
2060 ExtensionPopupGtk::SHOW_AND_INSPECT); | 2058 ExtensionPopupGtk::SHOW_AND_INSPECT); |
2061 } | 2059 } |
OLD | NEW |