#include "chrome/browser/extensions/api/identity/web_auth_flow.h"
-#include "apps/shell_window.h"
#include "base/base64.h"
+#include "base/debug/trace_event.h"
#include "base/location.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/extensions/component_loader.h"
#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/extension_system.h"
-#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/identity_private.h"
#include "chrome/common/extensions/extension_constants.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
-#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/resource_request_details.h"
#include "content/public/browser/web_contents.h"
#include "crypto/random.h"
+#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/event_router.h"
+#include "extensions/browser/extension_system.h"
+#include "extensions/browser/guest_view/guest_view_base.h"
#include "grit/browser_resources.h"
#include "url/gurl.h"
-using apps::ShellWindow;
using content::RenderViewHost;
using content::ResourceRedirectDetails;
using content::WebContents;
registrar_.RemoveAll();
WebContentsObserver::Observe(NULL);
- if (!shell_window_key_.empty()) {
- apps::ShellWindowRegistry::Get(profile_)->RemoveObserver(this);
+ if (!app_window_key_.empty()) {
+ AppWindowRegistry::Get(profile_)->RemoveObserver(this);
- if (shell_window_ && shell_window_->web_contents())
- shell_window_->web_contents()->Close();
+ if (app_window_ && app_window_->web_contents())
+ app_window_->web_contents()->Close();
}
}
void WebAuthFlow::Start() {
- apps::ShellWindowRegistry::Get(profile_)->AddObserver(this);
+ AppWindowRegistry::Get(profile_)->AddObserver(this);
// Attach a random ID string to the window so we can recoginize it
- // in OnShellWindowAdded.
+ // in OnAppWindowAdded.
std::string random_bytes;
crypto::RandBytes(WriteInto(&random_bytes, 33), 32);
- base::Base64Encode(random_bytes, &shell_window_key_);
+ base::Base64Encode(random_bytes, &app_window_key_);
- // identityPrivate.onWebFlowRequest(shell_window_key, provider_url_, mode_)
+ // identityPrivate.onWebFlowRequest(app_window_key, provider_url_, mode_)
scoped_ptr<base::ListValue> args(new base::ListValue());
- args->AppendString(shell_window_key_);
+ args->AppendString(app_window_key_);
args->AppendString(provider_url_.spec());
if (mode_ == WebAuthFlow::INTERACTIVE)
args->AppendString("interactive");
base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
}
-void WebAuthFlow::OnShellWindowAdded(ShellWindow* shell_window) {
- if (shell_window->window_key() == shell_window_key_ &&
- shell_window->extension()->id() == extension_misc::kIdentityApiUiAppId) {
- shell_window_ = shell_window;
- WebContentsObserver::Observe(shell_window->web_contents());
+void WebAuthFlow::OnAppWindowAdded(AppWindow* app_window) {
+ if (app_window->window_key() == app_window_key_ &&
+ app_window->extension_id() == extension_misc::kIdentityApiUiAppId) {
+ app_window_ = app_window;
+ WebContentsObserver::Observe(app_window->web_contents());
registrar_.Add(
this,
}
}
-void WebAuthFlow::OnShellWindowIconChanged(ShellWindow* shell_window) {}
-
-void WebAuthFlow::OnShellWindowRemoved(ShellWindow* shell_window) {
- if (shell_window->window_key() == shell_window_key_ &&
- shell_window->extension()->id() == extension_misc::kIdentityApiUiAppId) {
- shell_window_ = NULL;
+void WebAuthFlow::OnAppWindowRemoved(AppWindow* app_window) {
+ if (app_window->window_key() == app_window_key_ &&
+ app_window->extension_id() == extension_misc::kIdentityApiUiAppId) {
+ app_window_ = NULL;
registrar_.RemoveAll();
if (delegate_)
void WebAuthFlow::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- DCHECK(shell_window_);
+ DCHECK(app_window_);
if (!delegate_)
return;
RenderViewHost* render_view(
content::Details<RenderViewHost>(details).ptr());
WebContents* web_contents = WebContents::FromRenderViewHost(render_view);
-
+ GuestViewBase* guest = GuestViewBase::FromWebContents(web_contents);
+ WebContents* embedder = guest ? guest->embedder_web_contents() : NULL;
if (web_contents &&
- (web_contents->GetEmbedderWebContents() ==
- WebContentsObserver::web_contents())) {
- // Switch from watching the shell window to the guest inside it.
+ (embedder == WebContentsObserver::web_contents())) {
+ // Switch from watching the app window to the guest inside it.
embedded_window_created_ = true;
WebContentsObserver::Observe(web_contents);
}
void WebAuthFlow::DidStartProvisionalLoadForFrame(
- int64 frame_id,
- int64 parent_frame_id,
- bool is_main_frame,
+ content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
bool is_error_page,
- bool is_iframe_srcdoc,
- RenderViewHost* render_view_host) {
- if (is_main_frame)
+ bool is_iframe_srcdoc) {
+ if (!render_frame_host->GetParent())
BeforeUrlLoaded(validated_url);
}
void WebAuthFlow::DidFailProvisionalLoad(
- int64 frame_id,
- const base::string16& frame_unique_name,
- bool is_main_frame,
+ content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code,
- const base::string16& error_description,
- RenderViewHost* render_view_host) {
+ const base::string16& error_description) {
+ TRACE_EVENT_ASYNC_STEP_PAST1("identity",
+ "WebAuthFlow",
+ this,
+ "DidFailProvisionalLoad",
+ "error_code",
+ error_code);
if (delegate_)
delegate_->OnAuthFlowFailure(LOAD_FAILED);
}