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

Side by Side Diff: chrome/browser/ui/views/website_settings/website_settings_popup_view.cc

Issue 10828201: (Views only) Create a separate class for the contents of the Website Settings UI that is displayed … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 8 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/views/website_settings/website_settings_popup_view.h " 5 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h "
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/certificate_viewer.h" 9 #include "chrome/browser/certificate_viewer.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 127
128 private: 128 private:
129 // The label that displays the name of the site's identity. 129 // The label that displays the name of the site's identity.
130 views::Label* name_; 130 views::Label* name_;
131 // The label that displays the status of the identity check for this site. 131 // The label that displays the status of the identity check for this site.
132 views::Label* status_; 132 views::Label* status_;
133 133
134 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); 134 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView);
135 }; 135 };
136 136
137 // Website Settings are not supported for internal Chrome pages. Instead of the
138 // |WebsiteSettingsPopupView|, the |InternalPageInfoView| is
139 // displayed.
140 class InternalPageInfoView : public views::BubbleDelegateView {
141 public:
142 explicit InternalPageInfoView(views::View* anchor_view);
143 virtual ~InternalPageInfoView();
144
145 private:
146 // views::BubbleDelegate implementations.
147 virtual gfx::Rect GetAnchorRect() OVERRIDE;
148
149 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoView);
150 };
151
137 //////////////////////////////////////////////////////////////////////////////// 152 ////////////////////////////////////////////////////////////////////////////////
138 // Popup Header 153 // Popup Header
139 //////////////////////////////////////////////////////////////////////////////// 154 ////////////////////////////////////////////////////////////////////////////////
140 155
141 PopupHeaderView::PopupHeaderView(views::ButtonListener* close_button_listener) 156 PopupHeaderView::PopupHeaderView(views::ButtonListener* close_button_listener)
142 : name_(NULL), status_(NULL) { 157 : name_(NULL), status_(NULL) {
143 views::GridLayout* layout = new views::GridLayout(this); 158 views::GridLayout* layout = new views::GridLayout(this);
144 SetLayoutManager(layout); 159 SetLayoutManager(layout);
145 160
146 const int label_column = 0; 161 const int label_column = 0;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 void PopupHeaderView::SetIdentityName(const string16& name) { 215 void PopupHeaderView::SetIdentityName(const string16& name) {
201 name_->SetText(name); 216 name_->SetText(name);
202 } 217 }
203 218
204 void PopupHeaderView::SetIdentityStatus(const string16& status, 219 void PopupHeaderView::SetIdentityStatus(const string16& status,
205 SkColor text_color) { 220 SkColor text_color) {
206 status_->SetText(status); 221 status_->SetText(status);
207 status_->SetEnabledColor(text_color); 222 status_->SetEnabledColor(text_color);
208 } 223 }
209 224
210 /////////////////////////////////////////////////////////////////////////////// 225 ////////////////////////////////////////////////////////////////////////////////
226 // InternalPageInfoView
227 ////////////////////////////////////////////////////////////////////////////////
228
229 InternalPageInfoView::InternalPageInfoView(
230 views::View* anchor_view)
msw 2012/08/08 18:34:10 nit: fits on line above.
markusheintz_ 2012/08/08 22:10:02 Done.
231 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) {
232 const int kSpacing = 4;
233 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, kSpacing,
234 kSpacing, kSpacing));
235 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
msw 2012/08/08 18:34:10 nit: move down a line.
markusheintz_ 2012/08/08 22:10:02 Done.
236 views::ImageView* icon_view = new views::ImageView();
237 icon_view->SetImage(rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_26));
238 AddChildView(icon_view);
239
240 string16 text = l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE);
241 views::Label* label = new views::Label(text);
242 label->SetMultiLine(true);
243 label->SetAllowCharacterBreak(true);
244 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
245 AddChildView(label);
246
247 views::BubbleDelegateView::CreateBubble(this);
248 Show();
249 SizeToContents();
250 }
251
252 InternalPageInfoView::~InternalPageInfoView() {
253 }
254
255 gfx::Rect InternalPageInfoView::GetAnchorRect() {
256 // Compensate for some built-in padding in the icon. This will make the arrow
257 // point to the middle of the icon.
258 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect());
259 anchor.Inset(0, anchor_view() ? kLocationIconBottomMargin : 0);
260 return anchor;
261 }
262
263 ////////////////////////////////////////////////////////////////////////////////
211 // WebsiteSettingsPopupView 264 // WebsiteSettingsPopupView
212 /////////////////////////////////////////////////////////////////////////////// 265 ////////////////////////////////////////////////////////////////////////////////
213 266
214 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { 267 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() {
215 } 268 }
216 269
217 // static 270 // static
218 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view, 271 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view,
219 Profile* profile, 272 Profile* profile,
220 TabContents* tab_contents, 273 TabContents* tab_contents,
221 const GURL& url, 274 const GURL& url,
222 const content::SSLStatus& ssl) { 275 const content::SSLStatus& ssl) {
223 new WebsiteSettingsPopupView(anchor_view, profile, tab_contents, url, ssl); 276 if (InternalChromePage(url))
277 new InternalPageInfoView(anchor_view);
278 else
279 new WebsiteSettingsPopupView(anchor_view, profile, tab_contents, url, ssl);
224 } 280 }
225 281
226 WebsiteSettingsPopupView::WebsiteSettingsPopupView( 282 WebsiteSettingsPopupView::WebsiteSettingsPopupView(
227 views::View* anchor_view, 283 views::View* anchor_view,
228 Profile* profile, 284 Profile* profile,
229 TabContents* tab_contents, 285 TabContents* tab_contents,
230 const GURL& url, 286 const GURL& url,
231 const content::SSLStatus& ssl) 287 const content::SSLStatus& ssl)
232 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), 288 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT),
233 tab_contents_(tab_contents), 289 tab_contents_(tab_contents),
234 header_(NULL), 290 header_(NULL),
235 tabbed_pane_(NULL), 291 tabbed_pane_(NULL),
236 site_data_content_(NULL), 292 site_data_content_(NULL),
237 cookie_dialog_link_(NULL), 293 cookie_dialog_link_(NULL),
238 permissions_content_(NULL), 294 permissions_content_(NULL),
239 identity_info_content_(NULL), 295 identity_info_content_(NULL),
240 certificate_dialog_link_(NULL), 296 certificate_dialog_link_(NULL),
241 cert_id_(0), 297 cert_id_(0),
242 connection_info_content_(NULL), 298 connection_info_content_(NULL),
243 page_info_content_(NULL) { 299 page_info_content_(NULL) {
244 if (InternalChromePage(url)) {
245 views::GridLayout* layout = new views::GridLayout(this);
246 SetLayoutManager(layout);
247 views::ColumnSet* column_set = layout->AddColumnSet(0);
248 column_set->AddColumn(views::GridLayout::FILL,
249 views::GridLayout::FILL,
250 0, // Resize weight.
251 views::GridLayout::USE_PREF,
252 0,
253 0);
254 column_set->AddPaddingColumn(0, kIconMarginLeft);
255 column_set->AddColumn(views::GridLayout::FILL,
256 views::GridLayout::FILL,
257 1,
258 views::GridLayout::USE_PREF,
259 0,
260 0);
261
262 layout->StartRow(1, 0);
263
264 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
265 const gfx::Image& icon = rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_26);
266 views::ImageView* icon_view = new views::ImageView();
267 icon_view->SetImage(icon.ToImageSkia());
268 layout->AddView(icon_view, 1, 1, views::GridLayout::LEADING,
269 views::GridLayout::LEADING);
270
271 string16 text = l10n_util::GetStringUTF16(
272 IDS_PAGE_INFO_INTERNAL_PAGE);
273 views::Label* label = new views::Label(text);
274 label->SetMultiLine(true);
275 label->SetAllowCharacterBreak(true);
276 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
277 layout->AddView(label, 1, 1, views::GridLayout::LEADING,
278 views::GridLayout::CENTER);
279
280 views::BubbleDelegateView::CreateBubble(this);
281 Show();
282 SizeToContents();
283 } else {
284 // Non internal chrome page.
285 views::GridLayout* layout = new views::GridLayout(this); 300 views::GridLayout* layout = new views::GridLayout(this);
286 SetLayoutManager(layout); 301 SetLayoutManager(layout);
287 const int content_column = 0; 302 const int content_column = 0;
288 views::ColumnSet* column_set = layout->AddColumnSet(content_column); 303 views::ColumnSet* column_set = layout->AddColumnSet(content_column);
289 column_set->AddColumn(views::GridLayout::FILL, 304 column_set->AddColumn(views::GridLayout::FILL,
290 views::GridLayout::FILL, 305 views::GridLayout::FILL,
291 1, 306 1,
292 views::GridLayout::USE_PREF, 307 views::GridLayout::USE_PREF,
293 0, 308 0,
294 0); 309 0);
(...skipping 26 matching lines...) Expand all
321 views::BubbleDelegateView::CreateBubble(this); 336 views::BubbleDelegateView::CreateBubble(this);
322 this->Show(); 337 this->Show();
323 SizeToContents(); 338 SizeToContents();
324 339
325 presenter_.reset(new WebsiteSettings(this, profile, 340 presenter_.reset(new WebsiteSettings(this, profile,
326 tab_contents->content_settings(), 341 tab_contents->content_settings(),
327 tab_contents->infobar_tab_helper(), 342 tab_contents->infobar_tab_helper(),
328 url, 343 url,
329 ssl, 344 ssl,
330 content::CertStore::GetInstance())); 345 content::CertStore::GetInstance()));
331 }
332 } 346 }
333 347
334 void WebsiteSettingsPopupView::OnPermissionChanged( 348 void WebsiteSettingsPopupView::OnPermissionChanged(
335 PermissionSelectorView* permission_selector) { 349 PermissionSelectorView* permission_selector) {
336 DCHECK(permission_selector); 350 DCHECK(permission_selector);
337 // It's not necessary to check that the |presenter_| is not NULL since for
338 // internal chrome pages OnPermissionChanged can't be called.
339 presenter_->OnSitePermissionChanged( 351 presenter_->OnSitePermissionChanged(
340 permission_selector->GetPermissionType(), 352 permission_selector->GetPermissionType(),
341 permission_selector->GetSelectedSetting()); 353 permission_selector->GetSelectedSetting());
342 } 354 }
343 355
344 gfx::Rect WebsiteSettingsPopupView::GetAnchorRect() { 356 gfx::Rect WebsiteSettingsPopupView::GetAnchorRect() {
345 // Compensate for some built-in padding in the icon. This will make the arrow 357 // Compensate for some built-in padding in the icon. This will make the arrow
346 // point to the middle of the icon. 358 // point to the middle of the icon.
347 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect()); 359 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect());
348 anchor.Inset(0, anchor_view() ? kLocationIconBottomMargin : 0); 360 anchor.Inset(0, anchor_view() ? kLocationIconBottomMargin : 0);
349 return anchor; 361 return anchor;
350 } 362 }
351 363
352 void WebsiteSettingsPopupView::OnWidgetClosing(views::Widget* widget) { 364 void WebsiteSettingsPopupView::OnWidgetClosing(views::Widget* widget) {
353 if (presenter_.get()) 365 presenter_->OnUIClosing();
354 presenter_->OnUIClosing();
355 } 366 }
356 367
357 void WebsiteSettingsPopupView::ButtonPressed( 368 void WebsiteSettingsPopupView::ButtonPressed(
358 views::Button* button, 369 views::Button* button,
359 const views::Event& event) { 370 const views::Event& event) {
360 GetWidget()->Close(); 371 GetWidget()->Close();
361 } 372 }
362 373
363 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, 374 void WebsiteSettingsPopupView::LinkClicked(views::Link* source,
364 int event_flags) { 375 int event_flags) {
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 709
699 if (link) { 710 if (link) {
700 content_layout->StartRow(1, 0); 711 content_layout->StartRow(1, 0);
701 content_layout->AddView(link); 712 content_layout->AddView(link);
702 } 713 }
703 714
704 layout->AddView(content_pane, 1, 1, views::GridLayout::LEADING, 715 layout->AddView(content_pane, 1, 1, views::GridLayout::LEADING,
705 views::GridLayout::LEADING); 716 views::GridLayout::LEADING);
706 layout->AddPaddingRow(0, kConnectionSectionPaddingBottom); 717 layout->AddPaddingRow(0, kConnectionSectionPaddingBottom);
707 } 718 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698