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

Side by Side Diff: chrome/browser/ui/webui/print_preview/print_preview_handler.cc

Issue 1368013004: Define Print Preview default printer selection policy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add tags to DefaultPrinterSelection policy. Created 5 years, 2 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
« no previous file with comments | « chrome/browser/resources/print_preview/print_preview.js ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/webui/print_preview/print_preview_handler.h" 5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // Dictionary field to indicate whether Chrome is running in forced app (app 162 // Dictionary field to indicate whether Chrome is running in forced app (app
163 // kiosk) mode. It's not the same as desktop Chrome kiosk (the one above). 163 // kiosk) mode. It's not the same as desktop Chrome kiosk (the one above).
164 const char kAppKioskMode[] = "appKioskMode"; 164 const char kAppKioskMode[] = "appKioskMode";
165 // Dictionary field to store Cloud Print base URL. 165 // Dictionary field to store Cloud Print base URL.
166 const char kCloudPrintUrl[] = "cloudPrintUrl"; 166 const char kCloudPrintUrl[] = "cloudPrintUrl";
167 #if defined(OS_WIN) 167 #if defined(OS_WIN)
168 const char kHidePrintWithSystemDialogLink[] = "hidePrintWithSystemDialogLink"; 168 const char kHidePrintWithSystemDialogLink[] = "hidePrintWithSystemDialogLink";
169 #endif 169 #endif
170 // Name of a dictionary field holding the state of selection for document. 170 // Name of a dictionary field holding the state of selection for document.
171 const char kDocumentHasSelection[] = "documentHasSelection"; 171 const char kDocumentHasSelection[] = "documentHasSelection";
172 // Dictionary field holding the default destination selection rules.
173 const char kDefaultDestinationSelectionRules[] =
174 "defaultDestinationSelectionRules";
172 175
173 // Id of the predefined PDF printer. 176 // Id of the predefined PDF printer.
174 const char kLocalPdfPrinterId[] = "Save as PDF"; 177 const char kLocalPdfPrinterId[] = "Save as PDF";
175 178
176 // Additional printer capability setting keys. 179 // Additional printer capability setting keys.
177 const char kPrinterId[] = "printerId"; 180 const char kPrinterId[] = "printerId";
178 const char kPrinterCapabilities[] = "capabilities"; 181 const char kPrinterCapabilities[] = "capabilities";
179 182
180 // Get the print job settings dictionary from |args|. The caller takes 183 // Get the print job settings dictionary from |args|. The caller takes
181 // ownership of the returned DictionaryValue. Returns NULL on failure. 184 // ownership of the returned DictionaryValue. Returns NULL on failure.
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 base::DictionaryValue initial_settings; 1252 base::DictionaryValue initial_settings;
1250 initial_settings.SetString(kInitiatorTitle, 1253 initial_settings.SetString(kInitiatorTitle,
1251 print_preview_ui()->initiator_title()); 1254 print_preview_ui()->initiator_title());
1252 initial_settings.SetBoolean(printing::kSettingPreviewModifiable, 1255 initial_settings.SetBoolean(printing::kSettingPreviewModifiable,
1253 print_preview_ui()->source_is_modifiable()); 1256 print_preview_ui()->source_is_modifiable());
1254 initial_settings.SetString(printing::kSettingPrinterName, default_printer); 1257 initial_settings.SetString(printing::kSettingPrinterName, default_printer);
1255 initial_settings.SetBoolean(kDocumentHasSelection, 1258 initial_settings.SetBoolean(kDocumentHasSelection,
1256 print_preview_ui()->source_has_selection()); 1259 print_preview_ui()->source_has_selection());
1257 initial_settings.SetBoolean(printing::kSettingShouldPrintSelectionOnly, 1260 initial_settings.SetBoolean(printing::kSettingShouldPrintSelectionOnly,
1258 print_preview_ui()->print_selection_only()); 1261 print_preview_ui()->print_selection_only());
1262 PrefService* prefs = Profile::FromBrowserContext(
1263 preview_web_contents()->GetBrowserContext())->GetPrefs();
1259 printing::StickySettings* sticky_settings = GetStickySettings(); 1264 printing::StickySettings* sticky_settings = GetStickySettings();
1260 sticky_settings->RestoreFromPrefs(Profile::FromBrowserContext( 1265 sticky_settings->RestoreFromPrefs(prefs);
1261 preview_web_contents()->GetBrowserContext())->GetPrefs());
1262 if (sticky_settings->printer_app_state()) { 1266 if (sticky_settings->printer_app_state()) {
1263 initial_settings.SetString(kAppState, 1267 initial_settings.SetString(kAppState,
1264 *sticky_settings->printer_app_state()); 1268 *sticky_settings->printer_app_state());
1265 } 1269 }
1266 1270
1267 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); 1271 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
1268 initial_settings.SetBoolean(kPrintAutomaticallyInKioskMode, 1272 initial_settings.SetBoolean(kPrintAutomaticallyInKioskMode,
1269 cmdline->HasSwitch(switches::kKioskModePrinting)); 1273 cmdline->HasSwitch(switches::kKioskModePrinting));
1270 initial_settings.SetBoolean(kAppKioskMode, 1274 initial_settings.SetBoolean(kAppKioskMode,
1271 chrome::IsRunningInForcedAppMode()); 1275 chrome::IsRunningInForcedAppMode());
1272 #if defined(OS_WIN) 1276 #if defined(OS_WIN)
1273 // In Win8 metro, the system print dialog can only open on the desktop. Doing 1277 // In Win8 metro, the system print dialog can only open on the desktop. Doing
1274 // so will cause the browser to appear hung, so we don't show the link in 1278 // so will cause the browser to appear hung, so we don't show the link in
1275 // metro. 1279 // metro.
1276 bool is_ash = (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH); 1280 bool is_ash = (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH);
1277 initial_settings.SetBoolean(kHidePrintWithSystemDialogLink, is_ash); 1281 initial_settings.SetBoolean(kHidePrintWithSystemDialogLink, is_ash);
1278 #endif 1282 #endif
1283 if (prefs) {
1284 const std::string rules_str =
1285 prefs->GetString(prefs::kPrintPreviewDefaultDestinationSelectionRules);
1286 if (!rules_str.empty())
1287 initial_settings.SetString(kDefaultDestinationSelectionRules, rules_str);
1288 }
1279 1289
1280 if (print_preview_ui()->source_is_modifiable()) 1290 if (print_preview_ui()->source_is_modifiable())
1281 GetNumberFormatAndMeasurementSystem(&initial_settings); 1291 GetNumberFormatAndMeasurementSystem(&initial_settings);
1282 web_ui()->CallJavascriptFunction("setInitialSettings", initial_settings); 1292 web_ui()->CallJavascriptFunction("setInitialSettings", initial_settings);
1283 1293
1284 WebContents* initiator = GetInitiator(); 1294 WebContents* initiator = GetInitiator();
1285 if (initiator && cmdline->HasSwitch(switches::kEnableDomDistiller) && 1295 if (initiator && cmdline->HasSwitch(switches::kEnableDomDistiller) &&
1286 dom_distiller::url_utils::IsUrlDistillable( 1296 dom_distiller::url_utils::IsUrlDistillable(
1287 initiator->GetLastCommittedURL())) { 1297 initiator->GetLastCommittedURL())) {
1288 dom_distiller::IsDistillablePage( 1298 dom_distiller::IsDistillablePage(
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
1806 1816
1807 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { 1817 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() {
1808 if (gaia_cookie_manager_service_) 1818 if (gaia_cookie_manager_service_)
1809 gaia_cookie_manager_service_->RemoveObserver(this); 1819 gaia_cookie_manager_service_->RemoveObserver(this);
1810 } 1820 }
1811 1821
1812 void PrintPreviewHandler::SetPdfSavedClosureForTesting( 1822 void PrintPreviewHandler::SetPdfSavedClosureForTesting(
1813 const base::Closure& closure) { 1823 const base::Closure& closure) {
1814 pdf_file_saved_closure_ = closure; 1824 pdf_file_saved_closure_ = closure;
1815 } 1825 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview/print_preview.js ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698