| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/page_info_window.h" | 5 #include "chrome/browser/views/page_info_window.h" |
| 6 | 6 |
| 7 #include <cryptuiapi.h> | 7 #include <cryptuiapi.h> |
| 8 #pragma comment(lib, "cryptui.lib") | 8 #pragma comment(lib, "cryptui.lib") |
| 9 | 9 |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 layout->StartRow(1, 0); | 547 layout->StartRow(1, 0); |
| 548 layout->AddView(CreateSecurityTabView(profile, url, ssl, page_type, | 548 layout->AddView(CreateSecurityTabView(profile, url, ssl, page_type, |
| 549 show_history), 2, 1); | 549 show_history), 2, 1); |
| 550 | 550 |
| 551 layout->AddPaddingRow(0, kHorizontalPadding); | 551 layout->AddPaddingRow(0, kHorizontalPadding); |
| 552 | 552 |
| 553 if (opened_window_count_ > 0) { | 553 if (opened_window_count_ > 0) { |
| 554 // There already is a PageInfo window opened. Let's shift the location of | 554 // There already is a PageInfo window opened. Let's shift the location of |
| 555 // the new PageInfo window so they don't overlap entirely. | 555 // the new PageInfo window so they don't overlap entirely. |
| 556 // Window::Init will position the window from the stored location. | 556 // Window::Init will position the window from the stored location. |
| 557 CRect bounds; | 557 gfx::Rect bounds; |
| 558 bool maximized, always_on_top; | 558 bool maximized = false; |
| 559 if (RestoreWindowPosition(&bounds, &maximized, &always_on_top)) { | 559 if (GetSavedWindowBounds(&bounds) && GetSavedMaximizedState(&maximized)) { |
| 560 CalculateWindowBounds(&bounds); | 560 CRect bounds_crect(bounds.ToRECT()); |
| 561 SaveWindowPosition(bounds, maximized, always_on_top); | 561 CalculateWindowBounds(&bounds_crect); |
| 562 SaveWindowPlacement(gfx::Rect(bounds_crect), maximized, false); |
| 562 } | 563 } |
| 563 } | 564 } |
| 564 | 565 |
| 565 views::Window::CreateChromeWindow(parent, gfx::Rect(), this); | 566 views::Window::CreateChromeWindow(parent, gfx::Rect(), this); |
| 566 // TODO(beng): (Cleanup) - cert viewer button should use GetExtraView. | 567 // TODO(beng): (Cleanup) - cert viewer button should use GetExtraView. |
| 567 | 568 |
| 568 if (cert_id_) { | 569 if (cert_id_) { |
| 569 scoped_refptr<net::X509Certificate> cert; | 570 scoped_refptr<net::X509Certificate> cert; |
| 570 CertStore::GetSharedInstance()->RetrieveCert(cert_id_, &cert); | 571 CertStore::GetSharedInstance()->RetrieveCert(cert_id_, &cert); |
| 571 // When running with Gears, we have no os certificate, so there is no cert | 572 // When running with Gears, we have no os certificate, so there is no cert |
| (...skipping 25 matching lines...) Expand all Loading... |
| 597 } | 598 } |
| 598 | 599 |
| 599 int PageInfoWindow::GetDialogButtons() const { | 600 int PageInfoWindow::GetDialogButtons() const { |
| 600 return DIALOGBUTTON_CANCEL; | 601 return DIALOGBUTTON_CANCEL; |
| 601 } | 602 } |
| 602 | 603 |
| 603 std::wstring PageInfoWindow::GetWindowTitle() const { | 604 std::wstring PageInfoWindow::GetWindowTitle() const { |
| 604 return l10n_util::GetString(IDS_PAGEINFO_WINDOW_TITLE); | 605 return l10n_util::GetString(IDS_PAGEINFO_WINDOW_TITLE); |
| 605 } | 606 } |
| 606 | 607 |
| 607 void PageInfoWindow::SaveWindowPosition(const CRect& bounds, | 608 std::wstring PageInfoWindow::GetWindowName() const { |
| 608 bool maximized, | 609 return prefs::kPageInfoWindowPlacement; |
| 609 bool always_on_top) { | |
| 610 window()->SaveWindowPositionToPrefService(g_browser_process->local_state(), | |
| 611 prefs::kPageInfoWindowPlacement, | |
| 612 bounds, maximized, always_on_top); | |
| 613 } | |
| 614 | |
| 615 bool PageInfoWindow::RestoreWindowPosition(CRect* bounds, | |
| 616 bool* maximized, | |
| 617 bool* always_on_top) { | |
| 618 bool restore = window()->RestoreWindowPositionFromPrefService( | |
| 619 g_browser_process->local_state(), | |
| 620 prefs::kPageInfoWindowPlacement, | |
| 621 bounds, maximized, always_on_top); | |
| 622 | |
| 623 if (restore) { | |
| 624 // Force the correct width and height in case we've changed it | |
| 625 // or the pref got messed up (we know that some users will have | |
| 626 // the wrong preference if they ran into bug 3509). This isn't | |
| 627 // a resizable dialog, so overriding the saved width and height | |
| 628 // shouldn't be noticable. | |
| 629 gfx::Size size = contents_->GetPreferredSize(); | |
| 630 bounds->right = bounds->left + size.width(); | |
| 631 bounds->bottom = bounds->top + size.height(); | |
| 632 } | |
| 633 | |
| 634 return restore; | |
| 635 } | 610 } |
| 636 | 611 |
| 637 views::View* PageInfoWindow::GetContentsView() { | 612 views::View* PageInfoWindow::GetContentsView() { |
| 638 return contents_; | 613 return contents_; |
| 639 } | 614 } |
| 640 | 615 |
| 641 void PageInfoWindow::ButtonPressed(views::NativeButton* sender) { | 616 void PageInfoWindow::ButtonPressed(views::NativeButton* sender) { |
| 642 if (sender == cert_info_button_) { | 617 if (sender == cert_info_button_) { |
| 643 DCHECK(cert_id_ != 0); | 618 DCHECK(cert_id_ != 0); |
| 644 ShowCertDialog(cert_id_); | 619 ShowCertDialog(cert_id_); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 HCERTSTORE cert_store = view_info.pCertContext->hCertStore; | 678 HCERTSTORE cert_store = view_info.pCertContext->hCertStore; |
| 704 view_info.cStores = 1; | 679 view_info.cStores = 1; |
| 705 view_info.rghStores = &cert_store; | 680 view_info.rghStores = &cert_store; |
| 706 BOOL properties_changed; | 681 BOOL properties_changed; |
| 707 | 682 |
| 708 // This next call blocks but keeps processing windows messages, making it | 683 // This next call blocks but keeps processing windows messages, making it |
| 709 // modal to the browser window. | 684 // modal to the browser window. |
| 710 BOOL rv = ::CryptUIDlgViewCertificate(&view_info, &properties_changed); | 685 BOOL rv = ::CryptUIDlgViewCertificate(&view_info, &properties_changed); |
| 711 } | 686 } |
| 712 | 687 |
| OLD | NEW |