Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / content / public / browser / web_contents_delegate.cc
blob6f9b32e8f5f4039a0e259beddae0a38e8ac486ec
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/security_style_explanations.h"
12 #include "content/public/browser/web_contents.h"
13 #include "content/public/common/bindings_policy.h"
14 #include "content/public/common/security_style.h"
15 #include "content/public/common/url_constants.h"
16 #include "ui/gfx/geometry/rect.h"
18 namespace content {
20 WebContentsDelegate::WebContentsDelegate() {
23 WebContents* WebContentsDelegate::OpenURLFromTab(WebContents* source,
24 const OpenURLParams& params) {
25 return nullptr;
28 bool WebContentsDelegate::IsPopupOrPanel(const WebContents* source) const {
29 return false;
32 bool WebContentsDelegate::CanOverscrollContent() const { return false; }
34 gfx::Rect WebContentsDelegate::GetRootWindowResizerRect() const {
35 return gfx::Rect();
38 bool WebContentsDelegate::ShouldSuppressDialogs(WebContents* source) {
39 return false;
42 bool WebContentsDelegate::ShouldPreserveAbortedURLs(WebContents* source) {
43 return false;
46 bool WebContentsDelegate::AddMessageToConsole(WebContents* source,
47 int32 level,
48 const base::string16& message,
49 int32 line_no,
50 const base::string16& source_id) {
51 return false;
54 void WebContentsDelegate::BeforeUnloadFired(WebContents* web_contents,
55 bool proceed,
56 bool* proceed_to_fire_unload) {
57 *proceed_to_fire_unload = true;
60 bool WebContentsDelegate::ShouldFocusLocationBarByDefault(WebContents* source) {
61 return false;
64 bool WebContentsDelegate::ShouldFocusPageAfterCrash() {
65 return true;
68 bool WebContentsDelegate::ShouldResumeRequestsForCreatedWindow() {
69 return true;
72 bool WebContentsDelegate::TakeFocus(WebContents* source, bool reverse) {
73 return false;
76 void WebContentsDelegate::CanDownload(
77 const GURL& url,
78 const std::string& request_method,
79 const base::Callback<void(bool)>& callback) {
80 callback.Run(true);
83 bool WebContentsDelegate::HandleContextMenu(
84 const content::ContextMenuParams& params) {
85 return false;
88 void WebContentsDelegate::ViewSourceForTab(WebContents* source,
89 const GURL& page_url) {
90 // Fall back implementation based entirely on the view-source scheme.
91 // It suffers from http://crbug.com/523 and that is why browser overrides
92 // it with proper implementation.
93 GURL url = GURL(kViewSourceScheme + std::string(":") + page_url.spec());
94 OpenURLFromTab(source, OpenURLParams(url, Referrer(),
95 NEW_FOREGROUND_TAB,
96 ui::PAGE_TRANSITION_LINK, false));
99 void WebContentsDelegate::ViewSourceForFrame(WebContents* source,
100 const GURL& frame_url,
101 const PageState& page_state) {
102 // Same as ViewSourceForTab, but for given subframe.
103 GURL url = GURL(kViewSourceScheme + std::string(":") + frame_url.spec());
104 OpenURLFromTab(source, OpenURLParams(url, Referrer(),
105 NEW_FOREGROUND_TAB,
106 ui::PAGE_TRANSITION_LINK, false));
109 bool WebContentsDelegate::PreHandleKeyboardEvent(
110 WebContents* source,
111 const NativeWebKeyboardEvent& event,
112 bool* is_keyboard_shortcut) {
113 return false;
116 bool WebContentsDelegate::PreHandleGestureEvent(
117 WebContents* source,
118 const blink::WebGestureEvent& event) {
119 return false;
122 bool WebContentsDelegate::CanDragEnter(
123 WebContents* source,
124 const DropData& data,
125 blink::WebDragOperationsMask operations_allowed) {
126 return true;
129 bool WebContentsDelegate::OnGoToEntryOffset(int offset) {
130 return true;
133 bool WebContentsDelegate::ShouldCreateWebContents(
134 WebContents* web_contents,
135 int route_id,
136 int main_frame_route_id,
137 WindowContainerType window_container_type,
138 const std::string& frame_name,
139 const GURL& target_url,
140 const std::string& partition_id,
141 SessionStorageNamespace* session_storage_namespace) {
142 return true;
145 JavaScriptDialogManager* WebContentsDelegate::GetJavaScriptDialogManager(
146 WebContents* source) {
147 return nullptr;
150 scoped_ptr<BluetoothChooser> WebContentsDelegate::RunBluetoothChooser(
151 WebContents* web_contents,
152 const BluetoothChooser::EventHandler& event_handler,
153 const GURL& origin) {
154 return nullptr;
157 bool WebContentsDelegate::EmbedsFullscreenWidget() const {
158 return false;
161 bool WebContentsDelegate::IsFullscreenForTabOrPending(
162 const WebContents* web_contents) const {
163 return false;
166 blink::WebDisplayMode WebContentsDelegate::GetDisplayMode(
167 const WebContents* web_contents) const {
168 return blink::WebDisplayModeBrowser;
171 content::ColorChooser* WebContentsDelegate::OpenColorChooser(
172 WebContents* web_contents,
173 SkColor color,
174 const std::vector<ColorSuggestion>& suggestions) {
175 return nullptr;
178 void WebContentsDelegate::RequestMediaAccessPermission(
179 WebContents* web_contents,
180 const MediaStreamRequest& request,
181 const MediaResponseCallback& callback) {
182 LOG(ERROR) << "WebContentsDelegate::RequestMediaAccessPermission: "
183 << "Not supported.";
184 callback.Run(MediaStreamDevices(),
185 MEDIA_DEVICE_NOT_SUPPORTED,
186 scoped_ptr<MediaStreamUI>());
189 bool WebContentsDelegate::CheckMediaAccessPermission(
190 WebContents* web_contents,
191 const GURL& security_origin,
192 MediaStreamType type) {
193 LOG(ERROR) << "WebContentsDelegate::CheckMediaAccessPermission: "
194 << "Not supported.";
195 return false;
198 bool WebContentsDelegate::RequestPpapiBrokerPermission(
199 WebContents* web_contents,
200 const GURL& url,
201 const base::FilePath& plugin_path,
202 const base::Callback<void(bool)>& callback) {
203 return false;
206 WebContentsDelegate::~WebContentsDelegate() {
207 while (!attached_contents_.empty()) {
208 WebContents* web_contents = *attached_contents_.begin();
209 web_contents->SetDelegate(nullptr);
211 DCHECK(attached_contents_.empty());
214 void WebContentsDelegate::Attach(WebContents* web_contents) {
215 DCHECK(attached_contents_.find(web_contents) == attached_contents_.end());
216 attached_contents_.insert(web_contents);
219 void WebContentsDelegate::Detach(WebContents* web_contents) {
220 DCHECK(attached_contents_.find(web_contents) != attached_contents_.end());
221 attached_contents_.erase(web_contents);
224 gfx::Size WebContentsDelegate::GetSizeForNewRenderView(
225 WebContents* web_contents) const {
226 return gfx::Size();
229 bool WebContentsDelegate::IsNeverVisible(WebContents* web_contents) {
230 return false;
233 bool WebContentsDelegate::SaveFrame(const GURL& url, const Referrer& referrer) {
234 return false;
237 SecurityStyle WebContentsDelegate::GetSecurityStyle(
238 WebContents* web_contents,
239 SecurityStyleExplanations* security_style_explanations) {
240 return content::SECURITY_STYLE_UNKNOWN;
243 } // namespace content