Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.cc

Issue 10918275: [gtk] website settings bubble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fin Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/website_settings/website_settings_popup_gtk.h" 5 #include "chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/certificate_viewer.h" 10 #include "chrome/browser/certificate_viewer.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_list.h" 12 #include "chrome/browser/ui/browser_list.h"
13 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" 13 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h"
14 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 14 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
15 #include "chrome/browser/ui/gtk/collected_cookies_gtk.h" 15 #include "chrome/browser/ui/gtk/collected_cookies_gtk.h"
16 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" 16 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
17 #include "chrome/browser/ui/gtk/gtk_util.h" 17 #include "chrome/browser/ui/gtk/gtk_util.h"
18 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 18 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
19 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" 19 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h"
20 #include "chrome/browser/ui/gtk/nine_box.h"
20 #include "chrome/browser/ui/gtk/website_settings/permission_selector.h" 21 #include "chrome/browser/ui/gtk/website_settings/permission_selector.h"
21 #include "chrome/browser/ui/tab_contents/tab_contents.h" 22 #include "chrome/browser/ui/tab_contents/tab_contents.h"
22 #include "chrome/browser/ui/website_settings/website_settings.h" 23 #include "chrome/browser/ui/website_settings/website_settings.h"
23 #include "chrome/browser/ui/website_settings/website_settings_utils.h" 24 #include "chrome/browser/ui/website_settings/website_settings_utils.h"
25 #include "chrome/common/chrome_notification_types.h"
24 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
25 #include "content/public/browser/cert_store.h" 27 #include "content/public/browser/cert_store.h"
28 #include "content/public/browser/notification_service.h"
26 #include "content/public/browser/user_metrics.h" 29 #include "content/public/browser/user_metrics.h"
27 #include "googleurl/src/gurl.h" 30 #include "googleurl/src/gurl.h"
28 #include "grit/chromium_strings.h" 31 #include "grit/chromium_strings.h"
29 #include "grit/generated_resources.h" 32 #include "grit/generated_resources.h"
30 #include "grit/locale_settings.h" 33 #include "grit/locale_settings.h"
31 #include "grit/theme_resources.h" 34 #include "grit/theme_resources.h"
32 #include "grit/ui_resources.h" 35 #include "grit/ui_resources.h"
33 #include "ui/base/gtk/gtk_hig_constants.h" 36 #include "ui/base/gtk/gtk_hig_constants.h"
34 #include "ui/base/l10n/l10n_util.h" 37 #include "ui/base/l10n/l10n_util.h"
35 #include "ui/base/resource/resource_bundle.h" 38 #include "ui/base/resource/resource_bundle.h"
39 #include "ui/gfx/image/cairo_cached_surface.h"
40 #include "ui/gfx/image/image.h"
36 41
37 using content::OpenURLParams; 42 using content::OpenURLParams;
38 43
39 namespace { 44 namespace {
40 45
41 // The width of the popup. 46 // The width of the popup.
42 const int kPopupWidth = 400; 47 const int kPopupWidth = 400;
43 48
49 // Spacing between consecutive tabs in the tabstrip.
50 const int kInterTabSpacing = 2;
51
52 // Spacing between start of tab and tab text.
53 const int kTabTextHorizontalMargin = 12;
54
55 // The vertical lift of the tab's text off the bottom of the tab.
56 const int kTabTextBaseline = 4;
57
44 // The max width of the text labels on the connection tab. 58 // The max width of the text labels on the connection tab.
45 const int kConnectionTabTextWidth = 300; 59 const int kConnectionTabTextWidth = 300;
46 60
47 // The padding used for sections on the connection tab.
48 const int kConnectionTabSectionPadding = 10;
49
50 // The background color of the tabs if a theme other than the native GTK theme
51 // is selected.
52 const GdkColor kBackgroundColor = GDK_COLOR_RGB(0xff, 0xff, 0xff);
53 // The text color of the site identity status label for websites with a 61 // The text color of the site identity status label for websites with a
54 // verified identity. 62 // verified identity.
55 const GdkColor kGdkGreen = GDK_COLOR_RGB(0x29, 0x8a, 0x27); 63 const GdkColor kGdkGreen = GDK_COLOR_RGB(0x29, 0x8a, 0x27);
56 64
57 GtkWidget* CreateTextLabel(const std::string& text, 65 GtkWidget* CreateTextLabel(const std::string& text,
58 int width, 66 int width,
59 GtkThemeService* theme_service) { 67 GtkThemeService* theme_service,
60 GtkWidget* label = theme_service->BuildLabel(text, ui::kGdkBlack); 68 const GdkColor& color) {
69 GtkWidget* label = theme_service->BuildLabel(text, color);
61 if (width > 0) 70 if (width > 0)
62 gtk_util::SetLabelWidth(label, width); 71 gtk_util::SetLabelWidth(label, width);
63 gtk_label_set_selectable(GTK_LABEL(label), TRUE);
64 gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD_CHAR); 72 gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD_CHAR);
65 return label; 73 return label;
66 } 74 }
67 75
68 void ClearContainer(GtkWidget* container) { 76 void ClearContainer(GtkWidget* container) {
69 GList* child = gtk_container_get_children(GTK_CONTAINER(container)); 77 GList* child = gtk_container_get_children(GTK_CONTAINER(container));
70 while (child) { 78 while (child) {
71 gtk_container_remove(GTK_CONTAINER(container), GTK_WIDGET(child->data)); 79 gtk_container_remove(GTK_CONTAINER(container), GTK_WIDGET(child->data));
72 child = child->next; 80 child = child->next;
73 } 81 }
74 } 82 }
75 83
76 void SetConnectionSection(GtkWidget* section_box, 84 void SetConnectionSection(GtkWidget* section_box,
77 const gfx::Image& icon, 85 const gfx::Image& icon,
78 GtkWidget* content_box) { 86 GtkWidget* content_box) {
79 DCHECK(section_box); 87 DCHECK(section_box);
80 ClearContainer(section_box); 88 ClearContainer(section_box);
81 gtk_container_set_border_width(GTK_CONTAINER(section_box), 89 gtk_container_set_border_width(GTK_CONTAINER(section_box),
82 kConnectionTabSectionPadding); 90 ui::kContentAreaBorder);
83 91
84 GtkWidget* hbox = gtk_hbox_new(FALSE, ui::kControlSpacing); 92 GtkWidget* hbox = gtk_hbox_new(FALSE, ui::kControlSpacing);
85 93
86 GdkPixbuf* pixbuf = icon.ToGdkPixbuf(); 94 GdkPixbuf* pixbuf = icon.ToGdkPixbuf();
87 GtkWidget* image = gtk_image_new_from_pixbuf(pixbuf); 95 GtkWidget* image = gtk_image_new_from_pixbuf(pixbuf);
88 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); 96 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
89 gtk_misc_set_alignment(GTK_MISC(image), 0, 0); 97 gtk_misc_set_alignment(GTK_MISC(image), 0, 0);
90 98
91 gtk_box_pack_start(GTK_BOX(hbox), content_box, TRUE, TRUE, 0); 99 gtk_box_pack_start(GTK_BOX(hbox), content_box, TRUE, TRUE, 0);
92 100
93 gtk_box_pack_start(GTK_BOX(section_box), hbox, TRUE, TRUE, 0); 101 gtk_box_pack_start(GTK_BOX(section_box), hbox, TRUE, TRUE, 0);
94 gtk_widget_show_all(section_box); 102 gtk_widget_show_all(section_box);
95 } 103 }
96 104
97 GtkWidget* CreatePermissionTabSection(std::string section_title, 105 GtkWidget* CreatePermissionTabSection(std::string section_title,
98 GtkWidget* section_content, 106 GtkWidget* section_content,
99 GtkThemeService* theme_service) { 107 GtkThemeService* theme_service) {
100 GtkWidget* section_box = gtk_vbox_new(FALSE, ui::kControlSpacing); 108 GtkWidget* section_box = gtk_vbox_new(FALSE, ui::kControlSpacing);
101 109
102 // Add Section title 110 // Add Section title
103 GtkWidget* title_hbox = gtk_hbox_new(FALSE, ui::kControlSpacing); 111 GtkWidget* title_hbox = gtk_hbox_new(FALSE, ui::kControlSpacing);
104 112
105 GtkWidget* label = theme_service->BuildLabel(section_title, ui::kGdkBlack); 113 GtkWidget* label = theme_service->BuildLabel(section_title, ui::kGdkBlack);
106 gtk_label_set_selectable(GTK_LABEL(label), TRUE);
107 PangoAttrList* attributes = pango_attr_list_new(); 114 PangoAttrList* attributes = pango_attr_list_new();
108 pango_attr_list_insert(attributes, 115 pango_attr_list_insert(attributes,
109 pango_attr_weight_new(PANGO_WEIGHT_BOLD)); 116 pango_attr_weight_new(PANGO_WEIGHT_BOLD));
110 gtk_label_set_attributes(GTK_LABEL(label), attributes); 117 gtk_label_set_attributes(GTK_LABEL(label), attributes);
111 pango_attr_list_unref(attributes); 118 pango_attr_list_unref(attributes);
112 gtk_box_pack_start(GTK_BOX(section_box), title_hbox, FALSE, FALSE, 0); 119 gtk_box_pack_start(GTK_BOX(section_box), title_hbox, FALSE, FALSE, 0);
113 120
114 gtk_box_pack_start(GTK_BOX(title_hbox), label, FALSE, FALSE, 0); 121 gtk_box_pack_start(GTK_BOX(title_hbox), label, FALSE, FALSE, 0);
115 122
116 // Add section content 123 // Add section content
(...skipping 13 matching lines...) Expand all
130 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE; 137 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE;
131 138
132 // The popup bubble container. 139 // The popup bubble container.
133 BubbleGtk* bubble_; 140 BubbleGtk* bubble_;
134 141
135 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupGtk); 142 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupGtk);
136 }; 143 };
137 144
138 InternalPageInfoPopupGtk::InternalPageInfoPopupGtk( 145 InternalPageInfoPopupGtk::InternalPageInfoPopupGtk(
139 gfx::NativeWindow parent, Profile* profile) { 146 gfx::NativeWindow parent, Profile* profile) {
140 GtkWidget* contents = gtk_hbox_new(FALSE, ui::kContentAreaSpacing); 147 GtkWidget* contents = gtk_hbox_new(FALSE, ui::kLabelSpacing);
141 gtk_container_set_border_width(GTK_CONTAINER(contents), 148 gtk_container_set_border_width(GTK_CONTAINER(contents),
142 ui::kContentAreaBorder); 149 ui::kContentAreaBorder);
143 // Add the popup icon. 150 // Add the popup icon.
144 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 151 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
145 GdkPixbuf* pixbuf = rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_26).ToGdkPixbuf(); 152 GdkPixbuf* pixbuf = rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_26).ToGdkPixbuf();
146 GtkWidget* image = gtk_image_new_from_pixbuf(pixbuf); 153 GtkWidget* image = gtk_image_new_from_pixbuf(pixbuf);
147 gtk_box_pack_start(GTK_BOX(contents), image, FALSE, FALSE, 0); 154 gtk_box_pack_start(GTK_BOX(contents), image, FALSE, FALSE, 0);
148 gtk_misc_set_alignment(GTK_MISC(image), 0, 0); 155 gtk_misc_set_alignment(GTK_MISC(image), 0, 0);
149 156
150 // Add the popup text. 157 // Add the popup text.
151 GtkThemeService* theme_service = GtkThemeService::GetFrom(profile); 158 GtkThemeService* theme_service = GtkThemeService::GetFrom(profile);
152 GtkWidget* label = theme_service->BuildLabel( 159 GtkWidget* label = theme_service->BuildLabel(
153 l10n_util::GetStringUTF8(IDS_PAGE_INFO_INTERNAL_PAGE), ui::kGdkBlack); 160 l10n_util::GetStringUTF8(IDS_PAGE_INFO_INTERNAL_PAGE), ui::kGdkBlack);
154 gtk_label_set_selectable(GTK_LABEL(label), FALSE);
155 PangoAttrList* attributes = pango_attr_list_new(); 161 PangoAttrList* attributes = pango_attr_list_new();
156 pango_attr_list_insert(attributes, 162 pango_attr_list_insert(attributes,
157 pango_attr_weight_new(PANGO_WEIGHT_BOLD)); 163 pango_attr_weight_new(PANGO_WEIGHT_BOLD));
158 gtk_box_pack_start(GTK_BOX(contents), label, FALSE, FALSE, 0); 164 gtk_box_pack_start(GTK_BOX(contents), label, FALSE, FALSE, 0);
159 165
160 gtk_widget_show_all(contents); 166 gtk_widget_show_all(contents);
161 167
162 // Create the bubble. 168 // Create the bubble.
163 BubbleGtk::ArrowLocationGtk arrow_location = base::i18n::IsRTL() ? 169 BubbleGtk::ArrowLocationGtk arrow_location = base::i18n::IsRTL() ?
164 BubbleGtk::ARROW_LOCATION_TOP_RIGHT : 170 BubbleGtk::ARROW_LOCATION_TOP_RIGHT :
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 connection_contents_(NULL), 227 connection_contents_(NULL),
222 first_visit_contents_(NULL), 228 first_visit_contents_(NULL),
223 notebook_(NULL), 229 notebook_(NULL),
224 presenter_(NULL) { 230 presenter_(NULL) {
225 BrowserWindowGtk* browser_window = 231 BrowserWindowGtk* browser_window =
226 BrowserWindowGtk::GetBrowserWindowForNativeWindow(parent); 232 BrowserWindowGtk::GetBrowserWindowForNativeWindow(parent);
227 browser_ = browser_window->browser(); 233 browser_ = browser_window->browser();
228 anchor_ = browser_window-> 234 anchor_ = browser_window->
229 GetToolbar()->GetLocationBarView()->location_icon_widget(); 235 GetToolbar()->GetLocationBarView()->location_icon_widget();
230 236
237 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
238 content::Source<ThemeService>(theme_service_));
239
231 InitContents(); 240 InitContents();
232 241
233 BubbleGtk::ArrowLocationGtk arrow_location = base::i18n::IsRTL() ? 242 BubbleGtk::ArrowLocationGtk arrow_location = base::i18n::IsRTL() ?
234 BubbleGtk::ARROW_LOCATION_TOP_RIGHT : 243 BubbleGtk::ARROW_LOCATION_TOP_RIGHT :
235 BubbleGtk::ARROW_LOCATION_TOP_LEFT; 244 BubbleGtk::ARROW_LOCATION_TOP_LEFT;
236 bubble_ = BubbleGtk::Show(anchor_, 245 bubble_ = BubbleGtk::Show(anchor_,
237 NULL, // |rect| 246 NULL, // |rect|
238 contents_, 247 contents_,
239 arrow_location, 248 arrow_location,
240 BubbleGtk::MATCH_SYSTEM_THEME | 249 BubbleGtk::MATCH_SYSTEM_THEME |
(...skipping 20 matching lines...) Expand all
261 bool closed_by_escape) { 270 bool closed_by_escape) {
262 if (presenter_.get()) { 271 if (presenter_.get()) {
263 presenter_->OnUIClosing(); 272 presenter_->OnUIClosing();
264 presenter_.reset(); 273 presenter_.reset();
265 } 274 }
266 delete this; 275 delete this;
267 } 276 }
268 277
269 void WebsiteSettingsPopupGtk::InitContents() { 278 void WebsiteSettingsPopupGtk::InitContents() {
270 if (!contents_) { 279 if (!contents_) {
271 contents_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); 280 contents_ = gtk_vbox_new(FALSE, 0);
272 gtk_container_set_border_width(GTK_CONTAINER(contents_),
273 ui::kContentAreaBorder);
274 } else { 281 } else {
275 gtk_util::RemoveAllChildren(contents_); 282 gtk_util::RemoveAllChildren(contents_);
276 } 283 }
277 284
278 // Create popup header. 285 // Create popup header.
279 header_box_ = gtk_vbox_new(FALSE, ui::kControlSpacing); 286 header_box_ = gtk_vbox_new(FALSE, ui::kControlSpacing);
280 gtk_box_pack_start(GTK_BOX(contents_), header_box_, FALSE, FALSE, 0); 287 gtk_box_pack_start(GTK_BOX(contents_), header_box_, FALSE, FALSE, 0);
288 gtk_container_set_border_width(GTK_CONTAINER(header_box_),
289 ui::kContentAreaBorder);
281 290
282 // Create the container for the contents of the permissions tab. 291 // Create the container for the contents of the permissions tab.
283 GtkWidget* permission_tab_contents = gtk_vbox_new(FALSE, ui::kControlSpacing); 292 GtkWidget* permission_tab_contents =
284 gtk_container_set_border_width(GTK_CONTAINER(permission_tab_contents), 10); 293 gtk_vbox_new(FALSE, ui::kContentAreaSpacing);
294 gtk_container_set_border_width(GTK_CONTAINER(permission_tab_contents),
295 ui::kContentAreaBorder);
285 cookies_section_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); 296 cookies_section_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing);
286 std::string title = l10n_util::GetStringUTF8( 297 std::string title = l10n_util::GetStringUTF8(
287 IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA); 298 IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA);
288 gtk_box_pack_start(GTK_BOX(permission_tab_contents), 299 gtk_box_pack_start(GTK_BOX(permission_tab_contents),
289 CreatePermissionTabSection(title, 300 CreatePermissionTabSection(title,
290 cookies_section_contents_, 301 cookies_section_contents_,
291 theme_service_), 302 theme_service_),
292 FALSE, FALSE, 0); 303 FALSE, FALSE, 0);
293 gtk_box_pack_start(GTK_BOX(permission_tab_contents),
294 gtk_hseparator_new(),
295 FALSE, FALSE, 0);
296 permissions_section_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); 304 permissions_section_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing);
297 title = l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS); 305 title = l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS);
298 gtk_box_pack_start(GTK_BOX(permission_tab_contents), 306 gtk_box_pack_start(GTK_BOX(permission_tab_contents),
299 CreatePermissionTabSection(title, 307 CreatePermissionTabSection(title,
300 permissions_section_contents_, 308 permissions_section_contents_,
301 theme_service_), 309 theme_service_),
302 FALSE, FALSE, 0); 310 FALSE, FALSE, 0);
303 311
304 // Create the container for the contents of the identity tab. 312 // Create the container for the contents of the connection tab.
305 GtkWidget* connection_tab = gtk_vbox_new(FALSE, ui::kControlSpacing); 313 GtkWidget* connection_tab = gtk_vbox_new(FALSE, 0);
306 identity_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); 314 identity_contents_ = gtk_vbox_new(FALSE, 0);
307 gtk_box_pack_start(GTK_BOX(connection_tab), identity_contents_, FALSE, FALSE, 315 gtk_box_pack_start(GTK_BOX(connection_tab), identity_contents_, FALSE, FALSE,
308 0); 316 0);
309 gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE, 317 gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE,
310 FALSE, 0); 318 FALSE, 0);
311 connection_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); 319 connection_contents_ = gtk_vbox_new(FALSE, 0);
312 gtk_box_pack_start(GTK_BOX(connection_tab), connection_contents_, FALSE, 320 gtk_box_pack_start(GTK_BOX(connection_tab), connection_contents_, FALSE,
313 FALSE, 0); 321 FALSE, 0);
314 gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE, 322 gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE,
315 FALSE, 0); 323 FALSE, 0);
316 first_visit_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); 324 first_visit_contents_ = gtk_vbox_new(FALSE, 0);
317 gtk_box_pack_start(GTK_BOX(connection_tab), first_visit_contents_, FALSE, 325 gtk_box_pack_start(GTK_BOX(connection_tab), first_visit_contents_, FALSE,
318 FALSE, 0); 326 FALSE, 0);
319 gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE, 327 gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE,
320 FALSE, 0); 328 FALSE, 0);
321 329
322 GtkWidget* help_link = theme_service_->BuildChromeLinkButton( 330 GtkWidget* help_link = theme_service_->BuildChromeLinkButton(
323 l10n_util::GetStringUTF8(IDS_PAGE_INFO_HELP_CENTER_LINK)); 331 l10n_util::GetStringUTF8(IDS_PAGE_INFO_HELP_CENTER_LINK));
324 GtkWidget* help_link_hbox = gtk_hbox_new(FALSE, 0); 332 GtkWidget* help_link_hbox = gtk_hbox_new(FALSE, 0);
325 gtk_container_set_border_width(GTK_CONTAINER(help_link_hbox), 333 gtk_container_set_border_width(GTK_CONTAINER(help_link_hbox),
326 kConnectionTabSectionPadding); 334 ui::kContentAreaBorder);
327 gtk_box_pack_start(GTK_BOX(help_link_hbox), help_link, FALSE, FALSE, 0); 335 gtk_box_pack_start(GTK_BOX(help_link_hbox), help_link, FALSE, FALSE, 0);
328 gtk_box_pack_start(GTK_BOX(connection_tab), help_link_hbox, FALSE, FALSE, 0); 336 gtk_box_pack_start(GTK_BOX(connection_tab), help_link_hbox, FALSE, FALSE, 0);
329 g_signal_connect(help_link, "clicked", 337 g_signal_connect(help_link, "clicked",
330 G_CALLBACK(OnHelpLinkClickedThunk), this); 338 G_CALLBACK(OnHelpLinkClickedThunk), this);
331 339
340 // Create tabstrip (used only for Chrome-theme mode).
341 GtkWidget* tabstrip = gtk_hbox_new(FALSE, kInterTabSpacing);
342 tabstrip_alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
343 gtk_alignment_set_padding(GTK_ALIGNMENT(tabstrip_alignment_), 0, 0,
344 ui::kContentAreaBorder, ui::kContentAreaBorder);
345 int tab_height = ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
346 IDR_WEBSITE_SETTINGS_TAB_LEFT2).ToImageSkia()->height();
347 gtk_widget_set_size_request(tabstrip_alignment_, -1, tab_height);
348 g_signal_connect(tabstrip_alignment_, "expose-event",
349 G_CALLBACK(&OnTabstripExposeThunk), this);
350 gtk_container_add(GTK_CONTAINER(tabstrip_alignment_), tabstrip);
351 gtk_box_pack_start(GTK_BOX(contents_), tabstrip_alignment_, FALSE, FALSE, 0);
352
353 gtk_box_pack_start(GTK_BOX(tabstrip),
354 BuildTab(IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS),
355 FALSE, FALSE, 0);
356 gtk_box_pack_start(GTK_BOX(tabstrip),
357 BuildTab(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION),
358 FALSE, FALSE, 0);
359
332 // Create tab container and add all tabs. 360 // Create tab container and add all tabs.
333 notebook_ = gtk_notebook_new(); 361 notebook_ = gtk_notebook_new();
334 if (theme_service_->UsingNativeTheme()) 362 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(notebook_), 0);
335 gtk_widget_modify_bg(notebook_, GTK_STATE_NORMAL, NULL);
336 else
337 gtk_widget_modify_bg(notebook_, GTK_STATE_NORMAL, &kBackgroundColor);
338 363
339 GtkWidget* label = theme_service_->BuildLabel( 364 GtkWidget* label = gtk_label_new(l10n_util::GetStringUTF8(
340 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS), 365 IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS).c_str());
341 ui::kGdkBlack); 366 gtk_misc_set_padding(GTK_MISC(label), kTabTextHorizontalMargin, 0);
342 gtk_widget_show(label);
343 gtk_notebook_insert_page(GTK_NOTEBOOK(notebook_), permission_tab_contents, 367 gtk_notebook_insert_page(GTK_NOTEBOOK(notebook_), permission_tab_contents,
344 label, TAB_ID_PERMISSIONS); 368 label, TAB_ID_PERMISSIONS);
345 369
346 label = theme_service_->BuildLabel( 370 label = gtk_label_new(l10n_util::GetStringUTF8(
347 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION), 371 IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION).c_str());
348 ui::kGdkBlack); 372 gtk_misc_set_padding(GTK_MISC(label), kTabTextHorizontalMargin, 0);
349 gtk_widget_show(label);
350 gtk_notebook_insert_page(GTK_NOTEBOOK(notebook_), connection_tab, label, 373 gtk_notebook_insert_page(GTK_NOTEBOOK(notebook_), connection_tab, label,
351 TAB_ID_CONNECTION); 374 TAB_ID_CONNECTION);
352 375
353 DCHECK_EQ(gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook_)), NUM_TAB_IDS); 376 DCHECK_EQ(gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook_)), NUM_TAB_IDS);
354 377
355 gtk_box_pack_start(GTK_BOX(contents_), notebook_, FALSE, FALSE, 0); 378 gtk_box_pack_start(GTK_BOX(contents_), notebook_, FALSE, FALSE, 0);
379
380 theme_service_->InitThemesFor(this);
356 gtk_widget_show_all(contents_); 381 gtk_widget_show_all(contents_);
357 } 382 }
358 383
384 GtkWidget* WebsiteSettingsPopupGtk::BuildTab(int ids) {
385 GtkWidget* tab = gtk_event_box_new();
386 gtk_event_box_set_visible_window(GTK_EVENT_BOX(tab), FALSE);
387 GtkWidget* label = gtk_label_new(l10n_util::GetStringUTF8(ids).c_str());
388 gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &ui::kGdkBlack);
389 gtk_misc_set_padding(GTK_MISC(label),
390 kTabTextHorizontalMargin, kTabTextBaseline);
391 gtk_misc_set_alignment(GTK_MISC(label), 0.5, 1.0);
392 gtk_container_add(GTK_CONTAINER(tab), label);
393 g_signal_connect(tab, "button-press-event",
394 G_CALLBACK(&OnTabButtonPressThunk), this);
395 g_signal_connect(tab, "expose-event",
396 G_CALLBACK(&OnTabExposeThunk), this);
397 return tab;
398 }
399
400 void WebsiteSettingsPopupGtk::Observe(
401 int type,
402 const content::NotificationSource& source,
403 const content::NotificationDetails& details) {
404 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type);
405
406 if (theme_service_->UsingNativeTheme()) {
407 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook_), TRUE);
408 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook_), TRUE);
409 gtk_widget_set_no_show_all(tabstrip_alignment_, TRUE);
410 } else {
411 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook_), FALSE);
412 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook_), FALSE);
413 gtk_widget_set_no_show_all(tabstrip_alignment_, FALSE);
414 gtk_widget_show_all(tabstrip_alignment_);
415 }
416 }
417
359 void WebsiteSettingsPopupGtk::OnPermissionChanged( 418 void WebsiteSettingsPopupGtk::OnPermissionChanged(
360 PermissionSelector* selector) { 419 PermissionSelector* selector) {
361 presenter_->OnSitePermissionChanged(selector->GetType(), 420 presenter_->OnSitePermissionChanged(selector->GetType(),
362 selector->GetSetting()); 421 selector->GetSetting());
363 } 422 }
364 423
365 void WebsiteSettingsPopupGtk::OnComboboxShown() { 424 void WebsiteSettingsPopupGtk::OnComboboxShown() {
366 bubble_->HandlePointerAndKeyboardUngrabbedByContent(); 425 bubble_->HandlePointerAndKeyboardUngrabbedByContent();
367 } 426 }
368 427
(...skipping 17 matching lines...) Expand all
386 gtk_box_pack_start(GTK_BOX(cookies_info), image, FALSE, FALSE, 0); 445 gtk_box_pack_start(GTK_BOX(cookies_info), image, FALSE, FALSE, 0);
387 446
388 // Add the allowed and blocked cookies counts to the cookies info box. 447 // Add the allowed and blocked cookies counts to the cookies info box.
389 std::string info_str = l10n_util::GetStringFUTF8( 448 std::string info_str = l10n_util::GetStringFUTF8(
390 IDS_WEBSITE_SETTINGS_SITE_DATA_STATS_LINE, 449 IDS_WEBSITE_SETTINGS_SITE_DATA_STATS_LINE,
391 UTF8ToUTF16(it->cookie_source), 450 UTF8ToUTF16(it->cookie_source),
392 base::IntToString16(it->allowed), 451 base::IntToString16(it->allowed),
393 base::IntToString16(it->blocked)); 452 base::IntToString16(it->blocked));
394 453
395 GtkWidget* info = theme_service_->BuildLabel(info_str, ui::kGdkBlack); 454 GtkWidget* info = theme_service_->BuildLabel(info_str, ui::kGdkBlack);
396 gtk_label_set_selectable(GTK_LABEL(info), TRUE);
397 const int kPadding = 4; 455 const int kPadding = 4;
398 gtk_box_pack_start(GTK_BOX(cookies_info), info, FALSE, FALSE, kPadding); 456 gtk_box_pack_start(GTK_BOX(cookies_info), info, FALSE, FALSE, kPadding);
399 457
400 // Add the cookies info box to the section box. 458 // Add the cookies info box to the section box.
401 gtk_box_pack_start(GTK_BOX(cookies_section_contents_), 459 gtk_box_pack_start(GTK_BOX(cookies_section_contents_),
402 cookies_info, 460 cookies_info,
403 FALSE, FALSE, 0); 461 FALSE, FALSE, 0);
404 } 462 }
405 463
406 // Create row with links for cookie settings and for the cookies dialog. 464 // Create row with links for cookie settings and for the cookies dialog.
(...skipping 21 matching lines...) Expand all
428 GtkWidget* hbox = gtk_hbox_new(FALSE, 0); 486 GtkWidget* hbox = gtk_hbox_new(FALSE, 0);
429 GtkWidget* identity_label = theme_service_->BuildLabel( 487 GtkWidget* identity_label = theme_service_->BuildLabel(
430 identity_info.site_identity, ui::kGdkBlack); 488 identity_info.site_identity, ui::kGdkBlack);
431 gtk_label_set_selectable(GTK_LABEL(identity_label), TRUE); 489 gtk_label_set_selectable(GTK_LABEL(identity_label), TRUE);
432 PangoAttrList* attributes = pango_attr_list_new(); 490 PangoAttrList* attributes = pango_attr_list_new();
433 pango_attr_list_insert(attributes, 491 pango_attr_list_insert(attributes,
434 pango_attr_weight_new(PANGO_WEIGHT_BOLD)); 492 pango_attr_weight_new(PANGO_WEIGHT_BOLD));
435 gtk_label_set_attributes(GTK_LABEL(identity_label), attributes); 493 gtk_label_set_attributes(GTK_LABEL(identity_label), attributes);
436 pango_attr_list_unref(attributes); 494 pango_attr_list_unref(attributes);
437 gtk_box_pack_start(GTK_BOX(hbox), identity_label, FALSE, FALSE, 0); 495 gtk_box_pack_start(GTK_BOX(hbox), identity_label, FALSE, FALSE, 0);
438 GtkWidget* close_button = gtk_button_new(); 496 close_button_.reset(CustomDrawButton::CloseButton(theme_service_));
439 gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE); 497 g_signal_connect(close_button_->widget(), "clicked",
440 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
441 GdkPixbuf* pixbuf = rb.GetNativeImageNamed(IDR_CLOSE_BAR_H).ToGdkPixbuf();
442 GtkWidget* image = gtk_image_new_from_pixbuf(pixbuf);
443 gtk_button_set_image(GTK_BUTTON(close_button), image);
444 g_signal_connect(close_button, "clicked",
445 G_CALLBACK(OnCloseButtonClickedThunk), this); 498 G_CALLBACK(OnCloseButtonClickedThunk), this);
446 gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0); 499 gtk_box_pack_start(GTK_BOX(hbox), close_button_->widget(), FALSE, FALSE, 0);
447 int label_width = kPopupWidth - gdk_pixbuf_get_width(pixbuf); 500 int label_width = kPopupWidth - close_button_->SurfaceWidth();
448 gtk_util::SetLabelWidth(identity_label, label_width); 501 gtk_util::SetLabelWidth(identity_label, label_width);
449 gtk_box_pack_start(GTK_BOX(header_box_), hbox, FALSE, FALSE, 0); 502 gtk_box_pack_start(GTK_BOX(header_box_), hbox, FALSE, FALSE, 0);
450 503
451 std::string identity_status_text; 504 std::string identity_status_text;
452 const GdkColor* color = 505 const GdkColor* color = &ui::kGdkBlack;
453 theme_service_->UsingNativeTheme() ? NULL : &ui::kGdkBlack;
454 506
455 switch (identity_info.identity_status) { 507 switch (identity_info.identity_status) {
456 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT: 508 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT:
457 case WebsiteSettings::SITE_IDENTITY_STATUS_DNSSEC_CERT: 509 case WebsiteSettings::SITE_IDENTITY_STATUS_DNSSEC_CERT:
458 case WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT: 510 case WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT:
459 identity_status_text = 511 identity_status_text =
460 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_IDENTITY_VERIFIED); 512 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_IDENTITY_VERIFIED);
461 if (!theme_service_->UsingNativeTheme()) 513 color = &kGdkGreen;
462 color = &kGdkGreen;
463 break; 514 break;
464 default: 515 default:
465 identity_status_text = 516 identity_status_text =
466 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_IDENTITY_NOT_VERIFIED); 517 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_IDENTITY_NOT_VERIFIED);
467 break; 518 break;
468 } 519 }
469 GtkWidget* status_label = 520 GtkWidget* status_label = CreateTextLabel(
470 CreateTextLabel(identity_status_text, kPopupWidth, theme_service_); 521 identity_status_text, kPopupWidth, theme_service_, *color);
471 gtk_widget_modify_fg(status_label, GTK_STATE_NORMAL, color);
472 gtk_box_pack_start( 522 gtk_box_pack_start(
473 GTK_BOX(header_box_), status_label, FALSE, FALSE, 0); 523 GTK_BOX(header_box_), status_label, FALSE, FALSE, 0);
474 gtk_widget_show_all(header_box_); 524 gtk_widget_show_all(header_box_);
475 525
476 // Create identity section. 526 // Create identity section.
477 GtkWidget* section_content = gtk_vbox_new(FALSE, ui::kControlSpacing); 527 GtkWidget* section_content = gtk_vbox_new(FALSE, ui::kControlSpacing);
478 GtkWidget* identity_description = 528 GtkWidget* identity_description =
479 CreateTextLabel(identity_info.identity_status_description, 529 CreateTextLabel(identity_info.identity_status_description,
480 kConnectionTabTextWidth, theme_service_); 530 kConnectionTabTextWidth, theme_service_, ui::kGdkBlack);
481 gtk_box_pack_start(GTK_BOX(section_content), identity_description, FALSE, 531 gtk_box_pack_start(GTK_BOX(section_content), identity_description, FALSE,
482 FALSE, 0); 532 FALSE, 0);
483 if (identity_info.cert_id) { 533 if (identity_info.cert_id) {
484 cert_id_ = identity_info.cert_id; 534 cert_id_ = identity_info.cert_id;
485 GtkWidget* view_cert_link = theme_service_->BuildChromeLinkButton( 535 GtkWidget* view_cert_link = theme_service_->BuildChromeLinkButton(
486 l10n_util::GetStringUTF8(IDS_PAGEINFO_CERT_INFO_BUTTON)); 536 l10n_util::GetStringUTF8(IDS_PAGEINFO_CERT_INFO_BUTTON));
487 g_signal_connect(view_cert_link, "clicked", 537 g_signal_connect(view_cert_link, "clicked",
488 G_CALLBACK(OnViewCertLinkClickedThunk), this); 538 G_CALLBACK(OnViewCertLinkClickedThunk), this);
489 GtkWidget* link_hbox = gtk_hbox_new(FALSE, 0); 539 GtkWidget* link_hbox = gtk_hbox_new(FALSE, 0);
490 gtk_box_pack_start(GTK_BOX(link_hbox), view_cert_link, 540 gtk_box_pack_start(GTK_BOX(link_hbox), view_cert_link,
491 FALSE, FALSE, 0); 541 FALSE, FALSE, 0);
492 gtk_box_pack_start(GTK_BOX(section_content), link_hbox, FALSE, FALSE, 0); 542 gtk_box_pack_start(GTK_BOX(section_content), link_hbox, FALSE, FALSE, 0);
493 } 543 }
494 SetConnectionSection( 544 SetConnectionSection(
495 identity_contents_, 545 identity_contents_,
496 WebsiteSettingsUI::GetIdentityIcon(identity_info.identity_status), 546 WebsiteSettingsUI::GetIdentityIcon(identity_info.identity_status),
497 section_content); 547 section_content);
498 548
499 // Create connection section. 549 // Create connection section.
500 GtkWidget* connection_description = 550 GtkWidget* connection_description =
501 CreateTextLabel(identity_info.connection_status_description, 551 CreateTextLabel(identity_info.connection_status_description,
502 kConnectionTabTextWidth, theme_service_); 552 kConnectionTabTextWidth, theme_service_, ui::kGdkBlack);
503 section_content = gtk_vbox_new(FALSE, ui::kControlSpacing); 553 section_content = gtk_vbox_new(FALSE, ui::kControlSpacing);
504 gtk_box_pack_start(GTK_BOX(section_content), connection_description, FALSE, 554 gtk_box_pack_start(GTK_BOX(section_content), connection_description, FALSE,
505 FALSE, 0); 555 FALSE, 0);
506 SetConnectionSection( 556 SetConnectionSection(
507 connection_contents_, 557 connection_contents_,
508 WebsiteSettingsUI::GetConnectionIcon(identity_info.connection_status), 558 WebsiteSettingsUI::GetConnectionIcon(identity_info.connection_status),
509 section_content); 559 section_content);
510 } 560 }
511 561
512 void WebsiteSettingsPopupGtk::SetFirstVisit(const string16& first_visit) { 562 void WebsiteSettingsPopupGtk::SetFirstVisit(const string16& first_visit) {
513 GtkWidget* titel = theme_service_->BuildLabel( 563 GtkWidget* title = theme_service_->BuildLabel(
514 l10n_util::GetStringUTF8(IDS_PAGE_INFO_SITE_INFO_TITLE), 564 l10n_util::GetStringUTF8(IDS_PAGE_INFO_SITE_INFO_TITLE),
515 ui::kGdkBlack); 565 ui::kGdkBlack);
516 gtk_label_set_selectable(GTK_LABEL(titel), TRUE);
517 PangoAttrList* attributes = pango_attr_list_new(); 566 PangoAttrList* attributes = pango_attr_list_new();
518 pango_attr_list_insert(attributes, 567 pango_attr_list_insert(attributes,
519 pango_attr_weight_new(PANGO_WEIGHT_BOLD)); 568 pango_attr_weight_new(PANGO_WEIGHT_BOLD));
520 gtk_label_set_attributes(GTK_LABEL(titel), attributes); 569 gtk_label_set_attributes(GTK_LABEL(title), attributes);
521 pango_attr_list_unref(attributes); 570 pango_attr_list_unref(attributes);
522 gtk_misc_set_alignment(GTK_MISC(titel), 0, 0); 571 gtk_misc_set_alignment(GTK_MISC(title), 0, 0);
523 572
524 GtkWidget* first_visit_label = CreateTextLabel(UTF16ToUTF8(first_visit), 573 GtkWidget* first_visit_label = CreateTextLabel(UTF16ToUTF8(first_visit),
525 kConnectionTabTextWidth, 574 kConnectionTabTextWidth,
526 theme_service_); 575 theme_service_,
576 ui::kGdkBlack);
527 GtkWidget* section_contents = gtk_vbox_new(FALSE, ui::kControlSpacing); 577 GtkWidget* section_contents = gtk_vbox_new(FALSE, ui::kControlSpacing);
528 gtk_box_pack_start(GTK_BOX(section_contents), titel, FALSE, FALSE, 0); 578 gtk_box_pack_start(GTK_BOX(section_contents), title, FALSE, FALSE, 0);
529 gtk_box_pack_start( 579 gtk_box_pack_start(
530 GTK_BOX(section_contents), first_visit_label, FALSE, FALSE, 0); 580 GTK_BOX(section_contents), first_visit_label, FALSE, FALSE, 0);
531 581
532 SetConnectionSection( 582 SetConnectionSection(
533 first_visit_contents_, 583 first_visit_contents_,
534 WebsiteSettingsUI::GetFirstVisitIcon(first_visit), 584 WebsiteSettingsUI::GetFirstVisitIcon(first_visit),
535 section_contents); 585 section_contents);
536 } 586 }
537 587
538 void WebsiteSettingsPopupGtk::SetPermissionInfo( 588 void WebsiteSettingsPopupGtk::SetPermissionInfo(
(...skipping 23 matching lines...) Expand all
562 612
563 gtk_widget_show_all(permissions_section_contents_); 613 gtk_widget_show_all(permissions_section_contents_);
564 } 614 }
565 615
566 void WebsiteSettingsPopupGtk::SetSelectedTab(TabId tab_id) { 616 void WebsiteSettingsPopupGtk::SetSelectedTab(TabId tab_id) {
567 DCHECK(notebook_); 617 DCHECK(notebook_);
568 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook_), 618 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook_),
569 static_cast<gint>(tab_id)); 619 static_cast<gint>(tab_id));
570 } 620 }
571 621
622 int WebsiteSettingsPopupGtk::TabstripButtonToTabIndex(GtkWidget* button) {
623 GList* tabs = gtk_container_get_children(GTK_CONTAINER(button->parent));
624 int i = 0;
625 for (GList* it = tabs; it; it = g_list_next(it), ++i) {
626 if (it->data == button)
627 break;
628 }
629 g_list_free(tabs);
630
631 return i;
632 }
633
634 gboolean WebsiteSettingsPopupGtk::OnTabButtonPress(
635 GtkWidget* widget, GdkEvent* event) {
636 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook_),
637 TabstripButtonToTabIndex(widget));
638 gtk_widget_queue_draw(tabstrip_alignment_);
639 return FALSE;
640 }
641
642 gboolean WebsiteSettingsPopupGtk::OnTabExpose(
643 GtkWidget* widget, GdkEventExpose* event) {
644 if (gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_)) !=
645 TabstripButtonToTabIndex(widget)) {
646 return FALSE;
647 }
648
649 NineBox nine(IDR_WEBSITE_SETTINGS_TAB_LEFT2,
650 IDR_WEBSITE_SETTINGS_TAB_CENTER2,
651 IDR_WEBSITE_SETTINGS_TAB_RIGHT2,
652 0, 0, 0, 0, 0, 0);
653 nine.RenderToWidget(widget);
654 gtk_container_propagate_expose(GTK_CONTAINER(widget),
655 gtk_bin_get_child(GTK_BIN(widget)),
656 event);
657
658 return TRUE;
659 }
660
661 gboolean WebsiteSettingsPopupGtk::OnTabstripExpose(
662 GtkWidget* widget, GdkEventExpose* event) {
663 int tab_idx = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_));
664 GtkWidget* tabstrip = gtk_bin_get_child(GTK_BIN(tabstrip_alignment_));
665 GList* tabs = gtk_container_get_children(GTK_CONTAINER(tabstrip));
666 GtkWidget* selected_tab = GTK_WIDGET(g_list_nth_data(tabs, tab_idx));
667 g_list_free(tabs);
668 GtkAllocation tab_bounds;
669 gtk_widget_get_allocation(selected_tab, &tab_bounds);
670
671 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
672 GtkAllocation allocation;
673 gtk_widget_get_allocation(widget, &allocation);
674 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
675
676 // Draw the shadows that abut the selected tab.
markusheintz_ 2012/09/19 16:44:44 nit: typo abut
677 gfx::CairoCachedSurface* left_tab_shadow =
678 rb.GetNativeImageNamed(IDR_WEBSITE_SETTINGS_TABSTRIP_LEFT).ToCairo();
679 int tab_shadow_width = left_tab_shadow->Width();
680 left_tab_shadow->SetSource(cr, widget,
681 tab_bounds.x - tab_shadow_width, allocation.y);
682 cairo_paint(cr);
683
684 gfx::CairoCachedSurface* right_tab_shadow =
685 rb.GetNativeImageNamed(IDR_WEBSITE_SETTINGS_TABSTRIP_RIGHT).ToCairo();
686 right_tab_shadow->SetSource(cr, widget,
687 tab_bounds.x + tab_bounds.width, allocation.y);
688 cairo_paint(cr);
689
690 // Draw the shadow for the inactive part of the tabstrip.
691 gfx::CairoCachedSurface* tiling_shadow =
692 rb.GetNativeImageNamed(IDR_WEBSITE_SETTINGS_TABSTRIP_CENTER).ToCairo();
693
694 tiling_shadow->SetSource(cr, widget, allocation.x, allocation.y);
695 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
696
697 GdkRectangle left_tiling_area =
698 { allocation.x, allocation.y,
699 tab_bounds.x - tab_shadow_width, allocation.height };
700 GdkRectangle invalid_left_tiling_area;
701 if (gdk_rectangle_intersect(&left_tiling_area, &event->area,
702 &invalid_left_tiling_area)) {
703 gdk_cairo_rectangle(cr, &invalid_left_tiling_area);
704 cairo_fill(cr);
705 }
706
707 GdkRectangle right_tiling_area =
708 { tab_bounds.x + tab_bounds.width + tab_shadow_width,
709 allocation.y,
710 allocation.width,
711 allocation.height };
712 GdkRectangle invalid_right_tiling_area;
713 if (gdk_rectangle_intersect(&right_tiling_area, &event->area,
714 &invalid_right_tiling_area)) {
715 gdk_cairo_rectangle(cr, &invalid_right_tiling_area);
716 cairo_fill(cr);
717 }
718
719 cairo_destroy(cr);
720 return FALSE;
721 }
722
572 void WebsiteSettingsPopupGtk::OnCookiesLinkClicked(GtkWidget* widget) { 723 void WebsiteSettingsPopupGtk::OnCookiesLinkClicked(GtkWidget* widget) {
573 // Count how often the Collected Cookies dialog is opened. 724 // Count how often the Collected Cookies dialog is opened.
574 content::RecordAction( 725 content::RecordAction(
575 content::UserMetricsAction("WebsiteSettings_CookiesDialogOpened")); 726 content::UserMetricsAction("WebsiteSettings_CookiesDialogOpened"));
576 727
577 new CollectedCookiesGtk(GTK_WINDOW(parent_), 728 new CollectedCookiesGtk(GTK_WINDOW(parent_),
578 tab_contents_); 729 tab_contents_);
579 bubble_->Close(); 730 bubble_->Close();
580 } 731 }
581 732
582 void WebsiteSettingsPopupGtk::OnViewCertLinkClicked(GtkWidget* widget) { 733 void WebsiteSettingsPopupGtk::OnViewCertLinkClicked(GtkWidget* widget) {
583 DCHECK_NE(cert_id_, 0); 734 DCHECK_NE(cert_id_, 0);
584 ShowCertificateViewerByID( 735 ShowCertificateViewerByID(
585 tab_contents_->web_contents(), GTK_WINDOW(parent_), cert_id_); 736 tab_contents_->web_contents(), GTK_WINDOW(parent_), cert_id_);
586 bubble_->Close(); 737 bubble_->Close();
587 } 738 }
588 739
589 void WebsiteSettingsPopupGtk::OnCloseButtonClicked(GtkWidget* widget) { 740 void WebsiteSettingsPopupGtk::OnCloseButtonClicked(GtkWidget* widget) {
590 bubble_->Close(); 741 bubble_->Close();
591 } 742 }
592 743
593 void WebsiteSettingsPopupGtk::OnHelpLinkClicked(GtkWidget* widget) { 744 void WebsiteSettingsPopupGtk::OnHelpLinkClicked(GtkWidget* widget) {
594 browser_->OpenURL(OpenURLParams(GURL(chrome::kPageInfoHelpCenterURL), 745 browser_->OpenURL(OpenURLParams(GURL(chrome::kPageInfoHelpCenterURL),
595 content::Referrer(), 746 content::Referrer(),
596 NEW_FOREGROUND_TAB, 747 NEW_FOREGROUND_TAB,
597 content::PAGE_TRANSITION_LINK, 748 content::PAGE_TRANSITION_LINK,
598 false)); 749 false));
599 bubble_->Close(); 750 bubble_->Close();
600 } 751 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698