summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorglotov@chromium.org <glotov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-27 18:51:45 +0000
committerglotov@chromium.org <glotov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-27 18:51:45 +0000
commit9984f4cf936374b56520d1b625b06f36dc3283d5 (patch)
tree80452e35d2103c7f66d4d48ece2e7d52ab35e724
parent501844846a6651014ea21db7815f950f088539f5 (diff)
downloadchromium_src-9984f4cf936374b56520d1b625b06f36dc3283d5.zip
chromium_src-9984f4cf936374b56520d1b625b06f36dc3283d5.tar.gz
chromium_src-9984f4cf936374b56520d1b625b06f36dc3283d5.tar.bz2
TPM information dialog added to EULA screen
BUG=chromium-os:4945 TEST="System security setting" ling on EULA screen should show TPM dialog box OR appear disabled (grayed out) if TPM is disabled. Review URL: http://codereview.chromium.org/3496008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60686 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd8
-rw-r--r--chrome/app/resources/locale_settings.grd9
-rw-r--r--chrome/browser/chromeos/login/eula_view.cc112
-rw-r--r--chrome/browser/chromeos/login/eula_view.h18
4 files changed, 143 insertions, 4 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 8fa976a..13774ca 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -8607,9 +8607,15 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_EULA_ACCEPT_AND_CONTINUE_BUTTON" desc="Accept button text below EULA terms of service">
Accept and continue ยป
</message>
- <message name="IDS_EULA_SYSTEM_SECURITY_SETTINGS_LINK" desc="Link from the EULA wizard screen">
+ <message name="IDS_EULA_SYSTEM_SECURITY_SETTING" desc="Link from the EULA wizard screen and title of the according dialog box">
System security setting
</message>
+ <message name="IDS_EULA_SYSTEM_SECURITY_SETTING_DESCRIPTION" desc="Dialog box text">
+ Your computer contains a Trusted Platform Module (TPM) security device, which is used to implement many critical security features in Chrome OS.\n\nBelow is the randomly generated TPM password that has been assigned to your computer:
+ </message>
+ <message name="IDS_EULA_TPM_BUSY" desc="Message bubble text">
+ TPM is not ready yet, try later.
+ </message>
<message name="IDS_OPTION_DISABLED_BY_POLICY" desc="Tooltip for options managed by centrally-administered policy">
This option is controlled by an enterprise policy. Please contact your administrator for more information.
</message>
diff --git a/chrome/app/resources/locale_settings.grd b/chrome/app/resources/locale_settings.grd
index e503314..8c1935b 100644
--- a/chrome/app/resources/locale_settings.grd
+++ b/chrome/app/resources/locale_settings.grd
@@ -715,6 +715,15 @@
12
</message>
+ <!-- The width and height of the TPM setting dialog box in -->
+ <!-- characters and lines (See above). -->
+ <message name="IDS_TPM_INFO_DIALOG_WIDTH_CHARS" use_name_for_id="true">
+ 60
+ </message>
+ <message name="IDS_TPM_INFO_DIALOG_HEIGHT_LINES" use_name_for_id="true">
+ 12
+ </message>
+
<!-- The width and height of the password changed dialog box in -->
<!-- characters and lines (See above). -->
<message name="IDS_PASSWORD_CHANGED_DIALOG_WIDTH_CHARS" use_name_for_id="true">
diff --git a/chrome/browser/chromeos/login/eula_view.cc b/chrome/browser/chromeos/login/eula_view.cc
index 6d6d207..b9e7b2a 100644
--- a/chrome/browser/chromeos/login/eula_view.cc
+++ b/chrome/browser/chromeos/login/eula_view.cc
@@ -13,6 +13,7 @@
#include "base/basictypes.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/customization_document.h"
#include "chrome/browser/chromeos/login/help_app_launcher.h"
#include "chrome/browser/chromeos/login/network_screen_delegate.h"
@@ -26,8 +27,10 @@
#include "chrome/common/native_web_keyboard_event.h"
#include "chrome/common/url_constants.h"
#include "chrome/installer/util/google_update_settings.h"
+#include "cros/chromeos_cryptohome.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
+#include "grit/locale_settings.h"
#include "grit/theme_resources.h"
#include "views/controls/button/checkbox.h"
#include "views/controls/button/native_button.h"
@@ -36,6 +39,8 @@
#include "views/layout_manager.h"
#include "views/standard_layout.h"
#include "views/widget/widget_gtk.h"
+#include "views/window/dialog_delegate.h"
+#include "views/window/window.h"
#if defined(USE_LINUX_BREAKPAD)
#include "chrome/app/breakpad_linux.h"
@@ -75,6 +80,63 @@ struct FillLayoutWithBorder : public views::LayoutManager {
}
};
+// System security setting dialog.
+class TpmInfoView : public views::View,
+ public views::DialogDelegate {
+ public:
+ explicit TpmInfoView(std::wstring password) : password_(password) { }
+ void Init();
+
+ protected:
+ // views::DialogDelegate overrides:
+ virtual bool Accept() { return true; }
+ virtual bool IsModal() const { return true; }
+ virtual views::View* GetContentsView() { return this; }
+ virtual int GetDialogButtons() const {
+ return MessageBoxFlags::DIALOGBUTTON_OK;
+ }
+
+ // views::View overrides:
+ virtual std::wstring GetWindowTitle() const {
+ return l10n_util::GetString(IDS_EULA_SYSTEM_SECURITY_SETTING);
+ }
+
+ gfx::Size GetPreferredSize() {
+ return gfx::Size(views::Window::GetLocalizedContentsSize(
+ IDS_TPM_INFO_DIALOG_WIDTH_CHARS,
+ IDS_TPM_INFO_DIALOG_HEIGHT_LINES));
+ }
+
+ private:
+ std::wstring password_;
+ DISALLOW_COPY_AND_ASSIGN(TpmInfoView);
+};
+
+void TpmInfoView::Init() {
+ views::GridLayout* layout = CreatePanelGridLayout(this);
+ SetLayoutManager(layout);
+ views::ColumnSet* column_set = layout->AddColumnSet(0);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
+ views::GridLayout::USE_PREF, 0, 0);
+ layout->StartRow(0, 0);
+ views::Label* label = new views::Label(
+ l10n_util::GetString(IDS_EULA_SYSTEM_SECURITY_SETTING_DESCRIPTION));
+ label->SetMultiLine(true);
+ layout->AddView(label);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+
+ column_set = layout->AddColumnSet(1);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
+ views::GridLayout::USE_PREF, 0, 0);
+ layout->StartRow(0, 1);
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ gfx::Font password_font =
+ rb.GetFont(ResourceBundle::MediumFont).DeriveFont(0, gfx::Font::BOLD);
+ label = new views::Label(password_, password_font);
+ layout->AddView(label);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+}
+
} // namespace
namespace chromeos {
@@ -92,10 +154,14 @@ EulaView::EulaView(chromeos::ScreenObserver* observer)
system_security_settings_link_(NULL),
back_button_(NULL),
continue_button_(NULL),
- observer_(observer) {
+ observer_(observer),
+ bubble_(NULL) {
}
EulaView::~EulaView() {
+ // bubble_ will be set to NULL in callback.
+ if (bubble_)
+ bubble_->Close();
}
// Convenience function to set layout's columnsets for this screen.
@@ -229,6 +295,11 @@ void EulaView::Init() {
layout->StartRow(0, LAST_ROW);
system_security_settings_link_ = new views::Link();
system_security_settings_link_->SetController(this);
+ if (!chromeos::CrosLibrary::Get()->EnsureLoaded() ||
+ !chromeos::CryptohomeTpmIsEnabled()) {
+ system_security_settings_link_->SetEnabled(false);
+ // TODO(glotov): add tooltip with description.
+ }
layout->AddView(system_security_settings_link_);
back_button_ = new views::NativeButton(this, std::wstring());
@@ -261,7 +332,7 @@ void EulaView::UpdateLocalizedStrings() {
learn_more_link_->SetText(
l10n_util::GetString(IDS_LEARN_MORE));
system_security_settings_link_->SetText(
- l10n_util::GetString(IDS_EULA_SYSTEM_SECURITY_SETTINGS_LINK));
+ l10n_util::GetString(IDS_EULA_SYSTEM_SECURITY_SETTING));
continue_button_->SetLabel(
l10n_util::GetString(IDS_EULA_ACCEPT_AND_CONTINUE_BUTTON));
back_button_->SetLabel(
@@ -305,7 +376,30 @@ void EulaView::LinkActivated(views::Link* source, int event_flags) {
help_app_.reset(new HelpAppLauncher(GetNativeWindow()));
help_app_->ShowHelpTopic(HelpAppLauncher::HELP_STATS_USAGE);
} else if (source == system_security_settings_link_) {
- // TODO(glotov): Handle TPM link click.
+ // Pull the password from TPM.
+ std::string password;
+ if (!chromeos::CrosLibrary::Get()->EnsureLoaded()) {
+ LOG(ERROR) << "Cros library not loaded. "
+ << "We must have disabled the link that led here.";
+ return;
+ } else if (chromeos::CryptohomeTpmIsReady() &&
+ chromeos::CryptohomeTpmGetPassword(&password)) {
+ TpmInfoView* view = new TpmInfoView(ASCIIToWide(password));
+ view->Init();
+ views::Window* window = views::Window::CreateChromeWindow(
+ GetNativeWindow(), gfx::Rect(), view);
+ window->SetIsAlwaysOnTop(true);
+ window->Show();
+ } else {
+ if (!bubble_)
+ bubble_ = MessageBubble::Show(
+ system_security_settings_link_->GetWidget(),
+ system_security_settings_link_->GetScreenBounds(),
+ BubbleBorder::LEFT_TOP,
+ ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING),
+ l10n_util::GetString(IDS_EULA_TPM_BUSY),
+ std::wstring(), this);
+ }
}
}
@@ -357,4 +451,16 @@ void EulaView::LoadEulaView(DOMView* eula_view,
eula_view->tab_contents()->set_delegate(this);
}
+////////////////////////////////////////////////////////////////////////////////
+// EulaView, private, views::View implementation:
+
+bool EulaView::OnKeyPressed(const views::KeyEvent&) {
+ // Close message bubble if shown. bubble_ will be set to NULL in callback.
+ if (bubble_) {
+ bubble_->Close();
+ return true;
+ }
+ return false;
+}
+
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/eula_view.h b/chrome/browser/chromeos/login/eula_view.h
index 2d5683d..ca404002 100644
--- a/chrome/browser/chromeos/login/eula_view.h
+++ b/chrome/browser/chromeos/login/eula_view.h
@@ -7,6 +7,7 @@
#pragma once
#include "base/scoped_ptr.h"
+#include "chrome/browser/chromeos/login/message_bubble.h"
#include "chrome/browser/chromeos/login/view_screen.h"
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
#include "gfx/native_widget_types.h"
@@ -75,6 +76,7 @@ class EulaView
: public views::View,
public views::ButtonListener,
public views::LinkController,
+ public MessageBubbleDelegate,
public EULATabContentsDelegate {
public:
explicit EulaView(chromeos::ScreenObserver* observer);
@@ -97,6 +99,11 @@ class EulaView
void LinkActivated(views::Link* source, int event_flags);
private:
+ // views::View implementation.
+ virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e) {
+ return true; }
+ virtual bool OnKeyPressed(const views::KeyEvent& e);
+
// TabContentsDelegate implementation.
virtual void NavigationStateChanged(const TabContents* contents,
unsigned changed_flags);
@@ -111,6 +118,13 @@ class EulaView
views::Label* eula_label,
const GURL& eula_url);
+ // Overridden from views::InfoBubbleDelegate.
+ virtual void InfoBubbleClosing(InfoBubble* info_bubble,
+ bool closed_by_escape) { bubble_ = NULL; }
+ virtual bool CloseOnEscape() { return true; }
+ virtual bool FadeInOnShow() { return false; }
+ virtual void OnHelpLinkActivated() {}
+
// Dialog controls.
views::Label* google_eula_label_;
DOMView* google_eula_view_;
@@ -130,6 +144,10 @@ class EulaView
// Help application used for help dialogs.
scoped_ptr<HelpAppLauncher> help_app_;
+ // Pointer to shown message bubble. We don't need to delete it because
+ // it will be deleted on bubble closing.
+ MessageBubble* bubble_;
+
DISALLOW_COPY_AND_ASSIGN(EulaView);
};