Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: content/public/common/manifest.cc

Issue 2036803002: [WIP] Use Optional<SkColor> instead of int64 for colors in Manifest. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: with unit tests Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/public/common/manifest.h ('k') | content/renderer/manifest/manifest_parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/public/common/manifest.h" 5 #include "content/public/common/manifest.h"
6 6
7 namespace content { 7 namespace content {
8 8
9 // We need to provide a value here which is out of the range of a 32-bit integer
10 // since otherwise we would not be able to check whether a theme color was valid
11 // or not. The simplest way to do this is to simply add one to the maximum
12 // possible 32-bit integer.
13 const int64_t Manifest::kInvalidOrMissingColor =
14 static_cast<int64_t>(std::numeric_limits<int32_t>::max()) + 1;
15 const size_t Manifest::kMaxIPCStringLength = 4 * 1024; 9 const size_t Manifest::kMaxIPCStringLength = 4 * 1024;
16 10
17 Manifest::Icon::Icon() { } 11 Manifest::Icon::Icon() { }
18 12
19 Manifest::Icon::Icon(const Icon& other) = default; 13 Manifest::Icon::Icon(const Icon& other) = default;
20 14
21 Manifest::Icon::~Icon() { 15 Manifest::Icon::~Icon() {
22 } 16 }
23 17
24 bool Manifest::Icon::operator==(const Manifest::Icon& other) const { 18 bool Manifest::Icon::operator==(const Manifest::Icon& other) const {
25 return src == other.src && type == other.type && sizes == other.sizes; 19 return src == other.src && type == other.type && sizes == other.sizes;
26 } 20 }
27 21
28 Manifest::RelatedApplication::RelatedApplication() { 22 Manifest::RelatedApplication::RelatedApplication() {
29 } 23 }
30 24
31 Manifest::RelatedApplication::~RelatedApplication() { 25 Manifest::RelatedApplication::~RelatedApplication() {
32 } 26 }
33 27
34 Manifest::Manifest() 28 Manifest::Manifest()
35 : display(blink::WebDisplayModeUndefined), 29 : display(blink::WebDisplayModeUndefined),
36 orientation(blink::WebScreenOrientationLockDefault), 30 orientation(blink::WebScreenOrientationLockDefault),
37 prefer_related_applications(false), 31 prefer_related_applications(false) {
38 theme_color(Manifest::kInvalidOrMissingColor),
39 background_color(Manifest::kInvalidOrMissingColor) {
40 } 32 }
41 33
42 Manifest::Manifest(const Manifest& other) = default; 34 Manifest::Manifest(const Manifest& other) = default;
43 35
44 Manifest::~Manifest() { 36 Manifest::~Manifest() {
45 } 37 }
46 38
47 bool Manifest::IsEmpty() const { 39 bool Manifest::IsEmpty() const {
48 return name.is_null() && 40 return name.is_null() &&
49 short_name.is_null() && 41 short_name.is_null() &&
50 start_url.is_empty() && 42 start_url.is_empty() &&
51 display == blink::WebDisplayModeUndefined && 43 display == blink::WebDisplayModeUndefined &&
52 orientation == blink::WebScreenOrientationLockDefault && 44 orientation == blink::WebScreenOrientationLockDefault &&
53 icons.empty() && 45 icons.empty() &&
54 related_applications.empty() && 46 related_applications.empty() &&
55 !prefer_related_applications && 47 !prefer_related_applications &&
56 theme_color == Manifest::kInvalidOrMissingColor && 48 !theme_color.has_value() &&
57 background_color == Manifest::kInvalidOrMissingColor && 49 !background_color.has_value() &&
58 gcm_sender_id.is_null() && 50 gcm_sender_id.is_null() &&
59 scope.is_empty(); 51 scope.is_empty();
60 } 52 }
61 53
62 } // namespace content 54 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/manifest.h ('k') | content/renderer/manifest/manifest_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698