OLD | NEW |
---|---|
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/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/content_settings.h" | 17 #include "chrome/common/content_settings.h" |
17 #include "content/public/browser/render_frame_host.h" | 18 #include "content/public/browser/render_frame_host.h" |
18 #include "content/public/browser/render_process_host.h" | 19 #include "content/public/browser/render_process_host.h" |
19 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
21 #include "content/public/common/url_constants.h" | 22 #include "content/public/common/url_constants.h" |
22 #include "extensions/browser/event_router.h" | 23 #include "extensions/browser/event_router.h" |
24 #include "extensions/common/switches.h" | |
23 #include "third_party/WebKit/public/web/WebInputEvent.h" | 25 #include "third_party/WebKit/public/web/WebInputEvent.h" |
24 | 26 |
25 using content::WebContents; | 27 using content::WebContents; |
26 | 28 |
27 namespace { | 29 namespace { |
28 | 30 |
29 typedef std::map<WebContents*, GuestViewBase*> WebContentsGuestViewMap; | 31 typedef std::map<WebContents*, GuestViewBase*> WebContentsGuestViewMap; |
30 static base::LazyInstance<WebContentsGuestViewMap> webcontents_guestview_map = | 32 static base::LazyInstance<WebContentsGuestViewMap> webcontents_guestview_map = |
31 LAZY_INSTANCE_INITIALIZER; | 33 LAZY_INSTANCE_INITIALIZER; |
32 | 34 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 int guest_instance_id, | 130 int guest_instance_id, |
129 const std::string& view_type) { | 131 const std::string& view_type) { |
130 if (view_type == WebViewGuest::Type) { | 132 if (view_type == WebViewGuest::Type) { |
131 return new WebViewGuest(browser_context, guest_instance_id); | 133 return new WebViewGuest(browser_context, guest_instance_id); |
132 } else if (view_type == AppViewGuest::Type) { | 134 } else if (view_type == AppViewGuest::Type) { |
133 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 135 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
134 switches::kEnableAppView)) { | 136 switches::kEnableAppView)) { |
135 return NULL; | 137 return NULL; |
136 } | 138 } |
137 return new AppViewGuest(browser_context, guest_instance_id); | 139 return new AppViewGuest(browser_context, guest_instance_id); |
140 } else if (view_type == ExtensionOptionsGuest::Type) { | |
Fady Samuel
2014/07/11 21:08:05
Add a TODO at the top:
// TODO(fsamuel): All thes
ericzeng
2014/07/12 00:10:05
Done.
| |
141 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
142 extensions::switches::kEnableEmbeddedExtensionOptions)) { | |
143 return NULL; | |
144 } | |
145 return new ExtensionOptionsGuest(browser_context, guest_instance_id); | |
138 } | 146 } |
139 NOTREACHED(); | 147 NOTREACHED(); |
140 return NULL; | 148 return NULL; |
141 } | 149 } |
142 | 150 |
143 // static | 151 // static |
144 GuestViewBase* GuestViewBase::FromWebContents(WebContents* web_contents) { | 152 GuestViewBase* GuestViewBase::FromWebContents(WebContents* web_contents) { |
145 WebContentsGuestViewMap* guest_map = webcontents_guestview_map.Pointer(); | 153 WebContentsGuestViewMap* guest_map = webcontents_guestview_map.Pointer(); |
146 WebContentsGuestViewMap::iterator it = guest_map->find(web_contents); | 154 WebContentsGuestViewMap::iterator it = guest_map->find(web_contents); |
147 return it == guest_map->end() ? NULL : it->second; | 155 return it == guest_map->end() ? NULL : it->second; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 content::WebContents* guest_web_contents) { | 356 content::WebContents* guest_web_contents) { |
349 if (!guest_web_contents) { | 357 if (!guest_web_contents) { |
350 callback.Run(NULL); | 358 callback.Run(NULL); |
351 return; | 359 return; |
352 } | 360 } |
353 InitWithWebContents(embedder_extension_id, | 361 InitWithWebContents(embedder_extension_id, |
354 embedder_render_process_id, | 362 embedder_render_process_id, |
355 guest_web_contents); | 363 guest_web_contents); |
356 callback.Run(guest_web_contents); | 364 callback.Run(guest_web_contents); |
357 } | 365 } |
OLD | NEW |