diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/printing/page_overlays.cc | 50 | ||||
-rw-r--r-- | chrome/browser/printing/page_overlays.h | 6 | ||||
-rw-r--r-- | chrome/browser/printing/page_overlays_unittest.cc | 15 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 10 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 9 |
5 files changed, 84 insertions, 6 deletions
diff --git a/chrome/browser/printing/page_overlays.cc b/chrome/browser/printing/page_overlays.cc index eb1d3c6..4a20dd6 100644 --- a/chrome/browser/printing/page_overlays.cc +++ b/chrome/browser/printing/page_overlays.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -84,6 +84,54 @@ const std::wstring& PageOverlays::GetOverlay(HorizontalPosition x, return EmptyWString(); } +void PageOverlays::SetOverlay(HorizontalPosition x, VerticalPosition y, + std::wstring& input) { + switch (x) { + case LEFT: + switch (y) { + case TOP: + top_left = input; + break; + case BOTTOM: + bottom_left = input; + break; + default: + NOTREACHED(); + break; + } + break; + case CENTER: + switch (y) { + case TOP: + top_center = input; + break; + case BOTTOM: + bottom_center = input; + break; + default: + NOTREACHED(); + break; + } + break; + case RIGHT: + switch (y) { + case TOP: + top_right = input; + break; + case BOTTOM: + bottom_right = input; + break; + default: + NOTREACHED(); + break; + } + break; + default: + NOTREACHED(); + break; + } +} + //static std::wstring PageOverlays::ReplaceVariables(const std::wstring& input, const PrintedDocument& document, diff --git a/chrome/browser/printing/page_overlays.h b/chrome/browser/printing/page_overlays.h index 42e77fc..7663153 100644 --- a/chrome/browser/printing/page_overlays.h +++ b/chrome/browser/printing/page_overlays.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -39,6 +39,10 @@ class PageOverlays { const std::wstring& GetOverlay(HorizontalPosition x, VerticalPosition y) const; + // Sets the string of an overlay according to its x,y position. + void SetOverlay(HorizontalPosition x, VerticalPosition y, + std::wstring& input); + // Replaces the variables in |input| with their actual values according to the // properties of the current printed document and the current printed page. static std::wstring ReplaceVariables(const std::wstring& input, diff --git a/chrome/browser/printing/page_overlays_unittest.cc b/chrome/browser/printing/page_overlays_unittest.cc index 04104a8..0710f33 100644 --- a/chrome/browser/printing/page_overlays_unittest.cc +++ b/chrome/browser/printing/page_overlays_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -73,4 +73,17 @@ TEST_F(PageOverlaysTest, StringConversion) { EXPECT_EQ(StringPrintf(L"foo%lsbar", kOverlayKeys[i].expected), out) << kOverlayKeys[i].key; } + + // Check if SetOverlay really sets the page overlay. + overlays.SetOverlay(printing::PageOverlays::LEFT, + printing::PageOverlays::TOP, + UTF16ToWide(L"Page {page}")); + input = overlays.GetOverlay(printing::PageOverlays::LEFT, + printing::PageOverlays::TOP); + EXPECT_EQ(input, L"Page {page}"); + + // Replace the variables to see if the page number is correct. + out = printing::PageOverlays::ReplaceVariables(input, *doc.get(), + *page.get()); + EXPECT_EQ(out, L"Page 1"); } diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index d2608c5..300e6ab 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -235,6 +235,14 @@ const wchar_t kBookmarkManagerSplitLocation[] = // Boolean pref to define the default values for using spellchecker. const wchar_t kEnableSpellCheck[] = L"browser.enable_spellchecking"; +// String pref to define the default values for print overlays. +const wchar_t kPrintingPageHeaderLeft[] = L"printing.page.header.left"; +const wchar_t kPrintingPageHeaderCenter[] = L"printing.page.header.center"; +const wchar_t kPrintingPageHeaderRight[] = L"printing.page.header.right"; +const wchar_t kPrintingPageFooterLeft[] = L"printing.page.footer.left"; +const wchar_t kPrintingPageFooterCenter[] = L"printing.page.footer.center"; +const wchar_t kPrintingPageFooterRight[] = L"printing.page.footer.right"; + // *************** LOCAL STATE *************** // These are attached to the machine/installation diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index f3c2b15..9ca99fa 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -81,7 +81,12 @@ extern const wchar_t kBookmarkManagerPlacement[]; extern const wchar_t kBookmarkManagerSplitLocation[]; extern const wchar_t kEnableSpellCheck[]; extern const wchar_t kDeleteTimePeriod[]; - +extern const wchar_t kPrintingPageHeaderLeft[]; +extern const wchar_t kPrintingPageHeaderCenter[]; +extern const wchar_t kPrintingPageHeaderRight[]; +extern const wchar_t kPrintingPageFooterLeft[]; +extern const wchar_t kPrintingPageFooterCenter[]; +extern const wchar_t kPrintingPageFooterRight[]; // Local state extern const wchar_t kAvailableProfiles[]; |