| 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/identity/web_auth_flow.h" | 5 #include "chrome/browser/extensions/api/identity/web_auth_flow.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 app_window_->web_contents()->Close(); | 69 app_window_->web_contents()->Close(); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 void WebAuthFlow::Start() { | 73 void WebAuthFlow::Start() { |
| 74 AppWindowRegistry::Get(profile_)->AddObserver(this); | 74 AppWindowRegistry::Get(profile_)->AddObserver(this); |
| 75 | 75 |
| 76 // Attach a random ID string to the window so we can recoginize it | 76 // Attach a random ID string to the window so we can recoginize it |
| 77 // in OnAppWindowAdded. | 77 // in OnAppWindowAdded. |
| 78 std::string random_bytes; | 78 std::string random_bytes; |
| 79 crypto::RandBytes(WriteInto(&random_bytes, 33), 32); | 79 crypto::RandBytes(base::WriteInto(&random_bytes, 33), 32); |
| 80 base::Base64Encode(random_bytes, &app_window_key_); | 80 base::Base64Encode(random_bytes, &app_window_key_); |
| 81 | 81 |
| 82 // identityPrivate.onWebFlowRequest(app_window_key, provider_url_, mode_) | 82 // identityPrivate.onWebFlowRequest(app_window_key, provider_url_, mode_) |
| 83 scoped_ptr<base::ListValue> args(new base::ListValue()); | 83 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 84 args->AppendString(app_window_key_); | 84 args->AppendString(app_window_key_); |
| 85 args->AppendString(provider_url_.spec()); | 85 args->AppendString(provider_url_.spec()); |
| 86 if (mode_ == WebAuthFlow::INTERACTIVE) | 86 if (mode_ == WebAuthFlow::INTERACTIVE) |
| 87 args->AppendString("interactive"); | 87 args->AppendString("interactive"); |
| 88 else | 88 else |
| 89 args->AppendString("silent"); | 89 args->AppendString("silent"); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 } | 239 } |
| 240 | 240 |
| 241 void WebAuthFlow::DidNavigateMainFrame( | 241 void WebAuthFlow::DidNavigateMainFrame( |
| 242 const content::LoadCommittedDetails& details, | 242 const content::LoadCommittedDetails& details, |
| 243 const content::FrameNavigateParams& params) { | 243 const content::FrameNavigateParams& params) { |
| 244 if (delegate_ && details.http_status_code >= 400) | 244 if (delegate_ && details.http_status_code >= 400) |
| 245 delegate_->OnAuthFlowFailure(LOAD_FAILED); | 245 delegate_->OnAuthFlowFailure(LOAD_FAILED); |
| 246 } | 246 } |
| 247 | 247 |
| 248 } // namespace extensions | 248 } // namespace extensions |
| OLD | NEW |