Commit 98dddb18 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Simplify/constify code in PrintPreviewHandler and friends.

Change-Id: Ie5526d13b4126f317e269b32f3aed06aa04b6428
Reviewed-on: https://chromium-review.googlesource.com/758887Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#515417}
parent 6e15415d
......@@ -98,8 +98,8 @@ std::unique_ptr<base::DictionaryValue> GetPdfCapabilities(
default_media = Media(locale == "en-US" ? NA_LETTER : ISO_A4);
}
MediaCapability media;
for (size_t i = 0; i < arraysize(kPdfMedia); ++i) {
Media media_option(kPdfMedia[i]);
for (const auto& pdf_media : kPdfMedia) {
Media media_option(pdf_media);
media.AddDefaultOption(media_option,
default_media.type == media_option.type);
}
......@@ -145,7 +145,6 @@ PdfPrinterHandler::PdfPrinterHandler(Profile* profile,
: preview_web_contents_(preview_web_contents),
profile_(profile),
sticky_settings_(sticky_settings),
print_data_(nullptr),
weak_ptr_factory_(this) {}
PdfPrinterHandler::~PdfPrinterHandler() {
......
......@@ -79,7 +79,7 @@ class PdfPrinterHandler : public PrinterHandler,
bool prompt_user);
// The print preview web contents. Protected so unit tests can access it.
content::WebContents* preview_web_contents_;
content::WebContents* const preview_web_contents_;
// The underlying dialog object. Protected so unit tests can access it.
scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
......@@ -89,8 +89,8 @@ class PdfPrinterHandler : public PrinterHandler,
void OnGotUniqueFileName(const base::FilePath& path);
void OnDirectoryCreated(const base::FilePath& path);
Profile* profile_;
printing::StickySettings* sticky_settings_;
Profile* const profile_;
printing::StickySettings* const sticky_settings_;
// Holds the path to the print to pdf request. It is empty if no such request
// exists.
......
......@@ -23,7 +23,6 @@
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted_memory.h"
#include "base/metrics/histogram_macros.h"
#include "base/threading/thread.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
......@@ -62,9 +61,6 @@
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
......@@ -84,7 +80,6 @@
#include "chromeos/printing/printer_configuration.h"
#endif
using content::BrowserThread;
using content::RenderFrameHost;
using content::WebContents;
using printing::PrintViewManager;
......@@ -578,7 +573,7 @@ void PrintPreviewHandler::HandleGetPreview(const base::ListValue* args) {
++regenerate_preview_request_count_;
WebContents* initiator = GetInitiator();
content::RenderFrameHost* rfh =
RenderFrameHost* rfh =
initiator
? PrintViewManager::FromWebContents(initiator)->print_preview_rfh()
: nullptr;
......@@ -597,17 +592,13 @@ void PrintPreviewHandler::HandleGetPreview(const base::ListValue* args) {
if (display_header_footer) {
settings->SetString(printing::kSettingHeaderFooterTitle,
initiator->GetTitle());
std::string url;
content::NavigationEntry* entry =
initiator->GetController().GetLastCommittedEntry();
if (entry) {
url::Replacements<char> url_sanitizer;
url_sanitizer.ClearUsername();
url_sanitizer.ClearPassword();
url = entry->GetVirtualURL().ReplaceComponents(url_sanitizer).spec();
}
settings->SetString(printing::kSettingHeaderFooterURL, url);
url::Replacements<char> url_sanitizer;
url_sanitizer.ClearUsername();
url_sanitizer.ClearPassword();
const GURL& initiator_url = initiator->GetLastCommittedURL();
settings->SetString(printing::kSettingHeaderFooterURL,
initiator_url.ReplaceComponents(url_sanitizer).spec());
}
bool generate_draft_data = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment