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

Side by Side Diff: chrome/browser/ui/views/autofill/autofill_dialog_views.cc

Issue 319013002: Reland Fix Views web-modal dialog widget creation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert MediaGalleriesScanResultDialogViews::AcceptDialogForTesting. Created 6 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/views/autofill/autofill_dialog_views.h" 5 #include "chrome/browser/ui/views/autofill/autofill_dialog_views.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #include "ui/views/controls/webview/webview.h" 60 #include "ui/views/controls/webview/webview.h"
61 #include "ui/views/layout/box_layout.h" 61 #include "ui/views/layout/box_layout.h"
62 #include "ui/views/layout/fill_layout.h" 62 #include "ui/views/layout/fill_layout.h"
63 #include "ui/views/layout/grid_layout.h" 63 #include "ui/views/layout/grid_layout.h"
64 #include "ui/views/layout/layout_constants.h" 64 #include "ui/views/layout/layout_constants.h"
65 #include "ui/views/painter.h" 65 #include "ui/views/painter.h"
66 #include "ui/views/widget/widget.h" 66 #include "ui/views/widget/widget.h"
67 #include "ui/views/window/dialog_client_view.h" 67 #include "ui/views/window/dialog_client_view.h"
68 #include "ui/views/window/non_client_view.h" 68 #include "ui/views/window/non_client_view.h"
69 69
70 using web_modal::WebContentsModalDialogManager;
71 using web_modal::WebContentsModalDialogManagerDelegate;
72
73 namespace autofill { 70 namespace autofill {
74 71
75 namespace { 72 namespace {
76 73
77 // The width for the section container. 74 // The width for the section container.
78 const int kSectionContainerWidth = 440; 75 const int kSectionContainerWidth = 440;
79 76
80 // The minimum useful height of the contents area of the dialog. 77 // The minimum useful height of the contents area of the dialog.
81 const int kMinimumContentsHeight = 101; 78 const int kMinimumContentsHeight = 101;
82 79
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 HideErrorBubble(); 1231 HideErrorBubble();
1235 DCHECK(!window_); 1232 DCHECK(!window_);
1236 } 1233 }
1237 1234
1238 void AutofillDialogViews::Show() { 1235 void AutofillDialogViews::Show() {
1239 InitChildViews(); 1236 InitChildViews();
1240 UpdateAccountChooser(); 1237 UpdateAccountChooser();
1241 UpdateNotificationArea(); 1238 UpdateNotificationArea();
1242 UpdateButtonStripExtraView(); 1239 UpdateButtonStripExtraView();
1243 1240
1244 // Ownership of |contents_| is handed off by this call. The widget will take 1241 window_ = ShowWebModalDialogViews(this, delegate_->GetWebContents());
1245 // care of deleting itself after calling DeleteDelegate().
1246 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
1247 WebContentsModalDialogManager::FromWebContents(
1248 delegate_->GetWebContents());
1249 WebContentsModalDialogManagerDelegate* modal_delegate =
1250 web_contents_modal_dialog_manager->delegate();
1251 DCHECK(modal_delegate);
1252 window_ = views::Widget::CreateWindowAsFramelessChild(
1253 this, modal_delegate->GetWebContentsModalDialogHost()->GetHostView());
1254 web_contents_modal_dialog_manager->ShowModalDialog(
1255 window_->GetNativeView());
1256 focus_manager_ = window_->GetFocusManager(); 1242 focus_manager_ = window_->GetFocusManager();
1257 focus_manager_->AddFocusChangeListener(this); 1243 focus_manager_->AddFocusChangeListener(this);
1258 1244
1259 ShowDialogInMode(DETAIL_INPUT); 1245 ShowDialogInMode(DETAIL_INPUT);
1260 1246
1261 // Listen for size changes on the browser. 1247 // Listen for size changes on the browser.
1262 views::Widget* browser_widget = 1248 views::Widget* browser_widget =
1263 views::Widget::GetTopLevelWidgetForNativeView( 1249 views::Widget::GetTopLevelWidgetForNativeView(
1264 delegate_->GetWebContents()->GetNativeView()); 1250 delegate_->GetWebContents()->GetNativeView());
1265 observer_.Add(browser_widget); 1251 observer_.Add(browser_widget);
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 1515
1530 // NOTE: This color may change because of |auto_color_readability|, set on 1516 // NOTE: This color may change because of |auto_color_readability|, set on
1531 // |legal_document_view_|. 1517 // |legal_document_view_|.
1532 views::StyledLabel::RangeStyleInfo default_style; 1518 views::StyledLabel::RangeStyleInfo default_style;
1533 default_style.color = 1519 default_style.color =
1534 theme->GetSystemColor(ui::NativeTheme::kColorId_LabelDisabledColor); 1520 theme->GetSystemColor(ui::NativeTheme::kColorId_LabelDisabledColor);
1535 1521
1536 legal_document_view_->SetDefaultStyle(default_style); 1522 legal_document_view_->SetDefaultStyle(default_style);
1537 } 1523 }
1538 1524
1525 ui::ModalType AutofillDialogViews::GetModalType() const {
1526 return ui::MODAL_TYPE_CHILD;
1527 }
1528
1539 base::string16 AutofillDialogViews::GetWindowTitle() const { 1529 base::string16 AutofillDialogViews::GetWindowTitle() const {
1540 base::string16 title = delegate_->DialogTitle(); 1530 base::string16 title = delegate_->DialogTitle();
1541 // Hack alert: we don't want the dialog to jiggle when a title is added or 1531 // Hack alert: we don't want the dialog to jiggle when a title is added or
1542 // removed. Setting a non-empty string here keeps the dialog's title bar the 1532 // removed. Setting a non-empty string here keeps the dialog's title bar the
1543 // same size. 1533 // same size.
1544 return title.empty() ? base::ASCIIToUTF16(" ") : title; 1534 return title.empty() ? base::ASCIIToUTF16(" ") : title;
1545 } 1535 }
1546 1536
1547 void AutofillDialogViews::WindowClosing() { 1537 void AutofillDialogViews::WindowClosing() {
1548 focus_manager_->RemoveFocusChangeListener(this); 1538 focus_manager_->RemoveFocusChangeListener(this);
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 return gfx::Size(width + insets.width(), height + insets.height()); 1791 return gfx::Size(width + insets.width(), height + insets.height());
1802 } 1792 }
1803 1793
1804 gfx::Size AutofillDialogViews::GetMinimumSignInViewSize() const { 1794 gfx::Size AutofillDialogViews::GetMinimumSignInViewSize() const {
1805 return gfx::Size(GetDialogClientView()->size().width() - GetInsets().width(), 1795 return gfx::Size(GetDialogClientView()->size().width() - GetInsets().width(),
1806 kMinimumContentsHeight); 1796 kMinimumContentsHeight);
1807 } 1797 }
1808 1798
1809 gfx::Size AutofillDialogViews::GetMaximumSignInViewSize() const { 1799 gfx::Size AutofillDialogViews::GetMaximumSignInViewSize() const {
1810 web_modal::WebContentsModalDialogHost* dialog_host = 1800 web_modal::WebContentsModalDialogHost* dialog_host =
1811 WebContentsModalDialogManager::FromWebContents( 1801 web_modal::WebContentsModalDialogManager::FromWebContents(
1812 delegate_->GetWebContents())->delegate()-> 1802 delegate_->GetWebContents())->delegate()->
1813 GetWebContentsModalDialogHost(); 1803 GetWebContentsModalDialogHost();
1814 1804
1815 // Inset the maximum dialog height to get the maximum content height. 1805 // Inset the maximum dialog height to get the maximum content height.
1816 int height = dialog_host->GetMaximumDialogSize().height(); 1806 int height = dialog_host->GetMaximumDialogSize().height();
1817 const int non_client_height = GetWidget()->non_client_view()->height(); 1807 const int non_client_height = GetWidget()->non_client_view()->height();
1818 const int client_height = GetWidget()->client_view()->height(); 1808 const int client_height = GetWidget()->client_view()->height();
1819 // TODO(msw): Resolve the 12 pixel discrepancy; is that the bubble border? 1809 // TODO(msw): Resolve the 12 pixel discrepancy; is that the bubble border?
1820 height -= non_client_height - client_height - 12; 1810 height -= non_client_height - client_height - 12;
1821 height = std::max(height, kMinimumContentsHeight); 1811 height = std::max(height, kMinimumContentsHeight);
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
2323 if (updates_scope_ != 0) { 2313 if (updates_scope_ != 0) {
2324 needs_update_ = true; 2314 needs_update_ = true;
2325 return; 2315 return;
2326 } 2316 }
2327 2317
2328 preferred_size_ = gfx::Size(); 2318 preferred_size_ = gfx::Size();
2329 2319
2330 if (GetWidget() && delegate_ && delegate_->GetWebContents()) { 2320 if (GetWidget() && delegate_ && delegate_->GetWebContents()) {
2331 UpdateWebContentsModalDialogPosition( 2321 UpdateWebContentsModalDialogPosition(
2332 GetWidget(), 2322 GetWidget(),
2333 WebContentsModalDialogManager::FromWebContents( 2323 web_modal::WebContentsModalDialogManager::FromWebContents(
2334 delegate_->GetWebContents())->delegate()-> 2324 delegate_->GetWebContents())->delegate()->
2335 GetWebContentsModalDialogHost()); 2325 GetWebContentsModalDialogHost());
2336 SetBoundsRect(bounds()); 2326 SetBoundsRect(bounds());
2337 } 2327 }
2338 } 2328 }
2339 2329
2340 AutofillDialogViews::DetailsGroup* AutofillDialogViews::GroupForSection( 2330 AutofillDialogViews::DetailsGroup* AutofillDialogViews::GroupForSection(
2341 DialogSection section) { 2331 DialogSection section) {
2342 return &detail_groups_.find(section)->second; 2332 return &detail_groups_.find(section)->second;
2343 } 2333 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2512 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) 2502 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section)
2513 : section(section), 2503 : section(section),
2514 container(NULL), 2504 container(NULL),
2515 manual_input(NULL), 2505 manual_input(NULL),
2516 suggested_info(NULL), 2506 suggested_info(NULL),
2517 suggested_button(NULL) {} 2507 suggested_button(NULL) {}
2518 2508
2519 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} 2509 AutofillDialogViews::DetailsGroup::~DetailsGroup() {}
2520 2510
2521 } // namespace autofill 2511 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_dialog_views.h ('k') | chrome/browser/ui/views/collected_cookies_views.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698