summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/customization_document.cc21
-rw-r--r--chrome/browser/chromeos/customization_document.h46
-rw-r--r--chrome/browser/chromeos/login/eula_view.cc84
-rw-r--r--chrome/browser/chromeos/login/eula_view.h4
4 files changed, 124 insertions, 31 deletions
diff --git a/chrome/browser/chromeos/customization_document.cc b/chrome/browser/chromeos/customization_document.cc
index 19410ec..8d0e2e4 100644
--- a/chrome/browser/chromeos/customization_document.cc
+++ b/chrome/browser/chromeos/customization_document.cc
@@ -6,7 +6,6 @@
#include <string>
-#include "base/file_path.h"
#include "base/file_util.h"
#include "base/json/json_reader.h"
#include "base/logging.h"
@@ -72,6 +71,16 @@ bool CustomizationDocument::ParseFromJsonValue(const DictionaryValue* root) {
// StartupCustomizationDocument implementation.
+bool StartupCustomizationDocument::LoadManifestFromFile(
+ const FilePath& manifest_path) {
+ if (CustomizationDocument::LoadManifestFromFile(manifest_path)) {
+ manifest_path_ = manifest_path;
+ return true;
+ } else {
+ return false;
+ }
+}
+
bool StartupCustomizationDocument::ParseFromJsonValue(
const DictionaryValue* root) {
if (!CustomizationDocument::ParseFromJsonValue(root))
@@ -128,14 +137,14 @@ bool StartupCustomizationDocument::ParseFromJsonValue(
return true;
}
-const StartupCustomizationDocument::SetupContent*
- StartupCustomizationDocument::GetSetupContent(
- const std::string& locale) const {
+FilePath StartupCustomizationDocument::GetSetupContentPagePath(
+ const std::string& locale, std::string SetupContent::* page_path) const {
SetupContentMap::const_iterator content_iter = setup_content_.find(locale);
if (content_iter != setup_content_.end()) {
- return &content_iter->second;
+ return manifest_path_.DirName().Append(content_iter->second.*page_path);
+ } else {
+ return FilePath();
}
- return NULL;
}
// ServicesCustomizationDocument implementation.
diff --git a/chrome/browser/chromeos/customization_document.h b/chrome/browser/chromeos/customization_document.h
index ba6e0ba..2dd384a 100644
--- a/chrome/browser/chromeos/customization_document.h
+++ b/chrome/browser/chromeos/customization_document.h
@@ -11,12 +11,12 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/file_path.h"
#include "base/scoped_ptr.h"
#include "third_party/skia/include/core/SkColor.h"
class DictionaryValue;
class ListValue;
-class FilePath;
namespace chromeos {
@@ -36,6 +36,7 @@ class CustomizationDocument {
// Parses manifest's attributes from the JSON dictionary value.
virtual bool ParseFromJsonValue(const DictionaryValue* root);
+ private:
// Manifest version string.
std::string version_;
@@ -46,6 +47,22 @@ class CustomizationDocument {
class StartupCustomizationDocument : public CustomizationDocument {
public:
+ StartupCustomizationDocument() {}
+
+ virtual bool LoadManifestFromFile(const FilePath& manifest_path);
+
+ const std::string& product_sku() const { return product_sku_; }
+ const std::string& initial_locale() const { return initial_locale_; }
+ const std::string& initial_timezone() const { return initial_timezone_; }
+ SkColor background_color() const { return background_color_; }
+ const std::string& registration_url() const { return registration_url_; }
+
+ // Returns full path to the specified resource in the specified
+ // locale. If the locale is not found in manifest, empty path is returned.
+ FilePath GetHelpPagePath(const std::string& locale) const;
+ FilePath GetEULAPagePath(const std::string& locale) const;
+
+ private:
struct SetupContent {
SetupContent() {}
SetupContent(const std::string& help_page_path,
@@ -61,18 +78,9 @@ class StartupCustomizationDocument : public CustomizationDocument {
typedef std::map<std::string, SetupContent> SetupContentMap;
- StartupCustomizationDocument() {}
-
- const std::string& product_sku() const { return product_sku_; }
- const std::string& initial_locale() const { return initial_locale_; }
- const std::string& initial_timezone() const { return initial_timezone_; }
- SkColor background_color() const { return background_color_; }
- const std::string& registration_url() const { return registration_url_; }
-
- const SetupContent* GetSetupContent(const std::string& locale) const;
-
- protected:
virtual bool ParseFromJsonValue(const DictionaryValue* root);
+ FilePath GetSetupContentPagePath(const std::string& locale,
+ std::string SetupContent::* page_path) const;
// Product SKU.
std::string product_sku_;
@@ -92,9 +100,21 @@ class StartupCustomizationDocument : public CustomizationDocument {
// Setup content for different locales.
SetupContentMap setup_content_;
+ // Copy of manifest full path.
+ FilePath manifest_path_;
+
DISALLOW_COPY_AND_ASSIGN(StartupCustomizationDocument);
};
+inline FilePath StartupCustomizationDocument::GetHelpPagePath(
+ const std::string& locale) const {
+ return GetSetupContentPagePath(locale, &SetupContent::help_page_path);
+}
+inline FilePath StartupCustomizationDocument::GetEULAPagePath(
+ const std::string& locale) const {
+ return GetSetupContentPagePath(locale, &SetupContent::eula_page_path);
+}
+
// OEM services customization document class.
class ServicesCustomizationDocument : public CustomizationDocument {
@@ -115,7 +135,7 @@ class ServicesCustomizationDocument : public CustomizationDocument {
const StringList& web_apps() const { return web_apps_; }
const StringList& extensions() const { return extensions_; }
- protected:
+ private:
virtual bool ParseFromJsonValue(const DictionaryValue* root);
bool ParseStringListFromJsonValue(const ListValue* list_value,
diff --git a/chrome/browser/chromeos/login/eula_view.cc b/chrome/browser/chromeos/login/eula_view.cc
index ad3dd25..6dd820e 100644
--- a/chrome/browser/chromeos/login/eula_view.cc
+++ b/chrome/browser/chromeos/login/eula_view.cc
@@ -20,6 +20,7 @@
#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/common/url_constants.h"
#include "chrome/installer/util/google_update_settings.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -28,6 +29,7 @@
#include "views/controls/button/native_button.h"
#include "views/controls/label.h"
#include "views/grid_layout.h"
+#include "views/layout_manager.h"
#include "views/standard_layout.h"
namespace {
@@ -49,6 +51,19 @@ enum kLayoutColumnsets {
LAST_ROW
};
+// A simple LayoutManager that causes the associated view's one child to be
+// sized to match the bounds of its parent except the bounds, if set.
+struct FillLayoutWithBorder : public views::LayoutManager {
+ // Overridden from LayoutManager:
+ virtual void Layout(views::View* host) {
+ DCHECK(host->GetChildViewCount());
+ host->GetChildViewAt(0)->SetBounds(host->GetLocalBounds(false));
+ }
+ virtual gfx::Size GetPreferredSize(views::View* host) {
+ return gfx::Size(host->width(), host->height());
+ }
+};
+
} // namespace
namespace chromeos {
@@ -117,14 +132,24 @@ void EulaView::Init() {
static const int kPadding = kBorderSize + kMargin;
layout->AddPaddingRow(0, kPadding);
layout->StartRow(0, SINGLE_CONTROL_ROW);
- google_eula_label_ = new views::Label();
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ gfx::Font label_font =
+ rb.GetFont(ResourceBundle::MediumFont).DeriveFont(0, gfx::Font::NORMAL);
+ google_eula_label_ = new views::Label(std::wstring(), label_font);
layout->AddView(google_eula_label_, 1, 1,
views::GridLayout::LEADING, views::GridLayout::FILL);
+ layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing);
layout->StartRow(1, SINGLE_CONTROL_ROW);
+ views::View* box_view = new views::View();
+ box_view->set_border(views::Border::CreateSolidBorder(1, SK_ColorBLACK));
+ box_view->SetLayoutManager(new FillLayoutWithBorder());
+ layout->AddView(box_view);
+
google_eula_view_ = new DOMView();
- layout->AddView(google_eula_view_);
+ box_view->AddChildView(google_eula_view_);
+ layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing);
layout->StartRow(0, SINGLE_CONTROL_WITH_SHIFT_ROW);
usage_statistics_checkbox_ = new views::Checkbox();
usage_statistics_checkbox_->SetMultiLine(true);
@@ -139,15 +164,21 @@ void EulaView::Init() {
layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing);
layout->StartRow(0, SINGLE_CONTROL_ROW);
- oem_eula_label_ = new views::Label();
+ oem_eula_label_ = new views::Label(std::wstring(), label_font);
layout->AddView(oem_eula_label_, 1, 1,
views::GridLayout::LEADING, views::GridLayout::FILL);
+ layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing);
layout->StartRow(1, SINGLE_CONTROL_ROW);
+ box_view = new views::View();
+ box_view->set_border(views::Border::CreateSolidBorder(1, SK_ColorBLACK));
+ box_view->SetLayoutManager(new FillLayoutWithBorder());
+ layout->AddView(box_view);
+
oem_eula_view_ = new DOMView();
- layout->AddView(oem_eula_view_);
+ box_view->AddChildView(oem_eula_view_);
- layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
layout->StartRow(0, LAST_ROW);
system_security_settings_link_ = new views::Link();
system_security_settings_link_->SetController(this);
@@ -172,7 +203,6 @@ void EulaView::LoadEulaView(DOMView* eula_view,
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() {
@@ -183,13 +213,18 @@ void EulaView::UpdateLocalizedStrings() {
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));
+ const FilePath eula_page_path = customization->GetEULAPagePath(
+ g_browser_process->GetApplicationLocale());
+ if (!eula_page_path.empty()) {
+ const std::string page_path = std::string(chrome::kFileScheme) +
+ chrome::kStandardSchemeSeparator + eula_page_path.value();
+ LoadEulaView(oem_eula_view_, oem_eula_label_, GURL(page_path));
+ } else {
+ LOG(ERROR) << "No eula found for locale: "
+ << g_browser_process->GetApplicationLocale();
}
+ } else {
+ LOG(ERROR) << "No manifest found.";
}
// Load other labels from resources.
@@ -234,4 +269,29 @@ void EulaView::LinkActivated(views::Link* source, int event_flags) {
// TODO(glotov): handle link clicks.
}
+////////////////////////////////////////////////////////////////////////////////
+// TabContentsDelegate implementation:
+
+// Convenience function. Queries |eula_view| for HTML title and, if it
+// is ready, assigns it to |eula_label| and returns true so the caller
+// view calls Layout().
+static bool PublishTitleIfReady(const TabContents* contents,
+ DOMView* eula_view,
+ views::Label* eula_label) {
+ if (contents != eula_view->tab_contents())
+ return false;
+ eula_label->SetText(UTF16ToWide(eula_view->tab_contents()->GetTitle()));
+ return true;
+}
+
+void EulaView::NavigationStateChanged(const TabContents* contents,
+ unsigned changed_flags) {
+ if (changed_flags & TabContents::INVALIDATE_TITLE) {
+ if (PublishTitleIfReady(contents, google_eula_view_, google_eula_label_) ||
+ PublishTitleIfReady(contents, oem_eula_view_, oem_eula_label_)) {
+ Layout();
+ }
+ }
+}
+
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/eula_view.h b/chrome/browser/chromeos/login/eula_view.h
index 2a59345..fcbaa03 100644
--- a/chrome/browser/chromeos/login/eula_view.h
+++ b/chrome/browser/chromeos/login/eula_view.h
@@ -90,6 +90,10 @@ class EulaView
void LinkActivated(views::Link* source, int event_flags);
private:
+ // TabContentsDelegate implementation.
+ virtual void NavigationStateChanged(const TabContents* contents,
+ unsigned changed_flags);
+
// Loads specified URL to the specified DOMView and updates specified
// label with its title.
void LoadEulaView(DOMView* eula_view,