Chromium Code Reviews| 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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 487 page_action_views_.begin(); | 487 page_action_views_.begin(); |
| 488 iter != page_action_views_.end(); | 488 iter != page_action_views_.end(); |
| 489 ++iter) { | 489 ++iter) { |
| 490 if ((*iter)->page_action() == page_action) | 490 if ((*iter)->page_action() == page_action) |
| 491 return (*iter)->widget(); | 491 return (*iter)->widget(); |
| 492 } | 492 } |
| 493 return NULL; | 493 return NULL; |
| 494 } | 494 } |
| 495 | 495 |
| 496 void LocationBarViewGtk::Update(const WebContents* contents) { | 496 void LocationBarViewGtk::Update(const WebContents* contents) { |
| 497 UpdateZoomIcon(); | 497 UpdateZoomIcon(false); |
| 498 UpdateStarIcon(); | 498 UpdateStarIcon(); |
| 499 UpdateChromeToMobileIcon(); | 499 UpdateChromeToMobileIcon(); |
| 500 UpdateSiteTypeArea(); | 500 UpdateSiteTypeArea(); |
| 501 UpdateContentSettingsIcons(); | 501 UpdateContentSettingsIcons(); |
| 502 UpdatePageActions(); | 502 UpdatePageActions(); |
| 503 location_entry_->Update(contents); | 503 location_entry_->Update(contents); |
| 504 // The security level (background color) could have changed, etc. | 504 // The security level (background color) could have changed, etc. |
| 505 if (theme_service_->UsingNativeTheme()) { | 505 if (theme_service_->UsingNativeTheme()) { |
| 506 // In GTK mode, we need our parent to redraw, as it draws the text entry | 506 // In GTK mode, we need our parent to redraw, as it draws the text entry |
| 507 // border. | 507 // border. |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 913 gtk_alignment_set_padding(GTK_ALIGNMENT(location_entry_alignment_), | 913 gtk_alignment_set_padding(GTK_ALIGNMENT(location_entry_alignment_), |
| 914 kTopMargin + kBorderThickness, | 914 kTopMargin + kBorderThickness, |
| 915 kBottomMargin + kBorderThickness, | 915 kBottomMargin + kBorderThickness, |
| 916 top_bottom, top_bottom); | 916 top_bottom, top_bottom); |
| 917 gtk_alignment_set_padding(GTK_ALIGNMENT(tab_to_search_alignment_), | 917 gtk_alignment_set_padding(GTK_ALIGNMENT(tab_to_search_alignment_), |
| 918 1, 1, 0, 0); | 918 1, 1, 0, 0); |
| 919 gtk_alignment_set_padding(GTK_ALIGNMENT(site_type_alignment_), | 919 gtk_alignment_set_padding(GTK_ALIGNMENT(site_type_alignment_), |
| 920 1, 1, 0, 0); | 920 1, 1, 0, 0); |
| 921 } | 921 } |
| 922 | 922 |
| 923 UpdateZoomIcon(); | 923 UpdateZoomIcon(false); |
| 924 UpdateStarIcon(); | 924 UpdateStarIcon(); |
| 925 UpdateChromeToMobileIcon(); | 925 UpdateChromeToMobileIcon(); |
| 926 UpdateSiteTypeArea(); | 926 UpdateSiteTypeArea(); |
| 927 UpdateContentSettingsIcons(); | 927 UpdateContentSettingsIcons(); |
| 928 break; | 928 break; |
| 929 } | 929 } |
| 930 | 930 |
| 931 default: | 931 default: |
| 932 NOTREACHED(); | 932 NOTREACHED(); |
| 933 } | 933 } |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1251 gboolean LocationBarViewGtk::OnChromeToMobileButtonPress( | 1251 gboolean LocationBarViewGtk::OnChromeToMobileButtonPress( |
| 1252 GtkWidget* widget, | 1252 GtkWidget* widget, |
| 1253 GdkEventButton* event) { | 1253 GdkEventButton* event) { |
| 1254 if (event->button == 1) { | 1254 if (event->button == 1) { |
| 1255 chrome::ExecuteCommand(browser_, IDC_CHROME_TO_MOBILE_PAGE); | 1255 chrome::ExecuteCommand(browser_, IDC_CHROME_TO_MOBILE_PAGE); |
| 1256 return TRUE; | 1256 return TRUE; |
| 1257 } | 1257 } |
| 1258 return FALSE; | 1258 return FALSE; |
| 1259 } | 1259 } |
| 1260 | 1260 |
| 1261 void LocationBarViewGtk::ShowZoomBubble(int zoom_percent) { | 1261 void LocationBarViewGtk::ShowZoomBubble() { |
| 1262 if (!zoom_.get() || toolbar_model_->input_in_progress()) | 1262 if (!zoom_.get() || toolbar_model_->input_in_progress()) |
| 1263 return; | 1263 return; |
| 1264 | 1264 |
| 1265 ZoomBubbleGtk::Show(zoom_.get(), browser_->profile(), zoom_percent, true); | 1265 const ZoomController* zc = |
| 1266 TabContents::FromWebContents(GetWebContents())->zoom_controller(); | |
|
Evan Stade
2012/07/13 05:31:00
why not GetTabContents?
Dan Beam
2012/07/24 03:00:49
Done.
| |
| 1267 ZoomBubbleGtk::Show( | |
| 1268 zoom_.get(), browser_->profile(), zc->zoom_percent(), true); | |
| 1266 } | 1269 } |
| 1267 | 1270 |
| 1268 void LocationBarViewGtk::ShowStarBubble(const GURL& url, | 1271 void LocationBarViewGtk::ShowStarBubble(const GURL& url, |
| 1269 bool newly_bookmarked) { | 1272 bool newly_bookmarked) { |
| 1270 if (!star_.get()) | 1273 if (!star_.get()) |
| 1271 return; | 1274 return; |
| 1272 | 1275 |
| 1273 BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), url, | 1276 BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), url, |
| 1274 newly_bookmarked); | 1277 newly_bookmarked); |
| 1275 } | 1278 } |
| 1276 | 1279 |
| 1277 void LocationBarViewGtk::ShowChromeToMobileBubble() { | 1280 void LocationBarViewGtk::ShowChromeToMobileBubble() { |
| 1278 ChromeToMobileBubbleGtk::Show(GTK_IMAGE(chrome_to_mobile_image_), browser_); | 1281 ChromeToMobileBubbleGtk::Show(GTK_IMAGE(chrome_to_mobile_image_), browser_); |
| 1279 } | 1282 } |
| 1280 | 1283 |
| 1281 void LocationBarViewGtk::SetZoomIconTooltipPercent(int zoom_percent) { | 1284 void LocationBarViewGtk::ZoomChangedForActiveTab(TabContents* tab_contents, |
| 1282 UpdateZoomIcon(); | 1285 bool can_show_bubble) { |
| 1283 } | 1286 UpdateZoomIcon(can_show_bubble); |
| 1284 | |
| 1285 void LocationBarViewGtk::SetZoomIconState( | |
| 1286 ZoomController::ZoomIconState zoom_icon_state) { | |
| 1287 UpdateZoomIcon(); | |
| 1288 } | 1287 } |
| 1289 | 1288 |
| 1290 void LocationBarViewGtk::SetStarred(bool starred) { | 1289 void LocationBarViewGtk::SetStarred(bool starred) { |
| 1291 if (starred == starred_) | 1290 if (starred == starred_) |
| 1292 return; | 1291 return; |
| 1293 | 1292 |
| 1294 starred_ = starred; | 1293 starred_ = starred; |
| 1295 UpdateStarIcon(); | 1294 UpdateStarIcon(); |
| 1296 } | 1295 } |
| 1297 | 1296 |
| 1298 void LocationBarViewGtk::UpdateZoomIcon() { | 1297 void LocationBarViewGtk::UpdateZoomIcon(bool can_show_bubble) { |
| 1299 if (!zoom_.get() || !GetWebContents()) | 1298 if (!zoom_.get() || !GetWebContents()) |
| 1300 return; | 1299 return; |
| 1301 | 1300 |
| 1302 const ZoomController* zc = TabContents::FromWebContents( | 1301 const ZoomController* zc = GetTabContents()->zoom_controller(); |
| 1303 GetWebContents())->zoom_controller(); | 1302 if (toolbar_model_->input_in_progress() || zc->IsAtDefaultZoom()) { |
| 1304 | |
| 1305 if (toolbar_model_->input_in_progress() || | |
| 1306 zc->zoom_icon_state() == ZoomController::NONE) { | |
| 1307 gtk_widget_hide(zoom_.get()); | 1303 gtk_widget_hide(zoom_.get()); |
| 1308 ZoomBubbleGtk::Close(); | 1304 ZoomBubbleGtk::Close(); |
| 1309 return; | 1305 return; |
| 1310 } | 1306 } |
| 1311 | 1307 |
| 1312 gtk_widget_show(zoom_.get()); | 1308 int zoom_percent = zc->zoom_percent(); |
| 1313 int zoom_resource = zc->zoom_icon_state() == ZoomController::ZOOM_PLUS_ICON ? | 1309 int zoom_resource = zoom_percent > 100 ? IDR_ZOOM_PLUS : IDR_ZOOM_MINUS; |
| 1314 IDR_ZOOM_PLUS : IDR_ZOOM_MINUS; | |
| 1315 gtk_image_set_from_pixbuf(GTK_IMAGE(zoom_image_), | 1310 gtk_image_set_from_pixbuf(GTK_IMAGE(zoom_image_), |
| 1316 theme_service_->GetImageNamed(zoom_resource)->ToGdkPixbuf()); | 1311 theme_service_->GetImageNamed(zoom_resource)->ToGdkPixbuf()); |
| 1317 | 1312 |
| 1318 string16 tooltip = l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, | 1313 string16 tooltip = |
| 1319 zc->zoom_percent()); | 1314 l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent); |
| 1320 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str()); | 1315 gtk_widget_set_tooltip_text(zoom_.get(), UTF16ToUTF8(tooltip).c_str()); |
| 1316 | |
| 1317 gtk_widget_show(zoom_.get()); | |
| 1318 | |
| 1319 if (can_show_bubble) | |
| 1320 ZoomBubbleGtk::Show(zoom_.get(), browser_->profile(), zoom_percent, true); | |
| 1321 } | 1321 } |
| 1322 | 1322 |
| 1323 void LocationBarViewGtk::UpdateStarIcon() { | 1323 void LocationBarViewGtk::UpdateStarIcon() { |
| 1324 if (!star_.get()) | 1324 if (!star_.get()) |
| 1325 return; | 1325 return; |
| 1326 bool star_enabled = !toolbar_model_->input_in_progress() && | 1326 bool star_enabled = !toolbar_model_->input_in_progress() && |
| 1327 edit_bookmarks_enabled_.GetValue(); | 1327 edit_bookmarks_enabled_.GetValue(); |
| 1328 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); | 1328 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); |
| 1329 if (star_enabled) { | 1329 if (star_enabled) { |
| 1330 gtk_widget_show_all(star_.get()); | 1330 gtk_widget_show_all(star_.get()); |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1974 } | 1974 } |
| 1975 | 1975 |
| 1976 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( | 1976 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( |
| 1977 ExtensionAction* action) { | 1977 ExtensionAction* action) { |
| 1978 ExtensionPopupGtk::Show( | 1978 ExtensionPopupGtk::Show( |
| 1979 action->GetPopupUrl(current_tab_id_), | 1979 action->GetPopupUrl(current_tab_id_), |
| 1980 owner_->browser_, | 1980 owner_->browser_, |
| 1981 event_box_.get(), | 1981 event_box_.get(), |
| 1982 ExtensionPopupGtk::SHOW_AND_INSPECT); | 1982 ExtensionPopupGtk::SHOW_AND_INSPECT); |
| 1983 } | 1983 } |
| OLD | NEW |