blob: 8fbbedd5ec01c76cf0a0971697194cef182e95df (
plain)
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
|
// Copyright (c) 2012 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/browser/ui/browser.h"
#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
#include "chrome/browser/ui/constrained_window_tab_helper.h"
#include "chrome/browser/ui/search_engines/search_engine_tab_helper.h"
#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/zoom/zoom_controller.h"
#include "content/public/browser/web_contents.h"
using content::WebContents;
namespace {
const char kWebDialogDelegateUserDataKey[] = "BrowserAdoptedAsTabContents";
} // namespace
// static
void Browser::AdoptAsTabContents(WebContents* web_contents) {
// If already adopted, nothing to be done.
base::SupportsUserData::Data* adoption_tag =
web_contents->GetUserData(&kWebDialogDelegateUserDataKey);
if (adoption_tag)
return;
// Mark as adopted.
web_contents->SetUserData(&kWebDialogDelegateUserDataKey,
new base::SupportsUserData::Data());
// Create all the tab helpers.
TabContents::Factory::CreateTabContents(web_contents);
// ... more tab helper creation goes here ...
}
void Browser::SetAsDelegate(WebContents* web_contents, Browser* delegate) {
// WebContents...
web_contents->SetDelegate(delegate);
// ...and all the helpers.
TabContents* tab = TabContents::FromWebContents(web_contents);
BlockedContentTabHelper::FromWebContents(web_contents)->
set_delegate(delegate);
BookmarkTabHelper::FromWebContents(web_contents)->set_delegate(delegate);
tab->constrained_window_tab_helper()->set_delegate(delegate);
CoreTabHelper::FromWebContents(web_contents)->set_delegate(delegate);
SearchEngineTabHelper::FromWebContents(web_contents)->set_delegate(delegate);
ZoomController::FromWebContents(web_contents)->set_observer(delegate);
}
|