Chromium Code Reviews| 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/guest_view_constants.h" | 11 #include "chrome/browser/guest_view/guest_view_constants.h" |
| 12 #include "chrome/browser/guest_view/guest_view_manager.h" | 12 #include "chrome/browser/guest_view/guest_view_manager.h" |
| 13 #include "chrome/browser/guest_view/mime_handler_view/mime_handler_view_guest.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" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 int guest_instance_id, | 129 int guest_instance_id, |
| 129 const std::string& view_type) { | 130 const std::string& view_type) { |
| 130 if (view_type == WebViewGuest::Type) { | 131 if (view_type == WebViewGuest::Type) { |
| 131 return new WebViewGuest(browser_context, guest_instance_id); | 132 return new WebViewGuest(browser_context, guest_instance_id); |
| 132 } else if (view_type == AppViewGuest::Type) { | 133 } else if (view_type == AppViewGuest::Type) { |
| 133 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 134 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 134 switches::kEnableAppView)) { | 135 switches::kEnableAppView)) { |
| 135 return NULL; | 136 return NULL; |
| 136 } | 137 } |
| 137 return new AppViewGuest(browser_context, guest_instance_id); | 138 return new AppViewGuest(browser_context, guest_instance_id); |
| 139 } else if (view_type == MimeHandlerViewGuest::Type) { | |
| 140 printf("++++ GuestViewBase::Create MimeHandlerViewGuest\n"); | |
| 141 // TODO(lazyboy): Checks if we are allowed to create one. | |
| 142 return new MimeHandlerViewGuest(browser_context, guest_instance_id); | |
| 138 } | 143 } |
| 139 NOTREACHED(); | 144 NOTREACHED(); |
| 140 return NULL; | 145 return NULL; |
| 141 } | 146 } |
| 142 | 147 |
| 143 // static | 148 // static |
| 144 GuestViewBase* GuestViewBase::FromWebContents(WebContents* web_contents) { | 149 GuestViewBase* GuestViewBase::FromWebContents(WebContents* web_contents) { |
| 145 WebContentsGuestViewMap* guest_map = webcontents_guestview_map.Pointer(); | 150 WebContentsGuestViewMap* guest_map = webcontents_guestview_map.Pointer(); |
| 146 WebContentsGuestViewMap::iterator it = guest_map->find(web_contents); | 151 WebContentsGuestViewMap::iterator it = guest_map->find(web_contents); |
| 147 return it == guest_map->end() ? NULL : it->second; | 152 return it == guest_map->end() ? NULL : it->second; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 | 303 |
| 299 GuestViewManager::FromBrowserContext(browser_context_)-> | 304 GuestViewManager::FromBrowserContext(browser_context_)-> |
| 300 RemoveGuest(guest_instance_id_); | 305 RemoveGuest(guest_instance_id_); |
| 301 | 306 |
| 302 pending_events_.clear(); | 307 pending_events_.clear(); |
| 303 } | 308 } |
| 304 | 309 |
| 305 void GuestViewBase::DispatchEvent(Event* event) { | 310 void GuestViewBase::DispatchEvent(Event* event) { |
| 306 scoped_ptr<Event> event_ptr(event); | 311 scoped_ptr<Event> event_ptr(event); |
| 307 if (!in_extension()) { | 312 if (!in_extension()) { |
| 308 NOTREACHED(); | 313 //NOTREACHED(); |
|
Fady Samuel
2014/07/09 14:54:17
This shouldn't be causing problems. Why did you co
lazyboy
2014/07/10 04:11:00
Right, all changes in this file are leftover from
| |
| 309 return; | 314 return; |
| 310 } | 315 } |
| 311 | 316 |
| 312 if (!attached()) { | 317 if (!attached()) { |
| 313 pending_events_.push_back(linked_ptr<Event>(event_ptr.release())); | 318 pending_events_.push_back(linked_ptr<Event>(event_ptr.release())); |
| 314 return; | 319 return; |
| 315 } | 320 } |
| 316 | 321 |
| 317 Profile* profile = Profile::FromBrowserContext(browser_context_); | 322 Profile* profile = Profile::FromBrowserContext(browser_context_); |
| 318 | 323 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 348 content::WebContents* guest_web_contents) { | 353 content::WebContents* guest_web_contents) { |
| 349 if (!guest_web_contents) { | 354 if (!guest_web_contents) { |
| 350 callback.Run(NULL); | 355 callback.Run(NULL); |
| 351 return; | 356 return; |
| 352 } | 357 } |
| 353 InitWithWebContents(embedder_extension_id, | 358 InitWithWebContents(embedder_extension_id, |
| 354 embedder_render_process_id, | 359 embedder_render_process_id, |
| 355 guest_web_contents); | 360 guest_web_contents); |
| 356 callback.Run(guest_web_contents); | 361 callback.Run(guest_web_contents); |
| 357 } | 362 } |
| OLD | NEW |