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 bool success = base::Base64Encode(random_bytes, &shell_window_key_); | 79 base::Base64Encode(random_bytes, &shell_window_key_); |
80 DCHECK(success); | |
81 | 80 |
82 // identityPrivate.onWebFlowRequest(shell_window_key, provider_url_, mode_) | 81 // identityPrivate.onWebFlowRequest(shell_window_key, provider_url_, mode_) |
83 scoped_ptr<base::ListValue> args(new base::ListValue()); | 82 scoped_ptr<base::ListValue> args(new base::ListValue()); |
84 args->AppendString(shell_window_key_); | 83 args->AppendString(shell_window_key_); |
85 args->AppendString(provider_url_.spec()); | 84 args->AppendString(provider_url_.spec()); |
86 if (mode_ == WebAuthFlow::INTERACTIVE) | 85 if (mode_ == WebAuthFlow::INTERACTIVE) |
87 args->AppendString("interactive"); | 86 args->AppendString("interactive"); |
88 else | 87 else |
89 args->AppendString("silent"); | 88 args->AppendString("silent"); |
90 | 89 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } | 237 } |
239 | 238 |
240 void WebAuthFlow::DidNavigateMainFrame( | 239 void WebAuthFlow::DidNavigateMainFrame( |
241 const content::LoadCommittedDetails& details, | 240 const content::LoadCommittedDetails& details, |
242 const content::FrameNavigateParams& params) { | 241 const content::FrameNavigateParams& params) { |
243 if (delegate_ && details.http_status_code >= 400) | 242 if (delegate_ && details.http_status_code >= 400) |
244 delegate_->OnAuthFlowFailure(LOAD_FAILED); | 243 delegate_->OnAuthFlowFailure(LOAD_FAILED); |
245 } | 244 } |
246 | 245 |
247 } // namespace extensions | 246 } // namespace extensions |
OLD | NEW |