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

Side by Side Diff: chrome/browser/extensions/extension_debugger_api.cc

Issue 7464009: Removal of Profile from content part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: works now Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Implements the Chrome Extensions Debugger API. 5 // Implements the Chrome Extensions Debugger API.
6 6
7 #include "chrome/browser/extensions/extension_debugger_api.h" 7 #include "chrome/browser/extensions/extension_debugger_api.h"
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 const std::string& extension_id, 111 const std::string& extension_id,
112 int tab_id) 112 int tab_id)
113 : tab_contents_(tab_contents), 113 : tab_contents_(tab_contents),
114 extension_id_(extension_id), 114 extension_id_(extension_id),
115 tab_id_(tab_id), 115 tab_id_(tab_id),
116 last_request_id_(0) { 116 last_request_id_(0) {
117 AttachedClientHosts::GetInstance()->Add(this); 117 AttachedClientHosts::GetInstance()->Add(this);
118 118
119 // Detach from debugger when extension unloads. 119 // Detach from debugger when extension unloads.
120 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 120 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
121 Source<Profile>(tab_contents_->profile())); 121 Source<Profile>(
122 static_cast<Profile*>(tab_contents_->context())));
122 123
123 // Attach to debugger and tell it we are ready. 124 // Attach to debugger and tell it we are ready.
124 DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( 125 DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(
125 tab_contents_->render_view_host(), 126 tab_contents_->render_view_host(),
126 this); 127 this);
127 DevToolsManager::GetInstance()->ForwardToDevToolsAgent( 128 DevToolsManager::GetInstance()->ForwardToDevToolsAgent(
128 this, 129 this,
129 DevToolsAgentMsg_FrontendLoaded(MSG_ROUTING_NONE)); 130 DevToolsAgentMsg_FrontendLoaded(MSG_ROUTING_NONE));
130 } 131 }
131 132
132 ExtensionDevToolsClientHost::~ExtensionDevToolsClientHost() { 133 ExtensionDevToolsClientHost::~ExtensionDevToolsClientHost() {
133 AttachedClientHosts::GetInstance()->Remove(this); 134 AttachedClientHosts::GetInstance()->Remove(this);
134 } 135 }
135 136
136 bool ExtensionDevToolsClientHost::MatchesContentsAndExtensionId( 137 bool ExtensionDevToolsClientHost::MatchesContentsAndExtensionId(
137 TabContents* tab_contents, 138 TabContents* tab_contents,
138 const std::string& extension_id) { 139 const std::string& extension_id) {
139 return tab_contents == tab_contents_ && extension_id_ == extension_id; 140 return tab_contents == tab_contents_ && extension_id_ == extension_id;
140 } 141 }
141 142
142 // DevToolsClientHost interface 143 // DevToolsClientHost interface
143 void ExtensionDevToolsClientHost::InspectedTabClosing() { 144 void ExtensionDevToolsClientHost::InspectedTabClosing() {
144 // Tell extension that this client host has been detached. 145 // Tell extension that this client host has been detached.
145 Profile* profile = tab_contents_->profile(); 146 Profile* profile = static_cast<Profile*>(tab_contents_->context());
146 if (profile != NULL && profile->GetExtensionEventRouter()) { 147 if (profile != NULL && profile->GetExtensionEventRouter()) {
147 ListValue args; 148 ListValue args;
148 args.Append(Value::CreateIntegerValue(tab_id_)); 149 args.Append(Value::CreateIntegerValue(tab_id_));
149 150
150 std::string json_args; 151 std::string json_args;
151 base::JSONWriter::Write(&args, false, &json_args); 152 base::JSONWriter::Write(&args, false, &json_args);
152 153
153 profile->GetExtensionEventRouter()->DispatchEventToExtension( 154 profile->GetExtensionEventRouter()->DispatchEventToExtension(
154 extension_id_, keys::kOnDetach, json_args, profile, GURL()); 155 extension_id_, keys::kOnDetach, json_args, profile, GURL());
155 } 156 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 void ExtensionDevToolsClientHost::Observe( 199 void ExtensionDevToolsClientHost::Observe(
199 int type, 200 int type,
200 const NotificationSource& source, 201 const NotificationSource& source,
201 const NotificationDetails& details) { 202 const NotificationDetails& details) {
202 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED); 203 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED);
203 Close(); 204 Close();
204 } 205 }
205 206
206 void ExtensionDevToolsClientHost::OnDispatchOnInspectorFrontend( 207 void ExtensionDevToolsClientHost::OnDispatchOnInspectorFrontend(
207 const std::string& data) { 208 const std::string& data) {
208 Profile* profile = tab_contents_->profile(); 209 Profile* profile = static_cast<Profile*>(tab_contents_->context());
209 if (profile == NULL || !profile->GetExtensionEventRouter()) 210 if (profile == NULL || !profile->GetExtensionEventRouter())
210 return; 211 return;
211 212
212 scoped_ptr<Value> result(base::JSONReader::Read(data, false)); 213 scoped_ptr<Value> result(base::JSONReader::Read(data, false));
213 if (!result->IsType(Value::TYPE_DICTIONARY)) 214 if (!result->IsType(Value::TYPE_DICTIONARY))
214 return; 215 return;
215 DictionaryValue* dictionary = static_cast<DictionaryValue*>(result.get()); 216 DictionaryValue* dictionary = static_cast<DictionaryValue*>(result.get());
216 217
217 int id; 218 int id;
218 if (!dictionary->GetInteger("id", &id)) { 219 if (!dictionary->GetInteger("id", &id)) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 return; 355 return;
355 } 356 }
356 357
357 Value* result_body; 358 Value* result_body;
358 if (dictionary->Get("result", &result_body)) 359 if (dictionary->Get("result", &result_body))
359 result_.reset(result_body->DeepCopy()); 360 result_.reset(result_body->DeepCopy());
360 else 361 else
361 result_.reset(new DictionaryValue()); 362 result_.reset(new DictionaryValue());
362 SendResponse(true); 363 SendResponse(true);
363 } 364 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698