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

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: slightly simpler drawing 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
117 gtk_box_pack_start(GTK_BOX(section_box), section_content, FALSE, FALSE, 0); 124 gtk_box_pack_start(GTK_BOX(section_box), section_content, FALSE, FALSE, 0);
118 return section_box; 125 return section_box;
119 } 126 }
120 127
121 128 // A popup that is shown for internal pages (like chrome://).
122 class InternalPageInfoPopupGtk : public BubbleDelegateGtk { 129 class InternalPageInfoPopupGtk : public BubbleDelegateGtk {
123 public: 130 public:
124 explicit InternalPageInfoPopupGtk(gfx::NativeWindow parent, 131 explicit InternalPageInfoPopupGtk(gfx::NativeWindow parent,
125 Profile* profile); 132 Profile* profile);
126 virtual ~InternalPageInfoPopupGtk(); 133 virtual ~InternalPageInfoPopupGtk();
127 134
128 private: 135 private:
129 // BubbleDelegateGtk implementation. 136 // BubbleDelegateGtk implementation.
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 15 matching lines...) Expand all
256 265
257 WebsiteSettingsPopupGtk::~WebsiteSettingsPopupGtk() { 266 WebsiteSettingsPopupGtk::~WebsiteSettingsPopupGtk() {
258 } 267 }
259 268
260 void WebsiteSettingsPopupGtk::BubbleClosing(BubbleGtk* bubble, 269 void WebsiteSettingsPopupGtk::BubbleClosing(BubbleGtk* bubble,
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
276 // Slightly delay destruction to allow the event stack to unwind and release
277 // references to owned widgets.
278 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
267 } 279 }
268 280
269 void WebsiteSettingsPopupGtk::InitContents() { 281 void WebsiteSettingsPopupGtk::InitContents() {
270 if (!contents_) { 282 if (!contents_)
271 contents_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); 283 contents_ = gtk_vbox_new(FALSE, 0);
272 gtk_container_set_border_width(GTK_CONTAINER(contents_), 284 else
273 ui::kContentAreaBorder);
274 } else {
275 gtk_util::RemoveAllChildren(contents_); 285 gtk_util::RemoveAllChildren(contents_);
276 }
277 286
278 // Create popup header. 287 // Create popup header.
279 header_box_ = gtk_vbox_new(FALSE, ui::kControlSpacing); 288 header_box_ = gtk_vbox_new(FALSE, ui::kControlSpacing);
280 gtk_box_pack_start(GTK_BOX(contents_), header_box_, FALSE, FALSE, 0); 289 gtk_box_pack_start(GTK_BOX(contents_), header_box_, FALSE, FALSE, 0);
290 gtk_container_set_border_width(GTK_CONTAINER(header_box_),
291 ui::kContentAreaBorder);
281 292
282 // Create the container for the contents of the permissions tab. 293 // Create the container for the contents of the permissions tab.
283 GtkWidget* permission_tab_contents = gtk_vbox_new(FALSE, ui::kControlSpacing); 294 GtkWidget* permission_tab_contents =
284 gtk_container_set_border_width(GTK_CONTAINER(permission_tab_contents), 10); 295 gtk_vbox_new(FALSE, ui::kContentAreaSpacing);
296 gtk_container_set_border_width(GTK_CONTAINER(permission_tab_contents),
297 ui::kContentAreaBorder);
285 cookies_section_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); 298 cookies_section_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing);
286 std::string title = l10n_util::GetStringUTF8( 299 std::string title = l10n_util::GetStringUTF8(
287 IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA); 300 IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA);
288 gtk_box_pack_start(GTK_BOX(permission_tab_contents), 301 gtk_box_pack_start(GTK_BOX(permission_tab_contents),
289 CreatePermissionTabSection(title, 302 CreatePermissionTabSection(title,
290 cookies_section_contents_, 303 cookies_section_contents_,
291 theme_service_), 304 theme_service_),
292 FALSE, FALSE, 0); 305 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); 306 permissions_section_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing);
297 title = l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS); 307 title = l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS);
298 gtk_box_pack_start(GTK_BOX(permission_tab_contents), 308 gtk_box_pack_start(GTK_BOX(permission_tab_contents),
299 CreatePermissionTabSection(title, 309 CreatePermissionTabSection(title,
300 permissions_section_contents_, 310 permissions_section_contents_,
301 theme_service_), 311 theme_service_),
302 FALSE, FALSE, 0); 312 FALSE, FALSE, 0);
303 313
304 // Create the container for the contents of the identity tab. 314 // Create the container for the contents of the connection tab.
305 GtkWidget* connection_tab = gtk_vbox_new(FALSE, ui::kControlSpacing); 315 GtkWidget* connection_tab = gtk_vbox_new(FALSE, 0);
306 identity_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); 316 identity_contents_ = gtk_vbox_new(FALSE, 0);
307 gtk_box_pack_start(GTK_BOX(connection_tab), identity_contents_, FALSE, FALSE, 317 gtk_box_pack_start(GTK_BOX(connection_tab), identity_contents_, FALSE, FALSE,
308 0); 318 0);
309 gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE, 319 gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE,
310 FALSE, 0); 320 FALSE, 0);
311 connection_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); 321 connection_contents_ = gtk_vbox_new(FALSE, 0);
312 gtk_box_pack_start(GTK_BOX(connection_tab), connection_contents_, FALSE, 322 gtk_box_pack_start(GTK_BOX(connection_tab), connection_contents_, FALSE,
313 FALSE, 0); 323 FALSE, 0);
314 gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE, 324 gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE,
315 FALSE, 0); 325 FALSE, 0);
316 first_visit_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); 326 first_visit_contents_ = gtk_vbox_new(FALSE, 0);
317 gtk_box_pack_start(GTK_BOX(connection_tab), first_visit_contents_, FALSE, 327 gtk_box_pack_start(GTK_BOX(connection_tab), first_visit_contents_, FALSE,
318 FALSE, 0); 328 FALSE, 0);
319 gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE, 329 gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE,
320 FALSE, 0); 330 FALSE, 0);
321 331
322 GtkWidget* help_link = theme_service_->BuildChromeLinkButton( 332 GtkWidget* help_link = theme_service_->BuildChromeLinkButton(
323 l10n_util::GetStringUTF8(IDS_PAGE_INFO_HELP_CENTER_LINK)); 333 l10n_util::GetStringUTF8(IDS_PAGE_INFO_HELP_CENTER_LINK));
324 GtkWidget* help_link_hbox = gtk_hbox_new(FALSE, 0); 334 GtkWidget* help_link_hbox = gtk_hbox_new(FALSE, 0);
325 gtk_container_set_border_width(GTK_CONTAINER(help_link_hbox), 335 gtk_container_set_border_width(GTK_CONTAINER(help_link_hbox),
326 kConnectionTabSectionPadding); 336 ui::kContentAreaBorder);
327 gtk_box_pack_start(GTK_BOX(help_link_hbox), help_link, FALSE, FALSE, 0); 337 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); 338 gtk_box_pack_start(GTK_BOX(connection_tab), help_link_hbox, FALSE, FALSE, 0);
329 g_signal_connect(help_link, "clicked", 339 g_signal_connect(help_link, "clicked",
330 G_CALLBACK(OnHelpLinkClickedThunk), this); 340 G_CALLBACK(OnHelpLinkClickedThunk), this);
331 341
342 // Create tabstrip (used only for Chrome-theme mode).
343 GtkWidget* tabstrip = gtk_hbox_new(FALSE, kInterTabSpacing);
344 tabstrip_alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
345 gtk_alignment_set_padding(GTK_ALIGNMENT(tabstrip_alignment_), 0, 0,
346 ui::kContentAreaBorder, ui::kContentAreaBorder);
347 int tab_height = ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
348 IDR_WEBSITE_SETTINGS_TAB_LEFT2).ToImageSkia()->height();
349 gtk_widget_set_size_request(tabstrip_alignment_, -1, tab_height);
350 g_signal_connect(tabstrip_alignment_, "expose-event",
351 G_CALLBACK(&OnTabstripExposeThunk), this);
352 gtk_container_add(GTK_CONTAINER(tabstrip_alignment_), tabstrip);
353 gtk_box_pack_start(GTK_BOX(contents_), tabstrip_alignment_, FALSE, FALSE, 0);
354
355 gtk_box_pack_start(GTK_BOX(tabstrip),
356 BuildTab(IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS),
357 FALSE, FALSE, 0);
358 gtk_box_pack_start(GTK_BOX(tabstrip),
359 BuildTab(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION),
360 FALSE, FALSE, 0);
361
332 // Create tab container and add all tabs. 362 // Create tab container and add all tabs.
333 notebook_ = gtk_notebook_new(); 363 notebook_ = gtk_notebook_new();
334 if (theme_service_->UsingNativeTheme()) 364 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 365
339 GtkWidget* label = theme_service_->BuildLabel( 366 GtkWidget* label = gtk_label_new(l10n_util::GetStringUTF8(
340 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS), 367 IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS).c_str());
341 ui::kGdkBlack); 368 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, 369 gtk_notebook_insert_page(GTK_NOTEBOOK(notebook_), permission_tab_contents,
344 label, TAB_ID_PERMISSIONS); 370 label, TAB_ID_PERMISSIONS);
345 371
346 label = theme_service_->BuildLabel( 372 label = gtk_label_new(l10n_util::GetStringUTF8(
347 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION), 373 IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION).c_str());
348 ui::kGdkBlack); 374 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, 375 gtk_notebook_insert_page(GTK_NOTEBOOK(notebook_), connection_tab, label,
351 TAB_ID_CONNECTION); 376 TAB_ID_CONNECTION);
352 377
353 DCHECK_EQ(gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook_)), NUM_TAB_IDS); 378 DCHECK_EQ(gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook_)), NUM_TAB_IDS);
354 379
355 gtk_box_pack_start(GTK_BOX(contents_), notebook_, FALSE, FALSE, 0); 380 gtk_box_pack_start(GTK_BOX(contents_), notebook_, FALSE, FALSE, 0);
381
382 theme_service_->InitThemesFor(this);
356 gtk_widget_show_all(contents_); 383 gtk_widget_show_all(contents_);
357 } 384 }
358 385
386 GtkWidget* WebsiteSettingsPopupGtk::BuildTab(int ids) {
387 GtkWidget* tab = gtk_event_box_new();
388 gtk_event_box_set_visible_window(GTK_EVENT_BOX(tab), FALSE);
389 GtkWidget* label = gtk_label_new(l10n_util::GetStringUTF8(ids).c_str());
390 gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &ui::kGdkBlack);
391 gtk_misc_set_padding(GTK_MISC(label),
392 kTabTextHorizontalMargin, kTabTextBaseline);
393 gtk_misc_set_alignment(GTK_MISC(label), 0.5, 1.0);
394 gtk_container_add(GTK_CONTAINER(tab), label);
395 g_signal_connect(tab, "button-press-event",
396 G_CALLBACK(&OnTabButtonPressThunk), this);
397 g_signal_connect(tab, "expose-event",
398 G_CALLBACK(&OnTabExposeThunk), this);
399 return tab;
400 }
401
402 void WebsiteSettingsPopupGtk::Observe(
403 int type,
404 const content::NotificationSource& source,
405 const content::NotificationDetails& details) {
406 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type);
407
408 if (theme_service_->UsingNativeTheme()) {
409 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook_), TRUE);
410 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook_), TRUE);
411 gtk_widget_set_no_show_all(tabstrip_alignment_, TRUE);
412 } else {
413 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook_), FALSE);
414 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook_), FALSE);
415 gtk_widget_set_no_show_all(tabstrip_alignment_, FALSE);
416 gtk_widget_show_all(tabstrip_alignment_);
417 }
418 }
419
359 void WebsiteSettingsPopupGtk::OnPermissionChanged( 420 void WebsiteSettingsPopupGtk::OnPermissionChanged(
360 PermissionSelector* selector) { 421 PermissionSelector* selector) {
361 presenter_->OnSitePermissionChanged(selector->GetType(), 422 presenter_->OnSitePermissionChanged(selector->GetType(),
362 selector->GetSetting()); 423 selector->GetSetting());
363 } 424 }
364 425
365 void WebsiteSettingsPopupGtk::OnComboboxShown() { 426 void WebsiteSettingsPopupGtk::OnComboboxShown() {
366 bubble_->HandlePointerAndKeyboardUngrabbedByContent(); 427 bubble_->HandlePointerAndKeyboardUngrabbedByContent();
367 } 428 }
368 429
(...skipping 17 matching lines...) Expand all
386 gtk_box_pack_start(GTK_BOX(cookies_info), image, FALSE, FALSE, 0); 447 gtk_box_pack_start(GTK_BOX(cookies_info), image, FALSE, FALSE, 0);
387 448
388 // Add the allowed and blocked cookies counts to the cookies info box. 449 // Add the allowed and blocked cookies counts to the cookies info box.
389 std::string info_str = l10n_util::GetStringFUTF8( 450 std::string info_str = l10n_util::GetStringFUTF8(
390 IDS_WEBSITE_SETTINGS_SITE_DATA_STATS_LINE, 451 IDS_WEBSITE_SETTINGS_SITE_DATA_STATS_LINE,
391 UTF8ToUTF16(it->cookie_source), 452 UTF8ToUTF16(it->cookie_source),
392 base::IntToString16(it->allowed), 453 base::IntToString16(it->allowed),
393 base::IntToString16(it->blocked)); 454 base::IntToString16(it->blocked));
394 455
395 GtkWidget* info = theme_service_->BuildLabel(info_str, ui::kGdkBlack); 456 GtkWidget* info = theme_service_->BuildLabel(info_str, ui::kGdkBlack);
396 gtk_label_set_selectable(GTK_LABEL(info), TRUE);
397 const int kPadding = 4; 457 const int kPadding = 4;
398 gtk_box_pack_start(GTK_BOX(cookies_info), info, FALSE, FALSE, kPadding); 458 gtk_box_pack_start(GTK_BOX(cookies_info), info, FALSE, FALSE, kPadding);
399 459
400 // Add the cookies info box to the section box. 460 // Add the cookies info box to the section box.
401 gtk_box_pack_start(GTK_BOX(cookies_section_contents_), 461 gtk_box_pack_start(GTK_BOX(cookies_section_contents_),
402 cookies_info, 462 cookies_info,
403 FALSE, FALSE, 0); 463 FALSE, FALSE, 0);
404 } 464 }
405 465
406 // Create row with links for cookie settings and for the cookies dialog. 466 // 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); 488 GtkWidget* hbox = gtk_hbox_new(FALSE, 0);
429 GtkWidget* identity_label = theme_service_->BuildLabel( 489 GtkWidget* identity_label = theme_service_->BuildLabel(
430 identity_info.site_identity, ui::kGdkBlack); 490 identity_info.site_identity, ui::kGdkBlack);
431 gtk_label_set_selectable(GTK_LABEL(identity_label), TRUE); 491 gtk_label_set_selectable(GTK_LABEL(identity_label), TRUE);
432 PangoAttrList* attributes = pango_attr_list_new(); 492 PangoAttrList* attributes = pango_attr_list_new();
433 pango_attr_list_insert(attributes, 493 pango_attr_list_insert(attributes,
434 pango_attr_weight_new(PANGO_WEIGHT_BOLD)); 494 pango_attr_weight_new(PANGO_WEIGHT_BOLD));
435 gtk_label_set_attributes(GTK_LABEL(identity_label), attributes); 495 gtk_label_set_attributes(GTK_LABEL(identity_label), attributes);
436 pango_attr_list_unref(attributes); 496 pango_attr_list_unref(attributes);
437 gtk_box_pack_start(GTK_BOX(hbox), identity_label, FALSE, FALSE, 0); 497 gtk_box_pack_start(GTK_BOX(hbox), identity_label, FALSE, FALSE, 0);
438 GtkWidget* close_button = gtk_button_new(); 498 close_button_.reset(CustomDrawButton::CloseButton(theme_service_));
439 gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE); 499 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); 500 G_CALLBACK(OnCloseButtonClickedThunk), this);
446 gtk_box_pack_start(GTK_BOX(hbox), close_button, FALSE, FALSE, 0); 501 gtk_box_pack_start(GTK_BOX(hbox), close_button_->widget(), FALSE, FALSE, 0);
447 int label_width = kPopupWidth - gdk_pixbuf_get_width(pixbuf); 502 int label_width = kPopupWidth - close_button_->SurfaceWidth();
448 gtk_util::SetLabelWidth(identity_label, label_width); 503 gtk_util::SetLabelWidth(identity_label, label_width);
449 gtk_box_pack_start(GTK_BOX(header_box_), hbox, FALSE, FALSE, 0); 504 gtk_box_pack_start(GTK_BOX(header_box_), hbox, FALSE, FALSE, 0);
450 505
451 std::string identity_status_text; 506 std::string identity_status_text;
452 const GdkColor* color = 507 const GdkColor* color = &ui::kGdkBlack;
453 theme_service_->UsingNativeTheme() ? NULL : &ui::kGdkBlack;
454 508
455 switch (identity_info.identity_status) { 509 switch (identity_info.identity_status) {
456 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT: 510 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT:
457 case WebsiteSettings::SITE_IDENTITY_STATUS_DNSSEC_CERT: 511 case WebsiteSettings::SITE_IDENTITY_STATUS_DNSSEC_CERT:
458 case WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT: 512 case WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT:
459 identity_status_text = 513 identity_status_text =
460 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_IDENTITY_VERIFIED); 514 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_IDENTITY_VERIFIED);
461 if (!theme_service_->UsingNativeTheme()) 515 color = &kGdkGreen;
462 color = &kGdkGreen;
463 break; 516 break;
464 default: 517 default:
465 identity_status_text = 518 identity_status_text =
466 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_IDENTITY_NOT_VERIFIED); 519 l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_IDENTITY_NOT_VERIFIED);
467 break; 520 break;
468 } 521 }
469 GtkWidget* status_label = 522 GtkWidget* status_label = CreateTextLabel(
470 CreateTextLabel(identity_status_text, kPopupWidth, theme_service_); 523 identity_status_text, kPopupWidth, theme_service_, *color);
471 gtk_widget_modify_fg(status_label, GTK_STATE_NORMAL, color);
472 gtk_box_pack_start( 524 gtk_box_pack_start(
473 GTK_BOX(header_box_), status_label, FALSE, FALSE, 0); 525 GTK_BOX(header_box_), status_label, FALSE, FALSE, 0);
474 gtk_widget_show_all(header_box_); 526 gtk_widget_show_all(header_box_);
475 527
476 // Create identity section. 528 // Create identity section.
477 GtkWidget* section_content = gtk_vbox_new(FALSE, ui::kControlSpacing); 529 GtkWidget* section_content = gtk_vbox_new(FALSE, ui::kControlSpacing);
478 GtkWidget* identity_description = 530 GtkWidget* identity_description =
479 CreateTextLabel(identity_info.identity_status_description, 531 CreateTextLabel(identity_info.identity_status_description,
480 kConnectionTabTextWidth, theme_service_); 532 kConnectionTabTextWidth, theme_service_, ui::kGdkBlack);
481 gtk_box_pack_start(GTK_BOX(section_content), identity_description, FALSE, 533 gtk_box_pack_start(GTK_BOX(section_content), identity_description, FALSE,
482 FALSE, 0); 534 FALSE, 0);
483 if (identity_info.cert_id) { 535 if (identity_info.cert_id) {
484 cert_id_ = identity_info.cert_id; 536 cert_id_ = identity_info.cert_id;
485 GtkWidget* view_cert_link = theme_service_->BuildChromeLinkButton( 537 GtkWidget* view_cert_link = theme_service_->BuildChromeLinkButton(
486 l10n_util::GetStringUTF8(IDS_PAGEINFO_CERT_INFO_BUTTON)); 538 l10n_util::GetStringUTF8(IDS_PAGEINFO_CERT_INFO_BUTTON));
487 g_signal_connect(view_cert_link, "clicked", 539 g_signal_connect(view_cert_link, "clicked",
488 G_CALLBACK(OnViewCertLinkClickedThunk), this); 540 G_CALLBACK(OnViewCertLinkClickedThunk), this);
489 GtkWidget* link_hbox = gtk_hbox_new(FALSE, 0); 541 GtkWidget* link_hbox = gtk_hbox_new(FALSE, 0);
490 gtk_box_pack_start(GTK_BOX(link_hbox), view_cert_link, 542 gtk_box_pack_start(GTK_BOX(link_hbox), view_cert_link,
491 FALSE, FALSE, 0); 543 FALSE, FALSE, 0);
492 gtk_box_pack_start(GTK_BOX(section_content), link_hbox, FALSE, FALSE, 0); 544 gtk_box_pack_start(GTK_BOX(section_content), link_hbox, FALSE, FALSE, 0);
493 } 545 }
494 SetConnectionSection( 546 SetConnectionSection(
495 identity_contents_, 547 identity_contents_,
496 WebsiteSettingsUI::GetIdentityIcon(identity_info.identity_status), 548 WebsiteSettingsUI::GetIdentityIcon(identity_info.identity_status),
497 section_content); 549 section_content);
498 550
499 // Create connection section. 551 // Create connection section.
500 GtkWidget* connection_description = 552 GtkWidget* connection_description =
501 CreateTextLabel(identity_info.connection_status_description, 553 CreateTextLabel(identity_info.connection_status_description,
502 kConnectionTabTextWidth, theme_service_); 554 kConnectionTabTextWidth, theme_service_, ui::kGdkBlack);
503 section_content = gtk_vbox_new(FALSE, ui::kControlSpacing); 555 section_content = gtk_vbox_new(FALSE, ui::kControlSpacing);
504 gtk_box_pack_start(GTK_BOX(section_content), connection_description, FALSE, 556 gtk_box_pack_start(GTK_BOX(section_content), connection_description, FALSE,
505 FALSE, 0); 557 FALSE, 0);
506 SetConnectionSection( 558 SetConnectionSection(
507 connection_contents_, 559 connection_contents_,
508 WebsiteSettingsUI::GetConnectionIcon(identity_info.connection_status), 560 WebsiteSettingsUI::GetConnectionIcon(identity_info.connection_status),
509 section_content); 561 section_content);
510 } 562 }
511 563
512 void WebsiteSettingsPopupGtk::SetFirstVisit(const string16& first_visit) { 564 void WebsiteSettingsPopupGtk::SetFirstVisit(const string16& first_visit) {
513 GtkWidget* titel = theme_service_->BuildLabel( 565 GtkWidget* title = theme_service_->BuildLabel(
514 l10n_util::GetStringUTF8(IDS_PAGE_INFO_SITE_INFO_TITLE), 566 l10n_util::GetStringUTF8(IDS_PAGE_INFO_SITE_INFO_TITLE),
515 ui::kGdkBlack); 567 ui::kGdkBlack);
516 gtk_label_set_selectable(GTK_LABEL(titel), TRUE);
517 PangoAttrList* attributes = pango_attr_list_new(); 568 PangoAttrList* attributes = pango_attr_list_new();
518 pango_attr_list_insert(attributes, 569 pango_attr_list_insert(attributes,
519 pango_attr_weight_new(PANGO_WEIGHT_BOLD)); 570 pango_attr_weight_new(PANGO_WEIGHT_BOLD));
520 gtk_label_set_attributes(GTK_LABEL(titel), attributes); 571 gtk_label_set_attributes(GTK_LABEL(title), attributes);
521 pango_attr_list_unref(attributes); 572 pango_attr_list_unref(attributes);
522 gtk_misc_set_alignment(GTK_MISC(titel), 0, 0); 573 gtk_misc_set_alignment(GTK_MISC(title), 0, 0);
523 574
524 GtkWidget* first_visit_label = CreateTextLabel(UTF16ToUTF8(first_visit), 575 GtkWidget* first_visit_label = CreateTextLabel(UTF16ToUTF8(first_visit),
525 kConnectionTabTextWidth, 576 kConnectionTabTextWidth,
526 theme_service_); 577 theme_service_,
578 ui::kGdkBlack);
527 GtkWidget* section_contents = gtk_vbox_new(FALSE, ui::kControlSpacing); 579 GtkWidget* section_contents = gtk_vbox_new(FALSE, ui::kControlSpacing);
528 gtk_box_pack_start(GTK_BOX(section_contents), titel, FALSE, FALSE, 0); 580 gtk_box_pack_start(GTK_BOX(section_contents), title, FALSE, FALSE, 0);
529 gtk_box_pack_start( 581 gtk_box_pack_start(
530 GTK_BOX(section_contents), first_visit_label, FALSE, FALSE, 0); 582 GTK_BOX(section_contents), first_visit_label, FALSE, FALSE, 0);
531 583
532 SetConnectionSection( 584 SetConnectionSection(
533 first_visit_contents_, 585 first_visit_contents_,
534 WebsiteSettingsUI::GetFirstVisitIcon(first_visit), 586 WebsiteSettingsUI::GetFirstVisitIcon(first_visit),
535 section_contents); 587 section_contents);
536 } 588 }
537 589
538 void WebsiteSettingsPopupGtk::SetPermissionInfo( 590 void WebsiteSettingsPopupGtk::SetPermissionInfo(
(...skipping 23 matching lines...) Expand all
562 614
563 gtk_widget_show_all(permissions_section_contents_); 615 gtk_widget_show_all(permissions_section_contents_);
564 } 616 }
565 617
566 void WebsiteSettingsPopupGtk::SetSelectedTab(TabId tab_id) { 618 void WebsiteSettingsPopupGtk::SetSelectedTab(TabId tab_id) {
567 DCHECK(notebook_); 619 DCHECK(notebook_);
568 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook_), 620 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook_),
569 static_cast<gint>(tab_id)); 621 static_cast<gint>(tab_id));
570 } 622 }
571 623
624 int WebsiteSettingsPopupGtk::TabstripButtonToTabIndex(GtkWidget* button) {
625 GList* tabs = gtk_container_get_children(GTK_CONTAINER(button->parent));
626 int i = 0;
627 for (GList* it = tabs; it; it = g_list_next(it), ++i) {
628 if (it->data == button)
629 break;
630 }
631 g_list_free(tabs);
632
633 return i;
634 }
635
636 gboolean WebsiteSettingsPopupGtk::OnTabButtonPress(
637 GtkWidget* widget, GdkEvent* event) {
638 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook_),
639 TabstripButtonToTabIndex(widget));
640 gtk_widget_queue_draw(tabstrip_alignment_);
641 return FALSE;
642 }
643
644 gboolean WebsiteSettingsPopupGtk::OnTabExpose(
645 GtkWidget* widget, GdkEventExpose* event) {
646 if (gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_)) !=
647 TabstripButtonToTabIndex(widget)) {
648 return FALSE;
649 }
650
651 NineBox nine(IDR_WEBSITE_SETTINGS_TAB_LEFT2,
652 IDR_WEBSITE_SETTINGS_TAB_CENTER2,
653 IDR_WEBSITE_SETTINGS_TAB_RIGHT2,
654 0, 0, 0, 0, 0, 0);
655 nine.RenderToWidget(widget);
656
657 return FALSE;
658 }
659
660 gboolean WebsiteSettingsPopupGtk::OnTabstripExpose(
661 GtkWidget* widget, GdkEventExpose* event) {
662 int tab_idx = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_));
663 GtkWidget* tabstrip = gtk_bin_get_child(GTK_BIN(tabstrip_alignment_));
664 GList* tabs = gtk_container_get_children(GTK_CONTAINER(tabstrip));
665 GtkWidget* selected_tab = GTK_WIDGET(g_list_nth_data(tabs, tab_idx));
666 g_list_free(tabs);
667 GtkAllocation tab_bounds;
668 gtk_widget_get_allocation(selected_tab, &tab_bounds);
669
670 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
671 GtkAllocation allocation;
672 gtk_widget_get_allocation(widget, &allocation);
673 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
674
675 // Draw the shadows that abut the selected tab.
676 gfx::CairoCachedSurface* left_tab_shadow =
677 rb.GetNativeImageNamed(IDR_WEBSITE_SETTINGS_TABSTRIP_LEFT).ToCairo();
678 int tab_shadow_width = left_tab_shadow->Width();
679 left_tab_shadow->SetSource(cr, widget,
680 tab_bounds.x - tab_shadow_width, allocation.y);
681 cairo_paint(cr);
682
683 gfx::CairoCachedSurface* right_tab_shadow =
684 rb.GetNativeImageNamed(IDR_WEBSITE_SETTINGS_TABSTRIP_RIGHT).ToCairo();
685 right_tab_shadow->SetSource(cr, widget,
686 tab_bounds.x + tab_bounds.width, allocation.y);
687 cairo_paint(cr);
688
689 // Draw the shadow for the inactive part of the tabstrip.
690 gfx::CairoCachedSurface* tiling_shadow =
691 rb.GetNativeImageNamed(IDR_WEBSITE_SETTINGS_TABSTRIP_CENTER).ToCairo();
692
693 tiling_shadow->SetSource(cr, widget, allocation.x, allocation.y);
694 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
695
696 GdkRectangle left_tiling_area =
697 { allocation.x, allocation.y,
698 tab_bounds.x - tab_shadow_width, allocation.height };
699 GdkRectangle invalid_left_tiling_area;
700 if (gdk_rectangle_intersect(&left_tiling_area, &event->area,
701 &invalid_left_tiling_area)) {
702 gdk_cairo_rectangle(cr, &invalid_left_tiling_area);
703 cairo_fill(cr);
704 }
705
706 GdkRectangle right_tiling_area =
707 { tab_bounds.x + tab_bounds.width + tab_shadow_width,
708 allocation.y,
709 allocation.width,
710 allocation.height };
711 GdkRectangle invalid_right_tiling_area;
712 if (gdk_rectangle_intersect(&right_tiling_area, &event->area,
713 &invalid_right_tiling_area)) {
714 gdk_cairo_rectangle(cr, &invalid_right_tiling_area);
715 cairo_fill(cr);
716 }
717
718 cairo_destroy(cr);
719 return FALSE;
720 }
721
572 void WebsiteSettingsPopupGtk::OnCookiesLinkClicked(GtkWidget* widget) { 722 void WebsiteSettingsPopupGtk::OnCookiesLinkClicked(GtkWidget* widget) {
573 // Count how often the Collected Cookies dialog is opened. 723 // Count how often the Collected Cookies dialog is opened.
574 content::RecordAction( 724 content::RecordAction(
575 content::UserMetricsAction("WebsiteSettings_CookiesDialogOpened")); 725 content::UserMetricsAction("WebsiteSettings_CookiesDialogOpened"));
576 726
577 new CollectedCookiesGtk(GTK_WINDOW(parent_), 727 new CollectedCookiesGtk(GTK_WINDOW(parent_),
578 tab_contents_); 728 tab_contents_);
579 bubble_->Close(); 729 bubble_->Close();
580 } 730 }
581 731
582 void WebsiteSettingsPopupGtk::OnViewCertLinkClicked(GtkWidget* widget) { 732 void WebsiteSettingsPopupGtk::OnViewCertLinkClicked(GtkWidget* widget) {
583 DCHECK_NE(cert_id_, 0); 733 DCHECK_NE(cert_id_, 0);
584 ShowCertificateViewerByID( 734 ShowCertificateViewerByID(
585 tab_contents_->web_contents(), GTK_WINDOW(parent_), cert_id_); 735 tab_contents_->web_contents(), GTK_WINDOW(parent_), cert_id_);
586 bubble_->Close(); 736 bubble_->Close();
587 } 737 }
588 738
589 void WebsiteSettingsPopupGtk::OnCloseButtonClicked(GtkWidget* widget) { 739 void WebsiteSettingsPopupGtk::OnCloseButtonClicked(GtkWidget* widget) {
590 bubble_->Close(); 740 bubble_->Close();
591 } 741 }
592 742
593 void WebsiteSettingsPopupGtk::OnHelpLinkClicked(GtkWidget* widget) { 743 void WebsiteSettingsPopupGtk::OnHelpLinkClicked(GtkWidget* widget) {
594 browser_->OpenURL(OpenURLParams(GURL(chrome::kPageInfoHelpCenterURL), 744 browser_->OpenURL(OpenURLParams(GURL(chrome::kPageInfoHelpCenterURL),
595 content::Referrer(), 745 content::Referrer(),
596 NEW_FOREGROUND_TAB, 746 NEW_FOREGROUND_TAB,
597 content::PAGE_TRANSITION_LINK, 747 content::PAGE_TRANSITION_LINK,
598 false)); 748 false));
599 bubble_->Close(); 749 bubble_->Close();
600 } 750 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/website_settings/website_settings_popup_gtk.h ('k') | chrome/browser/ui/gtk/zoom_bubble_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698