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

Side by Side Diff: chrome/browser/printing/print_dialog_gtk.cc

Issue 3127009: Convert infobar APIs to UTF-16. (Closed)
Patch Set: works Created 10 years, 4 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/printing/print_dialog_gtk.h" 5 #include "chrome/browser/printing/print_dialog_gtk.h"
6 6
7 #include <gtk/gtkprintjob.h> 7 #include <gtk/gtkprintjob.h>
8 #include <gtk/gtkprintunixdialog.h> 8 #include <gtk/gtkprintunixdialog.h>
9 #include <gtk/gtkpagesetupunixdialog.h> 9 #include <gtk/gtkpagesetupunixdialog.h>
10 10
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/lock.h" 13 #include "base/lock.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/browser_list.h" 16 #include "chrome/browser/browser_list.h"
16 #include "chrome/browser/browser_window.h" 17 #include "chrome/browser/browser_window.h"
17 #include "chrome/browser/chrome_thread.h" 18 #include "chrome/browser/chrome_thread.h"
18 #include "chrome/browser/tab_contents/infobar_delegate.h" 19 #include "chrome/browser/tab_contents/infobar_delegate.h"
19 #include "chrome/browser/tab_contents/tab_contents.h" 20 #include "chrome/browser/tab_contents/tab_contents.h"
20 21
21 namespace { 22 namespace {
22 23
23 PrintDialogGtk* g_print_dialog = NULL; 24 PrintDialogGtk* g_print_dialog = NULL;
24 25
25 // Used to make accesses to the above thread safe. 26 // Used to make accesses to the above thread safe.
26 Lock& DialogLock() { 27 Lock& DialogLock() {
27 static base::LazyInstance<Lock> dialog_lock(base::LINKER_INITIALIZED); 28 static base::LazyInstance<Lock> dialog_lock(base::LINKER_INITIALIZED);
28 return dialog_lock.Get(); 29 return dialog_lock.Get();
29 } 30 }
30 31
31 // This is a temporary infobar designed to help gauge how many users are trying 32 // This is a temporary infobar designed to help gauge how many users are trying
32 // to print to printers that don't support PDF. 33 // to print to printers that don't support PDF.
33 class PdfUnsupportedInfoBarDelegate : public LinkInfoBarDelegate { 34 class PdfUnsupportedInfoBarDelegate : public LinkInfoBarDelegate {
34 public: 35 public:
35 explicit PdfUnsupportedInfoBarDelegate(Browser* browser) 36 explicit PdfUnsupportedInfoBarDelegate(Browser* browser)
36 : LinkInfoBarDelegate(NULL), 37 : LinkInfoBarDelegate(NULL),
37 browser_(browser) { 38 browser_(browser) {
38 } 39 }
39 40
40 virtual ~PdfUnsupportedInfoBarDelegate() {} 41 virtual ~PdfUnsupportedInfoBarDelegate() {}
41 42
42 virtual std::wstring GetMessageTextWithOffset(size_t* link_offset) const { 43 virtual string16 GetMessageTextWithOffset(size_t* link_offset) const {
43 std::wstring message(L"Oops! Your printer does not support PDF. Please " 44 string16 message = UTF8ToUTF16("Oops! Your printer does not support PDF. "
44 L"report this to us ."); 45 "Please report this to us.");
45 *link_offset = message.length() - 1; 46 *link_offset = message.length() - 1;
46 return message; 47 return message;
47 } 48 }
48 49
49 virtual std::wstring GetLinkText() const { 50 virtual string16 GetLinkText() const {
50 return std::wstring(L"here"); 51 return UTF8ToUTF16("here");
51 } 52 }
52 53
53 virtual Type GetInfoBarType() { 54 virtual Type GetInfoBarType() {
54 return ERROR_TYPE; 55 return ERROR_TYPE;
55 } 56 }
56 57
57 virtual bool LinkClicked(WindowOpenDisposition disposition) { 58 virtual bool LinkClicked(WindowOpenDisposition disposition) {
58 browser_->OpenURL( 59 browser_->OpenURL(
59 GURL("http://code.google.com/p/chromium/issues/detail?id=22027"), 60 GURL("http://code.google.com/p/chromium/issues/detail?id=22027"),
60 GURL(), NEW_FOREGROUND_TAB, PageTransition::TYPED); 61 GURL(), NEW_FOREGROUND_TAB, PageTransition::TYPED);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if (error) 161 if (error)
161 LOG(ERROR) << "Printing failed: " << error->message; 162 LOG(ERROR) << "Printing failed: " << error->message;
162 163
163 if (job) 164 if (job)
164 g_object_unref(job); 165 g_object_unref(job);
165 166
166 file_util::Delete(path_to_pdf_, false); 167 file_util::Delete(path_to_pdf_, false);
167 168
168 delete this; 169 delete this;
169 } 170 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698