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

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

Issue 2740013005: [Doodle] Move parsing from fetcher into the types themselves (Closed)
Patch Set: -auto 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
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 "url/gurl.h" 9 #include "url/gurl.h"
9 10
11 namespace base {
12 class DictionaryValue;
13 }
14
10 namespace doodle { 15 namespace doodle {
11 16
12 enum class DoodleState { 17 enum class DoodleState {
13 AVAILABLE, 18 AVAILABLE,
14 NO_DOODLE, 19 NO_DOODLE,
15 DOWNLOAD_ERROR, 20 DOWNLOAD_ERROR,
16 PARSING_ERROR, 21 PARSING_ERROR,
17 }; 22 };
18 23
19 enum class DoodleType { 24 enum class DoodleType {
20 UNKNOWN, 25 UNKNOWN,
21 SIMPLE, 26 SIMPLE,
22 RANDOM, 27 RANDOM,
23 VIDEO, 28 VIDEO,
24 INTERACTIVE, 29 INTERACTIVE,
25 INLINE_INTERACTIVE, 30 INLINE_INTERACTIVE,
26 SLIDESHOW, 31 SLIDESHOW,
27 }; 32 };
28 33
29 // Information about a Doodle image. If the image is invalid, the |url| will be 34 // Information about a Doodle image. If the image is invalid, the |url| will be
30 // empty and invalid. By default the dimensions are 0. 35 // empty and invalid. By default the dimensions are 0.
31 struct DoodleImage { 36 struct DoodleImage {
32 DoodleImage(); 37 DoodleImage();
33 ~DoodleImage(); 38 ~DoodleImage();
34 39
40 static base::Optional<DoodleImage> FromDictionary(
41 const base::DictionaryValue& dict,
42 const base::Optional<GURL>& base_url);
43
35 bool operator==(const DoodleImage& other) const; 44 bool operator==(const DoodleImage& other) const;
36 bool operator!=(const DoodleImage& other) const; 45 bool operator!=(const DoodleImage& other) const;
37 46
38 GURL url; 47 GURL url;
39 int height; 48 int height;
40 int width; 49 int width;
41 bool is_animated_gif; 50 bool is_animated_gif;
42 bool is_cta; 51 bool is_cta;
43 52
44 // Copying and assignment allowed. 53 // Copying and assignment allowed.
45 }; 54 };
46 55
47 // All information about a current doodle that can be fetched from the remote 56 // All information about a current doodle that can be fetched from the remote
48 // end. By default, all URLs are empty and therefore invalid. 57 // end. By default, all URLs are empty and therefore invalid.
49 struct DoodleConfig { 58 struct DoodleConfig {
50 DoodleConfig(); 59 DoodleConfig();
51 DoodleConfig(const DoodleConfig& config); // = default; 60 DoodleConfig(const DoodleConfig& config); // = default;
52 ~DoodleConfig(); 61 ~DoodleConfig();
53 62
63 static base::Optional<DoodleConfig> FromDictionary(
64 const base::DictionaryValue& dict,
65 const base::Optional<GURL>& base_url);
66
54 bool operator==(const DoodleConfig& other) const; 67 bool operator==(const DoodleConfig& other) const;
55 bool operator!=(const DoodleConfig& other) const; 68 bool operator!=(const DoodleConfig& other) const;
56 69
57 DoodleType doodle_type; 70 DoodleType doodle_type;
58 std::string alt_text; 71 std::string alt_text;
59 std::string interactive_html; 72 std::string interactive_html;
60 73
61 GURL search_url; 74 GURL search_url;
62 GURL target_url; 75 GURL target_url;
63 GURL fullpage_interactive_url; 76 GURL fullpage_interactive_url;
64 77
65 DoodleImage large_image; 78 DoodleImage large_image;
66 DoodleImage large_cta_image; 79 DoodleImage large_cta_image;
67 DoodleImage transparent_large_image; 80 DoodleImage transparent_large_image;
68 81
69 // Copying and assignment allowed. 82 // Copying and assignment allowed.
70 }; 83 };
71 84
72 } // namespace doodle 85 } // namespace doodle
73 86
74 #endif // COMPONENTS_DOODLE_DOODLE_TYPES_H_ 87 #endif // COMPONENTS_DOODLE_DOODLE_TYPES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698