| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 if (profile) | 284 if (profile) |
| 287 service = ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 285 service = ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 288 } else if (type == "device") { | 286 } else if (type == "device") { |
| 289 #if defined(OS_CHROMEOS) | 287 #if defined(OS_CHROMEOS) |
| 290 service = chromeos::DeviceOAuth2TokenServiceFactory::Get(); | 288 service = chromeos::DeviceOAuth2TokenServiceFactory::Get(); |
| 291 #endif | 289 #endif |
| 292 } | 290 } |
| 293 | 291 |
| 294 if (service) { | 292 if (service) { |
| 295 OAuth2TokenService::ScopeSet oauth_scopes; | 293 OAuth2TokenService::ScopeSet oauth_scopes; |
| 296 oauth_scopes.insert(kCloudPrintAuth); | 294 oauth_scopes.insert(cloud_print::kCloudPrintAuth); |
| 297 scoped_ptr<OAuth2TokenService::Request> request( | 295 scoped_ptr<OAuth2TokenService::Request> request( |
| 298 service->StartRequest(oauth_scopes, this)); | 296 service->StartRequest(oauth_scopes, this)); |
| 299 requests_[type].reset(request.release()); | 297 requests_[type].reset(request.release()); |
| 300 } else { | 298 } else { |
| 301 handler_->SendAccessToken(type, std::string()); // Unknown type. | 299 handler_->SendAccessToken(type, std::string()); // Unknown type. |
| 302 } | 300 } |
| 303 } | 301 } |
| 304 | 302 |
| 305 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 303 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
| 306 const std::string& access_token, | 304 const std::string& access_token, |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 if (!tmp_data.get()) { | 1079 if (!tmp_data.get()) { |
| 1082 // Nothing to print, no preview available. | 1080 // Nothing to print, no preview available. |
| 1083 return false; | 1081 return false; |
| 1084 } | 1082 } |
| 1085 DCHECK(tmp_data->size() && tmp_data->front()); | 1083 DCHECK(tmp_data->size() && tmp_data->front()); |
| 1086 | 1084 |
| 1087 *data = tmp_data; | 1085 *data = tmp_data; |
| 1088 *title = print_preview_ui->initiator_title(); | 1086 *title = print_preview_ui->initiator_title(); |
| 1089 return true; | 1087 return true; |
| 1090 } | 1088 } |
| 1091 | |
| OLD | NEW |