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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
|
// Copyright (c) 2011 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 "content/browser/tab_contents/tab_contents_delegate.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
#include "content/browser/javascript_dialogs.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/common/url_constants.h"
#include "ui/gfx/rect.h"
#include "webkit/glue/web_intent_data.h"
TabContentsDelegate::TabContentsDelegate() {
}
TabContents* TabContentsDelegate::OpenURLFromTab(
TabContents* source,
const GURL& url,
const GURL& referrer,
WindowOpenDisposition disposition,
PageTransition::Type transition) {
return OpenURLFromTab(source,
OpenURLParams(url, referrer, disposition, transition));
}
TabContents* TabContentsDelegate::OpenURLFromTab(TabContents* source,
const OpenURLParams& params) {
return NULL;
}
void TabContentsDelegate::NavigationStateChanged(const TabContents* source,
unsigned changed_flags) {
}
void TabContentsDelegate::AddNavigationHeaders(const GURL& url,
std::string* headers) {
}
void TabContentsDelegate::AddNewContents(TabContents* source,
TabContents* new_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_pos,
bool user_gesture) {
}
void TabContentsDelegate::ActivateContents(TabContents* contents) {
}
void TabContentsDelegate::DeactivateContents(TabContents* contents) {
}
void TabContentsDelegate::LoadingStateChanged(TabContents* source) {
}
void TabContentsDelegate::LoadProgressChanged(double progress) {
}
void TabContentsDelegate::CloseContents(TabContents* source) {
}
void TabContentsDelegate::MoveContents(TabContents* source,
const gfx::Rect& pos) {
}
void TabContentsDelegate::DetachContents(TabContents* source) {
}
bool TabContentsDelegate::IsPopupOrPanel(const TabContents* source) const {
return false;
}
void TabContentsDelegate::UpdateTargetURL(TabContents* source,
int32 page_id,
const GURL& url) {
}
void TabContentsDelegate::ContentsMouseEvent(
TabContents* source, const gfx::Point& location, bool motion) {
}
void TabContentsDelegate::ContentsZoomChange(bool zoom_in) { }
bool TabContentsDelegate::IsApplication() const { return false; }
void TabContentsDelegate::ConvertContentsToApplication(TabContents* source) { }
bool TabContentsDelegate::CanReloadContents(TabContents* source) const {
return true;
}
void TabContentsDelegate::WillRunBeforeUnloadConfirm() {
}
bool TabContentsDelegate::ShouldSuppressDialogs() {
return false;
}
void TabContentsDelegate::BeforeUnloadFired(TabContents* tab,
bool proceed,
bool* proceed_to_fire_unload) {
*proceed_to_fire_unload = true;
}
void TabContentsDelegate::SetFocusToLocationBar(bool select_all) {}
bool TabContentsDelegate::ShouldFocusPageAfterCrash() {
return true;
}
void TabContentsDelegate::RenderWidgetShowing() {}
bool TabContentsDelegate::TakeFocus(bool reverse) {
return false;
}
void TabContentsDelegate::LostCapture() {
}
void TabContentsDelegate::TabContentsFocused(TabContents* tab_content) {
}
int TabContentsDelegate::GetExtraRenderViewHeight() const {
return 0;
}
bool TabContentsDelegate::CanDownload(TabContents* source, int request_id) {
return true;
}
void TabContentsDelegate::OnStartDownload(TabContents* source,
DownloadItem* download) {
}
bool TabContentsDelegate::HandleContextMenu(const ContextMenuParams& params) {
return false;
}
bool TabContentsDelegate::ExecuteContextMenuCommand(int command) {
return false;
}
void TabContentsDelegate::ShowPageInfo(content::BrowserContext* browser_context,
const GURL& url,
const NavigationEntry::SSLStatus& ssl,
bool show_history) {
}
void TabContentsDelegate::ViewSourceForTab(TabContents* source,
const GURL& page_url) {
// Fall back implementation based entirely on the view-source scheme.
// It suffers from http://crbug.com/523 and that is why browser overrides
// it with proper implementation.
GURL url = GURL(chrome::kViewSourceScheme + std::string(":") +
page_url.spec());
OpenURLFromTab(source,
url,
GURL(),
NEW_FOREGROUND_TAB,
PageTransition::LINK);
}
void TabContentsDelegate::ViewSourceForFrame(TabContents* source,
const GURL& frame_url,
const std::string& content_state) {
// Same as ViewSourceForTab, but for given subframe.
GURL url = GURL(chrome::kViewSourceScheme + std::string(":") +
frame_url.spec());
OpenURLFromTab(source,
url,
GURL(),
NEW_FOREGROUND_TAB,
PageTransition::LINK);
}
bool TabContentsDelegate::PreHandleKeyboardEvent(
const NativeWebKeyboardEvent& event,
bool* is_keyboard_shortcut) {
return false;
}
void TabContentsDelegate::HandleKeyboardEvent(
const NativeWebKeyboardEvent& event) {
}
void TabContentsDelegate::HandleMouseUp() {
}
void TabContentsDelegate::HandleMouseActivate() {
}
void TabContentsDelegate::DragEnded() {
}
void TabContentsDelegate::ShowRepostFormWarningDialog(
TabContents* tab_contents) {
}
bool TabContentsDelegate::OnGoToEntryOffset(int offset) {
return true;
}
bool TabContentsDelegate::ShouldAddNavigationToHistory(
const history::HistoryAddPageArgs& add_page_args,
NavigationType::Type navigation_type) {
return true;
}
gfx::NativeWindow TabContentsDelegate::GetFrameNativeWindow() {
return NULL;
}
void TabContentsDelegate::TabContentsCreated(TabContents* new_contents) {
}
void TabContentsDelegate::ContentRestrictionsChanged(TabContents* source) {
}
void TabContentsDelegate::RendererUnresponsive(TabContents* source) {
}
void TabContentsDelegate::RendererResponsive(TabContents* source) {
}
void TabContentsDelegate::WorkerCrashed(TabContents* source) {
}
void TabContentsDelegate::DidNavigateMainFramePostCommit(
TabContents* tab) {
}
void TabContentsDelegate::DidNavigateToPendingEntry(TabContents* tab) {
}
// A stubbed-out version of JavaScriptDialogCreator that doesn't do anything.
class JavaScriptDialogCreatorStub : public content::JavaScriptDialogCreator {
public:
static JavaScriptDialogCreatorStub* GetInstance() {
return Singleton<JavaScriptDialogCreatorStub>::get();
}
virtual void RunJavaScriptDialog(content::JavaScriptDialogDelegate* delegate,
TitleType title_type,
const string16& title,
int dialog_flags,
const string16& message_text,
const string16& default_prompt_text,
IPC::Message* reply_message,
bool* did_suppress_message) OVERRIDE {
*did_suppress_message = true;
}
virtual void RunBeforeUnloadDialog(
content::JavaScriptDialogDelegate* delegate,
const string16& message_text,
IPC::Message* reply_message) OVERRIDE {
delegate->OnDialogClosed(reply_message, true, string16());
}
virtual void ResetJavaScriptState(
content::JavaScriptDialogDelegate* delegate) OVERRIDE {
}
private:
friend struct DefaultSingletonTraits<JavaScriptDialogCreatorStub>;
};
content::JavaScriptDialogCreator*
TabContentsDelegate::GetJavaScriptDialogCreator() {
return JavaScriptDialogCreatorStub::GetInstance();
}
void TabContentsDelegate::RunFileChooser(
TabContents* tab, const ViewHostMsg_RunFileChooser_Params& params) {
}
void TabContentsDelegate::EnumerateDirectory(TabContents* tab, int request_id,
const FilePath& path) {
}
void TabContentsDelegate::ToggleFullscreenModeForTab(TabContents* tab,
bool enter_fullscreen) {
}
bool TabContentsDelegate::IsFullscreenForTab(const TabContents* tab) const {
return false;
}
void TabContentsDelegate::JSOutOfMemory(TabContents* tab) {
}
void TabContentsDelegate::RegisterProtocolHandler(TabContents* tab,
const std::string& protocol,
const GURL& url,
const string16& title) {
}
void TabContentsDelegate::RegisterIntentHandler(TabContents* tab,
const string16& action,
const string16& type,
const string16& href,
const string16& title) {
}
void TabContentsDelegate::WebIntentDispatch(
TabContents* tab,
int routing_id,
const webkit_glue::WebIntentData& intent,
int intent_id) {
}
void TabContentsDelegate::FindReply(TabContents* tab,
int request_id,
int number_of_matches,
const gfx::Rect& selection_rect,
int active_match_ordinal,
bool final_update) {
}
void TabContentsDelegate::CrashedPlugin(TabContents* tab,
const FilePath& plugin_path) {
}
void TabContentsDelegate::UpdatePreferredSize(TabContents* source,
const gfx::Size& pref_size) {
}
TabContentsDelegate::~TabContentsDelegate() {
while (!attached_contents_.empty()) {
TabContents* tab_contents = *attached_contents_.begin();
tab_contents->set_delegate(NULL);
}
DCHECK(attached_contents_.empty());
}
void TabContentsDelegate::Attach(TabContents* tab_contents) {
DCHECK(attached_contents_.find(tab_contents) == attached_contents_.end());
attached_contents_.insert(tab_contents);
}
void TabContentsDelegate::Detach(TabContents* tab_contents) {
DCHECK(attached_contents_.find(tab_contents) != attached_contents_.end());
attached_contents_.erase(tab_contents);
}
|