OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/collected_cookies_gtk.h" | 5 #include "chrome/browser/ui/gtk/collected_cookies_gtk.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
| 9 #include "chrome/browser/content_settings/cookie_settings.h" |
9 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 11 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
11 #include "chrome/browser/cookies_tree_model.h" | 12 #include "chrome/browser/cookies_tree_model.h" |
12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" | 14 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" |
14 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" | 15 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" |
15 #include "chrome/browser/ui/gtk/gtk_chrome_cookie_view.h" | 16 #include "chrome/browser/ui/gtk/gtk_chrome_cookie_view.h" |
16 #include "chrome/browser/ui/gtk/gtk_util.h" | 17 #include "chrome/browser/ui/gtk/gtk_util.h" |
17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
18 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // horizontal axis. | 236 // horizontal axis. |
236 GtkWidget* box = gtk_hbox_new(FALSE, 0); | 237 GtkWidget* box = gtk_hbox_new(FALSE, 0); |
237 gtk_box_pack_start(GTK_BOX(box), cookie_list_vbox, TRUE, TRUE, | 238 gtk_box_pack_start(GTK_BOX(box), cookie_list_vbox, TRUE, TRUE, |
238 ui::kControlSpacing); | 239 ui::kControlSpacing); |
239 return box; | 240 return box; |
240 } | 241 } |
241 | 242 |
242 GtkWidget* CollectedCookiesGtk::CreateBlockedPane() { | 243 GtkWidget* CollectedCookiesGtk::CreateBlockedPane() { |
243 TabContentsWrapper* wrapper = | 244 TabContentsWrapper* wrapper = |
244 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_); | 245 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_); |
245 HostContentSettingsMap* host_content_settings_map = | 246 CookieSettings* cookie_settings = |
246 wrapper->profile()->GetHostContentSettingsMap(); | 247 CookieSettings::GetForProfile(wrapper->profile()); |
247 | 248 |
248 GtkWidget* cookie_list_vbox = gtk_vbox_new(FALSE, ui::kControlSpacing); | 249 GtkWidget* cookie_list_vbox = gtk_vbox_new(FALSE, ui::kControlSpacing); |
249 | 250 |
250 GtkWidget* label = gtk_label_new( | 251 GtkWidget* label = gtk_label_new( |
251 l10n_util::GetStringUTF8( | 252 l10n_util::GetStringUTF8( |
252 host_content_settings_map->BlockThirdPartyCookies() ? | 253 cookie_settings->ShouldBlockThirdPartyCookies() ? |
253 IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED : | 254 IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED : |
254 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_LABEL).c_str()); | 255 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_LABEL).c_str()); |
255 gtk_widget_set_size_request(label, kTreeViewWidth, -1); | 256 gtk_widget_set_size_request(label, kTreeViewWidth, -1); |
256 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | 257 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
257 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | 258 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
258 gtk_box_pack_start(GTK_BOX(cookie_list_vbox), label, TRUE, TRUE, | 259 gtk_box_pack_start(GTK_BOX(cookie_list_vbox), label, TRUE, TRUE, |
259 ui::kControlSpacing); | 260 ui::kControlSpacing); |
260 | 261 |
261 GtkWidget* scroll_window = gtk_scrolled_window_new(NULL, NULL); | 262 GtkWidget* scroll_window = gtk_scrolled_window_new(NULL, NULL); |
262 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window), | 263 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window), |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 continue; | 458 continue; |
458 CookieTreeOriginNode* origin_node = static_cast<CookieTreeOriginNode*>( | 459 CookieTreeOriginNode* origin_node = static_cast<CookieTreeOriginNode*>( |
459 node); | 460 node); |
460 if (origin_node->CanCreateContentException()) { | 461 if (origin_node->CanCreateContentException()) { |
461 if (!last_domain_name.empty()) | 462 if (!last_domain_name.empty()) |
462 multiple_domains_added = true; | 463 multiple_domains_added = true; |
463 last_domain_name = origin_node->GetTitle(); | 464 last_domain_name = origin_node->GetTitle(); |
464 Profile* profile = | 465 Profile* profile = |
465 Profile::FromBrowserContext(tab_contents_->browser_context()); | 466 Profile::FromBrowserContext(tab_contents_->browser_context()); |
466 origin_node->CreateContentException( | 467 origin_node->CreateContentException( |
467 profile->GetHostContentSettingsMap(), setting); | 468 CookieSettings::GetForProfile(profile), setting); |
468 } | 469 } |
469 } | 470 } |
470 g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); | 471 g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); |
471 g_list_free(paths); | 472 g_list_free(paths); |
472 if (last_domain_name.empty()) { | 473 if (last_domain_name.empty()) { |
473 gtk_widget_hide(infobar_); | 474 gtk_widget_hide(infobar_); |
474 } else { | 475 } else { |
475 gtk_label_set_text( | 476 gtk_label_set_text( |
476 GTK_LABEL(infobar_label_), GetInfobarLabel( | 477 GTK_LABEL(infobar_label_), GetInfobarLabel( |
477 setting, multiple_domains_added, last_domain_name).c_str()); | 478 setting, multiple_domains_added, last_domain_name).c_str()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); | 511 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); |
511 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree_view), path, TRUE); | 512 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree_view), path, TRUE); |
512 g_signal_handlers_unblock_by_func( | 513 g_signal_handlers_unblock_by_func( |
513 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); | 514 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); |
514 } | 515 } |
515 | 516 |
516 void CollectedCookiesGtk::OnTreeViewSelectionChange(GtkWidget* selection) { | 517 void CollectedCookiesGtk::OnTreeViewSelectionChange(GtkWidget* selection) { |
517 EnableControls(); | 518 EnableControls(); |
518 ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_))); | 519 ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_))); |
519 } | 520 } |
OLD | NEW |