summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/customization_document.h
blob: 169adb928f6025cefdaf7afd59b6a294bea0fe1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_DOCUMENT_H_
#define CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_DOCUMENT_H_

#include <map>
#include <string>
#include <vector>

#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "third_party/skia/include/core/SkColor.h"

class DictionaryValue;
class ListValue;
class FilePath;

namespace chromeos {

// Base class for OEM customization document classes.

class CustomizationDocument {
 public:
  CustomizationDocument() {}
  virtual ~CustomizationDocument() {}

  virtual bool LoadManifestFromFile(const FilePath& manifest_path);
  virtual bool LoadManifestFromString(const std::string& manifest);

  const std::string& version() const { return version_; }

 protected:
  // Parses manifest's attributes from the JSON dictionary value.
  virtual bool ParseFromJsonValue(const DictionaryValue* root);

  // Manifest version string.
  std::string version_;

  DISALLOW_COPY_AND_ASSIGN(CustomizationDocument);
};

// OEM startup customization document class.

class StartupCustomizationDocument : public CustomizationDocument {
 public:
  struct SetupContent {
    SetupContent() {}
    SetupContent(const std::string& help_page_path,
                 const std::string& eula_page_path)
        : help_page_path(help_page_path),
          eula_page_path(eula_page_path) {}

    // Partner's help page for specific locale.
    std::string help_page_path;
    // Partner's EULA for specific locale.
    std::string eula_page_path;
  };

  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);

  // Product SKU.
  std::string product_sku_;

  // Initial locale for the OOBE wizard.
  std::string initial_locale_;

  // Initial timezone for clock setting.
  std::string initial_timezone_;

  // OOBE wizard and login screen background color.
  SkColor background_color_;

  // Partner's product registration page URL.
  std::string registration_url_;

  // Setup content for different locales.
  SetupContentMap setup_content_;

  DISALLOW_COPY_AND_ASSIGN(StartupCustomizationDocument);
};

// OEM services customization document class.

class ServicesCustomizationDocument : public CustomizationDocument {
 public:
  typedef std::vector<std::string> StringList;

  ServicesCustomizationDocument() {}

  const std::string& initial_start_page_url() const {
    return initial_start_page_url_;
  }
  const std::string& app_menu_section_title() const {
    return app_menu_section_title_;
  }
  const std::string& app_menu_support_page_url() const {
    return app_menu_support_page_url_;
  }
  const StringList& web_apps() const { return web_apps_; }
  const StringList& extensions() const { return extensions_; }

 protected:
  virtual bool ParseFromJsonValue(const DictionaryValue* root);

  bool ParseStringListFromJsonValue(const ListValue* list_value,
                                    StringList* string_list);

  // Partner's welcome page that is opened right after the OOBE.
  std::string initial_start_page_url_;

  // Partner's featured apps URLs list.
  StringList web_apps_;

  // Partner's featured extensions URLs list.
  StringList extensions_;

  // Title for the partner's apps section in apps menu.
  std::string app_menu_section_title_;

  // Partner's apps section support page URL.
  std::string app_menu_support_page_url_;

  DISALLOW_COPY_AND_ASSIGN(ServicesCustomizationDocument);
};

}  // namespace chromeos

#endif  // CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_DOCUMENT_H_