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 "ppapi/shared_impl/flash_clipboard_format_registry.h" | 5 #include "ppapi/shared_impl/flash_clipboard_format_registry.h" |
6 | 6 |
7 #include <cctype> | 7 #include <cctype> |
8 | 8 |
9 namespace ppapi { | 9 namespace ppapi { |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 FlashClipboardFormatRegistry::FlashClipboardFormatRegistry() {} | 36 FlashClipboardFormatRegistry::FlashClipboardFormatRegistry() {} |
37 | 37 |
38 FlashClipboardFormatRegistry::~FlashClipboardFormatRegistry() {} | 38 FlashClipboardFormatRegistry::~FlashClipboardFormatRegistry() {} |
39 | 39 |
40 uint32_t FlashClipboardFormatRegistry::RegisterFormat( | 40 uint32_t FlashClipboardFormatRegistry::RegisterFormat( |
41 const std::string& format_name) { | 41 const std::string& format_name) { |
42 if (!IsValidFormatName(format_name) || | 42 if (!IsValidFormatName(format_name) || |
43 custom_formats_.size() > kMaxNumFormats) { | 43 custom_formats_.size() > kMaxNumFormats) { |
44 return PP_FLASH_CLIPBOARD_FORMAT_INVALID; | 44 return PP_FLASH_CLIPBOARD_FORMAT_INVALID; |
45 } | 45 } |
46 uint32_t key = kFirstCustomFormat + custom_formats_.size(); | 46 uint32_t key = kFirstCustomFormat + |
| 47 static_cast<uint32_t>(custom_formats_.size()); |
47 custom_formats_[key] = format_name; | 48 custom_formats_[key] = format_name; |
48 return key; | 49 return key; |
49 } | 50 } |
50 | 51 |
51 void FlashClipboardFormatRegistry::SetRegisteredFormat( | 52 void FlashClipboardFormatRegistry::SetRegisteredFormat( |
52 const std::string& format_name, | 53 const std::string& format_name, |
53 uint32_t format) { | 54 uint32_t format) { |
54 custom_formats_[format] = format_name; | 55 custom_formats_[format] = format_name; |
55 } | 56 } |
56 | 57 |
(...skipping 20 matching lines...) Expand all Loading... |
77 } | 78 } |
78 | 79 |
79 // static | 80 // static |
80 bool FlashClipboardFormatRegistry::IsValidPredefinedFormat(uint32_t format) { | 81 bool FlashClipboardFormatRegistry::IsValidPredefinedFormat(uint32_t format) { |
81 if (format == PP_FLASH_CLIPBOARD_FORMAT_INVALID) | 82 if (format == PP_FLASH_CLIPBOARD_FORMAT_INVALID) |
82 return false; | 83 return false; |
83 return format < kFirstCustomFormat; | 84 return format < kFirstCustomFormat; |
84 } | 85 } |
85 | 86 |
86 } // namespace ppapi | 87 } // namespace ppapi |
OLD | NEW |