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

Side by Side Diff: components/doodle/doodle_types.h

Issue 2743273002: [Doodle] Don't create invalid DoodleImages or DoodleConfigs (Closed)
Patch Set: add checks for absence of optional images Created 3 years, 9 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 | « components/doodle/doodle_service_unittest.cc ('k') | components/doodle/doodle_types.cc » ('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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #ifndef COMPONENTS_DOODLE_DOODLE_TYPES_H_ 5 #ifndef COMPONENTS_DOODLE_DOODLE_TYPES_H_
6 #define COMPONENTS_DOODLE_DOODLE_TYPES_H_ 6 #define COMPONENTS_DOODLE_DOODLE_TYPES_H_
7 7
8 #include "base/optional.h" 8 #include "base/optional.h"
9 #include "url/gurl.h" 9 #include "url/gurl.h"
10 10
(...skipping 13 matching lines...) Expand all
24 enum class DoodleType { 24 enum class DoodleType {
25 UNKNOWN, 25 UNKNOWN,
26 SIMPLE, 26 SIMPLE,
27 RANDOM, 27 RANDOM,
28 VIDEO, 28 VIDEO,
29 INTERACTIVE, 29 INTERACTIVE,
30 INLINE_INTERACTIVE, 30 INLINE_INTERACTIVE,
31 SLIDESHOW, 31 SLIDESHOW,
32 }; 32 };
33 33
34 // Information about a Doodle image. If the image is invalid, the |url| will be 34 // Information about a Doodle image. By default the dimensions are 0.
35 // empty and invalid. By default the dimensions are 0.
36 struct DoodleImage { 35 struct DoodleImage {
37 DoodleImage(); 36 DoodleImage(const GURL& url);
38 ~DoodleImage(); 37 ~DoodleImage();
39 38
40 static base::Optional<DoodleImage> FromDictionary( 39 static base::Optional<DoodleImage> FromDictionary(
41 const base::DictionaryValue& dict, 40 const base::DictionaryValue& dict,
42 const base::Optional<GURL>& base_url); 41 const base::Optional<GURL>& base_url);
43 42
44 bool operator==(const DoodleImage& other) const; 43 bool operator==(const DoodleImage& other) const;
45 bool operator!=(const DoodleImage& other) const; 44 bool operator!=(const DoodleImage& other) const;
46 45
47 GURL url; 46 GURL url;
48 int height; 47 int height;
49 int width; 48 int width;
50 bool is_animated_gif; 49 bool is_animated_gif;
51 bool is_cta; 50 bool is_cta;
52 51
53 // Copying and assignment allowed. 52 // Copying and assignment allowed.
54 }; 53 };
55 54
56 // All information about a current doodle that can be fetched from the remote 55 // All information about a current doodle that can be fetched from the remote
57 // end. By default, all URLs are empty and therefore invalid. 56 // end. By default, all URLs are empty and therefore invalid.
58 struct DoodleConfig { 57 struct DoodleConfig {
59 DoodleConfig(); 58 DoodleConfig(DoodleType doodle_type, const DoodleImage& large_image);
60 DoodleConfig(const DoodleConfig& config); // = default; 59 DoodleConfig(const DoodleConfig& config); // = default;
61 ~DoodleConfig(); 60 ~DoodleConfig();
62 61
63 static base::Optional<DoodleConfig> FromDictionary( 62 static base::Optional<DoodleConfig> FromDictionary(
64 const base::DictionaryValue& dict, 63 const base::DictionaryValue& dict,
65 const base::Optional<GURL>& base_url); 64 const base::Optional<GURL>& base_url);
66 65
67 bool operator==(const DoodleConfig& other) const; 66 bool operator==(const DoodleConfig& other) const;
68 bool operator!=(const DoodleConfig& other) const; 67 bool operator!=(const DoodleConfig& other) const;
69 68
70 DoodleType doodle_type; 69 DoodleType doodle_type;
71 std::string alt_text; 70 std::string alt_text;
72 std::string interactive_html; 71 std::string interactive_html;
73 72
74 GURL search_url; 73 GURL search_url;
75 GURL target_url; 74 GURL target_url;
76 GURL fullpage_interactive_url; 75 GURL fullpage_interactive_url;
77 76
78 DoodleImage large_image; 77 DoodleImage large_image;
79 DoodleImage large_cta_image; 78 base::Optional<DoodleImage> large_cta_image;
80 DoodleImage transparent_large_image; 79 base::Optional<DoodleImage> transparent_large_image;
81 80
82 // Copying and assignment allowed. 81 // Copying and assignment allowed.
83 }; 82 };
84 83
85 } // namespace doodle 84 } // namespace doodle
86 85
87 #endif // COMPONENTS_DOODLE_DOODLE_TYPES_H_ 86 #endif // COMPONENTS_DOODLE_DOODLE_TYPES_H_
OLDNEW
« no previous file with comments | « components/doodle/doodle_service_unittest.cc ('k') | components/doodle/doodle_types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698