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/extensions/api/chrome_auth_private/chrome_auth_private_
api.h" | 5 #include "chrome/browser/extensions/api/cloud_print_private/cloud_print_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 test_mode = false; | 16 bool test_mode = false; |
17 | 17 |
18 } // namespace | 18 } // namespace |
19 | 19 |
20 namespace extensions { | 20 namespace extensions { |
21 | 21 |
22 SetCloudPrintCredentialsFunction::SetCloudPrintCredentialsFunction() { | 22 CloudPrintSetCredentialsFunction::CloudPrintSetCredentialsFunction() { |
23 } | 23 } |
24 | 24 |
25 SetCloudPrintCredentialsFunction::~SetCloudPrintCredentialsFunction() { | 25 CloudPrintSetCredentialsFunction::~CloudPrintSetCredentialsFunction() { |
26 } | 26 } |
27 | 27 |
28 bool SetCloudPrintCredentialsFunction::RunImpl() { | 28 bool CloudPrintSetCredentialsFunction::RunImpl() { |
29 std::string user_email; | 29 std::string user_email; |
30 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &user_email)); | 30 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &user_email)); |
31 std::string robot_email; | 31 std::string robot_email; |
32 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &robot_email)); | 32 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &robot_email)); |
33 std::string credentials; | 33 std::string credentials; |
34 EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &credentials)); | 34 EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &credentials)); |
35 if (test_mode) { | 35 if (test_mode) { |
36 std::string test_response = user_email; | 36 std::string test_response = user_email; |
37 test_response.append(robot_email); | 37 test_response.append(robot_email); |
38 test_response.append(credentials); | 38 test_response.append(credentials); |
39 SetResult(Value::CreateStringValue(test_response)); | 39 SetResult(Value::CreateStringValue(test_response)); |
40 } else { | 40 } else { |
41 CloudPrintProxyServiceFactory::GetForProfile(profile_)-> | 41 CloudPrintProxyServiceFactory::GetForProfile(profile_)-> |
42 EnableForUserWithRobot(credentials, robot_email, user_email); | 42 EnableForUserWithRobot(credentials, robot_email, user_email); |
43 } | 43 } |
44 SendResponse(true); | 44 SendResponse(true); |
45 return true; | 45 return true; |
46 } | 46 } |
47 | 47 |
48 // static | 48 // static |
49 void SetCloudPrintCredentialsFunction::SetTestMode(bool test_mode_enabled) { | 49 void CloudPrintSetCredentialsFunction::SetTestMode(bool test_mode_enabled) { |
50 test_mode = test_mode_enabled; | 50 test_mode = test_mode_enabled; |
51 } | 51 } |
52 | 52 |
53 } // namespace extensions | 53 } // namespace extensions |
OLD | NEW |