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

Side by Side Diff: extensions/renderer/guest_view/guest_view_container.cc

Issue 598173003: Run clang-modernize -use-nullptr over src/extensions/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/renderer/guest_view/guest_view_container.h" 5 #include "extensions/renderer/guest_view/guest_view_container.h"
6 6
7 #include "content/public/renderer/browser_plugin_delegate.h" 7 #include "content/public/renderer/browser_plugin_delegate.h"
8 #include "content/public/renderer/render_frame.h" 8 #include "content/public/renderer/render_frame.h"
9 #include "content/public/renderer/render_view.h" 9 #include "content/public/renderer/render_view.h"
10 #include "extensions/common/extension_messages.h" 10 #include "extensions/common/extension_messages.h"
11 #include "extensions/common/guest_view/guest_view_constants.h" 11 #include "extensions/common/guest_view/guest_view_constants.h"
12 #include "third_party/WebKit/public/web/WebLocalFrame.h" 12 #include "third_party/WebKit/public/web/WebLocalFrame.h"
13 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" 13 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
14 #include "third_party/WebKit/public/web/WebView.h" 14 #include "third_party/WebKit/public/web/WebView.h"
15 15
16 namespace { 16 namespace {
17 typedef std::pair<int, int> GuestViewID; 17 typedef std::pair<int, int> GuestViewID;
18 typedef std::map<GuestViewID, extensions::GuestViewContainer*> 18 typedef std::map<GuestViewID, extensions::GuestViewContainer*>
19 GuestViewContainerMap; 19 GuestViewContainerMap;
20 static base::LazyInstance<GuestViewContainerMap> g_guest_view_container_map = 20 static base::LazyInstance<GuestViewContainerMap> g_guest_view_container_map =
21 LAZY_INSTANCE_INITIALIZER; 21 LAZY_INSTANCE_INITIALIZER;
22 } // namespace 22 } // namespace
23 23
24 namespace extensions { 24 namespace extensions {
25 25
26 GuestViewContainer::GuestViewContainer( 26 GuestViewContainer::GuestViewContainer(content::RenderFrame* render_frame,
27 content::RenderFrame* render_frame, 27 const std::string& mime_type)
28 const std::string& mime_type)
29 : content::BrowserPluginDelegate(render_frame, mime_type), 28 : content::BrowserPluginDelegate(render_frame, mime_type),
30 content::RenderFrameObserver(render_frame), 29 content::RenderFrameObserver(render_frame),
31 mime_type_(mime_type), 30 mime_type_(mime_type),
32 element_instance_id_(guestview::kInstanceIDNone), 31 element_instance_id_(guestview::kInstanceIDNone),
33 render_view_routing_id_(render_frame->GetRenderView()->GetRoutingID()), 32 render_view_routing_id_(render_frame->GetRenderView()->GetRoutingID()),
34 attached_(false), 33 attached_(false),
35 attach_pending_(false), 34 attach_pending_(false),
36 isolate_(NULL) { 35 isolate_(nullptr) {
37 } 36 }
38 37
39 GuestViewContainer::~GuestViewContainer() { 38 GuestViewContainer::~GuestViewContainer() {
40 if (element_instance_id_ != guestview::kInstanceIDNone) { 39 if (element_instance_id_ != guestview::kInstanceIDNone) {
41 g_guest_view_container_map.Get().erase( 40 g_guest_view_container_map.Get().erase(
42 GuestViewID(render_view_routing_id_, element_instance_id_)); 41 GuestViewID(render_view_routing_id_, element_instance_id_));
43 } 42 }
44 } 43 }
45 44
46 GuestViewContainer* GuestViewContainer::FromID(int render_view_routing_id, 45 GuestViewContainer* GuestViewContainer::FromID(int render_view_routing_id,
47 int element_instance_id) { 46 int element_instance_id) {
48 GuestViewContainerMap* guest_view_containers = 47 GuestViewContainerMap* guest_view_containers =
49 g_guest_view_container_map.Pointer(); 48 g_guest_view_container_map.Pointer();
50 GuestViewContainerMap::iterator it = guest_view_containers->find( 49 GuestViewContainerMap::iterator it = guest_view_containers->find(
51 GuestViewID(render_view_routing_id, element_instance_id)); 50 GuestViewID(render_view_routing_id, element_instance_id));
52 return it == guest_view_containers->end() ? NULL : it->second; 51 return it == guest_view_containers->end() ? nullptr : it->second;
53 } 52 }
54 53
55 54
56 void GuestViewContainer::AttachGuest(int element_instance_id, 55 void GuestViewContainer::AttachGuest(int element_instance_id,
57 int guest_instance_id, 56 int guest_instance_id,
58 scoped_ptr<base::DictionaryValue> params, 57 scoped_ptr<base::DictionaryValue> params,
59 v8::Handle<v8::Function> callback, 58 v8::Handle<v8::Function> callback,
60 v8::Isolate* isolate) { 59 v8::Isolate* isolate) {
61 // GuestViewContainer supports reattachment (i.e. attached_ == true) but not 60 // GuestViewContainer supports reattachment (i.e. attached_ == true) but not
62 // while a current attach process is pending. 61 // while a current attach process is pending.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 case ExtensionMsg_CreateMimeHandlerViewGuestACK::ID: 176 case ExtensionMsg_CreateMimeHandlerViewGuestACK::ID:
178 case ExtensionMsg_GuestAttached::ID: 177 case ExtensionMsg_GuestAttached::ID:
179 return true; 178 return true;
180 default: 179 default:
181 break; 180 break;
182 } 181 }
183 return false; 182 return false;
184 } 183 }
185 184
186 } // namespace extensions 185 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698