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

Side by Side Diff: ppapi/shared_impl/flash_clipboard_format_registry.cc

Issue 915403003: Enable size_t to int truncation warnings in PPAPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ppapi_unittests win x64 Created 5 years, 10 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 | « ppapi/shared_impl/array_writer.h ('k') | ppapi/tests/test_file_io.h » ('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 (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 #include "base/numerics/safe_conversions.h"
10
9 namespace ppapi { 11 namespace ppapi {
10 12
11 namespace { 13 namespace {
12 14
13 // These values are chosen arbitrarily. Flash will never exceed these but if 15 // These values are chosen arbitrarily. Flash will never exceed these but if
14 // the interface becomes public, we can reconsider these. 16 // the interface becomes public, we can reconsider these.
15 const size_t kMaxNumFormats = 10; 17 const size_t kMaxNumFormats = 10;
16 const size_t kMaxFormatNameLength = 50; 18 const size_t kMaxFormatNameLength = 50;
17 19
18 // All formats in PP_Flash_Clipboard_Format should be added here. 20 // All formats in PP_Flash_Clipboard_Format should be added here.
(...skipping 17 matching lines...) Expand all
36 FlashClipboardFormatRegistry::FlashClipboardFormatRegistry() {} 38 FlashClipboardFormatRegistry::FlashClipboardFormatRegistry() {}
37 39
38 FlashClipboardFormatRegistry::~FlashClipboardFormatRegistry() {} 40 FlashClipboardFormatRegistry::~FlashClipboardFormatRegistry() {}
39 41
40 uint32_t FlashClipboardFormatRegistry::RegisterFormat( 42 uint32_t FlashClipboardFormatRegistry::RegisterFormat(
41 const std::string& format_name) { 43 const std::string& format_name) {
42 if (!IsValidFormatName(format_name) || 44 if (!IsValidFormatName(format_name) ||
43 custom_formats_.size() > kMaxNumFormats) { 45 custom_formats_.size() > kMaxNumFormats) {
44 return PP_FLASH_CLIPBOARD_FORMAT_INVALID; 46 return PP_FLASH_CLIPBOARD_FORMAT_INVALID;
45 } 47 }
46 uint32_t key = kFirstCustomFormat + custom_formats_.size(); 48 uint32_t key = kFirstCustomFormat +
49 base::checked_cast<uint32_t>(custom_formats_.size());
47 custom_formats_[key] = format_name; 50 custom_formats_[key] = format_name;
48 return key; 51 return key;
49 } 52 }
50 53
51 void FlashClipboardFormatRegistry::SetRegisteredFormat( 54 void FlashClipboardFormatRegistry::SetRegisteredFormat(
52 const std::string& format_name, 55 const std::string& format_name,
53 uint32_t format) { 56 uint32_t format) {
54 custom_formats_[format] = format_name; 57 custom_formats_[format] = format_name;
55 } 58 }
56 59
(...skipping 20 matching lines...) Expand all
77 } 80 }
78 81
79 // static 82 // static
80 bool FlashClipboardFormatRegistry::IsValidPredefinedFormat(uint32_t format) { 83 bool FlashClipboardFormatRegistry::IsValidPredefinedFormat(uint32_t format) {
81 if (format == PP_FLASH_CLIPBOARD_FORMAT_INVALID) 84 if (format == PP_FLASH_CLIPBOARD_FORMAT_INVALID)
82 return false; 85 return false;
83 return format < kFirstCustomFormat; 86 return format < kFirstCustomFormat;
84 } 87 }
85 88
86 } // namespace ppapi 89 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/array_writer.h ('k') | ppapi/tests/test_file_io.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698