| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common_param_traits.h" | 5 #include "content/public/common/common_param_traits.h" |
| 6 | 6 |
| 7 #include "content/public/common/content_constants.h" | 7 #include "content/public/common/content_constants.h" |
| 8 #include "content/public/common/page_state.h" | 8 #include "content/public/common/page_state.h" |
| 9 #include "content/public/common/referrer.h" | 9 #include "content/public/common/referrer.h" |
| 10 #include "content/public/common/url_utils.h" |
| 10 #include "net/base/host_port_pair.h" | 11 #include "net/base/host_port_pair.h" |
| 11 #include "third_party/skia/include/core/SkBitmap.h" | 12 #include "third_party/skia/include/core/SkBitmap.h" |
| 12 #include "ui/gfx/rect.h" | 13 #include "ui/gfx/rect.h" |
| 13 #include "ui/gfx/rect_f.h" | 14 #include "ui/gfx/rect_f.h" |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 struct SkBitmap_Data { | 18 struct SkBitmap_Data { |
| 18 // The configuration for the bitmap (bits per pixel, etc). | 19 // The configuration for the bitmap (bits per pixel, etc). |
| 19 SkBitmap::Config fConfig; | 20 SkBitmap::Config fConfig; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 43 } | 44 } |
| 44 return true; | 45 return true; |
| 45 } | 46 } |
| 46 }; | 47 }; |
| 47 | 48 |
| 48 } // namespace | 49 } // namespace |
| 49 | 50 |
| 50 namespace IPC { | 51 namespace IPC { |
| 51 | 52 |
| 52 void ParamTraits<GURL>::Write(Message* m, const GURL& p) { | 53 void ParamTraits<GURL>::Write(Message* m, const GURL& p) { |
| 53 DCHECK(p.possibly_invalid_spec().length() <= content::kMaxURLChars); | 54 DCHECK(p.possibly_invalid_spec().length() <= content::MaxURLChars()); |
| 54 | 55 |
| 55 // Beware of print-parse inconsistency which would change an invalid | 56 // Beware of print-parse inconsistency which would change an invalid |
| 56 // URL into a valid one. Ideally, the message would contain this flag | 57 // URL into a valid one. Ideally, the message would contain this flag |
| 57 // so that the read side could make the check, but performing it here | 58 // so that the read side could make the check, but performing it here |
| 58 // avoids changing the on-the-wire representation of such a fundamental | 59 // avoids changing the on-the-wire representation of such a fundamental |
| 59 // type as GURL. See https://crbug.com/166486 for additional work in | 60 // type as GURL. See https://crbug.com/166486 for additional work in |
| 60 // this area. | 61 // this area. |
| 61 if (!p.is_valid()) { | 62 if (!p.is_valid()) { |
| 62 m->WriteString(std::string()); | 63 m->WriteString(std::string()); |
| 63 return; | 64 return; |
| 64 } | 65 } |
| 65 | 66 |
| 66 m->WriteString(p.possibly_invalid_spec()); | 67 m->WriteString(p.possibly_invalid_spec()); |
| 67 // TODO(brettw) bug 684583: Add encoding for query params. | 68 // TODO(brettw) bug 684583: Add encoding for query params. |
| 68 } | 69 } |
| 69 | 70 |
| 70 bool ParamTraits<GURL>::Read(const Message* m, PickleIterator* iter, GURL* p) { | 71 bool ParamTraits<GURL>::Read(const Message* m, PickleIterator* iter, GURL* p) { |
| 71 std::string s; | 72 std::string s; |
| 72 if (!m->ReadString(iter, &s) || s.length() > content::kMaxURLChars) { | 73 if (!m->ReadString(iter, &s) || s.length() > content::MaxURLChars()) { |
| 73 *p = GURL(); | 74 *p = GURL(); |
| 74 return false; | 75 return false; |
| 75 } | 76 } |
| 76 *p = GURL(s); | 77 *p = GURL(s); |
| 77 if (!s.empty() && !p->is_valid()) { | 78 if (!s.empty() && !p->is_valid()) { |
| 78 *p = GURL(); | 79 *p = GURL(); |
| 79 return false; | 80 return false; |
| 80 } | 81 } |
| 81 return true; | 82 return true; |
| 82 } | 83 } |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ | 378 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ |
| 378 #include "content/public/common/common_param_traits_macros.h" | 379 #include "content/public/common/common_param_traits_macros.h" |
| 379 } // namespace IPC | 380 } // namespace IPC |
| 380 | 381 |
| 381 // Generate param traits log methods. | 382 // Generate param traits log methods. |
| 382 #include "ipc/param_traits_log_macros.h" | 383 #include "ipc/param_traits_log_macros.h" |
| 383 namespace IPC { | 384 namespace IPC { |
| 384 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ | 385 #undef CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_MACROS_H_ |
| 385 #include "content/public/common/common_param_traits_macros.h" | 386 #include "content/public/common/common_param_traits_macros.h" |
| 386 } // namespace IPC | 387 } // namespace IPC |
| OLD | NEW |