Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(449)

Side by Side Diff: components/renderer_context_menu/render_view_context_menu_base.cc

Issue 1117893002: Moving extension code out of "components/" to avoid layering violations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing nit. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/renderer_context_menu/render_view_context_menu_base.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/renderer_context_menu/render_view_context_menu_base.h" 5 #include "components/renderer_context_menu/render_view_context_menu_base.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "content/public/browser/render_frame_host.h" 12 #include "content/public/browser/render_frame_host.h"
13 #include "content/public/browser/render_process_host.h" 13 #include "content/public/browser/render_process_host.h"
14 #include "content/public/browser/render_view_host.h" 14 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/render_widget_host_view.h" 15 #include "content/public/browser/render_widget_host_view.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/common/menu_item.h" 17 #include "content/public/common/menu_item.h"
18 #if defined(ENABLE_EXTENSIONS)
19 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h"
20 #endif
21 #include "third_party/WebKit/public/web/WebContextMenuData.h" 18 #include "third_party/WebKit/public/web/WebContextMenuData.h"
22 19
23 using blink::WebContextMenuData; 20 using blink::WebContextMenuData;
24 using blink::WebString; 21 using blink::WebString;
25 using blink::WebURL; 22 using blink::WebURL;
26 using content::BrowserContext; 23 using content::BrowserContext;
27 using content::OpenURLParams; 24 using content::OpenURLParams;
28 using content::RenderFrameHost; 25 using content::RenderFrameHost;
29 using content::RenderViewHost; 26 using content::RenderViewHost;
30 using content::WebContents; 27 using content::WebContents;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 submenu); 119 submenu);
123 break; 120 break;
124 } 121 }
125 default: 122 default:
126 NOTREACHED(); 123 NOTREACHED();
127 break; 124 break;
128 } 125 }
129 } 126 }
130 } 127 }
131 128
132 content::WebContents* GetWebContentsToUse(content::WebContents* web_contents) {
133 // If we're viewing in a MimeHandlerViewGuest, use its embedder WebContents.
134 #if defined(ENABLE_EXTENSIONS)
135 auto guest_view =
136 extensions::MimeHandlerViewGuest::FromWebContents(web_contents);
137 if (guest_view)
138 return guest_view->embedder_web_contents();
139 #endif
140 return web_contents;
141 }
142
143 } // namespace 129 } // namespace
144 130
145 // static 131 // static
146 void RenderViewContextMenuBase::SetContentCustomCommandIdRange( 132 void RenderViewContextMenuBase::SetContentCustomCommandIdRange(
147 int first, int last) { 133 int first, int last) {
148 // The range is inclusive. 134 // The range is inclusive.
149 content_context_custom_first = first; 135 content_context_custom_first = first;
150 content_context_custom_last = last; 136 content_context_custom_last = last;
151 } 137 }
152 138
153 // static 139 // static
154 const size_t RenderViewContextMenuBase::kMaxSelectionTextLength = 50; 140 const size_t RenderViewContextMenuBase::kMaxSelectionTextLength = 50;
155 141
156 // static 142 // static
157 int RenderViewContextMenuBase::ConvertToContentCustomCommandId(int id) { 143 int RenderViewContextMenuBase::ConvertToContentCustomCommandId(int id) {
158 return content_context_custom_first + id; 144 return content_context_custom_first + id;
159 } 145 }
160 146
161 // static 147 // static
162 bool RenderViewContextMenuBase::IsContentCustomCommandId(int id) { 148 bool RenderViewContextMenuBase::IsContentCustomCommandId(int id) {
163 return id >= content_context_custom_first && 149 return id >= content_context_custom_first &&
164 id <= content_context_custom_last; 150 id <= content_context_custom_last;
165 } 151 }
166 152
167 RenderViewContextMenuBase::RenderViewContextMenuBase( 153 RenderViewContextMenuBase::RenderViewContextMenuBase(
168 content::RenderFrameHost* render_frame_host, 154 content::RenderFrameHost* render_frame_host,
169 const content::ContextMenuParams& params) 155 const content::ContextMenuParams& params)
170 : params_(params), 156 : params_(params),
171 source_web_contents_(WebContents::FromRenderFrameHost(render_frame_host)), 157 source_web_contents_(WebContents::FromRenderFrameHost(render_frame_host)),
172 embedder_web_contents_(GetWebContentsToUse(source_web_contents_)),
173 browser_context_(source_web_contents_->GetBrowserContext()), 158 browser_context_(source_web_contents_->GetBrowserContext()),
174 menu_model_(this), 159 menu_model_(this),
175 render_frame_id_(render_frame_host->GetRoutingID()), 160 render_frame_id_(render_frame_host->GetRoutingID()),
176 command_executed_(false), 161 command_executed_(false),
177 render_process_id_(render_frame_host->GetProcess()->GetID()) { 162 render_process_id_(render_frame_host->GetProcess()->GetID()) {
178 } 163 }
179 164
180 RenderViewContextMenuBase::~RenderViewContextMenuBase() { 165 RenderViewContextMenuBase::~RenderViewContextMenuBase() {
181 } 166 }
182 167
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 392 }
408 393
409 bool RenderViewContextMenuBase::IsCustomItemChecked(int id) const { 394 bool RenderViewContextMenuBase::IsCustomItemChecked(int id) const {
410 return IsCustomItemCheckedInternal(params_.custom_items, id); 395 return IsCustomItemCheckedInternal(params_.custom_items, id);
411 } 396 }
412 397
413 bool RenderViewContextMenuBase::IsCustomItemEnabled(int id) const { 398 bool RenderViewContextMenuBase::IsCustomItemEnabled(int id) const {
414 return IsCustomItemEnabledInternal(params_.custom_items, id); 399 return IsCustomItemEnabledInternal(params_.custom_items, id);
415 } 400 }
416 401
OLDNEW
« no previous file with comments | « components/renderer_context_menu/render_view_context_menu_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698