Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / content / public / browser / web_contents_delegate.cc
blobd4028fbefd6c1df08f130d9bf9a8ceed8a601114
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/bindings_policy.h"
13 #include "content/public/common/url_constants.h"
14 #include "ui/gfx/geometry/rect.h"
16 namespace content {
18 WebContentsDelegate::WebContentsDelegate() {
21 WebContents* WebContentsDelegate::OpenURLFromTab(WebContents* source,
22 const OpenURLParams& params) {
23 return nullptr;
26 bool WebContentsDelegate::IsPopupOrPanel(const WebContents* source) const {
27 return false;
30 bool WebContentsDelegate::CanOverscrollContent() const { return false; }
32 gfx::Rect WebContentsDelegate::GetRootWindowResizerRect() const {
33 return gfx::Rect();
36 bool WebContentsDelegate::ShouldSuppressDialogs(WebContents* source) {
37 return false;
40 bool WebContentsDelegate::ShouldPreserveAbortedURLs(WebContents* source) {
41 return false;
44 bool WebContentsDelegate::AddMessageToConsole(WebContents* source,
45 int32 level,
46 const base::string16& message,
47 int32 line_no,
48 const base::string16& source_id) {
49 return false;
52 void WebContentsDelegate::BeforeUnloadFired(WebContents* web_contents,
53 bool proceed,
54 bool* proceed_to_fire_unload) {
55 *proceed_to_fire_unload = true;
58 bool WebContentsDelegate::ShouldFocusLocationBarByDefault(WebContents* source) {
59 return false;
62 bool WebContentsDelegate::ShouldFocusPageAfterCrash() {
63 return true;
66 bool WebContentsDelegate::TakeFocus(WebContents* source, bool reverse) {
67 return false;
70 void WebContentsDelegate::CanDownload(
71 RenderViewHost* render_view_host,
72 const GURL& url,
73 const std::string& request_method,
74 const base::Callback<void(bool)>& callback) {
75 callback.Run(true);
78 bool WebContentsDelegate::HandleContextMenu(
79 const content::ContextMenuParams& params) {
80 return false;
83 void WebContentsDelegate::ViewSourceForTab(WebContents* source,
84 const GURL& page_url) {
85 // Fall back implementation based entirely on the view-source scheme.
86 // It suffers from http://crbug.com/523 and that is why browser overrides
87 // it with proper implementation.
88 GURL url = GURL(kViewSourceScheme + std::string(":") + page_url.spec());
89 OpenURLFromTab(source, OpenURLParams(url, Referrer(),
90 NEW_FOREGROUND_TAB,
91 ui::PAGE_TRANSITION_LINK, false));
94 void WebContentsDelegate::ViewSourceForFrame(WebContents* source,
95 const GURL& frame_url,
96 const PageState& page_state) {
97 // Same as ViewSourceForTab, but for given subframe.
98 GURL url = GURL(kViewSourceScheme + std::string(":") + frame_url.spec());
99 OpenURLFromTab(source, OpenURLParams(url, Referrer(),
100 NEW_FOREGROUND_TAB,
101 ui::PAGE_TRANSITION_LINK, false));
104 bool WebContentsDelegate::PreHandleKeyboardEvent(
105 WebContents* source,
106 const NativeWebKeyboardEvent& event,
107 bool* is_keyboard_shortcut) {
108 return false;
111 bool WebContentsDelegate::PreHandleGestureEvent(
112 WebContents* source,
113 const blink::WebGestureEvent& event) {
114 return false;
117 bool WebContentsDelegate::CanDragEnter(
118 WebContents* source,
119 const DropData& data,
120 blink::WebDragOperationsMask operations_allowed) {
121 return true;
124 bool WebContentsDelegate::OnGoToEntryOffset(int offset) {
125 return true;
128 bool WebContentsDelegate::ShouldCreateWebContents(
129 WebContents* web_contents,
130 int route_id,
131 int main_frame_route_id,
132 WindowContainerType window_container_type,
133 const base::string16& frame_name,
134 const GURL& target_url,
135 const std::string& partition_id,
136 SessionStorageNamespace* session_storage_namespace) {
137 return true;
140 JavaScriptDialogManager* WebContentsDelegate::GetJavaScriptDialogManager(
141 WebContents* source) {
142 return nullptr;
145 bool WebContentsDelegate::EmbedsFullscreenWidget() const {
146 return false;
149 bool WebContentsDelegate::IsFullscreenForTabOrPending(
150 const WebContents* web_contents) const {
151 return false;
154 blink::WebDisplayMode WebContentsDelegate::GetDisplayMode(
155 const WebContents* web_contents) const {
156 return blink::WebDisplayModeBrowser;
159 content::ColorChooser* WebContentsDelegate::OpenColorChooser(
160 WebContents* web_contents,
161 SkColor color,
162 const std::vector<ColorSuggestion>& suggestions) {
163 return nullptr;
166 void WebContentsDelegate::RequestMediaAccessPermission(
167 WebContents* web_contents,
168 const MediaStreamRequest& request,
169 const MediaResponseCallback& callback) {
170 LOG(ERROR) << "WebContentsDelegate::RequestMediaAccessPermission: "
171 << "Not supported.";
172 callback.Run(MediaStreamDevices(),
173 MEDIA_DEVICE_NOT_SUPPORTED,
174 scoped_ptr<MediaStreamUI>());
177 bool WebContentsDelegate::CheckMediaAccessPermission(
178 WebContents* web_contents,
179 const GURL& security_origin,
180 MediaStreamType type) {
181 LOG(ERROR) << "WebContentsDelegate::CheckMediaAccessPermission: "
182 << "Not supported.";
183 return false;
186 bool WebContentsDelegate::RequestPpapiBrokerPermission(
187 WebContents* web_contents,
188 const GURL& url,
189 const base::FilePath& plugin_path,
190 const base::Callback<void(bool)>& callback) {
191 return false;
194 WebContentsDelegate::~WebContentsDelegate() {
195 while (!attached_contents_.empty()) {
196 WebContents* web_contents = *attached_contents_.begin();
197 web_contents->SetDelegate(nullptr);
199 DCHECK(attached_contents_.empty());
202 void WebContentsDelegate::Attach(WebContents* web_contents) {
203 DCHECK(attached_contents_.find(web_contents) == attached_contents_.end());
204 attached_contents_.insert(web_contents);
207 void WebContentsDelegate::Detach(WebContents* web_contents) {
208 DCHECK(attached_contents_.find(web_contents) != attached_contents_.end());
209 attached_contents_.erase(web_contents);
212 gfx::Size WebContentsDelegate::GetSizeForNewRenderView(
213 WebContents* web_contents) const {
214 return gfx::Size();
217 bool WebContentsDelegate::IsNeverVisible(WebContents* web_contents) {
218 return false;
221 bool WebContentsDelegate::SaveFrame(const GURL& url, const Referrer& referrer) {
222 return false;
225 } // namespace content