[Android WebView] Fix webview perf bot switchover to use org.chromium.webview_shell...
[chromium-blink-merge.git] / content / public / browser / web_contents_delegate.cc
blob3f8b87d5cd2633f71e473bcde68228f11cc4aa1a
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/security_style.h"
14 #include "content/public/common/url_constants.h"
15 #include "ui/gfx/geometry/rect.h"
17 namespace content {
19 WebContentsDelegate::WebContentsDelegate() {
22 WebContents* WebContentsDelegate::OpenURLFromTab(WebContents* source,
23 const OpenURLParams& params) {
24 return nullptr;
27 bool WebContentsDelegate::IsPopupOrPanel(const WebContents* source) const {
28 return false;
31 bool WebContentsDelegate::CanOverscrollContent() const { return false; }
33 gfx::Rect WebContentsDelegate::GetRootWindowResizerRect() const {
34 return gfx::Rect();
37 bool WebContentsDelegate::ShouldSuppressDialogs(WebContents* source) {
38 return false;
41 bool WebContentsDelegate::ShouldPreserveAbortedURLs(WebContents* source) {
42 return false;
45 bool WebContentsDelegate::AddMessageToConsole(WebContents* source,
46 int32 level,
47 const base::string16& message,
48 int32 line_no,
49 const base::string16& source_id) {
50 return false;
53 void WebContentsDelegate::BeforeUnloadFired(WebContents* web_contents,
54 bool proceed,
55 bool* proceed_to_fire_unload) {
56 *proceed_to_fire_unload = true;
59 bool WebContentsDelegate::ShouldFocusLocationBarByDefault(WebContents* source) {
60 return false;
63 bool WebContentsDelegate::ShouldFocusPageAfterCrash() {
64 return true;
67 bool WebContentsDelegate::ShouldResumeRequestsForCreatedWindow() {
68 return true;
71 bool WebContentsDelegate::TakeFocus(WebContents* source, bool reverse) {
72 return false;
75 void WebContentsDelegate::CanDownload(
76 const GURL& url,
77 const std::string& request_method,
78 const base::Callback<void(bool)>& callback) {
79 callback.Run(true);
82 bool WebContentsDelegate::HandleContextMenu(
83 const content::ContextMenuParams& params) {
84 return false;
87 void WebContentsDelegate::ViewSourceForTab(WebContents* source,
88 const GURL& page_url) {
89 // Fall back implementation based entirely on the view-source scheme.
90 // It suffers from http://crbug.com/523 and that is why browser overrides
91 // it with proper implementation.
92 GURL url = GURL(kViewSourceScheme + std::string(":") + page_url.spec());
93 OpenURLFromTab(source, OpenURLParams(url, Referrer(),
94 NEW_FOREGROUND_TAB,
95 ui::PAGE_TRANSITION_LINK, false));
98 void WebContentsDelegate::ViewSourceForFrame(WebContents* source,
99 const GURL& frame_url,
100 const PageState& page_state) {
101 // Same as ViewSourceForTab, but for given subframe.
102 GURL url = GURL(kViewSourceScheme + std::string(":") + frame_url.spec());
103 OpenURLFromTab(source, OpenURLParams(url, Referrer(),
104 NEW_FOREGROUND_TAB,
105 ui::PAGE_TRANSITION_LINK, false));
108 bool WebContentsDelegate::PreHandleKeyboardEvent(
109 WebContents* source,
110 const NativeWebKeyboardEvent& event,
111 bool* is_keyboard_shortcut) {
112 return false;
115 bool WebContentsDelegate::PreHandleGestureEvent(
116 WebContents* source,
117 const blink::WebGestureEvent& event) {
118 return false;
121 bool WebContentsDelegate::CanDragEnter(
122 WebContents* source,
123 const DropData& data,
124 blink::WebDragOperationsMask operations_allowed) {
125 return true;
128 bool WebContentsDelegate::OnGoToEntryOffset(int offset) {
129 return true;
132 bool WebContentsDelegate::ShouldCreateWebContents(
133 WebContents* web_contents,
134 int route_id,
135 int main_frame_route_id,
136 WindowContainerType window_container_type,
137 const base::string16& frame_name,
138 const GURL& target_url,
139 const std::string& partition_id,
140 SessionStorageNamespace* session_storage_namespace) {
141 return true;
144 JavaScriptDialogManager* WebContentsDelegate::GetJavaScriptDialogManager(
145 WebContents* source) {
146 return nullptr;
149 bool WebContentsDelegate::EmbedsFullscreenWidget() const {
150 return false;
153 bool WebContentsDelegate::IsFullscreenForTabOrPending(
154 const WebContents* web_contents) const {
155 return false;
158 blink::WebDisplayMode WebContentsDelegate::GetDisplayMode(
159 const WebContents* web_contents) const {
160 return blink::WebDisplayModeBrowser;
163 content::ColorChooser* WebContentsDelegate::OpenColorChooser(
164 WebContents* web_contents,
165 SkColor color,
166 const std::vector<ColorSuggestion>& suggestions) {
167 return nullptr;
170 void WebContentsDelegate::RequestMediaAccessPermission(
171 WebContents* web_contents,
172 const MediaStreamRequest& request,
173 const MediaResponseCallback& callback) {
174 LOG(ERROR) << "WebContentsDelegate::RequestMediaAccessPermission: "
175 << "Not supported.";
176 callback.Run(MediaStreamDevices(),
177 MEDIA_DEVICE_NOT_SUPPORTED,
178 scoped_ptr<MediaStreamUI>());
181 bool WebContentsDelegate::CheckMediaAccessPermission(
182 WebContents* web_contents,
183 const GURL& security_origin,
184 MediaStreamType type) {
185 LOG(ERROR) << "WebContentsDelegate::CheckMediaAccessPermission: "
186 << "Not supported.";
187 return false;
190 bool WebContentsDelegate::RequestPpapiBrokerPermission(
191 WebContents* web_contents,
192 const GURL& url,
193 const base::FilePath& plugin_path,
194 const base::Callback<void(bool)>& callback) {
195 return false;
198 WebContentsDelegate::~WebContentsDelegate() {
199 while (!attached_contents_.empty()) {
200 WebContents* web_contents = *attached_contents_.begin();
201 web_contents->SetDelegate(nullptr);
203 DCHECK(attached_contents_.empty());
206 void WebContentsDelegate::Attach(WebContents* web_contents) {
207 DCHECK(attached_contents_.find(web_contents) == attached_contents_.end());
208 attached_contents_.insert(web_contents);
211 void WebContentsDelegate::Detach(WebContents* web_contents) {
212 DCHECK(attached_contents_.find(web_contents) != attached_contents_.end());
213 attached_contents_.erase(web_contents);
216 gfx::Size WebContentsDelegate::GetSizeForNewRenderView(
217 WebContents* web_contents) const {
218 return gfx::Size();
221 bool WebContentsDelegate::IsNeverVisible(WebContents* web_contents) {
222 return false;
225 bool WebContentsDelegate::SaveFrame(const GURL& url, const Referrer& referrer) {
226 return false;
229 SecurityStyle WebContentsDelegate::GetSecurityStyle(WebContents* web_contents) {
230 return content::SECURITY_STYLE_UNKNOWN;
233 } // namespace content