| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/extension_chrome_auth_private_api.h" | 5 #include "chrome/browser/extensions/extension_chrome_auth_private_api.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 10 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
| 11 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" | 11 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 bool IsCloudPrintEnableURL(Profile* profile, const GURL& url) { | 16 bool IsCloudPrintEnableURL(Profile* profile, const GURL& url) { |
| 17 ExtensionService* service = profile->GetExtensionService(); | 17 ExtensionService* service = profile->GetExtensionService(); |
| 18 const Extension* cloud_print_app = service->GetExtensionById( | 18 const Extension* cloud_print_app = service->GetExtensionById( |
| 19 extension_misc::kCloudPrintAppId, false); | 19 extension_misc::kCloudPrintAppId, false); |
| 20 if (!cloud_print_app) { | 20 if (!cloud_print_app) { |
| 21 #if !defined(OS_CHROMEOS) | 21 #if !defined(OS_CHROMEOS) |
| 22 NOTREACHED(); | 22 NOTREACHED(); |
| 23 #endif // !defined(OS_CHROMEOS) | 23 #endif // !defined(OS_CHROMEOS) |
| 24 return false; | 24 return false; |
| 25 } | 25 } |
| 26 return (service->GetExtensionByWebExtent(url) == cloud_print_app); | 26 return (service->extensions()->GetByWebExtent(url) == cloud_print_app); |
| 27 } | 27 } |
| 28 | 28 |
| 29 bool test_mode = false; | 29 bool test_mode = false; |
| 30 | 30 |
| 31 const char kAccessDeniedError[] = | 31 const char kAccessDeniedError[] = |
| 32 "Cannot call this API from a non-cloudprint URL."; | 32 "Cannot call this API from a non-cloudprint URL."; |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 SetCloudPrintCredentialsFunction::SetCloudPrintCredentialsFunction() { | 35 SetCloudPrintCredentialsFunction::SetCloudPrintCredentialsFunction() { |
| 36 } | 36 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 61 EnableForUserWithRobot(credentials, robot_email, user_email); | 61 EnableForUserWithRobot(credentials, robot_email, user_email); |
| 62 } | 62 } |
| 63 SendResponse(true); | 63 SendResponse(true); |
| 64 return true; | 64 return true; |
| 65 } | 65 } |
| 66 | 66 |
| 67 // static | 67 // static |
| 68 void SetCloudPrintCredentialsFunction::SetTestMode(bool test_mode_enabled) { | 68 void SetCloudPrintCredentialsFunction::SetTestMode(bool test_mode_enabled) { |
| 69 test_mode = test_mode_enabled; | 69 test_mode = test_mode_enabled; |
| 70 } | 70 } |
| OLD | NEW |