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

Side by Side Diff: chrome/browser/guest_view/guest_view_base.cc

Issue 378783002: Initial implementation of the <extensionoptions> GuestView tag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
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 "chrome/browser/guest_view/guest_view_base.h" 5 #include "chrome/browser/guest_view/guest_view_base.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/guest_view/app_view/app_view_guest.h" 10 #include "chrome/browser/guest_view/app_view/app_view_guest.h"
11 #include "chrome/browser/guest_view/extension_options/extension_options_guest.h"
11 #include "chrome/browser/guest_view/guest_view_constants.h" 12 #include "chrome/browser/guest_view/guest_view_constants.h"
12 #include "chrome/browser/guest_view/guest_view_manager.h" 13 #include "chrome/browser/guest_view/guest_view_manager.h"
13 #include "chrome/browser/guest_view/web_view/web_view_guest.h" 14 #include "chrome/browser/guest_view/web_view/web_view_guest.h"
14 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/content_settings.h" 16 #include "chrome/common/content_settings.h"
16 #include "content/public/browser/render_frame_host.h" 17 #include "content/public/browser/render_frame_host.h"
17 #include "content/public/browser/render_process_host.h" 18 #include "content/public/browser/render_process_host.h"
18 #include "content/public/browser/render_view_host.h" 19 #include "content/public/browser/render_view_host.h"
19 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
20 #include "content/public/common/url_constants.h" 21 #include "content/public/common/url_constants.h"
21 #include "extensions/browser/event_router.h" 22 #include "extensions/browser/event_router.h"
23 #include "extensions/common/feature_switch.h"
22 #include "third_party/WebKit/public/web/WebInputEvent.h" 24 #include "third_party/WebKit/public/web/WebInputEvent.h"
23 25
24 using content::WebContents; 26 using content::WebContents;
25 27
26 namespace { 28 namespace {
27 29
28 typedef std::map<WebContents*, GuestViewBase*> WebContentsGuestViewMap; 30 typedef std::map<WebContents*, GuestViewBase*> WebContentsGuestViewMap;
29 static base::LazyInstance<WebContentsGuestViewMap> webcontents_guestview_map = 31 static base::LazyInstance<WebContentsGuestViewMap> webcontents_guestview_map =
30 LAZY_INSTANCE_INITIALIZER; 32 LAZY_INSTANCE_INITIALIZER;
31 33
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 139
138 // Give the derived class an opportunity to perform additional initialization. 140 // Give the derived class an opportunity to perform additional initialization.
139 DidInitialize(); 141 DidInitialize();
140 } 142 }
141 143
142 // static 144 // static
143 GuestViewBase* GuestViewBase::Create( 145 GuestViewBase* GuestViewBase::Create(
144 content::BrowserContext* browser_context, 146 content::BrowserContext* browser_context,
145 int guest_instance_id, 147 int guest_instance_id,
146 const std::string& view_type) { 148 const std::string& view_type) {
149 // TODO(fsamuel): All these string comparisons are a little inefficient. Maybe
150 // we want a registry of GuestView types in the future.
Fady Samuel 2014/07/21 19:44:47 I've addressed this TODO: https://codereview.chrom
ericzeng 2014/07/22 00:00:55 Done.
147 if (view_type == WebViewGuest::Type) { 151 if (view_type == WebViewGuest::Type) {
148 return new WebViewGuest(browser_context, guest_instance_id); 152 return new WebViewGuest(browser_context, guest_instance_id);
149 } else if (view_type == AppViewGuest::Type) { 153 } else if (view_type == AppViewGuest::Type) {
150 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 154 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
151 switches::kEnableAppView)) { 155 switches::kEnableAppView)) {
152 return NULL; 156 return NULL;
153 } 157 }
154 return new AppViewGuest(browser_context, guest_instance_id); 158 return new AppViewGuest(browser_context, guest_instance_id);
159 } else if (view_type == ExtensionOptionsGuest::Type) {
160 if (!extensions::FeatureSwitch::embedded_extension_options()->IsEnabled()) {
161 return NULL;
162 }
163 return new ExtensionOptionsGuest(browser_context, guest_instance_id);
155 } 164 }
156 NOTREACHED(); 165 NOTREACHED();
157 return NULL; 166 return NULL;
158 } 167 }
159 168
160 // static 169 // static
161 GuestViewBase* GuestViewBase::FromWebContents(WebContents* web_contents) { 170 GuestViewBase* GuestViewBase::FromWebContents(WebContents* web_contents) {
162 WebContentsGuestViewMap* guest_map = webcontents_guestview_map.Pointer(); 171 WebContentsGuestViewMap* guest_map = webcontents_guestview_map.Pointer();
163 WebContentsGuestViewMap::iterator it = guest_map->find(web_contents); 172 WebContentsGuestViewMap::iterator it = guest_map->find(web_contents);
164 return it == guest_map->end() ? NULL : it->second; 173 return it == guest_map->end() ? NULL : it->second;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // purpose. Let's self-destruct. 373 // purpose. Let's self-destruct.
365 delete this; 374 delete this;
366 callback.Run(NULL); 375 callback.Run(NULL);
367 return; 376 return;
368 } 377 }
369 InitWithWebContents(embedder_extension_id, 378 InitWithWebContents(embedder_extension_id,
370 embedder_render_process_id, 379 embedder_render_process_id,
371 guest_web_contents); 380 guest_web_contents);
372 callback.Run(guest_web_contents); 381 callback.Run(guest_web_contents);
373 } 382 }
OLDNEW
« no previous file with comments | « chrome/browser/guest_view/extension_options/extension_options_guest.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698