OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/public/browser/web_contents_delegate.h" | 5 #include "content/public/browser/web_contents_delegate.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 bool WebContentsDelegate::HandleContextMenu( | 80 bool WebContentsDelegate::HandleContextMenu( |
81 const content::ContextMenuParams& params) { | 81 const content::ContextMenuParams& params) { |
82 return false; | 82 return false; |
83 } | 83 } |
84 | 84 |
85 void WebContentsDelegate::ViewSourceForTab(WebContents* source, | 85 void WebContentsDelegate::ViewSourceForTab(WebContents* source, |
86 const GURL& page_url) { | 86 const GURL& page_url) { |
87 // Fall back implementation based entirely on the view-source scheme. | 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 | 88 // It suffers from http://crbug.com/523 and that is why browser overrides |
89 // it with proper implementation. | 89 // it with proper implementation. |
90 GURL url = GURL(chrome::kViewSourceScheme + std::string(":") + | 90 GURL url = GURL(kViewSourceScheme + std::string(":") + page_url.spec()); |
91 page_url.spec()); | |
92 OpenURLFromTab(source, OpenURLParams(url, Referrer(), | 91 OpenURLFromTab(source, OpenURLParams(url, Referrer(), |
93 NEW_FOREGROUND_TAB, | 92 NEW_FOREGROUND_TAB, |
94 PAGE_TRANSITION_LINK, false)); | 93 PAGE_TRANSITION_LINK, false)); |
95 } | 94 } |
96 | 95 |
97 void WebContentsDelegate::ViewSourceForFrame(WebContents* source, | 96 void WebContentsDelegate::ViewSourceForFrame(WebContents* source, |
98 const GURL& frame_url, | 97 const GURL& frame_url, |
99 const PageState& page_state) { | 98 const PageState& page_state) { |
100 // Same as ViewSourceForTab, but for given subframe. | 99 // Same as ViewSourceForTab, but for given subframe. |
101 GURL url = GURL(chrome::kViewSourceScheme + std::string(":") + | 100 GURL url = GURL(kViewSourceScheme + std::string(":") + frame_url.spec()); |
102 frame_url.spec()); | |
103 OpenURLFromTab(source, OpenURLParams(url, Referrer(), | 101 OpenURLFromTab(source, OpenURLParams(url, Referrer(), |
104 NEW_FOREGROUND_TAB, | 102 NEW_FOREGROUND_TAB, |
105 PAGE_TRANSITION_LINK, false)); | 103 PAGE_TRANSITION_LINK, false)); |
106 } | 104 } |
107 | 105 |
108 bool WebContentsDelegate::PreHandleKeyboardEvent( | 106 bool WebContentsDelegate::PreHandleKeyboardEvent( |
109 WebContents* source, | 107 WebContents* source, |
110 const NativeWebKeyboardEvent& event, | 108 const NativeWebKeyboardEvent& event, |
111 bool* is_keyboard_shortcut) { | 109 bool* is_keyboard_shortcut) { |
112 return false; | 110 return false; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 DCHECK(attached_contents_.find(web_contents) == attached_contents_.end()); | 157 DCHECK(attached_contents_.find(web_contents) == attached_contents_.end()); |
160 attached_contents_.insert(web_contents); | 158 attached_contents_.insert(web_contents); |
161 } | 159 } |
162 | 160 |
163 void WebContentsDelegate::Detach(WebContents* web_contents) { | 161 void WebContentsDelegate::Detach(WebContents* web_contents) { |
164 DCHECK(attached_contents_.find(web_contents) != attached_contents_.end()); | 162 DCHECK(attached_contents_.find(web_contents) != attached_contents_.end()); |
165 attached_contents_.erase(web_contents); | 163 attached_contents_.erase(web_contents); |
166 } | 164 } |
167 | 165 |
168 } // namespace content | 166 } // namespace content |
OLD | NEW |