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

Side by Side Diff: components/guest_view/browser/guest_view_manager.cc

Issue 1102173002: Move GuestView layer in browser to components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test change to build Created 5 years, 8 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 "extensions/browser/guest_view/guest_view_manager.h" 5 #include "components/guest_view/browser/guest_view_manager.h"
6 6
7 #include "base/macros.h"
7 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "components/guest_view/browser/guest_view_base.h"
10 #include "components/guest_view/browser/guest_view_manager_delegate.h"
11 #include "components/guest_view/browser/guest_view_manager_factory.h"
12 #include "components/guest_view/common/guest_view_constants.h"
8 #include "content/public/browser/browser_context.h" 13 #include "content/public/browser/browser_context.h"
9 #include "content/public/browser/render_frame_host.h" 14 #include "content/public/browser/render_frame_host.h"
10 #include "content/public/browser/render_process_host.h" 15 #include "content/public/browser/render_process_host.h"
11 #include "content/public/browser/render_view_host.h" 16 #include "content/public/browser/render_view_host.h"
12 #include "content/public/browser/user_metrics.h" 17 #include "content/public/browser/user_metrics.h"
13 #include "content/public/browser/web_contents_observer.h" 18 #include "content/public/browser/web_contents_observer.h"
14 #include "content/public/common/child_process_host.h" 19 #include "content/public/common/child_process_host.h"
15 #include "content/public/common/result_codes.h" 20 #include "content/public/common/result_codes.h"
16 #include "content/public/common/url_constants.h" 21 #include "content/public/common/url_constants.h"
17 #include "extensions/browser/guest_view/guest_view_base.h"
18 #include "extensions/browser/guest_view/guest_view_manager_delegate.h"
19 #include "extensions/browser/guest_view/guest_view_manager_factory.h"
20 #include "extensions/common/guest_view/guest_view_constants.h"
21 #include "net/base/escape.h" 22 #include "net/base/escape.h"
22 #include "url/gurl.h" 23 #include "url/gurl.h"
23 24
24 using content::BrowserContext; 25 using content::BrowserContext;
25 using content::SiteInstance; 26 using content::SiteInstance;
26 using content::WebContents; 27 using content::WebContents;
27 using guestview::GuestViewManagerDelegate;
28 28
29 namespace extensions { 29 namespace guestview {
30 30
31 // static 31 // static
32 GuestViewManagerFactory* GuestViewManager::factory_ = nullptr; 32 GuestViewManagerFactory* GuestViewManager::factory_ = nullptr;
33 33
34 GuestViewManager::GuestViewManager( 34 GuestViewManager::GuestViewManager(
35 content::BrowserContext* context, 35 content::BrowserContext* context,
36 scoped_ptr<GuestViewManagerDelegate> delegate) 36 scoped_ptr<GuestViewManagerDelegate> delegate)
37 : current_instance_id_(0), 37 : current_instance_id_(0),
38 last_instance_id_removed_(0), 38 last_instance_id_removed_(0),
39 context_(context), 39 context_(context),
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } 266 }
267 267
268 bool GuestViewManager::IsGuestAvailableToContext(GuestViewBase* guest) { 268 bool GuestViewManager::IsGuestAvailableToContext(GuestViewBase* guest) {
269 return delegate_->IsGuestAvailableToContext(guest); 269 return delegate_->IsGuestAvailableToContext(guest);
270 } 270 }
271 271
272 void GuestViewManager::DispatchEvent(const std::string& event_name, 272 void GuestViewManager::DispatchEvent(const std::string& event_name,
273 scoped_ptr<base::DictionaryValue> args, 273 scoped_ptr<base::DictionaryValue> args,
274 GuestViewBase* guest, 274 GuestViewBase* guest,
275 int instance_id) { 275 int instance_id) {
276 delegate_->DispatchEvent(event_name, args.Pass(), guest, instance_id); 276 // TODO(fsamuel): GuestViewManager should probably do something more useful
277 // here like log an error if the event could not be dispatched.
278 ignore_result(
279 delegate_->DispatchEvent(event_name, args.Pass(), guest, instance_id));
277 } 280 }
278 281
279 content::WebContents* GuestViewManager::GetGuestByInstanceID( 282 content::WebContents* GuestViewManager::GetGuestByInstanceID(
280 int guest_instance_id) { 283 int guest_instance_id) {
281 auto it = guest_web_contents_by_instance_id_.find(guest_instance_id); 284 auto it = guest_web_contents_by_instance_id_.find(guest_instance_id);
282 if (it == guest_web_contents_by_instance_id_.end()) 285 if (it == guest_web_contents_by_instance_id_.end())
283 return nullptr; 286 return nullptr;
284 return it->second; 287 return it->second;
285 } 288 }
286 289
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 368
366 return element_instance_id < other.element_instance_id; 369 return element_instance_id < other.element_instance_id;
367 } 370 }
368 371
369 bool GuestViewManager::ElementInstanceKey::operator==( 372 bool GuestViewManager::ElementInstanceKey::operator==(
370 const GuestViewManager::ElementInstanceKey& other) const { 373 const GuestViewManager::ElementInstanceKey& other) const {
371 return (embedder_process_id == other.embedder_process_id) && 374 return (embedder_process_id == other.embedder_process_id) &&
372 (element_instance_id == other.element_instance_id); 375 (element_instance_id == other.element_instance_id);
373 } 376 }
374 377
375 } // namespace extensions 378 } // namespace guestview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698