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