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