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/app_window.h" | 7 #include "apps/app_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" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/extensions/component_loader.h" | 13 #include "chrome/browser/extensions/component_loader.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "chrome/browser/guest_view/guest_view_base.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/common/extensions/api/identity_private.h" | 17 #include "chrome/common/extensions/api/identity_private.h" |
17 #include "chrome/common/extensions/extension_constants.h" | 18 #include "chrome/common/extensions/extension_constants.h" |
18 #include "content/public/browser/navigation_details.h" | 19 #include "content/public/browser/navigation_details.h" |
19 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
20 #include "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
21 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
22 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
23 #include "content/public/browser/notification_types.h" | 24 #include "content/public/browser/notification_types.h" |
24 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 150 |
150 if (!delegate_) | 151 if (!delegate_) |
151 return; | 152 return; |
152 | 153 |
153 if (!embedded_window_created_) { | 154 if (!embedded_window_created_) { |
154 DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED); | 155 DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED); |
155 | 156 |
156 RenderViewHost* render_view( | 157 RenderViewHost* render_view( |
157 content::Details<RenderViewHost>(details).ptr()); | 158 content::Details<RenderViewHost>(details).ptr()); |
158 WebContents* web_contents = WebContents::FromRenderViewHost(render_view); | 159 WebContents* web_contents = WebContents::FromRenderViewHost(render_view); |
159 | 160 GuestViewBase* guest = GuestViewBase::FromWebContents(web_contents); |
| 161 WebContents* embedder = guest ? guest->embedder_web_contents() : NULL; |
160 if (web_contents && | 162 if (web_contents && |
161 (web_contents->GetEmbedderWebContents() == | 163 (embedder == WebContentsObserver::web_contents())) { |
162 WebContentsObserver::web_contents())) { | |
163 // Switch from watching the app window to the guest inside it. | 164 // Switch from watching the app window to the guest inside it. |
164 embedded_window_created_ = true; | 165 embedded_window_created_ = true; |
165 WebContentsObserver::Observe(web_contents); | 166 WebContentsObserver::Observe(web_contents); |
166 | 167 |
167 registrar_.RemoveAll(); | 168 registrar_.RemoveAll(); |
168 registrar_.Add(this, | 169 registrar_.Add(this, |
169 content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, | 170 content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, |
170 content::Source<WebContents>(web_contents)); | 171 content::Source<WebContents>(web_contents)); |
171 registrar_.Add(this, | 172 registrar_.Add(this, |
172 content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, | 173 content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } | 236 } |
236 | 237 |
237 void WebAuthFlow::DidNavigateMainFrame( | 238 void WebAuthFlow::DidNavigateMainFrame( |
238 const content::LoadCommittedDetails& details, | 239 const content::LoadCommittedDetails& details, |
239 const content::FrameNavigateParams& params) { | 240 const content::FrameNavigateParams& params) { |
240 if (delegate_ && details.http_status_code >= 400) | 241 if (delegate_ && details.http_status_code >= 400) |
241 delegate_->OnAuthFlowFailure(LOAD_FAILED); | 242 delegate_->OnAuthFlowFailure(LOAD_FAILED); |
242 } | 243 } |
243 | 244 |
244 } // namespace extensions | 245 } // namespace extensions |
OLD | NEW |