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

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: Address comments 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" 7 #include "base/basictypes.h"
tfarina 2012/06/01 21:20:26 include this for DISALLOW_ macro and compiler_spec
markusheintz_ 2012/06/02 21:22:33 Done.
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/ui/website_settings/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"
32 #include "googleurl/src/gurl.h"
tfarina 2012/06/01 21:20:26 sort this.
markusheintz_ 2012/06/02 21:22:33 Done.
31 33
32 using content::OpenURLParams; 34 using content::OpenURLParams;
33 35
34 namespace { 36 namespace {
35 37
36 // The background color of the tabs if a theme other than the native GTK theme 38 // The background color of the tabs if a theme other than the native GTK theme
37 // is selected. 39 // is selected.
38 const GdkColor kBackgroundColor = GDK_COLOR_RGB(0xff, 0xff, 0xff); 40 const GdkColor kBackgroundColor = GDK_COLOR_RGB(0xff, 0xff, 0xff);
39 41
40 std::string PermissionTypeToString(ContentSettingsType type) { 42 std::string PermissionTypeToString(ContentSettingsType type) {
(...skipping 21 matching lines...) Expand all
62 case CONTENT_SETTING_ASK: 64 case CONTENT_SETTING_ASK:
63 return l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_PERMISSION_ASK); 65 return l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_PERMISSION_ASK);
64 default: 66 default:
65 NOTREACHED(); 67 NOTREACHED();
66 return ""; 68 return "";
67 } 69 }
68 } 70 }
69 71
70 } // namespace 72 } // namespace
71 73
74 // static
75 void WebsiteSettingsPopupGtk::Show(gfx::NativeWindow parent,
tfarina 2012/06/01 21:20:26 the order of the implementation of this function i
markusheintz_ 2012/06/02 21:22:33 I'd prefere to have the same order as in the heade
76 Profile* profile,
77 TabContentsWrapper* tab_contents_wrapper,
78 const GURL& url,
79 const content::SSLStatus& ssl) {
80 new WebsiteSettingsPopupGtk(parent,
tfarina 2012/06/01 21:20:26 since this is your code and I'm not the OWNER, thi
markusheintz_ 2012/06/02 21:22:33 Cool. This fits in a single line. Great.
81 profile,
82 tab_contents_wrapper,
83 url,
84 ssl);
85 }
86
72 WebsiteSettingsPopupGtk::WebsiteSettingsPopupGtk( 87 WebsiteSettingsPopupGtk::WebsiteSettingsPopupGtk(
73 gfx::NativeWindow parent, 88 gfx::NativeWindow parent,
74 Profile* profile, 89 Profile* profile,
75 TabContentsWrapper* tab_contents_wrapper) 90 TabContentsWrapper* tab_contents_wrapper,
91 const GURL& url,
92 const content::SSLStatus& ssl)
76 : parent_(parent), 93 : parent_(parent),
77 contents_(NULL), 94 contents_(NULL),
78 theme_service_(GtkThemeService::GetFrom(profile)), 95 theme_service_(GtkThemeService::GetFrom(profile)),
79 profile_(profile), 96 profile_(profile),
80 tab_contents_wrapper_(tab_contents_wrapper), 97 tab_contents_wrapper_(tab_contents_wrapper),
81 browser_(NULL), 98 browser_(NULL),
82 cert_id_(0), 99 cert_id_(0),
83 header_box_(NULL), 100 header_box_(NULL),
84 cookies_section_contents_(NULL), 101 cookies_section_contents_(NULL),
85 permissions_section_contents_(NULL), 102 permissions_section_contents_(NULL),
(...skipping 17 matching lines...) Expand all
103 arrow_location, 120 arrow_location,
104 BubbleGtk::MATCH_SYSTEM_THEME | 121 BubbleGtk::MATCH_SYSTEM_THEME |
105 BubbleGtk::POPUP_WINDOW | 122 BubbleGtk::POPUP_WINDOW |
106 BubbleGtk::GRAB_INPUT, 123 BubbleGtk::GRAB_INPUT,
107 theme_service_, 124 theme_service_,
108 this); // |delegate| 125 this); // |delegate|
109 if (!bubble_) { 126 if (!bubble_) {
110 NOTREACHED(); 127 NOTREACHED();
111 return; 128 return;
112 } 129 }
130
131 presenter_.reset(new WebsiteSettings(
tfarina 2012/06/01 21:20:26 so you will have to do this in views and cocoa. :/
markusheintz_ 2012/06/02 21:22:33 I instantiated the WebsiteSettings class in the pl
132 this,
133 profile,
134 tab_contents_wrapper->content_settings(),
135 url,
136 ssl,
137 content::CertStore::GetInstance()));
113 } 138 }
114 139
115 WebsiteSettingsPopupGtk::~WebsiteSettingsPopupGtk() { 140 WebsiteSettingsPopupGtk::~WebsiteSettingsPopupGtk() {
116 } 141 }
117 142
118 void WebsiteSettingsPopupGtk::SetPresenter(WebsiteSettings* presenter) {
119 presenter_ = presenter;
120 }
121
122 void WebsiteSettingsPopupGtk::BubbleClosing(BubbleGtk* bubble, 143 void WebsiteSettingsPopupGtk::BubbleClosing(BubbleGtk* bubble,
123 bool closed_by_escape) { 144 bool closed_by_escape) {
124 if (presenter_) 145 if (presenter_.get())
125 presenter_->OnUIClosing(); 146 presenter_.reset(NULL);
tfarina 2012/06/01 21:20:26 you don't need to pass NULL here, scoped_ptr::rese
markusheintz_ 2012/06/02 21:22:33 Done.
147 delete this;
126 } 148 }
127 149
128 void WebsiteSettingsPopupGtk::InitContents() { 150 void WebsiteSettingsPopupGtk::InitContents() {
129 if (!contents_) { 151 if (!contents_) {
130 contents_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); 152 contents_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing);
131 gtk_container_set_border_width(GTK_CONTAINER(contents_), 153 gtk_container_set_border_width(GTK_CONTAINER(contents_),
132 ui::kContentAreaBorder); 154 ui::kContentAreaBorder);
133 } else { 155 } else {
134 gtk_util::RemoveAllChildren(contents_); 156 gtk_util::RemoveAllChildren(contents_);
135 } 157 }
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 GtkTreeIter it; 528 GtkTreeIter it;
507 bool has_active = gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &it); 529 bool has_active = gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &it);
508 DCHECK(has_active); 530 DCHECK(has_active);
509 GtkTreeModel* store = 531 GtkTreeModel* store =
510 GTK_TREE_MODEL(gtk_combo_box_get_model(GTK_COMBO_BOX(widget))); 532 GTK_TREE_MODEL(gtk_combo_box_get_model(GTK_COMBO_BOX(widget)));
511 533
512 int value = -1; 534 int value = -1;
513 int type = -1; 535 int type = -1;
514 gtk_tree_model_get(store, &it, 1, &value, 2, &type, -1); 536 gtk_tree_model_get(store, &it, 1, &value, 2, &type, -1);
515 537
516 if (presenter_) 538 if (presenter_.get())
517 presenter_->OnSitePermissionChanged(ContentSettingsType(type), 539 presenter_->OnSitePermissionChanged(ContentSettingsType(type),
518 ContentSetting(value)); 540 ContentSetting(value));
tfarina 2012/06/01 21:20:26 nit: while you are, fix the indentation here.
markusheintz_ 2012/06/02 21:22:33 Done. Same above.
519 } 541 }
520 542
521 void WebsiteSettingsPopupGtk::OnViewCertLinkClicked(GtkWidget* widget) { 543 void WebsiteSettingsPopupGtk::OnViewCertLinkClicked(GtkWidget* widget) {
522 DCHECK_NE(cert_id_, 0); 544 DCHECK_NE(cert_id_, 0);
523 ShowCertificateViewerByID(GTK_WINDOW(parent_), cert_id_); 545 ShowCertificateViewerByID(GTK_WINDOW(parent_), cert_id_);
524 bubble_->Close(); 546 bubble_->Close();
525 } 547 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698