summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 14:49:30 +0000
committerrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 14:49:30 +0000
commitedf2c5de9f04ee37aeb55c74cd3bb7e4228dafa2 (patch)
treedb9b65559beb23b702919464a80cb08428b65531 /chrome
parentd84d00ee8720f26ffedc009f36fe4184c281f64d (diff)
downloadchromium_src-edf2c5de9f04ee37aeb55c74cd3bb7e4228dafa2.zip
chromium_src-edf2c5de9f04ee37aeb55c74cd3bb7e4228dafa2.tar.gz
chromium_src-edf2c5de9f04ee37aeb55c74cd3bb7e4228dafa2.tar.bz2
Revert 54313 - OEM EULA extracted correctly from manifest.
Fixing CustomizationDocument to return full path to the pages being queried. BUG=chromium:3178 TEST=none Review URL: http://codereview.chromium.org/2878051 TBR=glotov@chromium.org Review URL: http://codereview.chromium.org/3051026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54317 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-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, 31 insertions, 124 deletions
diff --git a/chrome/browser/chromeos/customization_document.cc b/chrome/browser/chromeos/customization_document.cc
index 8d0e2e4..19410ec 100644
--- a/chrome/browser/chromeos/customization_document.cc
+++ b/chrome/browser/chromeos/customization_document.cc
@@ -6,6 +6,7 @@
#include <string>
+#include "base/file_path.h"
#include "base/file_util.h"
#include "base/json/json_reader.h"
#include "base/logging.h"
@@ -71,16 +72,6 @@ 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))
@@ -137,14 +128,14 @@ bool StartupCustomizationDocument::ParseFromJsonValue(
return true;
}
-FilePath StartupCustomizationDocument::GetSetupContentPagePath(
- const std::string& locale, std::string SetupContent::* page_path) const {
+const StartupCustomizationDocument::SetupContent*
+ StartupCustomizationDocument::GetSetupContent(
+ const std::string& locale) const {
SetupContentMap::const_iterator content_iter = setup_content_.find(locale);
if (content_iter != setup_content_.end()) {
- return manifest_path_.DirName().Append(content_iter->second.*page_path);
- } else {
- return FilePath();
+ return &content_iter->second;
}
+ return NULL;
}
// ServicesCustomizationDocument implementation.
diff --git a/chrome/browser/chromeos/customization_document.h b/chrome/browser/chromeos/customization_document.h
index 2dd384a..ba6e0ba 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,7 +36,6 @@ class CustomizationDocument {
// Parses manifest's attributes from the JSON dictionary value.
virtual bool ParseFromJsonValue(const DictionaryValue* root);
- private:
// Manifest version string.
std::string version_;
@@ -47,22 +46,6 @@ 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,
@@ -78,9 +61,18 @@ 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_;
@@ -100,21 +92,9 @@ 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 {
@@ -135,7 +115,7 @@ class ServicesCustomizationDocument : public CustomizationDocument {
const StringList& web_apps() const { return web_apps_; }
const StringList& extensions() const { return extensions_; }
- private:
+ protected:
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 6dd820e..ad3dd25 100644
--- a/chrome/browser/chromeos/login/eula_view.cc
+++ b/chrome/browser/chromeos/login/eula_view.cc
@@ -20,7 +20,6 @@
#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"
@@ -29,7 +28,6 @@
#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 {
@@ -51,19 +49,6 @@ 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 {
@@ -132,24 +117,14 @@ void EulaView::Init() {
static const int kPadding = kBorderSize + kMargin;
layout->AddPaddingRow(0, kPadding);
layout->StartRow(0, SINGLE_CONTROL_ROW);
- 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);
+ google_eula_label_ = new views::Label();
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();
- box_view->AddChildView(google_eula_view_);
+ layout->AddView(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);
@@ -164,21 +139,15 @@ void EulaView::Init() {
layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing);
layout->StartRow(0, SINGLE_CONTROL_ROW);
- oem_eula_label_ = new views::Label(std::wstring(), label_font);
+ oem_eula_label_ = new views::Label();
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();
- box_view->AddChildView(oem_eula_view_);
+ layout->AddView(oem_eula_view_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+ layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing);
layout->StartRow(0, LAST_ROW);
system_security_settings_link_ = new views::Link();
system_security_settings_link_->SetController(this);
@@ -203,6 +172,7 @@ 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() {
@@ -213,18 +183,13 @@ void EulaView::UpdateLocalizedStrings() {
const StartupCustomizationDocument *customization =
WizardController::default_controller()->GetCustomization();
if (customization) {
- 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();
+ 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));
}
- } else {
- LOG(ERROR) << "No manifest found.";
}
// Load other labels from resources.
@@ -269,29 +234,4 @@ 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 fcbaa03..2a59345 100644
--- a/chrome/browser/chromeos/login/eula_view.h
+++ b/chrome/browser/chromeos/login/eula_view.h
@@ -90,10 +90,6 @@ 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,