summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos
diff options
context:
space:
mode:
authorglotov@chromium.org <glotov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-22 11:56:56 +0000
committerglotov@chromium.org <glotov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-22 11:56:56 +0000
commit7a9ddc534ddc60f07d592f6dd0898fed5d81988e (patch)
tree8a0f79bb1c955dbe07804fd32bffe6e5fcfc0230 /chrome/browser/chromeos
parent9bbe9fbe7d53b371cb80567a5cd1bbccef56888d (diff)
downloadchromium_src-7a9ddc534ddc60f07d592f6dd0898fed5d81988e.zip
chromium_src-7a9ddc534ddc60f07d592f6dd0898fed5d81988e.tar.gz
chromium_src-7a9ddc534ddc60f07d592f6dd0898fed5d81988e.tar.bz2
EULA screen updated to use DOMView to display EULAs,
actual EULAs are displayed. BUG=crosbug.com/3178 TEST=chrome --login-manager --login-screen=eula Review URL: http://codereview.chromium.org/3026008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53328 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
-rw-r--r--chrome/browser/chromeos/login/eula_view.cc117
-rw-r--r--chrome/browser/chromeos/login/eula_view.h56
-rw-r--r--chrome/browser/chromeos/login/wizard_controller.cc2
-rw-r--r--chrome/browser/chromeos/login/wizard_controller.h2
4 files changed, 127 insertions, 50 deletions
diff --git a/chrome/browser/chromeos/login/eula_view.cc b/chrome/browser/chromeos/login/eula_view.cc
index 2efe93f..2cdaff2 100644
--- a/chrome/browser/chromeos/login/eula_view.cc
+++ b/chrome/browser/chromeos/login/eula_view.cc
@@ -11,9 +11,15 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chromeos/customization_document.h"
#include "chrome/browser/chromeos/login/network_screen_delegate.h"
#include "chrome/browser/chromeos/login/rounded_rect_painter.h"
-#include "chrome/browser/chromeos/login/screen_observer.h"
+#include "chrome/browser/chromeos/login/wizard_controller.h"
+#include "chrome/browser/profile_manager.h"
+#include "chrome/browser/renderer_host/site_instance.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/views/dom_view.h"
#include "chrome/installer/util/google_update_settings.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -21,7 +27,6 @@
#include "views/controls/button/checkbox.h"
#include "views/controls/button/native_button.h"
#include "views/controls/label.h"
-#include "views/controls/textfield/textfield.h"
#include "views/grid_layout.h"
#include "views/standard_layout.h"
@@ -30,22 +35,12 @@ namespace {
const int kBorderSize = 10;
const int kMargin = 20;
const int kLastButtonHorizontalMargin = 10;
-const int kTextMargin = 10;
const int kCheckBowWidth = 22;
+const int kTextMargin = 10;
-// Fake EULA texts. TODO(glotov): implement reading actual file.
-const wchar_t kLoremIpsum[] = L"Lorem ipsum dolor sit amet, "
- L"consectetur adipisicing elit, sed do eiusmod tempor incididunt ut"
- L"labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud "
- L"exercitation ullamco laboris nisi ut aliquip ex ea commodo "
- L"consequat. Duis aute irure dolor in reprehenderit in voluptate velit "
- L"esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat "
- L"cupidatat non proident, sunt in culpa qui officia deserunt mollit anim "
- L"id est laborum.\n";
-const wchar_t kFakeGoogleEula[] = L"\nGoogle Chrome Terms of Service\n"
- L"These Terms of Service apply to the executable code version of "
- L"Google Chrome. ";
-const wchar_t kFakeOemEula[] = L"\nYBH Terms of Service\n";
+// TODO(glotov): this URL should be changed to actual Google ChromeOS EULA.
+// See crbug.com/4647
+const char kGoogleEulaUrl[] = "about:terms";
enum kLayoutColumnsets {
SINGLE_CONTROL_ROW,
@@ -59,10 +54,12 @@ enum kLayoutColumnsets {
namespace chromeos {
EulaView::EulaView(chromeos::ScreenObserver* observer)
- : google_eula_text_(NULL),
+ : google_eula_label_(NULL),
+ google_eula_view_(NULL),
usage_statistics_checkbox_(NULL),
learn_more_link_(NULL),
- oem_eula_text_(NULL),
+ oem_eula_label_(NULL),
+ oem_eula_view_(NULL),
system_security_settings_link_(NULL),
cancel_button_(NULL),
continue_button_(NULL),
@@ -72,17 +69,9 @@ EulaView::EulaView(chromeos::ScreenObserver* observer)
EulaView::~EulaView() {
}
-void EulaView::Init() {
- // Use rounded rect background.
- views::Painter* painter = CreateWizardPainter(
- &BorderDefinition::kScreenBorder);
- set_background(
- views::Background::CreateBackgroundPainter(true, painter));
-
- // Layout created controls.
+// Convenience function to set layout's columnsets for this screen.
+static void SetUpGridLayout(views::GridLayout* layout) {
static const int kPadding = kBorderSize + kMargin;
- views::GridLayout* layout = new views::GridLayout(this);
- SetLayoutManager(layout);
views::ColumnSet* column_set = layout->AddColumnSet(SINGLE_CONTROL_ROW);
column_set->AddPaddingColumn(0, kPadding);
column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
@@ -111,14 +100,30 @@ void EulaView::Init() {
column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
views::GridLayout::USE_PREF, 0, 0);
column_set->AddPaddingColumn(0, kLastButtonHorizontalMargin + kBorderSize);
+}
+
+void EulaView::Init() {
+ // Use rounded rect background.
+ views::Painter* painter = CreateWizardPainter(
+ &BorderDefinition::kScreenBorder);
+ set_background(
+ views::Background::CreateBackgroundPainter(true, painter));
+
+ // Layout created controls.
+ views::GridLayout* layout = new views::GridLayout(this);
+ SetLayoutManager(layout);
+ SetUpGridLayout(layout);
+ static const int kPadding = kBorderSize + kMargin;
layout->AddPaddingRow(0, kPadding);
+ layout->StartRow(0, SINGLE_CONTROL_ROW);
+ google_eula_label_ = new views::Label();
+ layout->AddView(google_eula_label_, 1, 1,
+ views::GridLayout::LEADING, views::GridLayout::FILL);
+
layout->StartRow(1, SINGLE_CONTROL_ROW);
- google_eula_text_ = new views::Textfield(views::Textfield::STYLE_MULTILINE);
- google_eula_text_->SetReadOnly(true);
- google_eula_text_->SetFocusable(true);
- google_eula_text_->SetHorizontalMargins(kTextMargin, kTextMargin);
- layout->AddView(google_eula_text_);
+ google_eula_view_ = new DOMView();
+ layout->AddView(google_eula_view_);
layout->StartRow(0, SINGLE_CONTROL_WITH_SHIFT_ROW);
usage_statistics_checkbox_ = new views::Checkbox();
@@ -133,12 +138,14 @@ void EulaView::Init() {
layout->AddView(learn_more_link_);
layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing);
+ layout->StartRow(0, SINGLE_CONTROL_ROW);
+ oem_eula_label_ = new views::Label();
+ layout->AddView(oem_eula_label_, 1, 1,
+ views::GridLayout::LEADING, views::GridLayout::FILL);
+
layout->StartRow(1, SINGLE_CONTROL_ROW);
- oem_eula_text_ = new views::Textfield(views::Textfield::STYLE_MULTILINE);
- oem_eula_text_->SetReadOnly(true);
- oem_eula_text_->SetFocusable(true);
- oem_eula_text_->SetHorizontalMargins(kTextMargin, kTextMargin);
- layout->AddView(oem_eula_text_);
+ oem_eula_view_ = new DOMView();
+ layout->AddView(oem_eula_view_);
layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing);
layout->StartRow(0, LAST_ROW);
@@ -157,13 +164,35 @@ void EulaView::Init() {
UpdateLocalizedStrings();
}
+void EulaView::LoadEulaView(DOMView* eula_view,
+ views::Label* eula_label,
+ const GURL& eula_url) {
+ Profile* profile = ProfileManager::GetDefaultProfile();
+ eula_view->Init(profile,
+ SiteInstance::CreateSiteInstanceForURL(profile, eula_url));
+ eula_view->LoadURL(eula_url);
+ eula_view->tab_contents()->set_delegate(this);
+ eula_label->SetText(UTF16ToWide(eula_view->tab_contents()->GetTitle()));
+}
+
void EulaView::UpdateLocalizedStrings() {
- google_eula_text_->SetText(WideToUTF16(kFakeGoogleEula) +
- WideToUTF16(kLoremIpsum) +
- WideToUTF16(kLoremIpsum));
- oem_eula_text_->SetText(WideToUTF16(kFakeOemEula) +
- WideToUTF16(kLoremIpsum) +
- WideToUTF16(kLoremIpsum));
+ // Load Google EULA and its title.
+ LoadEulaView(google_eula_view_, google_eula_label_, GURL(kGoogleEulaUrl));
+
+ // Load OEM EULA and its title.
+ const StartupCustomizationDocument *customization =
+ WizardController::default_controller()->GetCustomization();
+ if (customization) {
+ const StartupCustomizationDocument::SetupContent *setup_content =
+ customization->GetSetupContent(
+ g_browser_process->GetApplicationLocale());
+ if (setup_content) {
+ LoadEulaView(oem_eula_view_, oem_eula_label_,
+ GURL(setup_content->eula_page_path));
+ }
+ }
+
+ // Load other labels from resources.
usage_statistics_checkbox_->SetLabel(
l10n_util::GetString(IDS_EULA_CHECKBOX_ENABLE_LOGGING));
learn_more_link_->SetText(
diff --git a/chrome/browser/chromeos/login/eula_view.h b/chrome/browser/chromeos/login/eula_view.h
index 9e7c112..ebae697 100644
--- a/chrome/browser/chromeos/login/eula_view.h
+++ b/chrome/browser/chromeos/login/eula_view.h
@@ -8,6 +8,7 @@
#include <string>
#include "chrome/browser/chromeos/login/view_screen.h"
+#include "chrome/browser/tab_contents/tab_contents_delegate.h"
#include "views/controls/button/button.h"
#include "views/controls/link.h"
#include "views/view.h"
@@ -18,16 +19,55 @@ class Checkbox;
class Label;
class Link;
class NativeButton;
-class Textfield;
} // namespace views
+class DOMView;
+
namespace chromeos {
+// Delegate for TabContents that will show EULA.
+// Blocks context menu and other actions.
+class EULATabContentsDelegate : public TabContentsDelegate {
+ public:
+ EULATabContentsDelegate() {}
+ virtual ~EULATabContentsDelegate() {}
+
+ protected:
+ // TabContentsDelegate implementation:
+ virtual void OpenURLFromTab(TabContents* source,
+ const GURL& url, const GURL& referrer,
+ WindowOpenDisposition disposition,
+ PageTransition::Type transition) {}
+ virtual void NavigationStateChanged(const TabContents* source,
+ unsigned changed_flags) {}
+ virtual void AddNewContents(TabContents* source,
+ TabContents* new_contents,
+ WindowOpenDisposition disposition,
+ const gfx::Rect& initial_pos,
+ bool user_gesture) {}
+ virtual void ActivateContents(TabContents* contents) {}
+ virtual void LoadingStateChanged(TabContents* source) {}
+ virtual void CloseContents(TabContents* source) {}
+ virtual bool IsPopup(TabContents* source) { return false; }
+ virtual void URLStarredChanged(TabContents* source, bool starred) {}
+ virtual void UpdateTargetURL(TabContents* source, const GURL& url) {}
+ virtual bool ShouldAddNavigationToHistory() const { return false; }
+ virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {}
+ virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {}
+ virtual bool HandleContextMenu(const ContextMenuParams& params) {
+ return true;
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(EULATabContentsDelegate);
+};
+
class EulaView
: public views::View,
public views::ButtonListener,
- public views::LinkController {
+ public views::LinkController,
+ public EULATabContentsDelegate {
public:
explicit EulaView(chromeos::ScreenObserver* observer);
virtual ~EulaView();
@@ -49,11 +89,19 @@ class EulaView
void LinkActivated(views::Link* source, int event_flags);
private:
+ // Loads specified URL to the specified DOMView and updates specified
+ // label with its title.
+ void LoadEulaView(DOMView* eula_view,
+ views::Label* eula_label,
+ const GURL& eula_url);
+
// Dialog controls.
- views::Textfield* google_eula_text_;
+ views::Label* google_eula_label_;
+ DOMView* google_eula_view_;
views::Checkbox* usage_statistics_checkbox_;
views::Link* learn_more_link_;
- views::Textfield* oem_eula_text_;
+ views::Label* oem_eula_label_;
+ DOMView* oem_eula_view_;
views::Link* system_security_settings_link_;
views::NativeButton* cancel_button_;
views::NativeButton* continue_button_;
diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc
index 8506921..21388be 100644
--- a/chrome/browser/chromeos/login/wizard_controller.cc
+++ b/chrome/browser/chromeos/login/wizard_controller.cc
@@ -384,7 +384,7 @@ void WizardController::SetCustomization(
}
const chromeos::StartupCustomizationDocument*
- WizardController::GetCustomization() {
+ WizardController::GetCustomization() const {
return customization_.get();
}
diff --git a/chrome/browser/chromeos/login/wizard_controller.h b/chrome/browser/chromeos/login/wizard_controller.h
index 25394ff..d5c2b4f 100644
--- a/chrome/browser/chromeos/login/wizard_controller.h
+++ b/chrome/browser/chromeos/login/wizard_controller.h
@@ -105,7 +105,7 @@ class WizardController : public chromeos::ScreenObserver,
const chromeos::StartupCustomizationDocument* customization);
// Returns partner startup customization document owned by WizardController.
- const chromeos::StartupCustomizationDocument* GetCustomization();
+ const chromeos::StartupCustomizationDocument* GetCustomization() const;
// Registers OOBE preferences.
static void RegisterPrefs(PrefService* local_state);