Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: chrome/browser/ui/gtk/location_bar_view_gtk.cc

Issue 10736028: Refactor browser window zoom handling and enable zoom icon on all platforms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 entry_box_width_ = allocation->width; 1386 entry_box_width_ = allocation->width;
1387 AdjustChildrenVisibility(); 1387 AdjustChildrenVisibility();
1388 } 1388 }
1389 } 1389 }
1390 1390
1391 gboolean LocationBarViewGtk::OnZoomButtonPress(GtkWidget* widget, 1391 gboolean LocationBarViewGtk::OnZoomButtonPress(GtkWidget* widget,
1392 GdkEventButton* event) { 1392 GdkEventButton* event) {
1393 if (event->button == 1 && GetWebContents()) { 1393 if (event->button == 1 && GetWebContents()) {
1394 // If the zoom icon is clicked, show the zoom bubble and keep it open until 1394 // If the zoom icon is clicked, show the zoom bubble and keep it open until
1395 // it loses focus. 1395 // it loses focus.
1396 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), false); 1396 ShowZoomBubble();
Evan Stade 2012/08/15 22:01:34 false is important
Dan Beam 2012/08/15 23:13:38 Done. (reverted this change)
1397 return TRUE; 1397 return TRUE;
1398 } 1398 }
1399 return FALSE; 1399 return FALSE;
1400 } 1400 }
1401 1401
1402 gboolean LocationBarViewGtk::OnStarButtonPress(GtkWidget* widget, 1402 gboolean LocationBarViewGtk::OnStarButtonPress(GtkWidget* widget,
1403 GdkEventButton* event) { 1403 GdkEventButton* event) {
1404 if (event->button == 1) { 1404 if (event->button == 1) {
1405 chrome::ExecuteCommand(browser_, IDC_BOOKMARK_PAGE); 1405 chrome::ExecuteCommand(browser_, IDC_BOOKMARK_PAGE);
1406 return TRUE; 1406 return TRUE;
1407 } 1407 }
1408 return FALSE; 1408 return FALSE;
1409 } 1409 }
1410 1410
1411 gboolean LocationBarViewGtk::OnChromeToMobileButtonPress( 1411 gboolean LocationBarViewGtk::OnChromeToMobileButtonPress(
1412 GtkWidget* widget, 1412 GtkWidget* widget,
1413 GdkEventButton* event) { 1413 GdkEventButton* event) {
1414 if (event->button == 1) { 1414 if (event->button == 1) {
1415 chrome::ExecuteCommand(browser_, IDC_CHROME_TO_MOBILE_PAGE); 1415 chrome::ExecuteCommand(browser_, IDC_CHROME_TO_MOBILE_PAGE);
1416 return TRUE; 1416 return TRUE;
1417 } 1417 }
1418 return FALSE; 1418 return FALSE;
1419 } 1419 }
1420 1420
1421 void LocationBarViewGtk::ShowZoomBubble(int zoom_percent) { 1421 void LocationBarViewGtk::ShowZoomBubble() {
1422 if (!zoom_.get() || toolbar_model_->input_in_progress()) 1422 if (!zoom_.get() || toolbar_model_->input_in_progress())
1423 return; 1423 return;
1424 1424
1425 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), true); 1425 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), true);
1426 } 1426 }
1427 1427
1428 void LocationBarViewGtk::ShowStarBubble(const GURL& url, 1428 void LocationBarViewGtk::ShowStarBubble(const GURL& url,
1429 bool newly_bookmarked) { 1429 bool newly_bookmarked) {
1430 if (!star_.get()) 1430 if (!star_.get())
1431 return; 1431 return;
1432 1432
1433 BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), url, 1433 BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), url,
1434 newly_bookmarked); 1434 newly_bookmarked);
1435 } 1435 }
1436 1436
1437 void LocationBarViewGtk::ShowChromeToMobileBubble() { 1437 void LocationBarViewGtk::ShowChromeToMobileBubble() {
1438 ChromeToMobileBubbleGtk::Show(GTK_IMAGE(chrome_to_mobile_image_), browser_); 1438 ChromeToMobileBubbleGtk::Show(GTK_IMAGE(chrome_to_mobile_image_), browser_);
1439 } 1439 }
1440 1440
1441 void LocationBarViewGtk::SetZoomIconTooltipPercent(int zoom_percent) {
1442 UpdateZoomIcon();
1443 }
1444
1445 void LocationBarViewGtk::SetZoomIconState(
1446 ZoomController::ZoomIconState zoom_icon_state) {
1447 UpdateZoomIcon();
1448 }
1449
1450 void LocationBarViewGtk::SetStarred(bool starred) { 1441 void LocationBarViewGtk::SetStarred(bool starred) {
1451 if (starred == starred_) 1442 if (starred == starred_)
1452 return; 1443 return;
1453 1444
1454 starred_ = starred; 1445 starred_ = starred;
1455 UpdateStarIcon(); 1446 UpdateStarIcon();
1456 } 1447 }
1457 1448
1449 // TODO(dbeam): make a generic helper that updates both the zoom icon and shows
1450 // the zoom bubble, if appropriate, for a zoom change.
1451 void LocationBarViewGtk::ZoomChangedForActiveTab(bool can_show_bubble) {
1452 UpdateZoomIcon();
1453
1454 if (can_show_bubble)
1455 ShowZoomBubble();
1456 }
1457
1458 void LocationBarViewGtk::UpdateZoomIcon() { 1458 void LocationBarViewGtk::UpdateZoomIcon() {
1459 if (!zoom_.get() || !GetWebContents()) 1459 TabContents* tab_contents = GetTabContents();
1460 if (!zoom_.get() || !tab_contents)
1460 return; 1461 return;
1461 1462
1462 const ZoomController* zc = TabContents::FromWebContents( 1463 ZoomController* zoom_controller = tab_contents->zoom_controller();
1463 GetWebContents())->zoom_controller(); 1464 if (!zoom_controller || zoom_controller->IsAtDefaultZoom() ||
1464 1465 toolbar_model_->input_in_progress()) {
1465 if (toolbar_model_->input_in_progress() ||
1466 zc->zoom_icon_state() == ZoomController::NONE) {
1467 gtk_widget_hide(zoom_.get()); 1466 gtk_widget_hide(zoom_.get());
1468 ZoomBubbleGtk::Close();
1469 return; 1467 return;
1470 } 1468 }
1471 1469
1472 gtk_widget_show(zoom_.get()); 1470 const int zoom_resource = zoom_controller->GetResourceForZoomLevel();
1473 int zoom_resource = zc->zoom_icon_state() == ZoomController::ZOOM_PLUS_ICON ?
1474 IDR_ZOOM_PLUS : IDR_ZOOM_MINUS;
1475 gtk_image_set_from_pixbuf(GTK_IMAGE(zoom_image_), 1471 gtk_image_set_from_pixbuf(GTK_IMAGE(zoom_image_),
1476 theme_service_->GetImageNamed(zoom_resource)->ToGdkPixbuf()); 1472 theme_service_->GetImageNamed(zoom_resource)->ToGdkPixbuf());
1477 1473
1478 string16 tooltip = l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, 1474 string16 tooltip = l10n_util::GetStringFUTF16Int(
1479 zc->zoom_percent()); 1475 IDS_TOOLTIP_ZOOM, zoom_controller->zoom_percent());
1480 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str()); 1476 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str());
1477
1478 gtk_widget_show(zoom_.get());
1481 } 1479 }
1482 1480
1483 void LocationBarViewGtk::UpdateStarIcon() { 1481 void LocationBarViewGtk::UpdateStarIcon() {
1484 if (!star_.get()) 1482 if (!star_.get())
1485 return; 1483 return;
1486 bool star_enabled = !toolbar_model_->input_in_progress() && 1484 bool star_enabled = !toolbar_model_->input_in_progress() &&
1487 edit_bookmarks_enabled_.GetValue(); 1485 edit_bookmarks_enabled_.GetValue();
1488 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); 1486 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled);
1489 if (star_enabled) { 1487 if (star_enabled) {
1490 gtk_widget_show_all(star_.get()); 1488 gtk_widget_show_all(star_.get());
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
2051 } 2049 }
2052 2050
2053 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( 2051 void LocationBarViewGtk::PageActionViewGtk::InspectPopup(
2054 ExtensionAction* action) { 2052 ExtensionAction* action) {
2055 ExtensionPopupGtk::Show( 2053 ExtensionPopupGtk::Show(
2056 action->GetPopupUrl(current_tab_id_), 2054 action->GetPopupUrl(current_tab_id_),
2057 owner_->browser_, 2055 owner_->browser_,
2058 event_box_.get(), 2056 event_box_.get(),
2059 ExtensionPopupGtk::SHOW_AND_INSPECT); 2057 ExtensionPopupGtk::SHOW_AND_INSPECT);
2060 } 2058 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/location_bar_view_gtk.h ('k') | chrome/browser/ui/panels/panel_browser_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698