1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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));
}
|