Revert of Class for allocating a chunk of memory for RenderPass (patchset #31 id...
[chromium-blink-merge.git] / content / public / browser / web_contents_delegate.cc
blob72cabb4b62f5bff36c8bd7276506c702f76bf238
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::CanOverscrollContent() const { return false; }
32 gfx::Rect WebContentsDelegate::GetRootWindowResizerRect() const {
33 return gfx::Rect();
36 bool WebContentsDelegate::ShouldSuppressDialogs() {
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 int WebContentsDelegate::GetExtraRenderViewHeight() const {
71 return 0;
74 void WebContentsDelegate::CanDownload(
75 RenderViewHost* render_view_host,
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 WindowContainerType window_container_type,
136 const base::string16& frame_name,
137 const GURL& target_url,
138 const std::string& partition_id,
139 SessionStorageNamespace* session_storage_namespace) {
140 return true;
143 JavaScriptDialogManager* WebContentsDelegate::GetJavaScriptDialogManager() {
144 return NULL;
147 bool WebContentsDelegate::EmbedsFullscreenWidget() const {
148 return false;
151 bool WebContentsDelegate::IsFullscreenForTabOrPending(
152 const WebContents* web_contents) const {
153 return false;
156 content::ColorChooser* WebContentsDelegate::OpenColorChooser(
157 WebContents* web_contents,
158 SkColor color,
159 const std::vector<ColorSuggestion>& suggestions) {
160 return NULL;
163 void WebContentsDelegate::RequestMediaAccessPermission(
164 WebContents* web_contents,
165 const MediaStreamRequest& request,
166 const MediaResponseCallback& callback) {
167 callback.Run(MediaStreamDevices(),
168 MEDIA_DEVICE_INVALID_STATE,
169 scoped_ptr<MediaStreamUI>());
172 bool WebContentsDelegate::CheckMediaAccessPermission(
173 WebContents* web_contents,
174 const GURL& security_origin,
175 MediaStreamType type) {
176 DCHECK(type == MEDIA_DEVICE_AUDIO_CAPTURE ||
177 type == MEDIA_DEVICE_VIDEO_CAPTURE);
178 return false;
181 bool WebContentsDelegate::RequestPpapiBrokerPermission(
182 WebContents* web_contents,
183 const GURL& url,
184 const base::FilePath& plugin_path,
185 const base::Callback<void(bool)>& callback) {
186 return false;
189 WebContentsDelegate::~WebContentsDelegate() {
190 while (!attached_contents_.empty()) {
191 WebContents* web_contents = *attached_contents_.begin();
192 web_contents->SetDelegate(NULL);
194 DCHECK(attached_contents_.empty());
197 void WebContentsDelegate::Attach(WebContents* web_contents) {
198 DCHECK(attached_contents_.find(web_contents) == attached_contents_.end());
199 attached_contents_.insert(web_contents);
202 void WebContentsDelegate::Detach(WebContents* web_contents) {
203 DCHECK(attached_contents_.find(web_contents) != attached_contents_.end());
204 attached_contents_.erase(web_contents);
207 gfx::Size WebContentsDelegate::GetSizeForNewRenderView(
208 WebContents* web_contents) const {
209 return gfx::Size();
212 bool WebContentsDelegate::IsNeverVisible(WebContents* web_contents) {
213 return false;
216 } // namespace content