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

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

Issue 2748653002: [Doodle] Add conversion to dictionary for DoodleImage and DoodleConfig (Closed)
Patch Set: check invalid URL parsing result 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/BUILD.gn ('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 <memory>
9 #include <string>
10
8 #include "base/optional.h" 11 #include "base/optional.h"
9 #include "url/gurl.h" 12 #include "url/gurl.h"
10 13
11 namespace base { 14 namespace base {
12 class DictionaryValue; 15 class DictionaryValue;
13 } 16 }
14 17
15 namespace doodle { 18 namespace doodle {
16 19
17 enum class DoodleState { 20 enum class DoodleState {
(...skipping 15 matching lines...) Expand all
33 36
34 // Information about a Doodle image. By default the dimensions are 0. 37 // Information about a Doodle image. By default the dimensions are 0.
35 struct DoodleImage { 38 struct DoodleImage {
36 DoodleImage(const GURL& url); 39 DoodleImage(const GURL& url);
37 ~DoodleImage(); 40 ~DoodleImage();
38 41
39 static base::Optional<DoodleImage> FromDictionary( 42 static base::Optional<DoodleImage> FromDictionary(
40 const base::DictionaryValue& dict, 43 const base::DictionaryValue& dict,
41 const base::Optional<GURL>& base_url); 44 const base::Optional<GURL>& base_url);
42 45
46 std::unique_ptr<base::DictionaryValue> ToDictionary() const;
47
43 bool operator==(const DoodleImage& other) const; 48 bool operator==(const DoodleImage& other) const;
44 bool operator!=(const DoodleImage& other) const; 49 bool operator!=(const DoodleImage& other) const;
45 50
46 GURL url; 51 GURL url;
47 int height; 52 int height;
48 int width; 53 int width;
49 bool is_animated_gif; 54 bool is_animated_gif;
50 bool is_cta; 55 bool is_cta;
51 56
52 // Copying and assignment allowed. 57 // Copying and assignment allowed.
53 }; 58 };
54 59
55 // All information about a current doodle that can be fetched from the remote 60 // All information about a current doodle that can be fetched from the remote
56 // end. By default, all URLs are empty and therefore invalid. 61 // end. By default, all URLs are empty and therefore invalid.
57 struct DoodleConfig { 62 struct DoodleConfig {
58 DoodleConfig(DoodleType doodle_type, const DoodleImage& large_image); 63 DoodleConfig(DoodleType doodle_type, const DoodleImage& large_image);
59 DoodleConfig(const DoodleConfig& config); // = default; 64 DoodleConfig(const DoodleConfig& config); // = default;
60 ~DoodleConfig(); 65 ~DoodleConfig();
61 66
62 static base::Optional<DoodleConfig> FromDictionary( 67 static base::Optional<DoodleConfig> FromDictionary(
63 const base::DictionaryValue& dict, 68 const base::DictionaryValue& dict,
64 const base::Optional<GURL>& base_url); 69 const base::Optional<GURL>& base_url);
65 70
71 std::unique_ptr<base::DictionaryValue> ToDictionary() const;
72
66 bool operator==(const DoodleConfig& other) const; 73 bool operator==(const DoodleConfig& other) const;
67 bool operator!=(const DoodleConfig& other) const; 74 bool operator!=(const DoodleConfig& other) const;
68 75
69 DoodleType doodle_type; 76 DoodleType doodle_type;
70 std::string alt_text; 77 std::string alt_text;
71 std::string interactive_html; 78 std::string interactive_html;
72 79
73 GURL search_url; 80 GURL search_url;
74 GURL target_url; 81 GURL target_url;
75 GURL fullpage_interactive_url; 82 GURL fullpage_interactive_url;
76 83
77 DoodleImage large_image; 84 DoodleImage large_image;
78 base::Optional<DoodleImage> large_cta_image; 85 base::Optional<DoodleImage> large_cta_image;
79 base::Optional<DoodleImage> transparent_large_image; 86 base::Optional<DoodleImage> transparent_large_image;
80 87
81 // Copying and assignment allowed. 88 // Copying and assignment allowed.
82 }; 89 };
83 90
84 } // namespace doodle 91 } // namespace doodle
85 92
86 #endif // COMPONENTS_DOODLE_DOODLE_TYPES_H_ 93 #endif // COMPONENTS_DOODLE_DOODLE_TYPES_H_
OLDNEW
« no previous file with comments | « components/doodle/BUILD.gn ('k') | components/doodle/doodle_types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698