| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 const char kNotificationOriginUrl[] = "chrome://screenshot"; | 65 const char kNotificationOriginUrl[] = "chrome://screenshot"; |
| 66 | 66 |
| 67 const char kImageClipboardFormatPrefix[] = "<img src='data:image/png;base64,"; | 67 const char kImageClipboardFormatPrefix[] = "<img src='data:image/png;base64,"; |
| 68 const char kImageClipboardFormatSuffix[] = "'>"; | 68 const char kImageClipboardFormatSuffix[] = "'>"; |
| 69 | 69 |
| 70 void CopyScreenshotToClipboard(scoped_refptr<base::RefCountedString> png_data) { | 70 void CopyScreenshotToClipboard(scoped_refptr<base::RefCountedString> png_data) { |
| 71 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 71 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 72 | 72 |
| 73 std::string encoded; | 73 std::string encoded; |
| 74 if (!base::Base64Encode(png_data->data(), &encoded)) { | 74 base::Base64Encode(png_data->data(), &encoded); |
| 75 LOG(ERROR) << "Failed to encode base64"; | |
| 76 return; | |
| 77 } | |
| 78 | 75 |
| 79 // Only cares about HTML because ChromeOS doesn't need other formats. | 76 // Only cares about HTML because ChromeOS doesn't need other formats. |
| 80 // TODO(dcheng): Why don't we take advantage of the ability to write bitmaps | 77 // TODO(dcheng): Why don't we take advantage of the ability to write bitmaps |
| 81 // to the clipboard here? | 78 // to the clipboard here? |
| 82 { | 79 { |
| 83 ui::ScopedClipboardWriter scw(ui::Clipboard::GetForCurrentThread(), | 80 ui::ScopedClipboardWriter scw(ui::Clipboard::GetForCurrentThread(), |
| 84 ui::CLIPBOARD_TYPE_COPY_PASTE); | 81 ui::CLIPBOARD_TYPE_COPY_PASTE); |
| 85 std::string html(kImageClipboardFormatPrefix); | 82 std::string html(kImageClipboardFormatPrefix); |
| 86 html += encoded; | 83 html += encoded; |
| 87 html += kImageClipboardFormatSuffix; | 84 html += kImageClipboardFormatSuffix; |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 } | 590 } |
| 594 | 591 |
| 595 void ScreenshotTaker::SetScreenshotBasenameForTest( | 592 void ScreenshotTaker::SetScreenshotBasenameForTest( |
| 596 const std::string& basename) { | 593 const std::string& basename) { |
| 597 screenshot_basename_for_test_ = basename; | 594 screenshot_basename_for_test_ = basename; |
| 598 } | 595 } |
| 599 | 596 |
| 600 void ScreenshotTaker::SetScreenshotProfileForTest(Profile* profile) { | 597 void ScreenshotTaker::SetScreenshotProfileForTest(Profile* profile) { |
| 601 profile_for_test_ = profile; | 598 profile_for_test_ = profile; |
| 602 } | 599 } |
| OLD | NEW |