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