| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/gtk/location_bar_view_gtk.h" | 5 #include "chrome/browser/gtk/location_bar_view_gtk.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // as well the tab to search box and other widgets need to have the padding on | 69 // as well the tab to search box and other widgets need to have the padding on |
| 70 // top and bottom to avoid drawing larger than the location bar space. | 70 // top and bottom to avoid drawing larger than the location bar space. |
| 71 const int kHboxBorder = 4; | 71 const int kHboxBorder = 4; |
| 72 | 72 |
| 73 // Padding between the elements in the bar. | 73 // Padding between the elements in the bar. |
| 74 static const int kInnerPadding = 4; | 74 static const int kInnerPadding = 4; |
| 75 | 75 |
| 76 // TODO(deanm): Eventually this should be painted with the background png | 76 // TODO(deanm): Eventually this should be painted with the background png |
| 77 // image, but for now we get pretty close by just drawing a solid border. | 77 // image, but for now we get pretty close by just drawing a solid border. |
| 78 const GdkColor kBorderColor = GDK_COLOR_RGB(0xbe, 0xc8, 0xd4); | 78 const GdkColor kBorderColor = GDK_COLOR_RGB(0xbe, 0xc8, 0xd4); |
| 79 const GdkColor kEvTextColor = GDK_COLOR_RGB(0x00, 0x96, 0x14); // Green. | 79 const GdkColor kEvSecureTextColor = GDK_COLOR_RGB(0x07, 0x95, 0x00); |
| 80 const GdkColor kSecurityErrorTextColor = GDK_COLOR_RGB(0xa2, 0x00, 0x00); |
| 80 const GdkColor kKeywordBackgroundColor = GDK_COLOR_RGB(0xf0, 0xf4, 0xfa); | 81 const GdkColor kKeywordBackgroundColor = GDK_COLOR_RGB(0xf0, 0xf4, 0xfa); |
| 81 const GdkColor kKeywordBorderColor = GDK_COLOR_RGB(0xcb, 0xde, 0xf7); | 82 const GdkColor kKeywordBorderColor = GDK_COLOR_RGB(0xcb, 0xde, 0xf7); |
| 82 | 83 |
| 83 // Use weak gray for showing search and keyword hint text. | 84 // Use weak gray for showing search and keyword hint text. |
| 84 const GdkColor kHintTextColor = GDK_COLOR_RGB(0x75, 0x75, 0x75); | 85 const GdkColor kHintTextColor = GDK_COLOR_RGB(0x75, 0x75, 0x75); |
| 85 | 86 |
| 86 // Size of the rounding of the "Search site for:" box. | 87 // Size of the rounding of the "Search site for:" box. |
| 87 const int kCornerSize = 3; | 88 const int kCornerSize = 3; |
| 88 | 89 |
| 89 // Returns the short name for a keyword. | 90 // Returns the short name for a keyword. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 base::i18n::AdjustStringForLocaleDirection(min_string, &min_string); | 125 base::i18n::AdjustStringForLocaleDirection(min_string, &min_string); |
| 125 return min_string; | 126 return min_string; |
| 126 } | 127 } |
| 127 | 128 |
| 128 } // namespace | 129 } // namespace |
| 129 | 130 |
| 130 //////////////////////////////////////////////////////////////////////////////// | 131 //////////////////////////////////////////////////////////////////////////////// |
| 131 // LocationBarViewGtk | 132 // LocationBarViewGtk |
| 132 | 133 |
| 133 // static | 134 // static |
| 134 const GdkColor LocationBarViewGtk::kBackgroundColorByLevel[3] = { | 135 const GdkColor LocationBarViewGtk::kBackgroundColor = |
| 135 GDK_COLOR_RGB(255, 245, 195), // SecurityLevel SECURE: Yellow. | 136 GDK_COLOR_RGB(255, 255, 255); |
| 136 GDK_COLOR_RGB(255, 255, 255), // SecurityLevel NORMAL: White. | |
| 137 GDK_COLOR_RGB(255, 255, 255), // SecurityLevel INSECURE: White. | |
| 138 }; | |
| 139 | 137 |
| 140 LocationBarViewGtk::LocationBarViewGtk( | 138 LocationBarViewGtk::LocationBarViewGtk( |
| 141 const BubblePositioner* bubble_positioner, | 139 const BubblePositioner* bubble_positioner, |
| 142 Browser* browser) | 140 Browser* browser) |
| 143 : security_icon_event_box_(NULL), | 141 : security_icon_event_box_(NULL), |
| 144 security_lock_icon_image_(NULL), | 142 ev_secure_icon_image_(NULL), |
| 143 secure_icon_image_(NULL), |
| 145 security_warning_icon_image_(NULL), | 144 security_warning_icon_image_(NULL), |
| 146 info_label_(NULL), | 145 security_error_icon_image_(NULL), |
| 146 security_info_label_(NULL), |
| 147 tab_to_search_box_(NULL), | 147 tab_to_search_box_(NULL), |
| 148 tab_to_search_full_label_(NULL), | 148 tab_to_search_full_label_(NULL), |
| 149 tab_to_search_partial_label_(NULL), | 149 tab_to_search_partial_label_(NULL), |
| 150 tab_to_search_hint_(NULL), | 150 tab_to_search_hint_(NULL), |
| 151 tab_to_search_hint_leading_label_(NULL), | 151 tab_to_search_hint_leading_label_(NULL), |
| 152 tab_to_search_hint_icon_(NULL), | 152 tab_to_search_hint_icon_(NULL), |
| 153 tab_to_search_hint_trailing_label_(NULL), | 153 tab_to_search_hint_trailing_label_(NULL), |
| 154 type_to_search_hint_(NULL), | 154 type_to_search_hint_(NULL), |
| 155 profile_(NULL), | 155 profile_(NULL), |
| 156 command_updater_(browser->command_updater()), | 156 command_updater_(browser->command_updater()), |
| (...skipping 30 matching lines...) Expand all Loading... |
| 187 | 187 |
| 188 hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); | 188 hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); |
| 189 gtk_container_set_border_width(GTK_CONTAINER(hbox_.get()), kHboxBorder); | 189 gtk_container_set_border_width(GTK_CONTAINER(hbox_.get()), kHboxBorder); |
| 190 // We will paint for the alignment, to paint the background and border. | 190 // We will paint for the alignment, to paint the background and border. |
| 191 gtk_widget_set_app_paintable(hbox_.get(), TRUE); | 191 gtk_widget_set_app_paintable(hbox_.get(), TRUE); |
| 192 // Redraw the whole location bar when it changes size (e.g., when toggling | 192 // Redraw the whole location bar when it changes size (e.g., when toggling |
| 193 // the home button on/off. | 193 // the home button on/off. |
| 194 gtk_widget_set_redraw_on_allocate(hbox_.get(), TRUE); | 194 gtk_widget_set_redraw_on_allocate(hbox_.get(), TRUE); |
| 195 | 195 |
| 196 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 196 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 197 security_lock_icon_image_ = gtk_image_new_from_pixbuf( | 197 ev_secure_icon_image_ = |
| 198 rb.GetPixbufNamed(IDR_LOCK)); | 198 gtk_image_new_from_pixbuf(rb.GetPixbufNamed(IDR_EV_SECURE)); |
| 199 gtk_widget_set_name(security_lock_icon_image_, "chrome-security-lock-icon"); | 199 gtk_widget_set_name(ev_secure_icon_image_, "chrome-ev-secure-icon"); |
| 200 gtk_widget_hide(GTK_WIDGET(security_lock_icon_image_)); | 200 secure_icon_image_ = gtk_image_new_from_pixbuf(rb.GetPixbufNamed(IDR_SECURE)); |
| 201 security_warning_icon_image_ = gtk_image_new(); | 201 gtk_widget_set_name(secure_icon_image_, "chrome-secure-icon"); |
| 202 security_warning_icon_image_ = |
| 203 gtk_image_new_from_pixbuf(rb.GetPixbufNamed(IDR_SECURITY_WARNING)); |
| 202 gtk_widget_set_name(security_warning_icon_image_, | 204 gtk_widget_set_name(security_warning_icon_image_, |
| 203 "chrome-security-warning-icon"); | 205 "chrome-security-warning-icon"); |
| 204 gtk_widget_hide(GTK_WIDGET(security_warning_icon_image_)); | 206 security_error_icon_image_ = |
| 207 gtk_image_new_from_pixbuf(rb.GetPixbufNamed(IDR_SECURITY_ERROR)); |
| 208 gtk_widget_set_name(security_error_icon_image_, |
| 209 "chrome-security-error-icon"); |
| 205 | 210 |
| 206 info_label_ = gtk_label_new(NULL); | 211 security_info_label_ = gtk_label_new(NULL); |
| 207 gtk_widget_modify_base(info_label_, GTK_STATE_NORMAL, | 212 gtk_widget_modify_base(security_info_label_, GTK_STATE_NORMAL, |
| 208 &LocationBarViewGtk::kBackgroundColorByLevel[0]); | 213 &LocationBarViewGtk::kBackgroundColor); |
| 209 gtk_widget_hide(GTK_WIDGET(info_label_)); | 214 gtk_widget_set_name(security_info_label_, |
| 210 gtk_widget_set_name(info_label_, | 215 "chrome-location-bar-security-info-label"); |
| 211 "chrome-location-bar-info-label"); | |
| 212 | 216 |
| 213 g_signal_connect(hbox_.get(), "expose-event", | 217 g_signal_connect(hbox_.get(), "expose-event", |
| 214 G_CALLBACK(&HandleExposeThunk), this); | 218 G_CALLBACK(&HandleExposeThunk), this); |
| 215 | 219 |
| 216 // Put |tab_to_search_box_|, |location_entry_|, |tab_to_search_hint_| and | 220 // Put |tab_to_search_box_|, |location_entry_|, |tab_to_search_hint_| and |
| 217 // |type_to_search_hint_| into a sub hbox, so that we can make this part | 221 // |type_to_search_hint_| into a sub hbox, so that we can make this part |
| 218 // horizontally shrinkable without affecting other elements in the location | 222 // horizontally shrinkable without affecting other elements in the location |
| 219 // bar. | 223 // bar. |
| 220 GtkWidget* entry_box = gtk_hbox_new(FALSE, kInnerPadding); | 224 GtkWidget* entry_box = gtk_hbox_new(FALSE, kInnerPadding); |
| 221 gtk_widget_show(entry_box); | 225 gtk_widget_show(entry_box); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 kTopMargin + kBorderThickness, | 266 kTopMargin + kBorderThickness, |
| 263 kBottomMargin + kBorderThickness, | 267 kBottomMargin + kBorderThickness, |
| 264 kBorderThickness, | 268 kBorderThickness, |
| 265 kBorderThickness); | 269 kBorderThickness); |
| 266 } else { | 270 } else { |
| 267 gtk_alignment_set_padding(GTK_ALIGNMENT(align), | 271 gtk_alignment_set_padding(GTK_ALIGNMENT(align), |
| 268 kTopMargin + kBorderThickness, | 272 kTopMargin + kBorderThickness, |
| 269 kBottomMargin + kBorderThickness, | 273 kBottomMargin + kBorderThickness, |
| 270 0, 0); | 274 0, 0); |
| 271 } | 275 } |
| 272 gtk_container_add(GTK_CONTAINER(align), location_entry_->widget()); | 276 gtk_container_add(GTK_CONTAINER(align), location_entry_->GetNativeView()); |
| 273 gtk_box_pack_start(GTK_BOX(entry_box), align, TRUE, TRUE, 0); | 277 gtk_box_pack_start(GTK_BOX(entry_box), align, TRUE, TRUE, 0); |
| 274 | 278 |
| 275 // Tab to search notification (the hint on the right hand side). | 279 // Tab to search notification (the hint on the right hand side). |
| 276 tab_to_search_hint_ = gtk_hbox_new(FALSE, 0); | 280 tab_to_search_hint_ = gtk_hbox_new(FALSE, 0); |
| 277 gtk_widget_set_name(tab_to_search_hint_, "chrome-tab-to-search-hint"); | 281 gtk_widget_set_name(tab_to_search_hint_, "chrome-tab-to-search-hint"); |
| 278 tab_to_search_hint_leading_label_ = gtk_label_new(NULL); | 282 tab_to_search_hint_leading_label_ = gtk_label_new(NULL); |
| 279 gtk_widget_set_sensitive(tab_to_search_hint_leading_label_, FALSE); | 283 gtk_widget_set_sensitive(tab_to_search_hint_leading_label_, FALSE); |
| 280 tab_to_search_hint_icon_ = gtk_image_new_from_pixbuf( | 284 tab_to_search_hint_icon_ = gtk_image_new_from_pixbuf( |
| 281 rb.GetPixbufNamed(IDR_LOCATION_BAR_KEYWORD_HINT_TAB)); | 285 rb.GetPixbufNamed(IDR_LOCATION_BAR_KEYWORD_HINT_TAB)); |
| 282 tab_to_search_hint_trailing_label_ = gtk_label_new(NULL); | 286 tab_to_search_hint_trailing_label_ = gtk_label_new(NULL); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 296 // tab_to_search_hint_ gets hidden initially in OnChanged. Hiding it here | 300 // tab_to_search_hint_ gets hidden initially in OnChanged. Hiding it here |
| 297 // doesn't work, someone is probably calling show_all on our parent box. | 301 // doesn't work, someone is probably calling show_all on our parent box. |
| 298 gtk_box_pack_end(GTK_BOX(entry_box), tab_to_search_hint_, FALSE, FALSE, 0); | 302 gtk_box_pack_end(GTK_BOX(entry_box), tab_to_search_hint_, FALSE, FALSE, 0); |
| 299 | 303 |
| 300 // Type to search hint is on the right hand side. | 304 // Type to search hint is on the right hand side. |
| 301 type_to_search_hint_ = | 305 type_to_search_hint_ = |
| 302 gtk_label_new(l10n_util::GetStringUTF8(IDS_OMNIBOX_EMPTY_TEXT).c_str()); | 306 gtk_label_new(l10n_util::GetStringUTF8(IDS_OMNIBOX_EMPTY_TEXT).c_str()); |
| 303 gtk_widget_set_sensitive(type_to_search_hint_, FALSE); | 307 gtk_widget_set_sensitive(type_to_search_hint_, FALSE); |
| 304 gtk_box_pack_end(GTK_BOX(entry_box), type_to_search_hint_, FALSE, FALSE, 0); | 308 gtk_box_pack_end(GTK_BOX(entry_box), type_to_search_hint_, FALSE, FALSE, 0); |
| 305 | 309 |
| 306 // Pack info_label_ and security icons in hbox. We hide/show them | 310 // Pack security_info_label_ and security icons in hbox. We hide/show them |
| 307 // by SetSecurityIcon() and SetInfoText(). | 311 // by SetSecurityIcon() and SetInfoText(). |
| 308 gtk_box_pack_end(GTK_BOX(hbox_.get()), info_label_, FALSE, FALSE, 0); | 312 gtk_box_pack_end(GTK_BOX(hbox_.get()), security_info_label_, FALSE, FALSE, 0); |
| 309 | 313 |
| 310 GtkWidget* security_icon_box = gtk_hbox_new(FALSE, 0); | 314 GtkWidget* security_icon_box = gtk_hbox_new(FALSE, 0); |
| 311 gtk_box_pack_start(GTK_BOX(security_icon_box), | 315 gtk_box_pack_start(GTK_BOX(security_icon_box), |
| 312 security_lock_icon_image_, FALSE, FALSE, 0); | 316 ev_secure_icon_image_, FALSE, FALSE, 0); |
| 317 gtk_box_pack_start(GTK_BOX(security_icon_box), |
| 318 secure_icon_image_, FALSE, FALSE, 0); |
| 313 gtk_box_pack_start(GTK_BOX(security_icon_box), | 319 gtk_box_pack_start(GTK_BOX(security_icon_box), |
| 314 security_warning_icon_image_, FALSE, FALSE, 0); | 320 security_warning_icon_image_, FALSE, FALSE, 0); |
| 321 gtk_box_pack_start(GTK_BOX(security_icon_box), |
| 322 security_error_icon_image_, FALSE, FALSE, 0); |
| 315 | 323 |
| 316 // GtkImage is a "no window" widget and requires a GtkEventBox to receive | 324 // GtkImage is a "no window" widget and requires a GtkEventBox to receive |
| 317 // events. | 325 // events. |
| 318 security_icon_event_box_ = gtk_event_box_new(); | 326 security_icon_event_box_ = gtk_event_box_new(); |
| 319 // Make the event box not visible so it does not paint a background. | 327 // Make the event box not visible so it does not paint a background. |
| 320 gtk_event_box_set_visible_window(GTK_EVENT_BOX(security_icon_event_box_), | 328 gtk_event_box_set_visible_window(GTK_EVENT_BOX(security_icon_event_box_), |
| 321 FALSE); | 329 FALSE); |
| 322 g_signal_connect(security_icon_event_box_, "button-press-event", | 330 g_signal_connect(security_icon_event_box_, "button-press-event", |
| 323 G_CALLBACK(&OnSecurityIconPressed), this); | 331 G_CALLBACK(&OnSecurityIconPressed), this); |
| 324 | 332 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 345 | 353 |
| 346 page_action_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); | 354 page_action_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); |
| 347 gtk_widget_set_name(page_action_hbox_.get(), | 355 gtk_widget_set_name(page_action_hbox_.get(), |
| 348 "chrome-page-action-hbox"); | 356 "chrome-page-action-hbox"); |
| 349 gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(), | 357 gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(), |
| 350 FALSE, FALSE, 0); | 358 FALSE, FALSE, 0); |
| 351 | 359 |
| 352 // Until we switch to vector graphics, force the font size of labels. | 360 // Until we switch to vector graphics, force the font size of labels. |
| 353 gtk_util::ForceFontSizePixels(type_to_search_hint_, | 361 gtk_util::ForceFontSizePixels(type_to_search_hint_, |
| 354 browser_defaults::kAutocompleteEditFontPixelSize); | 362 browser_defaults::kAutocompleteEditFontPixelSize); |
| 355 gtk_util::ForceFontSizePixels(info_label_, | 363 gtk_util::ForceFontSizePixels(security_info_label_, |
| 356 browser_defaults::kAutocompleteEditFontPixelSize); | 364 browser_defaults::kAutocompleteEditFontPixelSize); |
| 357 gtk_util::ForceFontSizePixels(tab_to_search_full_label_, | 365 gtk_util::ForceFontSizePixels(tab_to_search_full_label_, |
| 358 browser_defaults::kAutocompleteEditFontPixelSize); | 366 browser_defaults::kAutocompleteEditFontPixelSize); |
| 359 gtk_util::ForceFontSizePixels(tab_to_search_partial_label_, | 367 gtk_util::ForceFontSizePixels(tab_to_search_partial_label_, |
| 360 browser_defaults::kAutocompleteEditFontPixelSize); | 368 browser_defaults::kAutocompleteEditFontPixelSize); |
| 361 gtk_util::ForceFontSizePixels(tab_to_search_hint_leading_label_, | 369 gtk_util::ForceFontSizePixels(tab_to_search_hint_leading_label_, |
| 362 browser_defaults::kAutocompleteEditFontPixelSize); | 370 browser_defaults::kAutocompleteEditFontPixelSize); |
| 363 gtk_util::ForceFontSizePixels(tab_to_search_hint_trailing_label_, | 371 gtk_util::ForceFontSizePixels(tab_to_search_hint_trailing_label_, |
| 364 browser_defaults::kAutocompleteEditFontPixelSize); | 372 browser_defaults::kAutocompleteEditFontPixelSize); |
| 365 gtk_util::ForceFontSizePixels(type_to_search_hint_, | 373 gtk_util::ForceFontSizePixels(type_to_search_hint_, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 page_action_views_.begin(); | 411 page_action_views_.begin(); |
| 404 iter != page_action_views_.end(); | 412 iter != page_action_views_.end(); |
| 405 ++iter) { | 413 ++iter) { |
| 406 if ((*iter)->page_action() == page_action) | 414 if ((*iter)->page_action() == page_action) |
| 407 return (*iter)->widget(); | 415 return (*iter)->widget(); |
| 408 } | 416 } |
| 409 return NULL; | 417 return NULL; |
| 410 } | 418 } |
| 411 | 419 |
| 412 void LocationBarViewGtk::Update(const TabContents* contents) { | 420 void LocationBarViewGtk::Update(const TabContents* contents) { |
| 413 SetSecurityIcon(toolbar_model_->GetIcon()); | 421 SetSecurityIcon(toolbar_model_->GetSecurityIcon()); |
| 414 UpdateContentSettingsIcons(); | 422 UpdateContentSettingsIcons(); |
| 415 UpdatePageActions(); | 423 UpdatePageActions(); |
| 416 SetInfoText(); | 424 SetInfoText(); |
| 417 location_entry_->Update(contents); | 425 location_entry_->Update(contents); |
| 418 // The security level (background color) could have changed, etc. | 426 // The security level (background color) could have changed, etc. |
| 419 if (theme_provider_->UseGtkTheme()) { | 427 if (theme_provider_->UseGtkTheme()) { |
| 420 // In GTK mode, we need our parent to redraw, as it draws the text entry | 428 // In GTK mode, we need our parent to redraw, as it draws the text entry |
| 421 // border. | 429 // border. |
| 422 gtk_widget_queue_draw(widget()->parent); | 430 gtk_widget_queue_draw(widget()->parent); |
| 423 } else { | 431 } else { |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 | 692 |
| 685 GdkColor border_color = theme_provider_->GetGdkColor( | 693 GdkColor border_color = theme_provider_->GetGdkColor( |
| 686 BrowserThemeProvider::COLOR_FRAME); | 694 BrowserThemeProvider::COLOR_FRAME); |
| 687 gtk_util::SetRoundedWindowBorderColor(tab_to_search_box_, border_color); | 695 gtk_util::SetRoundedWindowBorderColor(tab_to_search_box_, border_color); |
| 688 | 696 |
| 689 gtk_util::SetLabelColor(tab_to_search_full_label_, NULL); | 697 gtk_util::SetLabelColor(tab_to_search_full_label_, NULL); |
| 690 gtk_util::SetLabelColor(tab_to_search_partial_label_, NULL); | 698 gtk_util::SetLabelColor(tab_to_search_partial_label_, NULL); |
| 691 gtk_util::SetLabelColor(tab_to_search_hint_leading_label_, NULL); | 699 gtk_util::SetLabelColor(tab_to_search_hint_leading_label_, NULL); |
| 692 gtk_util::SetLabelColor(tab_to_search_hint_trailing_label_, NULL); | 700 gtk_util::SetLabelColor(tab_to_search_hint_trailing_label_, NULL); |
| 693 gtk_util::SetLabelColor(type_to_search_hint_, NULL); | 701 gtk_util::SetLabelColor(type_to_search_hint_, NULL); |
| 694 | |
| 695 gtk_image_set_from_stock(GTK_IMAGE(security_warning_icon_image_), | |
| 696 GTK_STOCK_DIALOG_WARNING, | |
| 697 GTK_ICON_SIZE_SMALL_TOOLBAR); | |
| 698 } else { | 702 } else { |
| 699 gtk_widget_modify_bg(tab_to_search_box_, GTK_STATE_NORMAL, | 703 gtk_widget_modify_bg(tab_to_search_box_, GTK_STATE_NORMAL, |
| 700 &kKeywordBackgroundColor); | 704 &kKeywordBackgroundColor); |
| 701 gtk_util::SetRoundedWindowBorderColor(tab_to_search_box_, | 705 gtk_util::SetRoundedWindowBorderColor(tab_to_search_box_, |
| 702 kKeywordBorderColor); | 706 kKeywordBorderColor); |
| 703 | 707 |
| 704 gtk_util::SetLabelColor(tab_to_search_full_label_, &gfx::kGdkBlack); | 708 gtk_util::SetLabelColor(tab_to_search_full_label_, &gfx::kGdkBlack); |
| 705 gtk_util::SetLabelColor(tab_to_search_partial_label_, &gfx::kGdkBlack); | 709 gtk_util::SetLabelColor(tab_to_search_partial_label_, &gfx::kGdkBlack); |
| 706 gtk_util::SetLabelColor(tab_to_search_hint_leading_label_, | 710 gtk_util::SetLabelColor(tab_to_search_hint_leading_label_, |
| 707 &kHintTextColor); | 711 &kHintTextColor); |
| 708 gtk_util::SetLabelColor(tab_to_search_hint_trailing_label_, | 712 gtk_util::SetLabelColor(tab_to_search_hint_trailing_label_, |
| 709 &kHintTextColor); | 713 &kHintTextColor); |
| 710 gtk_util::SetLabelColor(type_to_search_hint_, &kHintTextColor); | 714 gtk_util::SetLabelColor(type_to_search_hint_, &kHintTextColor); |
| 711 | |
| 712 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
| 713 gtk_image_set_from_pixbuf(GTK_IMAGE(security_warning_icon_image_), | |
| 714 rb.GetPixbufNamed(IDR_WARNING)); | |
| 715 } | 715 } |
| 716 } | 716 } |
| 717 | 717 |
| 718 gboolean LocationBarViewGtk::HandleExpose(GtkWidget* widget, | 718 gboolean LocationBarViewGtk::HandleExpose(GtkWidget* widget, |
| 719 GdkEventExpose* event) { | 719 GdkEventExpose* event) { |
| 720 GdkRectangle* alloc_rect = &hbox_->allocation; | 720 GdkRectangle* alloc_rect = &hbox_->allocation; |
| 721 | 721 |
| 722 // If we're not using GTK theming, draw our own border over the edge pixels | 722 // If we're not using GTK theming, draw our own border over the edge pixels |
| 723 // of the background. | 723 // of the background. |
| 724 if (!profile_ || | 724 if (!profile_ || |
| (...skipping 13 matching lines...) Expand all Loading... |
| 738 gdk_cairo_rectangle(cr, alloc_rect); | 738 gdk_cairo_rectangle(cr, alloc_rect); |
| 739 cairo_fill(cr); | 739 cairo_fill(cr); |
| 740 | 740 |
| 741 // But on top of that, we also need to draw the "inner" rect, which is all | 741 // But on top of that, we also need to draw the "inner" rect, which is all |
| 742 // the color that the background should be. | 742 // the color that the background should be. |
| 743 cairo_rectangle(cr, alloc_rect->x, | 743 cairo_rectangle(cr, alloc_rect->x, |
| 744 alloc_rect->y + kTopMargin + kBorderThickness, | 744 alloc_rect->y + kTopMargin + kBorderThickness, |
| 745 alloc_rect->width, | 745 alloc_rect->width, |
| 746 alloc_rect->height - kTopMargin - | 746 alloc_rect->height - kTopMargin - |
| 747 kBottomMargin - 2 * kBorderThickness); | 747 kBottomMargin - 2 * kBorderThickness); |
| 748 gdk_cairo_set_source_color(cr, const_cast<GdkColor*>( | 748 gdk_cairo_set_source_color(cr, const_cast<GdkColor*>(&kBackgroundColor)); |
| 749 &kBackgroundColorByLevel[toolbar_model_->GetSchemeSecurityLevel()])); | |
| 750 cairo_fill(cr); | 749 cairo_fill(cr); |
| 751 | 750 |
| 752 cairo_destroy(cr); | 751 cairo_destroy(cr); |
| 753 } | 752 } |
| 754 | 753 |
| 755 return FALSE; // Continue propagating the expose. | 754 return FALSE; // Continue propagating the expose. |
| 756 } | 755 } |
| 757 | 756 |
| 758 void LocationBarViewGtk::SetSecurityIcon(ToolbarModel::Icon icon) { | 757 void LocationBarViewGtk::SetSecurityIcon(int resource_id) { |
| 759 gtk_widget_hide(GTK_WIDGET(security_lock_icon_image_)); | 758 gtk_widget_hide(GTK_WIDGET(ev_secure_icon_image_)); |
| 759 gtk_widget_hide(GTK_WIDGET(secure_icon_image_)); |
| 760 gtk_widget_hide(GTK_WIDGET(security_warning_icon_image_)); | 760 gtk_widget_hide(GTK_WIDGET(security_warning_icon_image_)); |
| 761 if (icon != ToolbarModel::NO_ICON) | 761 gtk_widget_hide(GTK_WIDGET(security_error_icon_image_)); |
| 762 gtk_widget_show(GTK_WIDGET(security_icon_event_box_)); | 762 if (resource_id == 0) { |
| 763 else | |
| 764 gtk_widget_hide(GTK_WIDGET(security_icon_event_box_)); | 763 gtk_widget_hide(GTK_WIDGET(security_icon_event_box_)); |
| 765 switch (icon) { | 764 return; |
| 766 case ToolbarModel::LOCK_ICON: | 765 } |
| 767 gtk_widget_show(GTK_WIDGET(security_lock_icon_image_)); | 766 gtk_widget_show(GTK_WIDGET(security_icon_event_box_)); |
| 767 switch (resource_id) { |
| 768 case IDR_EV_SECURE: |
| 769 gtk_widget_show(GTK_WIDGET(ev_secure_icon_image_)); |
| 768 break; | 770 break; |
| 769 case ToolbarModel::WARNING_ICON: | 771 case IDR_SECURE: |
| 772 gtk_widget_show(GTK_WIDGET(secure_icon_image_)); |
| 773 break; |
| 774 case IDR_SECURITY_WARNING: |
| 770 gtk_widget_show(GTK_WIDGET(security_warning_icon_image_)); | 775 gtk_widget_show(GTK_WIDGET(security_warning_icon_image_)); |
| 771 break; | 776 break; |
| 772 case ToolbarModel::NO_ICON: | 777 case IDR_SECURITY_ERROR: |
| 778 gtk_widget_show(GTK_WIDGET(security_error_icon_image_)); |
| 773 break; | 779 break; |
| 774 default: | 780 default: |
| 775 NOTREACHED(); | 781 NOTREACHED(); |
| 776 break; | 782 break; |
| 777 } | 783 } |
| 778 } | 784 } |
| 779 | 785 |
| 780 void LocationBarViewGtk::SetInfoText() { | 786 void LocationBarViewGtk::SetInfoText() { |
| 781 std::wstring info_text, info_tooltip; | 787 std::wstring info_text = toolbar_model_->GetSecurityInfoText(); |
| 782 ToolbarModel::InfoTextType info_text_type = | 788 if (info_text.empty()) { |
| 783 toolbar_model_->GetInfoText(&info_text, &info_tooltip); | 789 gtk_widget_hide(GTK_WIDGET(security_info_label_)); |
| 784 if (info_text_type == ToolbarModel::INFO_EV_TEXT) { | |
| 785 gtk_widget_modify_fg(GTK_WIDGET(info_label_), GTK_STATE_NORMAL, | |
| 786 &kEvTextColor); | |
| 787 gtk_widget_show(GTK_WIDGET(info_label_)); | |
| 788 } else { | 790 } else { |
| 789 DCHECK_EQ(info_text_type, ToolbarModel::INFO_NO_INFO); | 791 gtk_widget_modify_fg(GTK_WIDGET(security_info_label_), GTK_STATE_NORMAL, |
| 790 DCHECK(info_text.empty()); | 792 toolbar_model_->GetSecurityLevel() == ToolbarModel::EV_SECURE ? |
| 791 // Clear info_text. Should we reset the fg here? | 793 &kEvSecureTextColor : &kSecurityErrorTextColor); |
| 792 gtk_widget_hide(GTK_WIDGET(info_label_)); | 794 gtk_widget_show(GTK_WIDGET(security_info_label_)); |
| 793 } | 795 } |
| 794 gtk_label_set_text(GTK_LABEL(info_label_), WideToUTF8(info_text).c_str()); | 796 gtk_label_set_text(GTK_LABEL(security_info_label_), |
| 795 gtk_widget_set_tooltip_text(GTK_WIDGET(info_label_), | 797 WideToUTF8(info_text).c_str()); |
| 796 WideToUTF8(info_tooltip).c_str()); | |
| 797 } | 798 } |
| 798 | 799 |
| 799 void LocationBarViewGtk::SetKeywordLabel(const std::wstring& keyword) { | 800 void LocationBarViewGtk::SetKeywordLabel(const std::wstring& keyword) { |
| 800 if (keyword.empty()) | 801 if (keyword.empty()) |
| 801 return; | 802 return; |
| 802 | 803 |
| 803 DCHECK(profile_); | 804 DCHECK(profile_); |
| 804 if (!profile_->GetTemplateURLModel()) | 805 if (!profile_->GetTemplateURLModel()) |
| 805 return; | 806 return; |
| 806 | 807 |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1254 | 1255 |
| 1255 std::string badge_text = page_action_->GetBadgeText(tab_id); | 1256 std::string badge_text = page_action_->GetBadgeText(tab_id); |
| 1256 if (badge_text.empty()) | 1257 if (badge_text.empty()) |
| 1257 return FALSE; | 1258 return FALSE; |
| 1258 | 1259 |
| 1259 gfx::CanvasPaint canvas(event, false); | 1260 gfx::CanvasPaint canvas(event, false); |
| 1260 gfx::Rect bounding_rect(widget->allocation); | 1261 gfx::Rect bounding_rect(widget->allocation); |
| 1261 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); | 1262 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); |
| 1262 return FALSE; | 1263 return FALSE; |
| 1263 } | 1264 } |
| OLD | NEW |