Remove inspectable_web_contents_

This commit is contained in:
Cheng Zhao 2015-06-25 14:32:38 +08:00
parent b2a8678c47
commit 01dc0f973c
2 changed files with 7 additions and 18 deletions

View file

@ -140,8 +140,7 @@ content::ServiceWorkerContext* GetServiceWorkerContext(
WebContents::WebContents(content::WebContents* web_contents) WebContents::WebContents(content::WebContents* web_contents)
: content::WebContentsObserver(web_contents), : content::WebContentsObserver(web_contents),
type_(REMOTE), type_(REMOTE) {
inspectable_web_contents_(nullptr) {
AttachAsUserData(web_contents); AttachAsUserData(web_contents);
} }
@ -168,7 +167,6 @@ WebContents::WebContents(const mate::Dictionary& options) {
Observe(web_contents); Observe(web_contents);
AttachAsUserData(web_contents); AttachAsUserData(web_contents);
InitWithWebContents(web_contents); InitWithWebContents(web_contents);
inspectable_web_contents_ = managed_web_contents();
if (is_guest) { if (is_guest) {
guest_delegate_->Initialize(this); guest_delegate_->Initialize(this);
@ -575,21 +573,22 @@ void WebContents::OpenDevTools(mate::Arguments* args) {
mate::Dictionary options; mate::Dictionary options;
args->GetNext(&options) && options.Get("detach", &detach); args->GetNext(&options) && options.Get("detach", &detach);
} }
inspectable_web_contents()->SetCanDock(!detach); managed_web_contents()->SetCanDock(!detach);
inspectable_web_contents()->ShowDevTools(); managed_web_contents()->ShowDevTools();
} }
void WebContents::CloseDevTools() { void WebContents::CloseDevTools() {
if (type_ == REMOTE) if (type_ == REMOTE)
return; return;
inspectable_web_contents()->CloseDevTools(); managed_web_contents()->CloseDevTools();
} }
bool WebContents::IsDevToolsOpened() { bool WebContents::IsDevToolsOpened() {
if (type_ == REMOTE) if (type_ == REMOTE)
return false; return false;
return inspectable_web_contents()->IsDevToolsViewShowing();
return managed_web_contents()->IsDevToolsViewShowing();
} }
void WebContents::ToggleDevTools() { void WebContents::ToggleDevTools() {
@ -617,7 +616,7 @@ void WebContents::InspectServiceWorker() {
if (agent_host->GetType() == if (agent_host->GetType() ==
content::DevToolsAgentHost::TYPE_SERVICE_WORKER) { content::DevToolsAgentHost::TYPE_SERVICE_WORKER) {
OpenDevTools(nullptr); OpenDevTools(nullptr);
inspectable_web_contents()->AttachTo(agent_host); managed_web_contents()->AttachTo(agent_host);
break; break;
} }
} }

View file

@ -105,12 +105,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
void SetAllowTransparency(bool allow); void SetAllowTransparency(bool allow);
bool IsGuest() const; bool IsGuest() const;
// Returns the current InspectableWebContents object, nullptr will be returned
// if current WebContents can not beinspected, e.g. it is the devtools.
brightray::InspectableWebContents* inspectable_web_contents() const {
return inspectable_web_contents_;
}
protected: protected:
explicit WebContents(content::WebContents* web_contents); explicit WebContents(content::WebContents* web_contents);
explicit WebContents(const mate::Dictionary& options); explicit WebContents(const mate::Dictionary& options);
@ -217,10 +211,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
// The type of current WebContents. // The type of current WebContents.
Type type_; Type type_;
// Current InspectableWebContents object, can be nullptr for WebContents of
// devtools. It is a weak reference.
brightray::InspectableWebContents* inspectable_web_contents_;
DISALLOW_COPY_AND_ASSIGN(WebContents); DISALLOW_COPY_AND_ASSIGN(WebContents);
}; };