| 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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 if (!profile->IsOffTheRecord() && profile->IsSyncAccessible() && | 565 if (!profile->IsOffTheRecord() && profile->IsSyncAccessible() && |
| 566 ChromeToMobileService::IsChromeToMobileEnabled()) { | 566 ChromeToMobileService::IsChromeToMobileEnabled()) { |
| 567 CreateChromeToMobileButton(); | 567 CreateChromeToMobileButton(); |
| 568 gtk_box_pack_end(GTK_BOX(hbox_.get()), chrome_to_mobile_view_.get(), | 568 gtk_box_pack_end(GTK_BOX(hbox_.get()), chrome_to_mobile_view_.get(), |
| 569 FALSE, FALSE, 0); | 569 FALSE, FALSE, 0); |
| 570 command_updater_->AddCommandObserver(IDC_CHROME_TO_MOBILE_PAGE, this); | 570 command_updater_->AddCommandObserver(IDC_CHROME_TO_MOBILE_PAGE, this); |
| 571 UpdateChromeToMobileIcon(); | 571 UpdateChromeToMobileIcon(); |
| 572 } | 572 } |
| 573 } | 573 } |
| 574 | 574 |
| 575 // TODO(khorimoto): Uncomment the following 2 lines when zoom icon/bubble | 575 CreateZoomButton(); |
| 576 // implementation is complete for M23. | 576 gtk_box_pack_end(GTK_BOX(hbox_.get()), zoom_.get(), FALSE, FALSE, 0); |
| 577 // CreateZoomButton(); | |
| 578 // gtk_box_pack_end(GTK_BOX(hbox_.get()), zoom_.get(), FALSE, FALSE, 0); | |
| 579 | 577 |
| 580 content_setting_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding + 1)); | 578 content_setting_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding + 1)); |
| 581 gtk_widget_set_name(content_setting_hbox_.get(), | 579 gtk_widget_set_name(content_setting_hbox_.get(), |
| 582 "chrome-content-setting-hbox"); | 580 "chrome-content-setting-hbox"); |
| 583 gtk_box_pack_end(GTK_BOX(hbox_.get()), content_setting_hbox_.get(), | 581 gtk_box_pack_end(GTK_BOX(hbox_.get()), content_setting_hbox_.get(), |
| 584 FALSE, FALSE, 1); | 582 FALSE, FALSE, 1); |
| 585 | 583 |
| 586 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 584 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 587 ContentSettingImageViewGtk* content_setting_view = | 585 ContentSettingImageViewGtk* content_setting_view = |
| 588 new ContentSettingImageViewGtk( | 586 new ContentSettingImageViewGtk( |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1495 gboolean LocationBarViewGtk::OnChromeToMobileButtonPress( | 1493 gboolean LocationBarViewGtk::OnChromeToMobileButtonPress( |
| 1496 GtkWidget* widget, | 1494 GtkWidget* widget, |
| 1497 GdkEventButton* event) { | 1495 GdkEventButton* event) { |
| 1498 if (event->button == 1) { | 1496 if (event->button == 1) { |
| 1499 chrome::ExecuteCommand(browser_, IDC_CHROME_TO_MOBILE_PAGE); | 1497 chrome::ExecuteCommand(browser_, IDC_CHROME_TO_MOBILE_PAGE); |
| 1500 return TRUE; | 1498 return TRUE; |
| 1501 } | 1499 } |
| 1502 return FALSE; | 1500 return FALSE; |
| 1503 } | 1501 } |
| 1504 | 1502 |
| 1505 void LocationBarViewGtk::ShowZoomBubble(int zoom_percent) { | 1503 void LocationBarViewGtk::ShowZoomBubble() { |
| 1506 if (!zoom_.get() || toolbar_model_->input_in_progress()) | 1504 if (!zoom_.get() || toolbar_model_->input_in_progress()) |
| 1507 return; | 1505 return; |
| 1508 | 1506 |
| 1509 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), true); | 1507 ZoomBubbleGtk::Show(zoom_.get(), GetTabContents(), true); |
| 1510 } | 1508 } |
| 1511 | 1509 |
| 1512 void LocationBarViewGtk::ShowStarBubble(const GURL& url, | 1510 void LocationBarViewGtk::ShowStarBubble(const GURL& url, |
| 1513 bool newly_bookmarked) { | 1511 bool newly_bookmarked) { |
| 1514 if (!star_.get()) | 1512 if (!star_.get()) |
| 1515 return; | 1513 return; |
| 1516 | 1514 |
| 1517 BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), url, | 1515 BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), url, |
| 1518 newly_bookmarked); | 1516 newly_bookmarked); |
| 1519 } | 1517 } |
| 1520 | 1518 |
| 1521 void LocationBarViewGtk::ShowChromeToMobileBubble() { | 1519 void LocationBarViewGtk::ShowChromeToMobileBubble() { |
| 1522 ChromeToMobileBubbleGtk::Show(GTK_IMAGE(chrome_to_mobile_image_), browser_); | 1520 ChromeToMobileBubbleGtk::Show(GTK_IMAGE(chrome_to_mobile_image_), browser_); |
| 1523 } | 1521 } |
| 1524 | 1522 |
| 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 | |
| 1534 void LocationBarViewGtk::SetStarred(bool starred) { | 1523 void LocationBarViewGtk::SetStarred(bool starred) { |
| 1535 if (starred == starred_) | 1524 if (starred == starred_) |
| 1536 return; | 1525 return; |
| 1537 | 1526 |
| 1538 starred_ = starred; | 1527 starred_ = starred; |
| 1539 UpdateStarIcon(); | 1528 UpdateStarIcon(); |
| 1540 } | 1529 } |
| 1541 | 1530 |
| 1531 void LocationBarViewGtk::ZoomChangedForActiveTab(bool can_show_bubble) { |
| 1532 UpdateZoomIcon(); |
| 1533 |
| 1534 // TODO(dbeam): don't show bubble if the wrench menu is showing. |
| 1535 if (can_show_bubble && gtk_widget_get_visible(zoom_.get())) |
| 1536 ShowZoomBubble(); |
| 1537 } |
| 1538 |
| 1542 void LocationBarViewGtk::UpdateZoomIcon() { | 1539 void LocationBarViewGtk::UpdateZoomIcon() { |
| 1543 if (!zoom_.get() || !GetWebContents()) | 1540 TabContents* tab_contents = GetTabContents(); |
| 1541 if (!zoom_.get() || !tab_contents) |
| 1544 return; | 1542 return; |
| 1545 | 1543 |
| 1546 const ZoomController* zc = TabContents::FromWebContents( | 1544 ZoomController* zoom_controller = tab_contents->zoom_controller(); |
| 1547 GetWebContents())->zoom_controller(); | 1545 if (!zoom_controller || zoom_controller->IsAtDefaultZoom() || |
| 1548 | 1546 toolbar_model_->input_in_progress()) { |
| 1549 if (toolbar_model_->input_in_progress() || | |
| 1550 zc->zoom_icon_state() == ZoomController::NONE) { | |
| 1551 gtk_widget_hide(zoom_.get()); | 1547 gtk_widget_hide(zoom_.get()); |
| 1552 ZoomBubbleGtk::Close(); | 1548 ZoomBubbleGtk::Close(); |
| 1553 return; | 1549 return; |
| 1554 } | 1550 } |
| 1555 | 1551 |
| 1556 gtk_widget_show(zoom_.get()); | 1552 const int zoom_resource = zoom_controller->GetResourceForZoomLevel(); |
| 1557 int zoom_resource = zc->zoom_icon_state() == ZoomController::ZOOM_PLUS_ICON ? | |
| 1558 IDR_ZOOM_PLUS : IDR_ZOOM_MINUS; | |
| 1559 gtk_image_set_from_pixbuf(GTK_IMAGE(zoom_image_), | 1553 gtk_image_set_from_pixbuf(GTK_IMAGE(zoom_image_), |
| 1560 theme_service_->GetImageNamed(zoom_resource)->ToGdkPixbuf()); | 1554 theme_service_->GetImageNamed(zoom_resource)->ToGdkPixbuf()); |
| 1561 | 1555 |
| 1562 string16 tooltip = l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, | 1556 string16 tooltip = l10n_util::GetStringFUTF16Int( |
| 1563 zc->zoom_percent()); | 1557 IDS_TOOLTIP_ZOOM, zoom_controller->zoom_percent()); |
| 1564 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str()); | 1558 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str()); |
| 1559 |
| 1560 gtk_widget_show(zoom_.get()); |
| 1565 } | 1561 } |
| 1566 | 1562 |
| 1567 void LocationBarViewGtk::UpdateStarIcon() { | 1563 void LocationBarViewGtk::UpdateStarIcon() { |
| 1568 if (!star_.get()) | 1564 if (!star_.get()) |
| 1569 return; | 1565 return; |
| 1570 bool star_enabled = !toolbar_model_->input_in_progress() && | 1566 bool star_enabled = !toolbar_model_->input_in_progress() && |
| 1571 edit_bookmarks_enabled_.GetValue(); | 1567 edit_bookmarks_enabled_.GetValue(); |
| 1572 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); | 1568 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); |
| 1573 if (star_enabled) { | 1569 if (star_enabled) { |
| 1574 gtk_widget_show_all(star_.get()); | 1570 gtk_widget_show_all(star_.get()); |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2135 } | 2131 } |
| 2136 | 2132 |
| 2137 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( | 2133 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( |
| 2138 ExtensionAction* action) { | 2134 ExtensionAction* action) { |
| 2139 ExtensionPopupGtk::Show( | 2135 ExtensionPopupGtk::Show( |
| 2140 action->GetPopupUrl(current_tab_id_), | 2136 action->GetPopupUrl(current_tab_id_), |
| 2141 owner_->browser_, | 2137 owner_->browser_, |
| 2142 event_box_.get(), | 2138 event_box_.get(), |
| 2143 ExtensionPopupGtk::SHOW_AND_INSPECT); | 2139 ExtensionPopupGtk::SHOW_AND_INSPECT); |
| 2144 } | 2140 } |
| OLD | NEW |