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

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

Issue 20070002: Demo UI for device discovery and registration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added FILE_PATH_LITERAL macro to fix windows compile problem Created 7 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) 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 <string> 9 #include <string>
10 10
(...skipping 28 matching lines...) Expand all
39 #include "chrome/browser/signin/oauth2_token_service.h" 39 #include "chrome/browser/signin/oauth2_token_service.h"
40 #include "chrome/browser/signin/profile_oauth2_token_service.h" 40 #include "chrome/browser/signin/profile_oauth2_token_service.h"
41 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 41 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
42 #include "chrome/browser/ui/browser_finder.h" 42 #include "chrome/browser/ui/browser_finder.h"
43 #include "chrome/browser/ui/browser_tabstrip.h" 43 #include "chrome/browser/ui/browser_tabstrip.h"
44 #include "chrome/browser/ui/chrome_select_file_policy.h" 44 #include "chrome/browser/ui/chrome_select_file_policy.h"
45 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" 45 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
46 #include "chrome/browser/ui/webui/print_preview/sticky_settings.h" 46 #include "chrome/browser/ui/webui/print_preview/sticky_settings.h"
47 #include "chrome/common/chrome_paths.h" 47 #include "chrome/common/chrome_paths.h"
48 #include "chrome/common/chrome_switches.h" 48 #include "chrome/common/chrome_switches.h"
49 #include "chrome/common/cloud_print/cloud_print_constants.h"
49 #include "chrome/common/pref_names.h" 50 #include "chrome/common/pref_names.h"
50 #include "chrome/common/print_messages.h" 51 #include "chrome/common/print_messages.h"
51 #include "content/public/browser/browser_context.h" 52 #include "content/public/browser/browser_context.h"
52 #include "content/public/browser/browser_thread.h" 53 #include "content/public/browser/browser_thread.h"
53 #include "content/public/browser/navigation_controller.h" 54 #include "content/public/browser/navigation_controller.h"
54 #include "content/public/browser/navigation_entry.h" 55 #include "content/public/browser/navigation_entry.h"
55 #include "content/public/browser/render_view_host.h" 56 #include "content/public/browser/render_view_host.h"
56 #include "content/public/browser/web_contents.h" 57 #include "content/public/browser/web_contents.h"
57 #include "content/public/browser/web_contents_view.h" 58 #include "content/public/browser/web_contents_view.h"
58 #include "content/public/browser/web_ui.h" 59 #include "content/public/browser/web_ui.h"
(...skipping 16 matching lines...) Expand all
75 using content::BrowserThread; 76 using content::BrowserThread;
76 using content::NavigationEntry; 77 using content::NavigationEntry;
77 using content::OpenURLParams; 78 using content::OpenURLParams;
78 using content::RenderViewHost; 79 using content::RenderViewHost;
79 using content::Referrer; 80 using content::Referrer;
80 using content::WebContents; 81 using content::WebContents;
81 using printing::Metafile; 82 using printing::Metafile;
82 83
83 namespace { 84 namespace {
84 85
85 // The cloud print OAuth2 scope.
86 const char kCloudPrintAuth[] = "https://www.googleapis.com/auth/cloudprint";
87
88 enum UserActionBuckets { 86 enum UserActionBuckets {
89 PRINT_TO_PRINTER, 87 PRINT_TO_PRINTER,
90 PRINT_TO_PDF, 88 PRINT_TO_PDF,
91 CANCEL, 89 CANCEL,
92 FALLBACK_TO_ADVANCED_SETTINGS_DIALOG, 90 FALLBACK_TO_ADVANCED_SETTINGS_DIALOG,
93 PREVIEW_FAILED, 91 PREVIEW_FAILED,
94 PREVIEW_STARTED, 92 PREVIEW_STARTED,
95 INITIATOR_CRASHED, // UNUSED 93 INITIATOR_CRASHED, // UNUSED
96 INITIATOR_CLOSED, 94 INITIATOR_CLOSED,
97 PRINT_WITH_CLOUD_PRINT, 95 PRINT_WITH_CLOUD_PRINT,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // locale. 161 // locale.
164 const char kMeasurementSystem[] = "measurementSystem"; 162 const char kMeasurementSystem[] = "measurementSystem";
165 // Name of a dictionary field holding the number format according to the locale. 163 // Name of a dictionary field holding the number format according to the locale.
166 const char kNumberFormat[] = "numberFormat"; 164 const char kNumberFormat[] = "numberFormat";
167 // Name of a dictionary field specifying whether to print automatically in 165 // Name of a dictionary field specifying whether to print automatically in
168 // kiosk mode. See http://crbug.com/31395. 166 // kiosk mode. See http://crbug.com/31395.
169 const char kPrintAutomaticallyInKioskMode[] = "printAutomaticallyInKioskMode"; 167 const char kPrintAutomaticallyInKioskMode[] = "printAutomaticallyInKioskMode";
170 // Name of a dictionary field holding the state of selection for document. 168 // Name of a dictionary field holding the state of selection for document.
171 const char kDocumentHasSelection[] = "documentHasSelection"; 169 const char kDocumentHasSelection[] = "documentHasSelection";
172 170
173
174 // Get the print job settings dictionary from |args|. The caller takes 171 // Get the print job settings dictionary from |args|. The caller takes
175 // ownership of the returned DictionaryValue. Returns NULL on failure. 172 // ownership of the returned DictionaryValue. Returns NULL on failure.
176 DictionaryValue* GetSettingsDictionary(const ListValue* args) { 173 DictionaryValue* GetSettingsDictionary(const ListValue* args) {
177 std::string json_str; 174 std::string json_str;
178 if (!args->GetString(0, &json_str)) { 175 if (!args->GetString(0, &json_str)) {
179 NOTREACHED() << "Could not read JSON argument"; 176 NOTREACHED() << "Could not read JSON argument";
180 return NULL; 177 return NULL;
181 } 178 }
182 if (json_str.empty()) { 179 if (json_str.empty()) {
183 NOTREACHED() << "Empty print job settings"; 180 NOTREACHED() << "Empty print job settings";
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 if (profile) 283 if (profile)
287 service = ProfileOAuth2TokenServiceFactory::GetForProfile(profile); 284 service = ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
288 } else if (type == "device") { 285 } else if (type == "device") {
289 #if defined(OS_CHROMEOS) 286 #if defined(OS_CHROMEOS)
290 service = chromeos::DeviceOAuth2TokenServiceFactory::Get(); 287 service = chromeos::DeviceOAuth2TokenServiceFactory::Get();
291 #endif 288 #endif
292 } 289 }
293 290
294 if (service) { 291 if (service) {
295 OAuth2TokenService::ScopeSet oauth_scopes; 292 OAuth2TokenService::ScopeSet oauth_scopes;
296 oauth_scopes.insert(kCloudPrintAuth); 293 oauth_scopes.insert(cloud_print::kCloudPrintAuth);
297 scoped_ptr<OAuth2TokenService::Request> request( 294 scoped_ptr<OAuth2TokenService::Request> request(
298 service->StartRequest(oauth_scopes, this)); 295 service->StartRequest(oauth_scopes, this));
299 requests_[type].reset(request.release()); 296 requests_[type].reset(request.release());
300 } else { 297 } else {
301 handler_->SendAccessToken(type, std::string()); // Unknown type. 298 handler_->SendAccessToken(type, std::string()); // Unknown type.
302 } 299 }
303 } 300 }
304 301
305 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 302 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
306 const std::string& access_token, 303 const std::string& access_token,
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 if (!tmp_data.get()) { 1078 if (!tmp_data.get()) {
1082 // Nothing to print, no preview available. 1079 // Nothing to print, no preview available.
1083 return false; 1080 return false;
1084 } 1081 }
1085 DCHECK(tmp_data->size() && tmp_data->front()); 1082 DCHECK(tmp_data->size() && tmp_data->front());
1086 1083
1087 *data = tmp_data; 1084 *data = tmp_data;
1088 *title = print_preview_ui->initiator_title(); 1085 *title = print_preview_ui->initiator_title();
1089 return true; 1086 return true;
1090 } 1087 }
1091
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698