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/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
8 #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" |
9 #include "chrome/browser/guest_view/guest_view_constants.h" | 11 #include "chrome/browser/guest_view/guest_view_constants.h" |
10 #include "chrome/browser/guest_view/guest_view_manager.h" | 12 #include "chrome/browser/guest_view/guest_view_manager.h" |
11 #include "chrome/browser/guest_view/web_view/web_view_guest.h" | 13 #include "chrome/browser/guest_view/web_view/web_view_guest.h" |
12 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/content_settings.h" | 16 #include "chrome/common/content_settings.h" |
14 #include "content/public/browser/render_frame_host.h" | 17 #include "content/public/browser/render_frame_host.h" |
15 #include "content/public/browser/render_process_host.h" | 18 #include "content/public/browser/render_process_host.h" |
16 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
17 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
18 #include "content/public/common/url_constants.h" | 21 #include "content/public/common/url_constants.h" |
19 #include "extensions/browser/event_router.h" | 22 #include "extensions/browser/event_router.h" |
20 #include "third_party/WebKit/public/web/WebInputEvent.h" | 23 #include "third_party/WebKit/public/web/WebInputEvent.h" |
21 | 24 |
22 using content::WebContents; | 25 using content::WebContents; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 120 |
118 // Give the derived class an opportunity to perform additional initialization. | 121 // Give the derived class an opportunity to perform additional initialization. |
119 DidInitialize(); | 122 DidInitialize(); |
120 } | 123 } |
121 | 124 |
122 // static | 125 // static |
123 GuestViewBase* GuestViewBase::Create( | 126 GuestViewBase* GuestViewBase::Create( |
124 content::BrowserContext* browser_context, | 127 content::BrowserContext* browser_context, |
125 int guest_instance_id, | 128 int guest_instance_id, |
126 const std::string& view_type) { | 129 const std::string& view_type) { |
127 if (view_type == "webview") { | 130 if (view_type == WebViewGuest::Type) { |
128 return new WebViewGuest(browser_context, guest_instance_id); | 131 return new WebViewGuest(browser_context, guest_instance_id); |
| 132 } else if (view_type == AppViewGuest::Type) { |
| 133 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 134 switches::kEnableAppView)) { |
| 135 return NULL; |
| 136 } |
| 137 return new AppViewGuest(browser_context, guest_instance_id); |
129 } | 138 } |
130 NOTREACHED(); | 139 NOTREACHED(); |
131 return NULL; | 140 return NULL; |
132 } | 141 } |
133 | 142 |
134 // static | 143 // static |
135 GuestViewBase* GuestViewBase::FromWebContents(WebContents* web_contents) { | 144 GuestViewBase* GuestViewBase::FromWebContents(WebContents* web_contents) { |
136 WebContentsGuestViewMap* guest_map = webcontents_guestview_map.Pointer(); | 145 WebContentsGuestViewMap* guest_map = webcontents_guestview_map.Pointer(); |
137 WebContentsGuestViewMap::iterator it = guest_map->find(web_contents); | 146 WebContentsGuestViewMap::iterator it = guest_map->find(web_contents); |
138 return it == guest_map->end() ? NULL : it->second; | 147 return it == guest_map->end() ? NULL : it->second; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 content::WebContents* guest_web_contents) { | 348 content::WebContents* guest_web_contents) { |
340 if (!guest_web_contents) { | 349 if (!guest_web_contents) { |
341 callback.Run(NULL); | 350 callback.Run(NULL); |
342 return; | 351 return; |
343 } | 352 } |
344 InitWithWebContents(embedder_extension_id, | 353 InitWithWebContents(embedder_extension_id, |
345 embedder_render_process_id, | 354 embedder_render_process_id, |
346 guest_web_contents); | 355 guest_web_contents); |
347 callback.Run(guest_web_contents); | 356 callback.Run(guest_web_contents); |
348 } | 357 } |
OLD | NEW |