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

Side by Side Diff: chrome/browser/ui/gtk/website_settings_popup_gtk.cc

Issue 10440092: Remove any platform specific code from the chrome/browser/website_settings.* . (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort includes Created 8 years, 6 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_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"
9 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
10 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
11 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/certificate_viewer.h" 10 #include "chrome/browser/certificate_viewer.h"
13 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_list.h" 12 #include "chrome/browser/ui/browser_list.h"
15 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" 13 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h"
16 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 14 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
17 #include "chrome/browser/ui/gtk/collected_cookies_gtk.h" 15 #include "chrome/browser/ui/gtk/collected_cookies_gtk.h"
18 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" 16 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
19 #include "chrome/browser/ui/gtk/gtk_util.h" 17 #include "chrome/browser/ui/gtk/gtk_util.h"
20 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 18 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
21 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" 19 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h"
22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
23 #include "chrome/browser/website_settings.h" 21 #include "chrome/browser/ui/website_settings/website_settings.h"
24 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
23 #include "content/public/browser/cert_store.h"
24 #include "googleurl/src/gurl.h"
25 #include "grit/generated_resources.h" 25 #include "grit/generated_resources.h"
26 #include "grit/locale_settings.h" 26 #include "grit/locale_settings.h"
27 #include "grit/theme_resources.h" 27 #include "grit/theme_resources.h"
28 #include "ui/base/gtk/gtk_hig_constants.h" 28 #include "ui/base/gtk/gtk_hig_constants.h"
29 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
30 #include "ui/base/resource/resource_bundle.h" 30 #include "ui/base/resource/resource_bundle.h"
31 31
32 using content::OpenURLParams; 32 using content::OpenURLParams;
33 33
34 namespace { 34 namespace {
(...skipping 27 matching lines...) Expand all
62 case CONTENT_SETTING_ASK: 62 case CONTENT_SETTING_ASK:
63 return l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_PERMISSION_ASK); 63 return l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_PERMISSION_ASK);
64 default: 64 default:
65 NOTREACHED(); 65 NOTREACHED();
66 return ""; 66 return "";
67 } 67 }
68 } 68 }
69 69
70 } // namespace 70 } // namespace
71 71
72 // static
73 void WebsiteSettingsPopupGtk::Show(gfx::NativeWindow parent,
74 Profile* profile,
75 TabContentsWrapper* tab_contents_wrapper,
76 const GURL& url,
77 const content::SSLStatus& ssl) {
78 new WebsiteSettingsPopupGtk(parent, profile, tab_contents_wrapper, url, ssl);
79 }
80
72 WebsiteSettingsPopupGtk::WebsiteSettingsPopupGtk( 81 WebsiteSettingsPopupGtk::WebsiteSettingsPopupGtk(
73 gfx::NativeWindow parent, 82 gfx::NativeWindow parent,
74 Profile* profile, 83 Profile* profile,
75 TabContentsWrapper* tab_contents_wrapper) 84 TabContentsWrapper* tab_contents_wrapper,
85 const GURL& url,
86 const content::SSLStatus& ssl)
76 : parent_(parent), 87 : parent_(parent),
77 contents_(NULL), 88 contents_(NULL),
78 theme_service_(GtkThemeService::GetFrom(profile)), 89 theme_service_(GtkThemeService::GetFrom(profile)),
79 profile_(profile), 90 profile_(profile),
80 tab_contents_wrapper_(tab_contents_wrapper), 91 tab_contents_wrapper_(tab_contents_wrapper),
81 browser_(NULL), 92 browser_(NULL),
82 cert_id_(0), 93 cert_id_(0),
83 header_box_(NULL), 94 header_box_(NULL),
84 cookies_section_contents_(NULL), 95 cookies_section_contents_(NULL),
85 permissions_section_contents_(NULL), 96 permissions_section_contents_(NULL),
(...skipping 17 matching lines...) Expand all
103 arrow_location, 114 arrow_location,
104 BubbleGtk::MATCH_SYSTEM_THEME | 115 BubbleGtk::MATCH_SYSTEM_THEME |
105 BubbleGtk::POPUP_WINDOW | 116 BubbleGtk::POPUP_WINDOW |
106 BubbleGtk::GRAB_INPUT, 117 BubbleGtk::GRAB_INPUT,
107 theme_service_, 118 theme_service_,
108 this); // |delegate| 119 this); // |delegate|
109 if (!bubble_) { 120 if (!bubble_) {
110 NOTREACHED(); 121 NOTREACHED();
111 return; 122 return;
112 } 123 }
124
125 presenter_.reset(new WebsiteSettings(this, profile,
126 tab_contents_wrapper->content_settings(),
127 url, ssl,
128 content::CertStore::GetInstance()));
113 } 129 }
114 130
115 WebsiteSettingsPopupGtk::~WebsiteSettingsPopupGtk() { 131 WebsiteSettingsPopupGtk::~WebsiteSettingsPopupGtk() {
116 } 132 }
117 133
118 void WebsiteSettingsPopupGtk::SetPresenter(WebsiteSettings* presenter) {
119 presenter_ = presenter;
120 }
121
122 void WebsiteSettingsPopupGtk::BubbleClosing(BubbleGtk* bubble, 134 void WebsiteSettingsPopupGtk::BubbleClosing(BubbleGtk* bubble,
123 bool closed_by_escape) { 135 bool closed_by_escape) {
124 if (presenter_) 136 if (presenter_.get())
125 presenter_->OnUIClosing(); 137 presenter_.reset();
138 delete this;
126 } 139 }
127 140
128 void WebsiteSettingsPopupGtk::InitContents() { 141 void WebsiteSettingsPopupGtk::InitContents() {
129 if (!contents_) { 142 if (!contents_) {
130 contents_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); 143 contents_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing);
131 gtk_container_set_border_width(GTK_CONTAINER(contents_), 144 gtk_container_set_border_width(GTK_CONTAINER(contents_),
132 ui::kContentAreaBorder); 145 ui::kContentAreaBorder);
133 } else { 146 } else {
134 gtk_util::RemoveAllChildren(contents_); 147 gtk_util::RemoveAllChildren(contents_);
135 } 148 }
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 void WebsiteSettingsPopupGtk::OnCookiesLinkClicked(GtkWidget* widget) { 500 void WebsiteSettingsPopupGtk::OnCookiesLinkClicked(GtkWidget* widget) {
488 new CollectedCookiesGtk(GTK_WINDOW(parent_), 501 new CollectedCookiesGtk(GTK_WINDOW(parent_),
489 tab_contents_wrapper_); 502 tab_contents_wrapper_);
490 bubble_->Close(); 503 bubble_->Close();
491 } 504 }
492 505
493 void WebsiteSettingsPopupGtk::OnPermissionsSettingsLinkClicked( 506 void WebsiteSettingsPopupGtk::OnPermissionsSettingsLinkClicked(
494 GtkWidget* widget) { 507 GtkWidget* widget) {
495 browser_->OpenURL(OpenURLParams( 508 browser_->OpenURL(OpenURLParams(
496 GURL(std::string( 509 GURL(std::string(
497 chrome::kChromeUISettingsURL) + chrome::kContentSettingsSubPage), 510 chrome::kChromeUISettingsURL) + chrome::kContentSettingsSubPage),
498 content::Referrer(), 511 content::Referrer(),
499 NEW_FOREGROUND_TAB, 512 NEW_FOREGROUND_TAB,
500 content::PAGE_TRANSITION_LINK, 513 content::PAGE_TRANSITION_LINK,
501 false)); 514 false));
502 bubble_->Close(); 515 bubble_->Close();
503 } 516 }
504 517
505 void WebsiteSettingsPopupGtk::OnPermissionChanged(GtkWidget* widget) { 518 void WebsiteSettingsPopupGtk::OnPermissionChanged(GtkWidget* widget) {
506 GtkTreeIter it; 519 GtkTreeIter it;
507 bool has_active = gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &it); 520 bool has_active = gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &it);
508 DCHECK(has_active); 521 DCHECK(has_active);
509 GtkTreeModel* store = 522 GtkTreeModel* store =
510 GTK_TREE_MODEL(gtk_combo_box_get_model(GTK_COMBO_BOX(widget))); 523 GTK_TREE_MODEL(gtk_combo_box_get_model(GTK_COMBO_BOX(widget)));
511 524
512 int value = -1; 525 int value = -1;
513 int type = -1; 526 int type = -1;
514 gtk_tree_model_get(store, &it, 1, &value, 2, &type, -1); 527 gtk_tree_model_get(store, &it, 1, &value, 2, &type, -1);
515 528
516 if (presenter_) 529 if (presenter_.get())
517 presenter_->OnSitePermissionChanged(ContentSettingsType(type), 530 presenter_->OnSitePermissionChanged(ContentSettingsType(type),
518 ContentSetting(value)); 531 ContentSetting(value));
519 } 532 }
520 533
521 void WebsiteSettingsPopupGtk::OnViewCertLinkClicked(GtkWidget* widget) { 534 void WebsiteSettingsPopupGtk::OnViewCertLinkClicked(GtkWidget* widget) {
522 DCHECK_NE(cert_id_, 0); 535 DCHECK_NE(cert_id_, 0);
523 ShowCertificateViewerByID(GTK_WINDOW(parent_), cert_id_); 536 ShowCertificateViewerByID(GTK_WINDOW(parent_), cert_id_);
524 bubble_->Close(); 537 bubble_->Close();
525 } 538 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/website_settings_popup_gtk.h ('k') | chrome/browser/ui/website_settings/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698