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

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

Issue 1280673003: [Mac] Enable MacViews site settings bubble behind --enable-mac-views-dialogs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@enabledialogs
Patch Set: Address comments. Created 5 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
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 views::Label* status_; 134 views::Label* status_;
135 135
136 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); 136 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView);
137 }; 137 };
138 138
139 // Website Settings are not supported for internal Chrome pages. Instead of the 139 // Website Settings are not supported for internal Chrome pages. Instead of the
140 // |WebsiteSettingsPopupView|, the |InternalPageInfoPopupView| is 140 // |WebsiteSettingsPopupView|, the |InternalPageInfoPopupView| is
141 // displayed. 141 // displayed.
142 class InternalPageInfoPopupView : public views::BubbleDelegateView { 142 class InternalPageInfoPopupView : public views::BubbleDelegateView {
143 public: 143 public:
144 explicit InternalPageInfoPopupView(views::View* anchor_view); 144 // If |anchor_view| is nullptr, or has no Widget, |parent_window| may be
145 // provided to ensure this bubble is closed when the parent closes.
146 InternalPageInfoPopupView(views::View* anchor_view,
147 gfx::NativeView parent_window);
145 ~InternalPageInfoPopupView() override; 148 ~InternalPageInfoPopupView() override;
146 149
147 // views::BubbleDelegateView: 150 // views::BubbleDelegateView:
148 void OnWidgetDestroying(views::Widget* widget) override; 151 void OnWidgetDestroying(views::Widget* widget) override;
149 152
150 private: 153 private:
154 friend class WebsiteSettingsPopupView;
155
151 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); 156 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView);
152 }; 157 };
153 158
154 //////////////////////////////////////////////////////////////////////////////// 159 ////////////////////////////////////////////////////////////////////////////////
155 // Popup Header 160 // Popup Header
156 //////////////////////////////////////////////////////////////////////////////// 161 ////////////////////////////////////////////////////////////////////////////////
157 162
158 PopupHeaderView::PopupHeaderView(views::ButtonListener* close_button_listener) 163 PopupHeaderView::PopupHeaderView(views::ButtonListener* close_button_listener)
159 : name_(nullptr), status_(nullptr) { 164 : name_(nullptr), status_(nullptr) {
160 views::GridLayout* layout = new views::GridLayout(this); 165 views::GridLayout* layout = new views::GridLayout(this);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 void PopupHeaderView::SetIdentityStatus(const base::string16& status, 227 void PopupHeaderView::SetIdentityStatus(const base::string16& status,
223 SkColor text_color) { 228 SkColor text_color) {
224 status_->SetText(status); 229 status_->SetText(status);
225 status_->SetEnabledColor(text_color); 230 status_->SetEnabledColor(text_color);
226 } 231 }
227 232
228 //////////////////////////////////////////////////////////////////////////////// 233 ////////////////////////////////////////////////////////////////////////////////
229 // InternalPageInfoPopupView 234 // InternalPageInfoPopupView
230 //////////////////////////////////////////////////////////////////////////////// 235 ////////////////////////////////////////////////////////////////////////////////
231 236
232 InternalPageInfoPopupView::InternalPageInfoPopupView(views::View* anchor_view) 237 InternalPageInfoPopupView::InternalPageInfoPopupView(
238 views::View* anchor_view,
239 gfx::NativeView parent_window)
233 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) { 240 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) {
241 set_parent_window(parent_window);
242
234 // Compensate for built-in vertical padding in the anchor view's image. 243 // Compensate for built-in vertical padding in the anchor view's image.
235 set_anchor_view_insets(gfx::Insets(kLocationIconVerticalMargin, 0, 244 set_anchor_view_insets(gfx::Insets(kLocationIconVerticalMargin, 0,
236 kLocationIconVerticalMargin, 0)); 245 kLocationIconVerticalMargin, 0));
237 246
238 const int kSpacing = 4; 247 const int kSpacing = 4;
239 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, kSpacing, 248 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, kSpacing,
240 kSpacing, kSpacing)); 249 kSpacing, kSpacing));
241 views::ImageView* icon_view = new views::ImageView(); 250 views::ImageView* icon_view = new views::ImageView();
242 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 251 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
243 icon_view->SetImage(rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_26)); 252 icon_view->SetImage(rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_26));
244 AddChildView(icon_view); 253 AddChildView(icon_view);
245 254
246 views::Label* label = 255 views::Label* label =
247 new views::Label(l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE)); 256 new views::Label(l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE));
248 label->SetMultiLine(true); 257 label->SetMultiLine(true);
249 label->SetAllowCharacterBreak(true); 258 label->SetAllowCharacterBreak(true);
250 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 259 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
251 AddChildView(label); 260 AddChildView(label);
252 261
253 views::BubbleDelegateView::CreateBubble(this)->Show(); 262 views::BubbleDelegateView::CreateBubble(this);
254 SizeToContents();
255 } 263 }
256 264
257 InternalPageInfoPopupView::~InternalPageInfoPopupView() { 265 InternalPageInfoPopupView::~InternalPageInfoPopupView() {
258 } 266 }
259 267
260 void InternalPageInfoPopupView::OnWidgetDestroying(views::Widget* widget) { 268 void InternalPageInfoPopupView::OnWidgetDestroying(views::Widget* widget) {
261 is_popup_showing = false; 269 is_popup_showing = false;
262 } 270 }
263 271
264 //////////////////////////////////////////////////////////////////////////////// 272 ////////////////////////////////////////////////////////////////////////////////
265 // WebsiteSettingsPopupView 273 // WebsiteSettingsPopupView
266 //////////////////////////////////////////////////////////////////////////////// 274 ////////////////////////////////////////////////////////////////////////////////
267 275
268 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { 276 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() {
269 } 277 }
270 278
271 // static 279 // static
272 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view, 280 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view,
281 const gfx::Rect& anchor_rect,
273 Profile* profile, 282 Profile* profile,
274 content::WebContents* web_contents, 283 content::WebContents* web_contents,
275 const GURL& url, 284 const GURL& url,
276 const content::SSLStatus& ssl) { 285 const content::SSLStatus& ssl) {
277 is_popup_showing = true; 286 is_popup_showing = true;
287 gfx::NativeView parent_window =
288 anchor_view ? nullptr : web_contents->GetNativeView();
278 if (InternalChromePage(url)) { 289 if (InternalChromePage(url)) {
279 new InternalPageInfoPopupView(anchor_view); 290 // Use the concrete type so that SetAnchorRect() can be called as a friend.
291 InternalPageInfoPopupView* popup =
292 new InternalPageInfoPopupView(anchor_view, parent_window);
293 if (!anchor_view)
294 popup->SetAnchorRect(anchor_rect);
295 popup->GetWidget()->Show();
280 } else { 296 } else {
281 new WebsiteSettingsPopupView(anchor_view, profile, web_contents, url, ssl); 297 WebsiteSettingsPopupView* popup = new WebsiteSettingsPopupView(
298 anchor_view, parent_window, profile, web_contents, url, ssl);
299 if (!anchor_view)
300 popup->SetAnchorRect(anchor_rect);
301 popup->GetWidget()->Show();
282 } 302 }
283 } 303 }
284 304
285 // static 305 // static
286 bool WebsiteSettingsPopupView::IsPopupShowing() { 306 bool WebsiteSettingsPopupView::IsPopupShowing() {
287 return is_popup_showing; 307 return is_popup_showing;
288 } 308 }
289 309
290 WebsiteSettingsPopupView::WebsiteSettingsPopupView( 310 WebsiteSettingsPopupView::WebsiteSettingsPopupView(
291 views::View* anchor_view, 311 views::View* anchor_view,
312 gfx::NativeView parent_window,
292 Profile* profile, 313 Profile* profile,
293 content::WebContents* web_contents, 314 content::WebContents* web_contents,
294 const GURL& url, 315 const GURL& url,
295 const content::SSLStatus& ssl) 316 const content::SSLStatus& ssl)
296 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), 317 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT),
297 web_contents_(web_contents), 318 web_contents_(web_contents),
298 header_(nullptr), 319 header_(nullptr),
299 tabbed_pane_(nullptr), 320 tabbed_pane_(nullptr),
300 permissions_tab_(nullptr), 321 permissions_tab_(nullptr),
301 site_data_content_(nullptr), 322 site_data_content_(nullptr),
302 cookie_dialog_link_(nullptr), 323 cookie_dialog_link_(nullptr),
303 permissions_content_(nullptr), 324 permissions_content_(nullptr),
304 connection_tab_(nullptr), 325 connection_tab_(nullptr),
305 identity_info_content_(nullptr), 326 identity_info_content_(nullptr),
306 certificate_dialog_link_(nullptr), 327 certificate_dialog_link_(nullptr),
307 reset_decisions_button_(nullptr), 328 reset_decisions_button_(nullptr),
308 help_center_content_(nullptr), 329 help_center_content_(nullptr),
309 cert_id_(0), 330 cert_id_(0),
310 help_center_link_(nullptr), 331 help_center_link_(nullptr),
311 connection_info_content_(nullptr), 332 connection_info_content_(nullptr),
312 weak_factory_(this) { 333 weak_factory_(this) {
334 set_parent_window(parent_window);
335
313 // Compensate for built-in vertical padding in the anchor view's image. 336 // Compensate for built-in vertical padding in the anchor view's image.
314 set_anchor_view_insets(gfx::Insets(kLocationIconVerticalMargin, 0, 337 set_anchor_view_insets(gfx::Insets(kLocationIconVerticalMargin, 0,
315 kLocationIconVerticalMargin, 0)); 338 kLocationIconVerticalMargin, 0));
316 339
317 views::GridLayout* layout = new views::GridLayout(this); 340 views::GridLayout* layout = new views::GridLayout(this);
318 SetLayoutManager(layout); 341 SetLayoutManager(layout);
319 const int content_column = 0; 342 const int content_column = 0;
320 views::ColumnSet* column_set = layout->AddColumnSet(content_column); 343 views::ColumnSet* column_set = layout->AddColumnSet(content_column);
321 column_set->AddColumn(views::GridLayout::FILL, 344 column_set->AddColumn(views::GridLayout::FILL,
322 views::GridLayout::FILL, 345 views::GridLayout::FILL,
(...skipping 24 matching lines...) Expand all
347 tabbed_pane_->AddTabAtIndex( 370 tabbed_pane_->AddTabAtIndex(
348 TAB_ID_CONNECTION, 371 TAB_ID_CONNECTION,
349 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION), 372 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION),
350 connection_tab_); 373 connection_tab_);
351 DCHECK_EQ(tabbed_pane_->GetTabCount(), NUM_TAB_IDS); 374 DCHECK_EQ(tabbed_pane_->GetTabCount(), NUM_TAB_IDS);
352 tabbed_pane_->set_listener(this); 375 tabbed_pane_->set_listener(this);
353 376
354 set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft, 377 set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft,
355 kPopupMarginBottom, kPopupMarginRight)); 378 kPopupMarginBottom, kPopupMarginRight));
356 379
357 views::BubbleDelegateView::CreateBubble(this)->Show(); 380 views::BubbleDelegateView::CreateBubble(this);
358 SizeToContents();
359 381
360 presenter_.reset(new WebsiteSettings( 382 presenter_.reset(new WebsiteSettings(
361 this, profile, 383 this, profile,
362 TabSpecificContentSettings::FromWebContents(web_contents), 384 TabSpecificContentSettings::FromWebContents(web_contents),
363 InfoBarService::FromWebContents(web_contents), url, ssl, 385 InfoBarService::FromWebContents(web_contents), url, ssl,
364 content::CertStore::GetInstance())); 386 content::CertStore::GetInstance()));
365 } 387 }
366 388
367 void WebsiteSettingsPopupView::OnPermissionChanged( 389 void WebsiteSettingsPopupView::OnPermissionChanged(
368 const WebsiteSettingsUI::PermissionInfo& permission) { 390 const WebsiteSettingsUI::PermissionInfo& permission) {
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 // desktop we should link to that here, too. 824 // desktop we should link to that here, too.
803 web_contents_->OpenURL(content::OpenURLParams( 825 web_contents_->OpenURL(content::OpenURLParams(
804 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(), 826 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(),
805 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, false)); 827 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, false));
806 presenter_->RecordWebsiteSettingsAction( 828 presenter_->RecordWebsiteSettingsAction(
807 WebsiteSettings::WEBSITE_SETTINGS_SITE_SETTINGS_OPENED); 829 WebsiteSettings::WEBSITE_SETTINGS_SITE_SETTINGS_OPENED);
808 } else { 830 } else {
809 NOTREACHED(); 831 NOTREACHED();
810 } 832 }
811 } 833 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/website_settings/website_settings_popup_view.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698