| 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/gtk_dnd_util.h" | 9 #include "app/gtk_dnd_util.h" |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 131 |
| 132 } // namespace | 132 } // namespace |
| 133 | 133 |
| 134 //////////////////////////////////////////////////////////////////////////////// | 134 //////////////////////////////////////////////////////////////////////////////// |
| 135 // LocationBarViewGtk | 135 // LocationBarViewGtk |
| 136 | 136 |
| 137 // static | 137 // static |
| 138 const GdkColor LocationBarViewGtk::kBackgroundColor = | 138 const GdkColor LocationBarViewGtk::kBackgroundColor = |
| 139 GDK_COLOR_RGB(255, 255, 255); | 139 GDK_COLOR_RGB(255, 255, 255); |
| 140 | 140 |
| 141 LocationBarViewGtk::LocationBarViewGtk( | 141 LocationBarViewGtk::LocationBarViewGtk(Browser* browser) |
| 142 const BubblePositioner* bubble_positioner, | |
| 143 Browser* browser) | |
| 144 : star_image_(NULL), | 142 : star_image_(NULL), |
| 145 starred_(false), | 143 starred_(false), |
| 146 security_icon_event_box_(NULL), | 144 security_icon_event_box_(NULL), |
| 147 ev_secure_icon_image_(NULL), | 145 ev_secure_icon_image_(NULL), |
| 148 secure_icon_image_(NULL), | 146 secure_icon_image_(NULL), |
| 149 security_warning_icon_image_(NULL), | 147 security_warning_icon_image_(NULL), |
| 150 security_error_icon_image_(NULL), | 148 security_error_icon_image_(NULL), |
| 151 location_icon_event_box_(NULL), | 149 location_icon_event_box_(NULL), |
| 152 location_icon_image_(NULL), | 150 location_icon_image_(NULL), |
| 153 security_info_label_(NULL), | 151 security_info_label_(NULL), |
| 154 tab_to_search_box_(NULL), | 152 tab_to_search_box_(NULL), |
| 155 tab_to_search_full_label_(NULL), | 153 tab_to_search_full_label_(NULL), |
| 156 tab_to_search_partial_label_(NULL), | 154 tab_to_search_partial_label_(NULL), |
| 157 tab_to_search_hint_(NULL), | 155 tab_to_search_hint_(NULL), |
| 158 tab_to_search_hint_leading_label_(NULL), | 156 tab_to_search_hint_leading_label_(NULL), |
| 159 tab_to_search_hint_icon_(NULL), | 157 tab_to_search_hint_icon_(NULL), |
| 160 tab_to_search_hint_trailing_label_(NULL), | 158 tab_to_search_hint_trailing_label_(NULL), |
| 161 type_to_search_hint_(NULL), | 159 type_to_search_hint_(NULL), |
| 162 profile_(NULL), | 160 profile_(NULL), |
| 163 command_updater_(browser->command_updater()), | 161 command_updater_(browser->command_updater()), |
| 164 toolbar_model_(browser->toolbar_model()), | 162 toolbar_model_(browser->toolbar_model()), |
| 165 browser_(browser), | 163 browser_(browser), |
| 166 bubble_positioner_(bubble_positioner), | |
| 167 disposition_(CURRENT_TAB), | 164 disposition_(CURRENT_TAB), |
| 168 transition_(PageTransition::TYPED), | 165 transition_(PageTransition::TYPED), |
| 169 first_run_bubble_(this), | 166 first_run_bubble_(this), |
| 170 popup_window_mode_(false), | 167 popup_window_mode_(false), |
| 171 theme_provider_(NULL), | 168 theme_provider_(NULL), |
| 172 entry_box_width_(0), | 169 entry_box_width_(0), |
| 173 show_selected_keyword_(false), | 170 show_selected_keyword_(false), |
| 174 show_keyword_hint_(false), | 171 show_keyword_hint_(false), |
| 175 show_search_hint_(false) { | 172 show_search_hint_(false) { |
| 176 } | 173 } |
| 177 | 174 |
| 178 LocationBarViewGtk::~LocationBarViewGtk() { | 175 LocationBarViewGtk::~LocationBarViewGtk() { |
| 179 // All of our widgets should have be children of / owned by the alignment. | 176 // All of our widgets should have be children of / owned by the alignment. |
| 180 star_.Destroy(); | 177 star_.Destroy(); |
| 181 hbox_.Destroy(); | 178 hbox_.Destroy(); |
| 182 content_setting_hbox_.Destroy(); | 179 content_setting_hbox_.Destroy(); |
| 183 page_action_hbox_.Destroy(); | 180 page_action_hbox_.Destroy(); |
| 184 } | 181 } |
| 185 | 182 |
| 186 void LocationBarViewGtk::Init(bool popup_window_mode) { | 183 void LocationBarViewGtk::Init(bool popup_window_mode) { |
| 187 popup_window_mode_ = popup_window_mode; | 184 popup_window_mode_ = popup_window_mode; |
| 188 location_entry_.reset(new AutocompleteEditViewGtk(this, | |
| 189 toolbar_model_, | |
| 190 profile_, | |
| 191 command_updater_, | |
| 192 popup_window_mode_, | |
| 193 bubble_positioner_)); | |
| 194 location_entry_->Init(); | |
| 195 | 185 |
| 186 // Create the widget first, so we can pass it to the AutocompleteEditViewGtk. |
| 196 hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); | 187 hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); |
| 197 gtk_container_set_border_width(GTK_CONTAINER(hbox_.get()), kHboxBorder); | 188 gtk_container_set_border_width(GTK_CONTAINER(hbox_.get()), kHboxBorder); |
| 198 // We will paint for the alignment, to paint the background and border. | 189 // We will paint for the alignment, to paint the background and border. |
| 199 gtk_widget_set_app_paintable(hbox_.get(), TRUE); | 190 gtk_widget_set_app_paintable(hbox_.get(), TRUE); |
| 200 // Redraw the whole location bar when it changes size (e.g., when toggling | 191 // Redraw the whole location bar when it changes size (e.g., when toggling |
| 201 // the home button on/off. | 192 // the home button on/off. |
| 202 gtk_widget_set_redraw_on_allocate(hbox_.get(), TRUE); | 193 gtk_widget_set_redraw_on_allocate(hbox_.get(), TRUE); |
| 203 | 194 |
| 195 // Now initialize the AutocompleteEditViewGtk. |
| 196 location_entry_.reset(new AutocompleteEditViewGtk(this, |
| 197 toolbar_model_, |
| 198 profile_, |
| 199 command_updater_, |
| 200 popup_window_mode_, |
| 201 hbox_.get())); |
| 202 location_entry_->Init(); |
| 203 |
| 204 security_info_label_ = gtk_label_new(NULL); | 204 security_info_label_ = gtk_label_new(NULL); |
| 205 gtk_widget_modify_base(security_info_label_, GTK_STATE_NORMAL, | 205 gtk_widget_modify_base(security_info_label_, GTK_STATE_NORMAL, |
| 206 &LocationBarViewGtk::kBackgroundColor); | 206 &LocationBarViewGtk::kBackgroundColor); |
| 207 gtk_widget_set_name(security_info_label_, | 207 gtk_widget_set_name(security_info_label_, |
| 208 "chrome-location-bar-security-info-label"); | 208 "chrome-location-bar-security-info-label"); |
| 209 | 209 |
| 210 g_signal_connect(hbox_.get(), "expose-event", | 210 g_signal_connect(hbox_.get(), "expose-event", |
| 211 G_CALLBACK(&HandleExposeThunk), this); | 211 G_CALLBACK(&HandleExposeThunk), this); |
| 212 | 212 |
| 213 BuildLocationIcon(); | 213 BuildLocationIcon(); |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 | 1303 |
| 1304 std::string badge_text = page_action_->GetBadgeText(tab_id); | 1304 std::string badge_text = page_action_->GetBadgeText(tab_id); |
| 1305 if (badge_text.empty()) | 1305 if (badge_text.empty()) |
| 1306 return FALSE; | 1306 return FALSE; |
| 1307 | 1307 |
| 1308 gfx::CanvasPaint canvas(event, false); | 1308 gfx::CanvasPaint canvas(event, false); |
| 1309 gfx::Rect bounding_rect(widget->allocation); | 1309 gfx::Rect bounding_rect(widget->allocation); |
| 1310 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); | 1310 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); |
| 1311 return FALSE; | 1311 return FALSE; |
| 1312 } | 1312 } |
| OLD | NEW |