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/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map.h" |
10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
11 #include "chrome/browser/cookies_tree_model.h" | 11 #include "chrome/browser/cookies_tree_model.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" | 13 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" |
14 #include "chrome/browser/ui/gtk/gtk_chrome_cookie_view.h" | 14 #include "chrome/browser/ui/gtk/gtk_chrome_cookie_view.h" |
15 #include "chrome/browser/ui/gtk/gtk_util.h" | 15 #include "chrome/browser/ui/gtk/gtk_util.h" |
16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 17 #include "chrome/common/chrome_notification_types.h" |
17 #include "content/common/notification_source.h" | 18 #include "content/common/notification_source.h" |
18 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
19 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
20 | 21 |
21 namespace { | 22 namespace { |
22 // Width and height of the cookie tree view. | 23 // Width and height of the cookie tree view. |
23 const int kTreeViewWidth = 450; | 24 const int kTreeViewWidth = 450; |
24 const int kTreeViewHeight = 150; | 25 const int kTreeViewHeight = 150; |
25 | 26 |
26 // The page numbers of the pages in the notebook. | 27 // The page numbers of the pages in the notebook. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 76 } |
76 } // namespace | 77 } // namespace |
77 | 78 |
78 CollectedCookiesGtk::CollectedCookiesGtk(GtkWindow* parent, | 79 CollectedCookiesGtk::CollectedCookiesGtk(GtkWindow* parent, |
79 TabContents* tab_contents) | 80 TabContents* tab_contents) |
80 : tab_contents_(tab_contents), | 81 : tab_contents_(tab_contents), |
81 status_changed_(false) { | 82 status_changed_(false) { |
82 TabSpecificContentSettings* content_settings = | 83 TabSpecificContentSettings* content_settings = |
83 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents)-> | 84 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents)-> |
84 content_settings(); | 85 content_settings(); |
85 registrar_.Add(this, NotificationType::COLLECTED_COOKIES_SHOWN, | 86 registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, |
86 Source<TabSpecificContentSettings>(content_settings)); | 87 Source<TabSpecificContentSettings>(content_settings)); |
87 | 88 |
88 Init(); | 89 Init(); |
89 } | 90 } |
90 | 91 |
91 void CollectedCookiesGtk::Init() { | 92 void CollectedCookiesGtk::Init() { |
92 dialog_ = gtk_vbox_new(FALSE, gtk_util::kContentAreaSpacing); | 93 dialog_ = gtk_vbox_new(FALSE, gtk_util::kContentAreaSpacing); |
93 gtk_box_set_spacing(GTK_BOX(dialog_), gtk_util::kContentAreaSpacing); | 94 gtk_box_set_spacing(GTK_BOX(dialog_), gtk_util::kContentAreaSpacing); |
94 | 95 |
95 GtkWidget* label = gtk_label_new( | 96 GtkWidget* label = gtk_label_new( |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 | 414 |
414 bool enable_for_blocked_cookies = | 415 bool enable_for_blocked_cookies = |
415 SelectionContainsOriginNode(blocked_selection_, | 416 SelectionContainsOriginNode(blocked_selection_, |
416 blocked_cookies_tree_adapter_.get()); | 417 blocked_cookies_tree_adapter_.get()); |
417 gtk_widget_set_sensitive(allow_blocked_cookie_button_, | 418 gtk_widget_set_sensitive(allow_blocked_cookie_button_, |
418 enable_for_blocked_cookies); | 419 enable_for_blocked_cookies); |
419 gtk_widget_set_sensitive(for_session_blocked_cookie_button_, | 420 gtk_widget_set_sensitive(for_session_blocked_cookie_button_, |
420 enable_for_blocked_cookies); | 421 enable_for_blocked_cookies); |
421 } | 422 } |
422 | 423 |
423 void CollectedCookiesGtk::Observe(NotificationType type, | 424 void CollectedCookiesGtk::Observe(int type, |
424 const NotificationSource& source, | 425 const NotificationSource& source, |
425 const NotificationDetails& details) { | 426 const NotificationDetails& details) { |
426 DCHECK(type == NotificationType::COLLECTED_COOKIES_SHOWN); | 427 DCHECK(type == chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN); |
427 window_->CloseConstrainedWindow(); | 428 window_->CloseConstrainedWindow(); |
428 } | 429 } |
429 | 430 |
430 void CollectedCookiesGtk::OnClose(GtkWidget* close_button) { | 431 void CollectedCookiesGtk::OnClose(GtkWidget* close_button) { |
431 if (status_changed_) { | 432 if (status_changed_) { |
432 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)->AddInfoBar( | 433 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)->AddInfoBar( |
433 new CollectedCookiesInfoBarDelegate(tab_contents_)); | 434 new CollectedCookiesInfoBarDelegate(tab_contents_)); |
434 } | 435 } |
435 window_->CloseConstrainedWindow(); | 436 window_->CloseConstrainedWindow(); |
436 } | 437 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); | 506 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); |
506 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree_view), path, TRUE); | 507 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree_view), path, TRUE); |
507 g_signal_handlers_unblock_by_func( | 508 g_signal_handlers_unblock_by_func( |
508 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); | 509 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); |
509 } | 510 } |
510 | 511 |
511 void CollectedCookiesGtk::OnTreeViewSelectionChange(GtkWidget* selection) { | 512 void CollectedCookiesGtk::OnTreeViewSelectionChange(GtkWidget* selection) { |
512 EnableControls(); | 513 EnableControls(); |
513 ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_))); | 514 ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_))); |
514 } | 515 } |
OLD | NEW |