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

Side by Side Diff: ui/base/clipboard/clipboard_win.cc

Issue 141113003: Refactor base/safe_numerics.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « tools/imagediff/image_diff.cc ('k') | ui/snapshot/snapshot_aura.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 (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 // Many of these functions are based on those found in 5 // Many of these functions are based on those found in
6 // webkit/port/platform/PasteboardWin.cpp 6 // webkit/port/platform/PasteboardWin.cpp
7 7
8 #include "ui/base/clipboard/clipboard.h" 8 #include "ui/base/clipboard/clipboard.h"
9 9
10 #include <shellapi.h>
10 #include <shlobj.h> 11 #include <shlobj.h>
11 #include <shellapi.h>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/memory/shared_memory.h" 17 #include "base/memory/shared_memory.h"
18 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
19 #include "base/safe_numerics.h" 19 #include "base/numerics/safe_conversions.h"
20 #include "base/stl_util.h" 20 #include "base/stl_util.h"
21 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/string_util.h" 22 #include "base/strings/string_util.h"
23 #include "base/strings/utf_offset_string_conversions.h" 23 #include "base/strings/utf_offset_string_conversions.h"
24 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
25 #include "base/win/message_window.h" 25 #include "base/win/message_window.h"
26 #include "base/win/scoped_gdi_object.h" 26 #include "base/win/scoped_gdi_object.h"
27 #include "base/win/scoped_hdc.h" 27 #include "base/win/scoped_hdc.h"
28 #include "third_party/skia/include/core/SkBitmap.h" 28 #include "third_party/skia/include/core/SkBitmap.h"
29 #include "ui/base/clipboard/clipboard_util_win.h" 29 #include "ui/base/clipboard/clipboard_util_win.h"
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 return; 511 return;
512 512
513 if (start_index < html_start || end_index < start_index) 513 if (start_index < html_start || end_index < start_index)
514 return; 514 return;
515 515
516 std::vector<size_t> offsets; 516 std::vector<size_t> offsets;
517 offsets.push_back(start_index - html_start); 517 offsets.push_back(start_index - html_start);
518 offsets.push_back(end_index - html_start); 518 offsets.push_back(end_index - html_start);
519 markup->assign(base::UTF8ToUTF16AndAdjustOffsets(cf_html.data() + html_start, 519 markup->assign(base::UTF8ToUTF16AndAdjustOffsets(cf_html.data() + html_start,
520 &offsets)); 520 &offsets));
521 *fragment_start = base::checked_numeric_cast<uint32>(offsets[0]); 521 *fragment_start = base::checked_cast<uint32>(offsets[0]);
522 *fragment_end = base::checked_numeric_cast<uint32>(offsets[1]); 522 *fragment_end = base::checked_cast<uint32>(offsets[1]);
523 } 523 }
524 524
525 void Clipboard::ReadRTF(ClipboardType type, std::string* result) const { 525 void Clipboard::ReadRTF(ClipboardType type, std::string* result) const {
526 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); 526 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE);
527 527
528 ReadData(GetRtfFormatType(), result); 528 ReadData(GetRtfFormatType(), result);
529 } 529 }
530 530
531 SkBitmap Clipboard::ReadImage(ClipboardType type) const { 531 SkBitmap Clipboard::ReadImage(ClipboardType type) const {
532 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); 532 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE);
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 if (!clipboard_owner_) 827 if (!clipboard_owner_)
828 return NULL; 828 return NULL;
829 829
830 if (clipboard_owner_->hwnd() == NULL) 830 if (clipboard_owner_->hwnd() == NULL)
831 clipboard_owner_->Create(base::Bind(&ClipboardOwnerWndProc)); 831 clipboard_owner_->Create(base::Bind(&ClipboardOwnerWndProc));
832 832
833 return clipboard_owner_->hwnd(); 833 return clipboard_owner_->hwnd();
834 } 834 }
835 835
836 } // namespace ui 836 } // namespace ui
OLDNEW
« no previous file with comments | « tools/imagediff/image_diff.cc ('k') | ui/snapshot/snapshot_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698