Chromium Code Reviews| 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/content_blocked_bubble_gtk.h" | 5 #include "chrome/browser/gtk/content_blocked_bubble_gtk.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "chrome/browser/blocked_popup_container.h" | 9 #include "chrome/browser/blocked_popup_container.h" |
| 10 #include "chrome/browser/content_setting_bubble_model.h" | 10 #include "chrome/browser/content_setting_bubble_model.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 DCHECK(source == Source<TabContents>(tab_contents_)); | 65 DCHECK(source == Source<TabContents>(tab_contents_)); |
| 66 tab_contents_ = NULL; | 66 tab_contents_ = NULL; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void ContentSettingBubbleGtk::BuildBubble() { | 69 void ContentSettingBubbleGtk::BuildBubble() { |
| 70 GtkThemeProvider* theme_provider = GtkThemeProvider::GetFrom(profile_); | 70 GtkThemeProvider* theme_provider = GtkThemeProvider::GetFrom(profile_); |
| 71 | 71 |
| 72 GtkWidget* bubble_content = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); | 72 GtkWidget* bubble_content = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); |
| 73 gtk_container_set_border_width(GTK_CONTAINER(bubble_content), kContentBorder); | 73 gtk_container_set_border_width(GTK_CONTAINER(bubble_content), kContentBorder); |
| 74 | 74 |
| 75 // Add the content label. | 75 const ContentSettingBubbleModel::BubbleContent& content = |
| 76 GtkWidget* label = gtk_label_new( | 76 content_setting_bubble_model_->bubble_content(); |
| 77 content_setting_bubble_model_->bubble_content().title.c_str()); | 77 if (!content.title.empty()) { |
| 78 gtk_box_pack_start(GTK_BOX(bubble_content), label, FALSE, FALSE, 0); | 78 // Add the content label. |
| 79 GtkWidget* label = gtk_label_new(content.title.c_str()); | |
| 80 gtk_box_pack_start(GTK_BOX(bubble_content), label, FALSE, FALSE, 0); | |
| 81 } | |
| 79 | 82 |
| 80 if (content_setting_bubble_model_->content_type() == | 83 if (content_setting_bubble_model_->content_type() == |
| 81 CONTENT_SETTINGS_TYPE_POPUPS) { | 84 CONTENT_SETTINGS_TYPE_POPUPS) { |
| 82 const std::vector<ContentSettingBubbleModel::PopupItem>& popup_items = | 85 const std::vector<ContentSettingBubbleModel::PopupItem>& popup_items = |
| 83 content_setting_bubble_model_->bubble_content().popup_items; | 86 content.popup_items; |
| 84 GtkWidget* table = gtk_table_new(popup_items.size(), 2, FALSE); | 87 GtkWidget* table = gtk_table_new(popup_items.size(), 2, FALSE); |
| 85 int row = 0; | 88 int row = 0; |
| 86 for (std::vector<ContentSettingBubbleModel::PopupItem>::const_iterator | 89 for (std::vector<ContentSettingBubbleModel::PopupItem>::const_iterator |
| 87 i(popup_items.begin()); i != popup_items.end(); ++i, ++row) { | 90 i(popup_items.begin()); i != popup_items.end(); ++i, ++row) { |
| 88 GtkWidget* image = gtk_image_new(); | 91 GtkWidget* image = gtk_image_new(); |
| 89 if (!i->bitmap.empty()) { | 92 if (!i->bitmap.empty()) { |
| 90 GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(&i->bitmap); | 93 GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(&i->bitmap); |
| 91 gtk_image_set_from_pixbuf(GTK_IMAGE(image), icon_pixbuf); | 94 gtk_image_set_from_pixbuf(GTK_IMAGE(image), icon_pixbuf); |
| 92 g_object_unref(icon_pixbuf); | 95 g_object_unref(icon_pixbuf); |
| 93 | 96 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 112 GTK_FILL, GTK_FILL, gtk_util::kControlSpacing / 2, | 115 GTK_FILL, GTK_FILL, gtk_util::kControlSpacing / 2, |
| 113 gtk_util::kControlSpacing / 2); | 116 gtk_util::kControlSpacing / 2); |
| 114 } | 117 } |
| 115 | 118 |
| 116 gtk_box_pack_start(GTK_BOX(bubble_content), table, FALSE, FALSE, 0); | 119 gtk_box_pack_start(GTK_BOX(bubble_content), table, FALSE, FALSE, 0); |
| 117 } | 120 } |
| 118 | 121 |
| 119 if (content_setting_bubble_model_->content_type() != | 122 if (content_setting_bubble_model_->content_type() != |
| 120 CONTENT_SETTINGS_TYPE_COOKIES) { | 123 CONTENT_SETTINGS_TYPE_COOKIES) { |
| 121 const ContentSettingBubbleModel::RadioGroups& radio_groups = | 124 const ContentSettingBubbleModel::RadioGroups& radio_groups = |
| 122 content_setting_bubble_model_->bubble_content().radio_groups; | 125 content.radio_groups; |
| 123 for (ContentSettingBubbleModel::RadioGroups::const_iterator i = | 126 for (ContentSettingBubbleModel::RadioGroups::const_iterator i = |
| 124 radio_groups.begin(); i != radio_groups.end(); ++i) { | 127 radio_groups.begin(); i != radio_groups.end(); ++i) { |
| 125 const ContentSettingBubbleModel::RadioItems& radio_items = i->radio_items; | 128 const ContentSettingBubbleModel::RadioItems& radio_items = i->radio_items; |
| 126 RadioGroupGtk radio_group_gtk; | 129 RadioGroupGtk radio_group_gtk; |
| 127 for (ContentSettingBubbleModel::RadioItems::const_iterator j = | 130 for (ContentSettingBubbleModel::RadioItems::const_iterator j = |
| 128 radio_items.begin(); j != radio_items.end(); ++j) { | 131 radio_items.begin(); j != radio_items.end(); ++j) { |
| 129 GtkWidget* radio = | 132 GtkWidget* radio = |
| 130 radio_group_gtk.empty() ? | 133 radio_group_gtk.empty() ? |
| 131 gtk_radio_button_new_with_label(NULL, j->c_str()) : | 134 gtk_radio_button_new_with_label(NULL, j->c_str()) : |
| 132 gtk_radio_button_new_with_label_from_widget( | 135 gtk_radio_button_new_with_label_from_widget( |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 143 for (std::vector<GtkWidget*>::const_iterator j = radio_group_gtk.begin(); | 146 for (std::vector<GtkWidget*>::const_iterator j = radio_group_gtk.begin(); |
| 144 j != radio_group_gtk.end(); ++j) { | 147 j != radio_group_gtk.end(); ++j) { |
| 145 g_signal_connect(*j, "toggled", G_CALLBACK(OnRadioToggled), this); | 148 g_signal_connect(*j, "toggled", G_CALLBACK(OnRadioToggled), this); |
| 146 } | 149 } |
| 147 radio_groups_gtk_.push_back(radio_group_gtk); | 150 radio_groups_gtk_.push_back(radio_group_gtk); |
| 148 gtk_box_pack_start(GTK_BOX(bubble_content), gtk_hseparator_new(), FALSE, | 151 gtk_box_pack_start(GTK_BOX(bubble_content), gtk_hseparator_new(), FALSE, |
| 149 FALSE, 0); | 152 FALSE, 0); |
| 150 } | 153 } |
| 151 } | 154 } |
| 152 | 155 |
| 156 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i = | |
| 157 content.domain_lists.begin(); | |
| 158 i != content.domain_lists.end(); ++i) { | |
| 159 // Put each list into its own vbox to allow spacing between lists. | |
| 160 GtkWidget* list_content = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); | |
| 161 | |
| 162 GtkWidget* label = gtk_label_new(i->title.c_str()); | |
| 163 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
| 164 GtkWidget* label_box = gtk_hbox_new(FALSE, 0); | |
| 165 gtk_box_pack_start(GTK_BOX(label_box), label, FALSE, FALSE, 0); | |
| 166 gtk_box_pack_start(GTK_BOX(list_content), label_box, FALSE, FALSE, 0); | |
| 167 for (std::set<std::string>::const_iterator j = i->hosts.begin(); | |
| 168 j != i->hosts.end(); ++j) { | |
| 169 gtk_box_pack_start(GTK_BOX(list_content), | |
| 170 gtk_util::IndentWidget(gtk_util::CreateBoldLabel(*j)), | |
| 171 FALSE, FALSE, 0); | |
| 172 } | |
| 173 gtk_box_pack_start(GTK_BOX(bubble_content), list_content, FALSE, FALSE, | |
| 174 gtk_util::kControlSpacing); | |
| 175 } | |
| 176 | |
| 177 if (!content.clear_link.empty()) { | |
| 178 GtkWidget* clear_link_box = gtk_hbox_new(FALSE, 0); | |
| 179 GtkWidget* clear_link = gtk_chrome_link_button_new( | |
| 180 content.clear_link.c_str()); | |
| 181 g_signal_connect(clear_link, "clicked", G_CALLBACK(OnClearLinkClicked), | |
| 182 this); | |
| 183 gtk_box_pack_start(GTK_BOX(clear_link_box), clear_link, FALSE, FALSE, 0); | |
| 184 gtk_box_pack_start(GTK_BOX(bubble_content), clear_link_box, | |
| 185 FALSE, FALSE, 0); | |
| 186 gtk_box_pack_start(GTK_BOX(bubble_content), gtk_hseparator_new(), | |
| 187 FALSE, FALSE, 0); | |
| 188 } | |
| 189 | |
| 153 GtkWidget* bottom_box = gtk_hbox_new(FALSE, 0); | 190 GtkWidget* bottom_box = gtk_hbox_new(FALSE, 0); |
| 154 | 191 |
| 155 GtkWidget* manage_link = gtk_chrome_link_button_new( | 192 GtkWidget* manage_link = gtk_chrome_link_button_new( |
| 156 content_setting_bubble_model_->bubble_content().manage_link.c_str()); | 193 content.manage_link.c_str()); |
| 157 g_signal_connect(manage_link, "clicked", G_CALLBACK(OnManageLinkClicked), | 194 g_signal_connect(manage_link, "clicked", G_CALLBACK(OnManageLinkClicked), |
| 158 this); | 195 this); |
| 159 gtk_box_pack_start(GTK_BOX(bottom_box), manage_link, FALSE, FALSE, 0); | 196 gtk_box_pack_start(GTK_BOX(bottom_box), manage_link, FALSE, FALSE, 0); |
| 160 | 197 |
| 161 GtkWidget* button = gtk_button_new_with_label( | 198 GtkWidget* button = gtk_button_new_with_label( |
| 162 l10n_util::GetStringUTF8(IDS_DONE).c_str()); | 199 l10n_util::GetStringUTF8(IDS_DONE).c_str()); |
| 163 g_signal_connect(button, "clicked", G_CALLBACK(OnCloseButtonClicked), this); | 200 g_signal_connect(button, "clicked", G_CALLBACK(OnCloseButtonClicked), this); |
| 164 gtk_box_pack_end(GTK_BOX(bottom_box), button, FALSE, FALSE, 0); | 201 gtk_box_pack_end(GTK_BOX(bottom_box), button, FALSE, FALSE, 0); |
| 165 | 202 |
| 166 gtk_box_pack_start(GTK_BOX(bubble_content), bottom_box, FALSE, FALSE, 0); | 203 gtk_box_pack_start(GTK_BOX(bubble_content), bottom_box, FALSE, FALSE, 0); |
| 204 gtk_widget_grab_focus(bottom_box); | |
| 205 gtk_widget_grab_focus(button); | |
|
Evan Stade
2013/09/09 20:43:18
why are these two calls both necessary?
| |
| 167 | 206 |
| 168 InfoBubbleGtk::ArrowLocationGtk arrow_location = | 207 InfoBubbleGtk::ArrowLocationGtk arrow_location = |
| 169 !base::i18n::IsRTL() ? | 208 !base::i18n::IsRTL() ? |
| 170 InfoBubbleGtk::ARROW_LOCATION_TOP_RIGHT : | 209 InfoBubbleGtk::ARROW_LOCATION_TOP_RIGHT : |
| 171 InfoBubbleGtk::ARROW_LOCATION_TOP_LEFT; | 210 InfoBubbleGtk::ARROW_LOCATION_TOP_LEFT; |
| 172 info_bubble_ = InfoBubbleGtk::Show( | 211 info_bubble_ = InfoBubbleGtk::Show( |
| 173 toplevel_window_, | 212 toplevel_window_, |
| 174 bounds_, | 213 bounds_, |
| 175 bubble_content, | 214 bubble_content, |
| 176 arrow_location, | 215 arrow_location, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 bubble->Close(); | 271 bubble->Close(); |
| 233 } | 272 } |
| 234 | 273 |
| 235 // static | 274 // static |
| 236 void ContentSettingBubbleGtk::OnManageLinkClicked( | 275 void ContentSettingBubbleGtk::OnManageLinkClicked( |
| 237 GtkButton* button, | 276 GtkButton* button, |
| 238 ContentSettingBubbleGtk* bubble) { | 277 ContentSettingBubbleGtk* bubble) { |
| 239 bubble->content_setting_bubble_model_->OnManageLinkClicked(); | 278 bubble->content_setting_bubble_model_->OnManageLinkClicked(); |
| 240 bubble->Close(); | 279 bubble->Close(); |
| 241 } | 280 } |
| 281 | |
| 282 void ContentSettingBubbleGtk::OnClearLinkClicked( | |
| 283 GtkButton* button, | |
| 284 ContentSettingBubbleGtk* bubble) { | |
| 285 bubble->content_setting_bubble_model_->OnClearLinkClicked(); | |
| 286 bubble->Close(); | |
| 287 } | |
| OLD | NEW |