Removed unused VideoCaptureCapability parameters.
[chromium-blink-merge.git] / content / public / browser / web_contents_delegate.cc
blob924cabb7e2d65aeb9db6a580d34116b3fefcc631
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/public/browser/web_contents_delegate.h"
7 #include "base/compiler_specific.h"
8 #include "base/logging.h"
9 #include "base/memory/singleton.h"
10 #include "content/public/browser/render_view_host.h"
11 #include "content/public/browser/web_contents.h"
12 #include "content/public/common/url_constants.h"
13 #include "content/public/common/bindings_policy.h"
14 #include "ui/gfx/rect.h"
16 namespace content {
18 WebContentsDelegate::WebContentsDelegate() {
21 WebContents* WebContentsDelegate::OpenURLFromTab(WebContents* source,
22 const OpenURLParams& params) {
23 return NULL;
26 bool WebContentsDelegate::IsPopupOrPanel(const WebContents* source) const {
27 return false;
30 bool WebContentsDelegate::CanLoadDataURLsInWebUI() const { return false; }
32 bool WebContentsDelegate::CanOverscrollContent() const { return false; }
34 gfx::Rect WebContentsDelegate::GetRootWindowResizerRect() const {
35 return gfx::Rect();
38 bool WebContentsDelegate::ShouldSuppressDialogs() {
39 return false;
42 bool WebContentsDelegate::AddMessageToConsole(WebContents* source,
43 int32 level,
44 const string16& message,
45 int32 line_no,
46 const string16& source_id) {
47 return false;
50 void WebContentsDelegate::BeforeUnloadFired(WebContents* web_contents,
51 bool proceed,
52 bool* proceed_to_fire_unload) {
53 *proceed_to_fire_unload = true;
56 bool WebContentsDelegate::ShouldFocusLocationBarByDefault(WebContents* source) {
57 return false;
60 bool WebContentsDelegate::ShouldFocusPageAfterCrash() {
61 return true;
64 bool WebContentsDelegate::TakeFocus(WebContents* source, bool reverse) {
65 return false;
68 int WebContentsDelegate::GetExtraRenderViewHeight() const {
69 return 0;
72 void WebContentsDelegate::CanDownload(
73 RenderViewHost* render_view_host,
74 int request_id,
75 const std::string& request_method,
76 const base::Callback<void(bool)>& callback) {
77 callback.Run(true);
80 bool WebContentsDelegate::HandleContextMenu(
81 const content::ContextMenuParams& params) {
82 return false;
85 void WebContentsDelegate::ViewSourceForTab(WebContents* source,
86 const GURL& page_url) {
87 // Fall back implementation based entirely on the view-source scheme.
88 // It suffers from http://crbug.com/523 and that is why browser overrides
89 // it with proper implementation.
90 GURL url = GURL(kViewSourceScheme + std::string(":") + page_url.spec());
91 OpenURLFromTab(source, OpenURLParams(url, Referrer(),
92 NEW_FOREGROUND_TAB,
93 PAGE_TRANSITION_LINK, false));
96 void WebContentsDelegate::ViewSourceForFrame(WebContents* source,
97 const GURL& frame_url,
98 const PageState& page_state) {
99 // Same as ViewSourceForTab, but for given subframe.
100 GURL url = GURL(kViewSourceScheme + std::string(":") + frame_url.spec());
101 OpenURLFromTab(source, OpenURLParams(url, Referrer(),
102 NEW_FOREGROUND_TAB,
103 PAGE_TRANSITION_LINK, false));
106 bool WebContentsDelegate::PreHandleKeyboardEvent(
107 WebContents* source,
108 const NativeWebKeyboardEvent& event,
109 bool* is_keyboard_shortcut) {
110 return false;
113 bool WebContentsDelegate::CanDragEnter(
114 WebContents* source,
115 const DropData& data,
116 WebKit::WebDragOperationsMask operations_allowed) {
117 return true;
120 bool WebContentsDelegate::OnGoToEntryOffset(int offset) {
121 return true;
124 bool WebContentsDelegate::ShouldCreateWebContents(
125 WebContents* web_contents,
126 int route_id,
127 WindowContainerType window_container_type,
128 const string16& frame_name,
129 const GURL& target_url,
130 const std::string& partition_id,
131 SessionStorageNamespace* session_storage_namespace) {
132 return true;
135 JavaScriptDialogManager* WebContentsDelegate::GetJavaScriptDialogManager() {
136 return NULL;
139 bool WebContentsDelegate::EmbedsFullscreenWidget() const {
140 return false;
143 bool WebContentsDelegate::IsFullscreenForTabOrPending(
144 const WebContents* web_contents) const {
145 return false;
148 content::ColorChooser* WebContentsDelegate::OpenColorChooser(
149 WebContents* web_contents, SkColor color) {
150 return NULL;
153 void WebContentsDelegate::RequestMediaAccessPermission(
154 WebContents* web_contents,
155 const MediaStreamRequest& request,
156 const MediaResponseCallback& callback) {
157 callback.Run(MediaStreamDevices(), scoped_ptr<MediaStreamUI>());
160 bool WebContentsDelegate::RequestPpapiBrokerPermission(
161 WebContents* web_contents,
162 const GURL& url,
163 const base::FilePath& plugin_path,
164 const base::Callback<void(bool)>& callback) {
165 return false;
168 WebContentsDelegate::~WebContentsDelegate() {
169 while (!attached_contents_.empty()) {
170 WebContents* web_contents = *attached_contents_.begin();
171 web_contents->SetDelegate(NULL);
173 DCHECK(attached_contents_.empty());
176 void WebContentsDelegate::Attach(WebContents* web_contents) {
177 DCHECK(attached_contents_.find(web_contents) == attached_contents_.end());
178 attached_contents_.insert(web_contents);
181 void WebContentsDelegate::Detach(WebContents* web_contents) {
182 DCHECK(attached_contents_.find(web_contents) != attached_contents_.end());
183 attached_contents_.erase(web_contents);
186 gfx::Size WebContentsDelegate::GetSizeForNewRenderView(
187 const WebContents* web_contents) const {
188 return gfx::Size();
191 } // namespace content