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

Side by Side Diff: trunk/src/chrome/browser/ui/ash/screenshot_taker.cc

Issue 101113004: Revert 239759 "The comment in base64.h implies that base::Base64..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years 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
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 "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
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 base::Base64Encode(png_data->data(), &encoded); 74 if (!base::Base64Encode(png_data->data(), &encoded)) {
75 LOG(ERROR) << "Failed to encode base64";
76 return;
77 }
75 78
76 // Only cares about HTML because ChromeOS doesn't need other formats. 79 // Only cares about HTML because ChromeOS doesn't need other formats.
77 // TODO(dcheng): Why don't we take advantage of the ability to write bitmaps 80 // TODO(dcheng): Why don't we take advantage of the ability to write bitmaps
78 // to the clipboard here? 81 // to the clipboard here?
79 { 82 {
80 ui::ScopedClipboardWriter scw(ui::Clipboard::GetForCurrentThread(), 83 ui::ScopedClipboardWriter scw(ui::Clipboard::GetForCurrentThread(),
81 ui::CLIPBOARD_TYPE_COPY_PASTE); 84 ui::CLIPBOARD_TYPE_COPY_PASTE);
82 std::string html(kImageClipboardFormatPrefix); 85 std::string html(kImageClipboardFormatPrefix);
83 html += encoded; 86 html += encoded;
84 html += kImageClipboardFormatSuffix; 87 html += kImageClipboardFormatSuffix;
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 } 593 }
591 594
592 void ScreenshotTaker::SetScreenshotBasenameForTest( 595 void ScreenshotTaker::SetScreenshotBasenameForTest(
593 const std::string& basename) { 596 const std::string& basename) {
594 screenshot_basename_for_test_ = basename; 597 screenshot_basename_for_test_ = basename;
595 } 598 }
596 599
597 void ScreenshotTaker::SetScreenshotProfileForTest(Profile* profile) { 600 void ScreenshotTaker::SetScreenshotProfileForTest(Profile* profile) {
598 profile_for_test_ = profile; 601 profile_for_test_ = profile;
599 } 602 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698