summaryrefslogtreecommitdiffstats
path: root/chrome_frame/external_tab.cc
diff options
context:
space:
mode:
authorstoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-13 16:02:26 +0000
committerstoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-13 16:02:26 +0000
commit11b6e60b413fe6b596cbf08f78e689a360faeb61 (patch)
tree04d332597120edd9a87f42efab62f3b1d7f4f8f4 /chrome_frame/external_tab.cc
parent18004a3331147f8f84ad8a21caa2ce695d75c28a (diff)
downloadchromium_src-11b6e60b413fe6b596cbf08f78e689a360faeb61.zip
chromium_src-11b6e60b413fe6b596cbf08f78e689a360faeb61.tar.gz
chromium_src-11b6e60b413fe6b596cbf08f78e689a360faeb61.tar.bz2
Review URL: http://codereview.chromium.org/3685006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62407 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/external_tab.cc')
-rw-r--r--chrome_frame/external_tab.cc175
1 files changed, 167 insertions, 8 deletions
diff --git a/chrome_frame/external_tab.cc b/chrome_frame/external_tab.cc
index ecf7927..322f74a 100644
--- a/chrome_frame/external_tab.cc
+++ b/chrome_frame/external_tab.cc
@@ -12,6 +12,14 @@
DISABLE_RUNNABLE_METHOD_REFCOUNT(ExternalTabProxy);
DISABLE_RUNNABLE_METHOD_REFCOUNT(UIDelegate);
+namespace {
+ struct UserDataHolder : public SyncMessageContext {
+ explicit UserDataHolder(void* p) : data(p) {}
+ void* data;
+ };
+}
+
+
ExternalTabProxy::ExternalTabProxy() : state_(NONE), tab_(0), proxy_(NULL),
ui_delegate_(NULL) {
}
@@ -20,10 +28,22 @@ ExternalTabProxy::~ExternalTabProxy() {
Destroy();
}
+void ExternalTabProxy::Init() {
+ if (m_hWnd == NULL) {
+ // Create a window on the UI thread for marshaling messages back and forth
+ // from the IPC thread. This window cannot be a message only window as the
+ // external chrome tab window initially is created as a child of this window
+ CWindowImpl<ExternalTabProxy>::Create(GetDesktopWindow(), NULL, NULL,
+ WS_CHILDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_TOOLWINDOW);
+ DCHECK(m_hWnd != NULL);
+ ui_.SetWindow(m_hWnd, WM_APP + 6);
+ }
+}
+
void ExternalTabProxy::Destroy() {
DCHECK(NULL == done_.get());
done_.reset(new base::WaitableEvent(true, false));
- proxy_factory_->ReleaseProxy(this, tab_params_.profile);
+ proxy_factory_->ReleaseProxy(this, tab_params_.proxy_params.profile);
done_->Wait();
done_.reset(NULL);
@@ -35,12 +55,12 @@ void ExternalTabProxy::CreateTab(const CreateTabParams& create_params,
UIDelegate* delegate) {
DCHECK(ui_delegate_ != NULL);
DCHECK_EQ(NONE, state_);
+ // Create host window if needed.
+ Init();
ui_delegate_ = delegate;
tab_params_ = create_params;
state_ = INIT_IN_PROGRESS;
- // TODO(stoyan): initialize ProxyParams from CreateTabParams.
- ProxyParams p;
- proxy_factory_->GetProxy(this, p);
+ proxy_factory_->GetProxy(this, create_params.proxy_params);
}
void ExternalTabProxy::Connected(ChromeProxy* proxy) {
@@ -48,6 +68,14 @@ void ExternalTabProxy::Connected(ChromeProxy* proxy) {
ui_.PostTask(FROM_HERE, NewRunnableMethod(this,
&ExternalTabProxy::UiConnected, proxy));
}
+
+void ExternalTabProxy::UiConnected(ChromeProxy* proxy) {
+ proxy_ = proxy;
+ IPC::ExternalTabSettings settings;
+ // TODO(stoyan): Initialize settings.
+ proxy->CreateTab(this, settings);
+}
+
void ExternalTabProxy::Disconnected() {
// in ipc thread
DCHECK(done_.get() != NULL);
@@ -59,6 +87,10 @@ void ExternalTabProxy::PeerLost(ChromeProxy* proxy, DisconnectReason reason) {
proxy, reason));
}
+void ExternalTabProxy::UiPeerLost(ChromeProxy* proxy, DisconnectReason reason) {
+ // TODO(stoyan):
+}
+
void ExternalTabProxy::Navigate(const std::string& url,
const std::string& referrer, bool is_privileged) {
// in ui thread
@@ -69,23 +101,74 @@ void ExternalTabProxy::Navigate(const std::string& url,
return;
}
+ GURL parsed_referrer(referrer);
+ // If we are still establishing channel, simply replace the params
if (state_ == INIT_IN_PROGRESS) {
- // TODO(stoyan): replace CreateTabParams with the new ones
+ tab_params_.url = parsed_url;
+ tab_params_.referrer = parsed_referrer;
}
+ // Ah! Too late. Wait to get tab handle and then navigate.
if (state_ == CREATE_TAB_IN_PROGRESS) {
- // ah! too late. wait to get tab handle and then navigate
- pending_navigation_.Set(parsed_url, GURL(referrer));
+ pending_navigation_.Set(parsed_url, parsed_referrer);
}
if (state_ == READY) {
- proxy_->Tab_Navigate(tab_, parsed_url, GURL(referrer));
+ proxy_->Tab_Navigate(tab_, parsed_url, parsed_referrer);
}
}
+void ExternalTabProxy::ConnectToExternalTab(uint64 external_tab_cookie) {
+ proxy_->ConnectTab(this, m_hWnd, external_tab_cookie);
+}
+
+
+void ExternalTabProxy::BlockExternalTab(uint64 cookie) {
+ proxy_->BlockTab(cookie);
+}
+
+void ExternalTabProxy::SetZoomLevel(PageZoom::Function zoom_level) {
+ proxy_->Tab_Zoom(tab_, zoom_level);
+}
+
+void ExternalTabProxy::NavigateToIndex(int index) {
+ CHECK(0);
+}
+
+void ExternalTabProxy::ForwardMessageFromExternalHost(
+ const std::string& message, const std::string& origin,
+ const std::string& target) {
+ proxy_->Tab_PostMessage(tab_, message, origin, target);
+}
+
+void ExternalTabProxy::SetEnableExtensionAutomation(
+ const std::vector<std::string>& functions_enabled) {
+ proxy_->Tab_SetEnableExtensionAutomation(tab_, functions_enabled);
+}
+
+void ExternalTabProxy::InstallExtension(const FilePath& crx_path,
+ void* user_data) {
+ proxy_->InstallExtension(this, crx_path, new UserDataHolder(user_data));
+}
+
+void ExternalTabProxy::LoadExpandedExtension(const FilePath& path,
+ void* user_data) {
+ proxy_->LoadExtension(this, path, new UserDataHolder(user_data));
+}
+
+void ExternalTabProxy::GetEnabledExtensions(void* user_data) {
+ proxy_->GetEnabledExtensions(this, new UserDataHolder(user_data));
+}
+
+void ExternalTabProxy::ChromeFrameHostMoved() {
+ proxy_->Tab_OnHostMoved(tab_);
+}
+
+//////////////////////////////////////////////////////////////////////////
void ExternalTabProxy::Completed_CreateTab(bool success, HWND chrome_wnd,
HWND tab_window, int tab_handle) {
// in ipc_thread.
+ // ui_.PostTask()
}
void ExternalTabProxy::Completed_ConnectToTab(bool success,
@@ -129,3 +212,79 @@ void ExternalTabProxy::TabLoaded(const GURL& url) {
ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_,
&UIDelegate::OnLoad, url));
}
+
+void ExternalTabProxy::MessageToHost(const std::string& message,
+ const std::string& origin,
+ const std::string& target) {
+ ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_,
+ &UIDelegate::OnMessageFromChromeFrame, message, origin, target));
+}
+
+void ExternalTabProxy::HandleAccelerator(const MSG& accel_message) {
+ ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_,
+ &UIDelegate::OnHandleAccelerator, accel_message));
+}
+
+void ExternalTabProxy::HandleContextMenu(HANDLE menu_handle, int align_flags,
+ const IPC::ContextMenuParams& params) {
+ ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_,
+ &UIDelegate::OnHandleContextMenu, menu_handle, align_flags, params));
+}
+
+void ExternalTabProxy::TabbedOut(bool reverse) {
+ ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_,
+ &UIDelegate::OnTabbedOut, reverse));
+}
+
+void ExternalTabProxy::GoToHistoryOffset(int offset) {
+ ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_,
+ &UIDelegate::OnGoToHistoryOffset, offset));
+}
+
+void ExternalTabProxy::OpenURL(const GURL& url_to_open, const GURL& referrer,
+ int open_disposition) {
+ ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_,
+ &UIDelegate::OnOpenURL, url_to_open, referrer, open_disposition));
+}
+
+void ExternalTabProxy::NavigationFailed(int error_code, const GURL& gurl) {
+ // TODO(stoyan):
+}
+
+void ExternalTabProxy::DidNavigate(const IPC::NavigationInfo& navigation_info) {
+ // TODO(stoyan):
+}
+
+void ExternalTabProxy::Network_Start(
+ int request_id, const IPC::AutomationURLRequest& request_info) {
+ // TODO(stoyan): url_fetcher_.Start();
+}
+
+void ExternalTabProxy::Network_Read(int request_id, int bytes_to_read) {
+ // TODO(stoyan): url_fetcher_.Read();
+}
+
+void ExternalTabProxy::Network_End(int request_id, const URLRequestStatus& s) {
+ // TODO(stoyan):
+}
+
+void ExternalTabProxy::Network_DownloadInHost(int request_id) {
+ // TODO(stoyan):
+}
+
+void ExternalTabProxy::GetCookies(const GURL& url, int cookie_id) {
+ // TODO(stoyan):
+}
+
+void ExternalTabProxy::SetCookie(const GURL& url, const std::string& cookie) {
+ // TODO(stoyan):
+}
+
+void ExternalTabProxy::TabClosed() {
+ // TODO(stoyan):
+}
+
+void ExternalTabProxy::AttachTab(
+ const IPC::AttachExternalTabParams& attach_params) {
+ // TODO(stoyan):
+}