diff options
author | stoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-05 23:38:55 +0000 |
---|---|---|
committer | stoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-05 23:38:55 +0000 |
commit | 23f5ee3f8b0c9f854c080db48b1f97603576d865 (patch) | |
tree | 0b244a27b3a84e61fcea00316b5ff578b38d4ed4 /chrome_frame/external_tab.cc | |
parent | 06552c1abc14f20e5dcc374a44c17e2cd29d9746 (diff) | |
download | chromium_src-23f5ee3f8b0c9f854c080db48b1f97603576d865.zip chromium_src-23f5ee3f8b0c9f854c080db48b1f97603576d865.tar.gz chromium_src-23f5ee3f8b0c9f854c080db48b1f97603576d865.tar.bz2 |
Initial skeleton for refactored ChromeFrameAutomationClient and AutomationProxy for the needs of ChromeFrame.
CFProxy is ready to some extent, while CFAC is mostly structure-only.
Review URL: http://codereview.chromium.org/3528004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61583 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/external_tab.cc')
-rw-r--r-- | chrome_frame/external_tab.cc | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/chrome_frame/external_tab.cc b/chrome_frame/external_tab.cc new file mode 100644 index 0000000..ecf7927 --- /dev/null +++ b/chrome_frame/external_tab.cc @@ -0,0 +1,131 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome_frame/external_tab.h" +#include "base/tracked.h" +#include "base/task.h" +#include "base/waitable_event.h" +#include "chrome/test/automation/automation_messages.h" +#include "chrome_frame/utils.h" + +DISABLE_RUNNABLE_METHOD_REFCOUNT(ExternalTabProxy); +DISABLE_RUNNABLE_METHOD_REFCOUNT(UIDelegate); + +ExternalTabProxy::ExternalTabProxy() : state_(NONE), tab_(0), proxy_(NULL), + ui_delegate_(NULL) { +} + +ExternalTabProxy::~ExternalTabProxy() { + Destroy(); +} + +void ExternalTabProxy::Destroy() { + DCHECK(NULL == done_.get()); + done_.reset(new base::WaitableEvent(true, false)); + proxy_factory_->ReleaseProxy(this, tab_params_.profile); + done_->Wait(); + done_.reset(NULL); + + proxy_ = NULL; + tab_ = 0; +} + +void ExternalTabProxy::CreateTab(const CreateTabParams& create_params, + UIDelegate* delegate) { + DCHECK(ui_delegate_ != NULL); + DCHECK_EQ(NONE, state_); + ui_delegate_ = delegate; + tab_params_ = create_params; + state_ = INIT_IN_PROGRESS; + // TODO(stoyan): initialize ProxyParams from CreateTabParams. + ProxyParams p; + proxy_factory_->GetProxy(this, p); +} + +void ExternalTabProxy::Connected(ChromeProxy* proxy) { + // in ipc thread + ui_.PostTask(FROM_HERE, NewRunnableMethod(this, + &ExternalTabProxy::UiConnected, proxy)); +} +void ExternalTabProxy::Disconnected() { + // in ipc thread + DCHECK(done_.get() != NULL); + done_->Signal(); +} + +void ExternalTabProxy::PeerLost(ChromeProxy* proxy, DisconnectReason reason) { + ui_.PostTask(FROM_HERE, NewRunnableMethod(this, &ExternalTabProxy::UiPeerLost, + proxy, reason)); +} + +void ExternalTabProxy::Navigate(const std::string& url, + const std::string& referrer, bool is_privileged) { + // in ui thread + // Catch invalid URLs early. Can we allow this navigation to happen? + GURL parsed_url(url); + if (!CanNavigate(parsed_url, security_manager_, is_privileged)) { + DLOG(ERROR) << __FUNCTION__ << " Not allowing navigation to: " << url; + return; + } + + if (state_ == INIT_IN_PROGRESS) { + // TODO(stoyan): replace CreateTabParams with the new ones + } + + if (state_ == CREATE_TAB_IN_PROGRESS) { + // ah! too late. wait to get tab handle and then navigate + pending_navigation_.Set(parsed_url, GURL(referrer)); + } + + if (state_ == READY) { + proxy_->Tab_Navigate(tab_, parsed_url, GURL(referrer)); + } +} + +void ExternalTabProxy::Completed_CreateTab(bool success, HWND chrome_wnd, + HWND tab_window, int tab_handle) { + // in ipc_thread. +} + +void ExternalTabProxy::Completed_ConnectToTab(bool success, + HWND chrome_window, HWND tab_window, int tab_handle) { + CHECK(0); +} + +void ExternalTabProxy::Completed_Navigate(bool success, + enum AutomationMsg_NavigationResponseValues res) { + // ipc_thread; + CHECK(0); +} + +void ExternalTabProxy::Completed_InstallExtension(bool success, + enum AutomationMsg_ExtensionResponseValues res, SyncMessageContext* ctx) { + CHECK(0); +} + +void ExternalTabProxy::Completed_LoadExpandedExtension(bool success, + enum AutomationMsg_ExtensionResponseValues res, SyncMessageContext* ctx) { + CHECK(0); +} + +void ExternalTabProxy::Completed_GetEnabledExtensions(bool success, + const std::vector<FilePath>* extensions) { + CHECK(0); +} + +void ExternalTabProxy::NavigationStateChanged(int flags, + const IPC::NavigationInfo& nav_info) { + ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, + &UIDelegate::OnNavigationStateChanged, flags, nav_info)); +} + +void ExternalTabProxy::UpdateTargetUrl(const std::wstring& url) { + ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, + &UIDelegate::OnUpdateTargetUrl, url)); +} + +void ExternalTabProxy::TabLoaded(const GURL& url) { + ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, + &UIDelegate::OnLoad, url)); +} |