blob: 309c22df707011ab510bd58c2982f572622ff2ef [file] [log] [blame]
Alexey Baskakovfd3894e2018-10-16 06:09:581// Copyright 2018 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Alexey Baskakov4768f6232018-11-08 09:26:465#include <ios>
Alexey Baskakov393b2aa2018-10-25 06:42:316#include <ostream>
7
Alexey Baskakovfd3894e2018-10-16 06:09:588#include "chrome/browser/web_applications/web_app.h"
Alexey Baskakov8975f352018-12-05 02:28:269
10#include "base/logging.h"
Alexey Baskakov4768f6232018-11-08 09:26:4611#include "ui/gfx/color_utils.h"
Alexey Baskakovfd3894e2018-10-16 06:09:5812
13namespace web_app {
14
15WebApp::WebApp(const AppId& app_id) : app_id_(app_id) {}
16
17WebApp::~WebApp() = default;
18
19void WebApp::SetName(const std::string& name) {
20 name_ = name;
21}
22
23void WebApp::SetDescription(const std::string& description) {
24 description_ = description;
25}
26
Alexey Baskakov79b06902018-11-08 05:30:0327void WebApp::SetLaunchUrl(const GURL& launch_url) {
28 DCHECK(!launch_url.is_empty() && launch_url.is_valid());
Alexey Baskakovfd3894e2018-10-16 06:09:5829 launch_url_ = launch_url;
30}
31
Alexey Baskakov4768f6232018-11-08 09:26:4632void WebApp::SetScope(const GURL& scope) {
33 DCHECK(scope.is_empty() || scope.is_valid());
34 scope_ = scope;
35}
36
37void WebApp::SetThemeColor(base::Optional<SkColor> theme_color) {
38 theme_color_ = theme_color;
39}
40
Alexey Baskakov8975f352018-12-05 02:28:2641void WebApp::SetIcons(Icons icons) {
42 DCHECK(!icons.empty());
43 icons_ = std::move(icons);
44}
45
Alexey Baskakov393b2aa2018-10-25 06:42:3146std::ostream& operator<<(std::ostream& out, const WebApp& app) {
Alexey Baskakov4768f6232018-11-08 09:26:4647 const std::string theme_color =
48 app.theme_color()
49 ? color_utils::SkColorToRgbaString(app.theme_color().value())
50 : "none";
51
Alexey Baskakov393b2aa2018-10-25 06:42:3152 return out << "app_id: " << app.app_id() << std::endl
53 << " name: " << app.name() << std::endl
54 << " launch_url: " << app.launch_url() << std::endl
Alexey Baskakov4768f6232018-11-08 09:26:4655 << " scope: " << app.scope() << std::endl
56 << " theme_color: " << theme_color << std::endl
Alexey Baskakov393b2aa2018-10-25 06:42:3157 << " description: " << app.description();
58}
59
Alexey Baskakovfd3894e2018-10-16 06:09:5860} // namespace web_app