OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/devtools/devtools_targets_ui.h" | 5 #include "chrome/browser/devtools/devtools_targets_ui.h" |
6 | 6 |
7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "base/version.h" | 11 #include "base/version.h" |
12 #include "chrome/browser/devtools/device/devtools_android_bridge.h" | 12 #include "chrome/browser/devtools/device/devtools_android_bridge.h" |
13 #include "chrome/browser/devtools/devtools_target_impl.h" | 13 #include "chrome/browser/devtools/devtools_target_impl.h" |
| 14 #include "chrome/browser/guest_view/guest_view_base.h" |
14 #include "chrome/common/chrome_version_info.h" | 15 #include "chrome/common/chrome_version_info.h" |
15 #include "content/public/browser/browser_child_process_observer.h" | 16 #include "content/public/browser/browser_child_process_observer.h" |
16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/browser/child_process_data.h" | 18 #include "content/public/browser/child_process_data.h" |
18 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
19 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
20 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
21 #include "content/public/browser/notification_source.h" | 22 #include "content/public/browser/notification_source.h" |
22 #include "content/public/browser/notification_types.h" | 23 #include "content/public/browser/notification_types.h" |
23 #include "content/public/browser/render_frame_host.h" | 24 #include "content/public/browser/render_frame_host.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 71 |
71 class CancelableTimer { | 72 class CancelableTimer { |
72 public: | 73 public: |
73 CancelableTimer(base::Closure callback, base::TimeDelta delay) | 74 CancelableTimer(base::Closure callback, base::TimeDelta delay) |
74 : callback_(callback), | 75 : callback_(callback), |
75 weak_factory_(this) { | 76 weak_factory_(this) { |
76 base::MessageLoop::current()->PostDelayedTask( | 77 base::MessageLoop::current()->PostDelayedTask( |
77 FROM_HERE, | 78 FROM_HERE, |
78 base::Bind(&CancelableTimer::Fire, weak_factory_.GetWeakPtr()), | 79 base::Bind(&CancelableTimer::Fire, weak_factory_.GetWeakPtr()), |
79 delay); | 80 delay); |
80 }; | 81 } |
81 | 82 |
82 private: | 83 private: |
83 void Fire() { callback_.Run(); } | 84 void Fire() { callback_.Run(); } |
84 | 85 |
85 base::Closure callback_; | 86 base::Closure callback_; |
86 base::WeakPtrFactory<CancelableTimer> weak_factory_; | 87 base::WeakPtrFactory<CancelableTimer> weak_factory_; |
87 }; | 88 }; |
88 | 89 |
89 // RenderViewHostTargetsUIHandler --------------------------------------------- | 90 // RenderViewHostTargetsUIHandler --------------------------------------------- |
90 | 91 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 list_value->Append(descriptor); | 169 list_value->Append(descriptor); |
169 } | 170 } |
170 } | 171 } |
171 | 172 |
172 // Add the list of nested targets to each of its owners. | 173 // Add the list of nested targets to each of its owners. |
173 for (std::vector<RenderFrameHost*>::iterator it(nested_frames.begin()); | 174 for (std::vector<RenderFrameHost*>::iterator it(nested_frames.begin()); |
174 it != nested_frames.end(); ++it) { | 175 it != nested_frames.end(); ++it) { |
175 RenderFrameHost* rfh = (*it); | 176 RenderFrameHost* rfh = (*it); |
176 RenderFrameHost* parent_rfh = NULL; | 177 RenderFrameHost* parent_rfh = NULL; |
177 content::RenderViewHost* rvh = rfh->GetRenderViewHost(); | 178 content::RenderViewHost* rvh = rfh->GetRenderViewHost(); |
178 if (rvh->GetProcess()->IsGuest()) { | 179 WebContents* nested_web_contents = WebContents::FromRenderViewHost(rvh); |
179 WebContents* nested_web_contents = WebContents::FromRenderViewHost(rvh); | 180 GuestViewBase* guest = GuestViewBase::FromWebContents(nested_web_contents); |
180 WebContents* embedder = nested_web_contents->GetEmbedderWebContents(); | 181 if (guest) { |
| 182 WebContents* embedder = guest->embedder_web_contents(); |
181 parent_rfh = embedder->GetRenderViewHost()->GetMainFrame(); | 183 parent_rfh = embedder->GetRenderViewHost()->GetMainFrame(); |
182 } else { | 184 } else { |
183 parent_rfh = rfh->GetParent(); | 185 parent_rfh = rfh->GetParent(); |
184 DCHECK(parent_rfh); | 186 DCHECK(parent_rfh); |
185 } | 187 } |
186 if (parent_rfh && rfh_to_descriptor.count(parent_rfh) > 0) { | 188 if (parent_rfh && rfh_to_descriptor.count(parent_rfh) > 0) { |
187 base::DictionaryValue* parent = rfh_to_descriptor[parent_rfh]; | 189 base::DictionaryValue* parent = rfh_to_descriptor[parent_rfh]; |
188 base::ListValue* guests = NULL; | 190 base::ListValue* guests = NULL; |
189 if (!parent->GetList(kGuestList, &guests)) { | 191 if (!parent->GetList(kGuestList, &guests)) { |
190 guests = new base::ListValue(); | 192 guests = new base::ListValue(); |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 base::StringPrintf("%d", it->first), it->second); | 584 base::StringPrintf("%d", it->first), it->second); |
583 } | 585 } |
584 | 586 |
585 std::string device_id = base::StringPrintf( | 587 std::string device_id = base::StringPrintf( |
586 kAdbDeviceIdFormat, | 588 kAdbDeviceIdFormat, |
587 sit->first.c_str()); | 589 sit->first.c_str()); |
588 result.Set(device_id, device_status_dict); | 590 result.Set(device_id, device_status_dict); |
589 } | 591 } |
590 callback_.Run(result); | 592 callback_.Run(result); |
591 } | 593 } |
OLD | NEW |