| OLD | NEW |
| 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_popup_gtk.h" | 5 #include "chrome/browser/ui/gtk/website_settings_popup_gtk.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/certificate_viewer.h" | 12 #include "chrome/browser/certificate_viewer.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
| 15 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" | 15 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" |
| 16 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 16 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
| 17 #include "chrome/browser/ui/gtk/collected_cookies_gtk.h" | 17 #include "chrome/browser/ui/gtk/collected_cookies_gtk.h" |
| 18 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" | 18 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" |
| 19 #include "chrome/browser/ui/gtk/gtk_util.h" | 19 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 20 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 20 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 21 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" | 21 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
| 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 23 #include "chrome/browser/website_settings.h" | 23 #include "chrome/browser/website_settings.h" |
| 24 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
| 25 #include "content/public/browser/cert_store.h" |
| 25 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 26 #include "grit/locale_settings.h" | 27 #include "grit/locale_settings.h" |
| 27 #include "grit/theme_resources.h" | 28 #include "grit/theme_resources.h" |
| 28 #include "ui/base/gtk/gtk_hig_constants.h" | 29 #include "ui/base/gtk/gtk_hig_constants.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| 30 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
| 31 | 32 |
| 32 using content::OpenURLParams; | 33 using content::OpenURLParams; |
| 33 | 34 |
| 34 namespace { | 35 namespace { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 62 case CONTENT_SETTING_ASK: | 63 case CONTENT_SETTING_ASK: |
| 63 return l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_PERMISSION_ASK); | 64 return l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_PERMISSION_ASK); |
| 64 default: | 65 default: |
| 65 NOTREACHED(); | 66 NOTREACHED(); |
| 66 return ""; | 67 return ""; |
| 67 } | 68 } |
| 68 } | 69 } |
| 69 | 70 |
| 70 } // namespace | 71 } // namespace |
| 71 | 72 |
| 73 // static |
| 74 void WebsiteSettingsPopupGtk::Show(gfx::NativeWindow parent, |
| 75 Profile* profile, |
| 76 TabContentsWrapper* tab_contents_wrapper, |
| 77 const GURL& url, |
| 78 const content::SSLStatus& ssl) { |
| 79 new WebsiteSettingsPopupGtk(parent, |
| 80 profile, |
| 81 tab_contents_wrapper, |
| 82 url, |
| 83 ssl); |
| 84 } |
| 85 |
| 72 WebsiteSettingsPopupGtk::WebsiteSettingsPopupGtk( | 86 WebsiteSettingsPopupGtk::WebsiteSettingsPopupGtk( |
| 73 gfx::NativeWindow parent, | 87 gfx::NativeWindow parent, |
| 74 Profile* profile, | 88 Profile* profile, |
| 75 TabContentsWrapper* tab_contents_wrapper) | 89 TabContentsWrapper* tab_contents_wrapper, |
| 90 const GURL& url, |
| 91 const content::SSLStatus& ssl) |
| 76 : parent_(parent), | 92 : parent_(parent), |
| 77 contents_(NULL), | 93 contents_(NULL), |
| 78 theme_service_(GtkThemeService::GetFrom(profile)), | 94 theme_service_(GtkThemeService::GetFrom(profile)), |
| 79 profile_(profile), | 95 profile_(profile), |
| 80 tab_contents_wrapper_(tab_contents_wrapper), | 96 tab_contents_wrapper_(tab_contents_wrapper), |
| 81 browser_(NULL), | 97 browser_(NULL), |
| 82 cert_id_(0), | 98 cert_id_(0), |
| 83 header_box_(NULL), | 99 header_box_(NULL), |
| 84 cookies_section_contents_(NULL), | 100 cookies_section_contents_(NULL), |
| 85 permissions_section_contents_(NULL), | 101 permissions_section_contents_(NULL), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 103 arrow_location, | 119 arrow_location, |
| 104 BubbleGtk::MATCH_SYSTEM_THEME | | 120 BubbleGtk::MATCH_SYSTEM_THEME | |
| 105 BubbleGtk::POPUP_WINDOW | | 121 BubbleGtk::POPUP_WINDOW | |
| 106 BubbleGtk::GRAB_INPUT, | 122 BubbleGtk::GRAB_INPUT, |
| 107 theme_service_, | 123 theme_service_, |
| 108 this); // |delegate| | 124 this); // |delegate| |
| 109 if (!bubble_) { | 125 if (!bubble_) { |
| 110 NOTREACHED(); | 126 NOTREACHED(); |
| 111 return; | 127 return; |
| 112 } | 128 } |
| 129 |
| 130 presenter_.reset(new WebsiteSettings( |
| 131 this, |
| 132 profile, |
| 133 tab_contents_wrapper->content_settings(), |
| 134 url, |
| 135 ssl, |
| 136 content::CertStore::GetInstance())); |
| 113 } | 137 } |
| 114 | 138 |
| 115 WebsiteSettingsPopupGtk::~WebsiteSettingsPopupGtk() { | 139 WebsiteSettingsPopupGtk::~WebsiteSettingsPopupGtk() { |
| 116 } | 140 } |
| 117 | 141 |
| 118 void WebsiteSettingsPopupGtk::SetPresenter(WebsiteSettings* presenter) { | |
| 119 presenter_ = presenter; | |
| 120 } | |
| 121 | |
| 122 void WebsiteSettingsPopupGtk::BubbleClosing(BubbleGtk* bubble, | 142 void WebsiteSettingsPopupGtk::BubbleClosing(BubbleGtk* bubble, |
| 123 bool closed_by_escape) { | 143 bool closed_by_escape) { |
| 124 if (presenter_) | 144 if (presenter_.get()) |
| 125 presenter_->OnUIClosing(); | 145 presenter_.reset(NULL); |
| 146 delete this; |
| 126 } | 147 } |
| 127 | 148 |
| 128 void WebsiteSettingsPopupGtk::InitContents() { | 149 void WebsiteSettingsPopupGtk::InitContents() { |
| 129 if (!contents_) { | 150 if (!contents_) { |
| 130 contents_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); | 151 contents_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); |
| 131 gtk_container_set_border_width(GTK_CONTAINER(contents_), | 152 gtk_container_set_border_width(GTK_CONTAINER(contents_), |
| 132 ui::kContentAreaBorder); | 153 ui::kContentAreaBorder); |
| 133 } else { | 154 } else { |
| 134 gtk_util::RemoveAllChildren(contents_); | 155 gtk_util::RemoveAllChildren(contents_); |
| 135 } | 156 } |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 GtkTreeIter it; | 527 GtkTreeIter it; |
| 507 bool has_active = gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &it); | 528 bool has_active = gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &it); |
| 508 DCHECK(has_active); | 529 DCHECK(has_active); |
| 509 GtkTreeModel* store = | 530 GtkTreeModel* store = |
| 510 GTK_TREE_MODEL(gtk_combo_box_get_model(GTK_COMBO_BOX(widget))); | 531 GTK_TREE_MODEL(gtk_combo_box_get_model(GTK_COMBO_BOX(widget))); |
| 511 | 532 |
| 512 int value = -1; | 533 int value = -1; |
| 513 int type = -1; | 534 int type = -1; |
| 514 gtk_tree_model_get(store, &it, 1, &value, 2, &type, -1); | 535 gtk_tree_model_get(store, &it, 1, &value, 2, &type, -1); |
| 515 | 536 |
| 516 if (presenter_) | 537 if (presenter_.get()) |
| 517 presenter_->OnSitePermissionChanged(ContentSettingsType(type), | 538 presenter_->OnSitePermissionChanged(ContentSettingsType(type), |
| 518 ContentSetting(value)); | 539 ContentSetting(value)); |
| 519 } | 540 } |
| 520 | 541 |
| 521 void WebsiteSettingsPopupGtk::OnViewCertLinkClicked(GtkWidget* widget) { | 542 void WebsiteSettingsPopupGtk::OnViewCertLinkClicked(GtkWidget* widget) { |
| 522 DCHECK_NE(cert_id_, 0); | 543 DCHECK_NE(cert_id_, 0); |
| 523 ShowCertificateViewerByID(GTK_WINDOW(parent_), cert_id_); | 544 ShowCertificateViewerByID(GTK_WINDOW(parent_), cert_id_); |
| 524 bubble_->Close(); | 545 bubble_->Close(); |
| 525 } | 546 } |
| OLD | NEW |