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

Side by Side Diff: chrome/browser/debugger/devtools_window.cc

Issue 10533051: TabContentsWrapper -> TabContents, part 10. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
« no previous file with comments | « chrome/browser/debugger/devtools_window.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/debugger/devtools_window.h" 15 #include "chrome/browser/debugger/devtools_window.h"
16 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/prefs/pref_service.h" 17 #include "chrome/browser/prefs/pref_service.h"
18 #include "chrome/browser/prefs/scoped_user_pref_update.h" 18 #include "chrome/browser/prefs/scoped_user_pref_update.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/sessions/restore_tab_helper.h" 20 #include "chrome/browser/sessions/restore_tab_helper.h"
21 #include "chrome/browser/themes/theme_service.h" 21 #include "chrome/browser/themes/theme_service.h"
22 #include "chrome/browser/themes/theme_service_factory.h" 22 #include "chrome/browser/themes/theme_service_factory.h"
23 #include "chrome/browser/ui/browser.h" 23 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_list.h" 24 #include "chrome/browser/ui/browser_list.h"
25 #include "chrome/browser/ui/browser_window.h" 25 #include "chrome/browser/ui/browser_window.h"
26 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 26 #include "chrome/browser/ui/tab_contents/tab_contents.h"
27 #include "chrome/browser/ui/tabs/tab_strip_model.h" 27 #include "chrome/browser/ui/tabs/tab_strip_model.h"
28 #include "chrome/common/chrome_notification_types.h" 28 #include "chrome/common/chrome_notification_types.h"
29 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
31 #include "chrome/common/render_messages.h" 31 #include "chrome/common/render_messages.h"
32 #include "chrome/common/url_constants.h" 32 #include "chrome/common/url_constants.h"
33 #include "content/public/browser/content_browser_client.h" 33 #include "content/public/browser/content_browser_client.h"
34 #include "content/public/browser/devtools_agent_host_registry.h" 34 #include "content/public/browser/devtools_agent_host_registry.h"
35 #include "content/public/browser/devtools_manager.h" 35 #include "content/public/browser/devtools_manager.h"
36 #include "content/public/browser/favicon_status.h" 36 #include "content/public/browser/favicon_status.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 true, 74 true,
75 PrefService::UNSYNCABLE_PREF); 75 PrefService::UNSYNCABLE_PREF);
76 prefs->RegisterStringPref(prefs::kDevToolsDockSide, 76 prefs->RegisterStringPref(prefs::kDevToolsDockSide,
77 kDockSideBottom, 77 kDockSideBottom,
78 PrefService::UNSYNCABLE_PREF); 78 PrefService::UNSYNCABLE_PREF);
79 prefs->RegisterDictionaryPref(prefs::kDevToolsEditedFiles, 79 prefs->RegisterDictionaryPref(prefs::kDevToolsEditedFiles,
80 PrefService::UNSYNCABLE_PREF); 80 PrefService::UNSYNCABLE_PREF);
81 } 81 }
82 82
83 // static 83 // static
84 TabContentsWrapper* DevToolsWindow::GetDevToolsContents( 84 TabContents* DevToolsWindow::GetDevToolsContents(WebContents* inspected_tab) {
85 WebContents* inspected_tab) {
86 if (!inspected_tab) 85 if (!inspected_tab)
87 return NULL; 86 return NULL;
88 87
89 if (!DevToolsAgentHostRegistry::HasDevToolsAgentHost( 88 if (!DevToolsAgentHostRegistry::HasDevToolsAgentHost(
90 inspected_tab->GetRenderViewHost())) 89 inspected_tab->GetRenderViewHost()))
91 return NULL; 90 return NULL;
92 DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost( 91 DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost(
93 inspected_tab->GetRenderViewHost()); 92 inspected_tab->GetRenderViewHost());
94 DevToolsManager* manager = DevToolsManager::GetInstance(); 93 DevToolsManager* manager = DevToolsManager::GetInstance();
95 DevToolsClientHost* client_host = manager->GetDevToolsClientHostFor(agent); 94 DevToolsClientHost* client_host = manager->GetDevToolsClientHostFor(agent);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // renderer. Otherwise, we still can hit a race condition here. 164 // renderer. Otherwise, we still can hit a race condition here.
166 OpenDevToolsWindow(inspected_rvh); 165 OpenDevToolsWindow(inspected_rvh);
167 } 166 }
168 167
169 168
170 DevToolsWindow* DevToolsWindow::Create( 169 DevToolsWindow* DevToolsWindow::Create(
171 Profile* profile, 170 Profile* profile,
172 RenderViewHost* inspected_rvh, 171 RenderViewHost* inspected_rvh,
173 bool docked, 172 bool docked,
174 bool shared_worker_frontend) { 173 bool shared_worker_frontend) {
175 // Create TabContentsWrapper with devtools. 174 // Create TabContents with devtools.
176 TabContentsWrapper* tab_contents = 175 TabContents* tab_contents =
177 Browser::TabContentsFactory(profile, NULL, MSG_ROUTING_NONE, NULL, NULL); 176 Browser::TabContentsFactory(profile, NULL, MSG_ROUTING_NONE, NULL, NULL);
178 tab_contents->web_contents()->GetRenderViewHost()->AllowBindings( 177 tab_contents->web_contents()->GetRenderViewHost()->AllowBindings(
179 content::BINDINGS_POLICY_WEB_UI); 178 content::BINDINGS_POLICY_WEB_UI);
180 tab_contents->web_contents()->GetController().LoadURL( 179 tab_contents->web_contents()->GetController().LoadURL(
181 GetDevToolsUrl(profile, docked, shared_worker_frontend), 180 GetDevToolsUrl(profile, docked, shared_worker_frontend),
182 content::Referrer(), 181 content::Referrer(),
183 content::PAGE_TRANSITION_START_PAGE, 182 content::PAGE_TRANSITION_START_PAGE,
184 std::string()); 183 std::string());
185 return new DevToolsWindow(tab_contents, profile, inspected_rvh, docked); 184 return new DevToolsWindow(tab_contents, profile, inspected_rvh, docked);
186 } 185 }
187 186
188 DevToolsWindow::DevToolsWindow(TabContentsWrapper* tab_contents, 187 DevToolsWindow::DevToolsWindow(TabContents* tab_contents,
189 Profile* profile, 188 Profile* profile,
190 RenderViewHost* inspected_rvh, 189 RenderViewHost* inspected_rvh,
191 bool docked) 190 bool docked)
192 : profile_(profile), 191 : profile_(profile),
193 inspected_tab_(NULL), 192 inspected_tab_(NULL),
194 tab_contents_(tab_contents), 193 tab_contents_(tab_contents),
195 browser_(NULL), 194 browser_(NULL),
196 docked_(docked), 195 docked_(docked),
197 is_loaded_(false), 196 is_loaded_(false),
198 action_on_load_(DEVTOOLS_TOGGLE_ACTION_NONE) { 197 action_on_load_(DEVTOOLS_TOGGLE_ACTION_NONE) {
(...skipping 22 matching lines...) Expand all
221 &tab_contents_->web_contents()->GetController())); 220 &tab_contents_->web_contents()->GetController()));
222 registrar_.Add( 221 registrar_.Add(
223 this, 222 this,
224 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, 223 chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
225 content::Source<ThemeService>( 224 content::Source<ThemeService>(
226 ThemeServiceFactory::GetForProfile(profile_))); 225 ThemeServiceFactory::GetForProfile(profile_)));
227 // There is no inspected_rvh in case of shared workers. 226 // There is no inspected_rvh in case of shared workers.
228 if (inspected_rvh) { 227 if (inspected_rvh) {
229 WebContents* tab = WebContents::FromRenderViewHost(inspected_rvh); 228 WebContents* tab = WebContents::FromRenderViewHost(inspected_rvh);
230 if (tab) 229 if (tab)
231 inspected_tab_ = TabContentsWrapper::GetCurrentWrapperForContents(tab); 230 inspected_tab_ = TabContents::GetOwningTabContentsForWebContents(tab);
232 } 231 }
233 } 232 }
234 233
235 DevToolsWindow::~DevToolsWindow() { 234 DevToolsWindow::~DevToolsWindow() {
236 DevToolsWindowList& instances = g_instances.Get(); 235 DevToolsWindowList& instances = g_instances.Get();
237 DevToolsWindowList::iterator it = std::find(instances.begin(), 236 DevToolsWindowList::iterator it = std::find(instances.begin(),
238 instances.end(), 237 instances.end(),
239 this); 238 this);
240 DCHECK(it != instances.end()); 239 DCHECK(it != instances.end());
241 instances.erase(it); 240 instances.erase(it);
(...skipping 14 matching lines...) Expand all
256 // First, initiate self-destruct to free all the registrars. 255 // First, initiate self-destruct to free all the registrars.
257 // Then close all tabs. Browser will take care of deleting tab_contents 256 // Then close all tabs. Browser will take care of deleting tab_contents
258 // for us. 257 // for us.
259 Browser* browser = browser_; 258 Browser* browser = browser_;
260 delete this; 259 delete this;
261 browser->CloseAllTabs(); 260 browser->CloseAllTabs();
262 } 261 }
263 } 262 }
264 263
265 void DevToolsWindow::ContentsReplaced(WebContents* new_contents) { 264 void DevToolsWindow::ContentsReplaced(WebContents* new_contents) {
266 TabContentsWrapper* new_tab_wrapper = 265 TabContents* new_tab_contents =
267 TabContentsWrapper::GetCurrentWrapperForContents(new_contents); 266 TabContents::GetOwningTabContentsForWebContents(new_contents);
268 DCHECK(new_tab_wrapper); 267 DCHECK(new_tab_contents);
269 if (!new_tab_wrapper) 268 if (!new_tab_contents)
270 return; 269 return;
271 DCHECK_EQ(profile_, new_tab_wrapper->profile()); 270 DCHECK_EQ(profile_, new_tab_contents->profile());
272 inspected_tab_ = new_tab_wrapper; 271 inspected_tab_ = new_tab_contents;
273 } 272 }
274 273
275 void DevToolsWindow::Show(DevToolsToggleAction action) { 274 void DevToolsWindow::Show(DevToolsToggleAction action) {
276 if (docked_) { 275 if (docked_) {
277 Browser* inspected_browser; 276 Browser* inspected_browser;
278 int inspected_tab_index; 277 int inspected_tab_index;
279 // Tell inspected browser to update splitter and switch to inspected panel. 278 // Tell inspected browser to update splitter and switch to inspected panel.
280 if (!IsInspectedBrowserPopupOrPanel() && 279 if (!IsInspectedBrowserPopupOrPanel() &&
281 FindInspectedBrowserAndTabIndex(&inspected_browser, 280 FindInspectedBrowserAndTabIndex(&inspected_browser,
282 &inspected_tab_index)) { 281 &inspected_tab_index)) {
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 CallClientFunction("InspectorFrontendAPI.appendedToURL", &url_value); 750 CallClientFunction("InspectorFrontendAPI.appendedToURL", &url_value);
752 } 751 }
753 752
754 content::JavaScriptDialogCreator* DevToolsWindow::GetJavaScriptDialogCreator() { 753 content::JavaScriptDialogCreator* DevToolsWindow::GetJavaScriptDialogCreator() {
755 if (inspected_tab_ && inspected_tab_->web_contents()->GetDelegate()) { 754 if (inspected_tab_ && inspected_tab_->web_contents()->GetDelegate()) {
756 return inspected_tab_->web_contents()->GetDelegate()-> 755 return inspected_tab_->web_contents()->GetDelegate()->
757 GetJavaScriptDialogCreator(); 756 GetJavaScriptDialogCreator();
758 } 757 }
759 return content::WebContentsDelegate::GetJavaScriptDialogCreator(); 758 return content::WebContentsDelegate::GetJavaScriptDialogCreator();
760 } 759 }
OLDNEW
« no previous file with comments | « chrome/browser/debugger/devtools_window.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698