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 "chrome/browser/ui/ash/screenshot_taker.h" | 5 #include "chrome/browser/ui/ash/screenshot_taker.h" |
6 | 6 |
7 #include <climits> | 7 #include <climits> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 void CopyScreenshotToClipboard(scoped_refptr<base::RefCountedString> png_data) { | 67 void CopyScreenshotToClipboard(scoped_refptr<base::RefCountedString> png_data) { |
68 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 68 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
69 | 69 |
70 std::string encoded; | 70 std::string encoded; |
71 base::Base64Encode(png_data->data(), &encoded); | 71 base::Base64Encode(png_data->data(), &encoded); |
72 | 72 |
73 // Only cares about HTML because ChromeOS doesn't need other formats. | 73 // Only cares about HTML because ChromeOS doesn't need other formats. |
74 // TODO(dcheng): Why don't we take advantage of the ability to write bitmaps | 74 // TODO(dcheng): Why don't we take advantage of the ability to write bitmaps |
75 // to the clipboard here? | 75 // to the clipboard here? |
76 { | 76 { |
77 ui::ScopedClipboardWriter scw(ui::Clipboard::GetForCurrentThread(), | 77 ui::ScopedClipboardWriter scw(ui::CLIPBOARD_TYPE_COPY_PASTE); |
78 ui::CLIPBOARD_TYPE_COPY_PASTE); | |
79 std::string html(kImageClipboardFormatPrefix); | 78 std::string html(kImageClipboardFormatPrefix); |
80 html += encoded; | 79 html += encoded; |
81 html += kImageClipboardFormatSuffix; | 80 html += kImageClipboardFormatSuffix; |
82 scw.WriteHTML(base::UTF8ToUTF16(html), std::string()); | 81 scw.WriteHTML(base::UTF8ToUTF16(html), std::string()); |
83 } | 82 } |
84 content::RecordAction(base::UserMetricsAction("Screenshot_CopyClipboard")); | 83 content::RecordAction(base::UserMetricsAction("Screenshot_CopyClipboard")); |
85 } | 84 } |
86 | 85 |
87 void ReadFileAndCopyToClipboardLocal(const base::FilePath& screenshot_path) { | 86 void ReadFileAndCopyToClipboardLocal(const base::FilePath& screenshot_path) { |
88 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 87 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 } | 625 } |
627 | 626 |
628 void ScreenshotTaker::SetScreenshotBasenameForTest( | 627 void ScreenshotTaker::SetScreenshotBasenameForTest( |
629 const std::string& basename) { | 628 const std::string& basename) { |
630 screenshot_basename_for_test_ = basename; | 629 screenshot_basename_for_test_ = basename; |
631 } | 630 } |
632 | 631 |
633 void ScreenshotTaker::SetScreenshotProfileForTest(Profile* profile) { | 632 void ScreenshotTaker::SetScreenshotProfileForTest(Profile* profile) { |
634 profile_for_test_ = profile; | 633 profile_for_test_ = profile; |
635 } | 634 } |
OLD | NEW |