Chromium Code Reviews| 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" | |
| 8 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
|
tfarina
2012/06/03 16:12:19
nit: remove this, already included in header file.
markusheintz_
2012/06/04 16:33:54
Done.
| |
| 9 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 10 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 11 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/certificate_viewer.h" | 11 #include "chrome/browser/certificate_viewer.h" |
| 13 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_list.h" | 13 #include "chrome/browser/ui/browser_list.h" |
| 15 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" | 14 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" |
| 16 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 15 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
| 17 #include "chrome/browser/ui/gtk/collected_cookies_gtk.h" | 16 #include "chrome/browser/ui/gtk/collected_cookies_gtk.h" |
| 18 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" | 17 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" |
| 19 #include "chrome/browser/ui/gtk/gtk_util.h" | 18 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 20 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 19 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 21 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" | 20 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
| 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 23 #include "chrome/browser/website_settings.h" | 22 #include "chrome/browser/ui/website_settings/website_settings.h" |
| 24 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 24 #include "content/public/browser/cert_store.h" | |
| 25 #include "googleurl/src/gurl.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, profile, tab_contents_wrapper, url, ssl); | |
| 80 } | |
| 81 | |
| 72 WebsiteSettingsPopupGtk::WebsiteSettingsPopupGtk( | 82 WebsiteSettingsPopupGtk::WebsiteSettingsPopupGtk( |
| 73 gfx::NativeWindow parent, | 83 gfx::NativeWindow parent, |
| 74 Profile* profile, | 84 Profile* profile, |
| 75 TabContentsWrapper* tab_contents_wrapper) | 85 TabContentsWrapper* tab_contents_wrapper, |
| 86 const GURL& url, | |
| 87 const content::SSLStatus& ssl) | |
| 76 : parent_(parent), | 88 : parent_(parent), |
| 77 contents_(NULL), | 89 contents_(NULL), |
| 78 theme_service_(GtkThemeService::GetFrom(profile)), | 90 theme_service_(GtkThemeService::GetFrom(profile)), |
| 79 profile_(profile), | 91 profile_(profile), |
| 80 tab_contents_wrapper_(tab_contents_wrapper), | 92 tab_contents_wrapper_(tab_contents_wrapper), |
| 81 browser_(NULL), | 93 browser_(NULL), |
| 82 cert_id_(0), | 94 cert_id_(0), |
| 83 header_box_(NULL), | 95 header_box_(NULL), |
| 84 cookies_section_contents_(NULL), | 96 cookies_section_contents_(NULL), |
| 85 permissions_section_contents_(NULL), | 97 permissions_section_contents_(NULL), |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 103 arrow_location, | 115 arrow_location, |
| 104 BubbleGtk::MATCH_SYSTEM_THEME | | 116 BubbleGtk::MATCH_SYSTEM_THEME | |
| 105 BubbleGtk::POPUP_WINDOW | | 117 BubbleGtk::POPUP_WINDOW | |
| 106 BubbleGtk::GRAB_INPUT, | 118 BubbleGtk::GRAB_INPUT, |
| 107 theme_service_, | 119 theme_service_, |
| 108 this); // |delegate| | 120 this); // |delegate| |
| 109 if (!bubble_) { | 121 if (!bubble_) { |
| 110 NOTREACHED(); | 122 NOTREACHED(); |
| 111 return; | 123 return; |
| 112 } | 124 } |
| 125 | |
| 126 presenter_.reset(new WebsiteSettings(this, profile, | |
| 127 tab_contents_wrapper->content_settings(), | |
| 128 url, ssl, | |
| 129 content::CertStore::GetInstance())); | |
| 113 } | 130 } |
| 114 | 131 |
| 115 WebsiteSettingsPopupGtk::~WebsiteSettingsPopupGtk() { | 132 WebsiteSettingsPopupGtk::~WebsiteSettingsPopupGtk() { |
| 116 } | 133 } |
| 117 | 134 |
| 118 void WebsiteSettingsPopupGtk::SetPresenter(WebsiteSettings* presenter) { | |
| 119 presenter_ = presenter; | |
| 120 } | |
| 121 | |
| 122 void WebsiteSettingsPopupGtk::BubbleClosing(BubbleGtk* bubble, | 135 void WebsiteSettingsPopupGtk::BubbleClosing(BubbleGtk* bubble, |
| 123 bool closed_by_escape) { | 136 bool closed_by_escape) { |
| 124 if (presenter_) | 137 if (presenter_.get()) |
| 125 presenter_->OnUIClosing(); | 138 presenter_.reset(); |
| 139 delete this; | |
| 126 } | 140 } |
| 127 | 141 |
| 128 void WebsiteSettingsPopupGtk::InitContents() { | 142 void WebsiteSettingsPopupGtk::InitContents() { |
| 129 if (!contents_) { | 143 if (!contents_) { |
| 130 contents_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); | 144 contents_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); |
| 131 gtk_container_set_border_width(GTK_CONTAINER(contents_), | 145 gtk_container_set_border_width(GTK_CONTAINER(contents_), |
| 132 ui::kContentAreaBorder); | 146 ui::kContentAreaBorder); |
| 133 } else { | 147 } else { |
| 134 gtk_util::RemoveAllChildren(contents_); | 148 gtk_util::RemoveAllChildren(contents_); |
| 135 } | 149 } |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 487 void WebsiteSettingsPopupGtk::OnCookiesLinkClicked(GtkWidget* widget) { | 501 void WebsiteSettingsPopupGtk::OnCookiesLinkClicked(GtkWidget* widget) { |
| 488 new CollectedCookiesGtk(GTK_WINDOW(parent_), | 502 new CollectedCookiesGtk(GTK_WINDOW(parent_), |
| 489 tab_contents_wrapper_); | 503 tab_contents_wrapper_); |
| 490 bubble_->Close(); | 504 bubble_->Close(); |
| 491 } | 505 } |
| 492 | 506 |
| 493 void WebsiteSettingsPopupGtk::OnPermissionsSettingsLinkClicked( | 507 void WebsiteSettingsPopupGtk::OnPermissionsSettingsLinkClicked( |
| 494 GtkWidget* widget) { | 508 GtkWidget* widget) { |
| 495 browser_->OpenURL(OpenURLParams( | 509 browser_->OpenURL(OpenURLParams( |
| 496 GURL(std::string( | 510 GURL(std::string( |
| 497 chrome::kChromeUISettingsURL) + chrome::kContentSettingsSubPage), | 511 chrome::kChromeUISettingsURL) + chrome::kContentSettingsSubPage), |
| 498 content::Referrer(), | 512 content::Referrer(), |
| 499 NEW_FOREGROUND_TAB, | 513 NEW_FOREGROUND_TAB, |
| 500 content::PAGE_TRANSITION_LINK, | 514 content::PAGE_TRANSITION_LINK, |
| 501 false)); | 515 false)); |
| 502 bubble_->Close(); | 516 bubble_->Close(); |
| 503 } | 517 } |
| 504 | 518 |
| 505 void WebsiteSettingsPopupGtk::OnPermissionChanged(GtkWidget* widget) { | 519 void WebsiteSettingsPopupGtk::OnPermissionChanged(GtkWidget* widget) { |
| 506 GtkTreeIter it; | 520 GtkTreeIter it; |
| 507 bool has_active = gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &it); | 521 bool has_active = gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &it); |
| 508 DCHECK(has_active); | 522 DCHECK(has_active); |
| 509 GtkTreeModel* store = | 523 GtkTreeModel* store = |
| 510 GTK_TREE_MODEL(gtk_combo_box_get_model(GTK_COMBO_BOX(widget))); | 524 GTK_TREE_MODEL(gtk_combo_box_get_model(GTK_COMBO_BOX(widget))); |
| 511 | 525 |
| 512 int value = -1; | 526 int value = -1; |
| 513 int type = -1; | 527 int type = -1; |
| 514 gtk_tree_model_get(store, &it, 1, &value, 2, &type, -1); | 528 gtk_tree_model_get(store, &it, 1, &value, 2, &type, -1); |
| 515 | 529 |
| 516 if (presenter_) | 530 if (presenter_.get()) |
| 517 presenter_->OnSitePermissionChanged(ContentSettingsType(type), | 531 presenter_->OnSitePermissionChanged(ContentSettingsType(type), |
| 518 ContentSetting(value)); | 532 ContentSetting(value)); |
| 519 } | 533 } |
| 520 | 534 |
| 521 void WebsiteSettingsPopupGtk::OnViewCertLinkClicked(GtkWidget* widget) { | 535 void WebsiteSettingsPopupGtk::OnViewCertLinkClicked(GtkWidget* widget) { |
| 522 DCHECK_NE(cert_id_, 0); | 536 DCHECK_NE(cert_id_, 0); |
| 523 ShowCertificateViewerByID(GTK_WINDOW(parent_), cert_id_); | 537 ShowCertificateViewerByID(GTK_WINDOW(parent_), cert_id_); |
| 524 bubble_->Close(); | 538 bubble_->Close(); |
| 525 } | 539 } |
| OLD | NEW |