OLD | NEW |
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_tabstrip.h" |
25 #include "chrome/browser/ui/browser_window.h" | 26 #include "chrome/browser/ui/browser_window.h" |
26 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 27 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
27 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
28 #include "chrome/common/chrome_notification_types.h" | 29 #include "chrome/common/chrome_notification_types.h" |
29 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
30 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
31 #include "chrome/common/render_messages.h" | 32 #include "chrome/common/render_messages.h" |
32 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
33 #include "content/public/browser/content_browser_client.h" | 34 #include "content/public/browser/content_browser_client.h" |
34 #include "content/public/browser/devtools_agent_host_registry.h" | 35 #include "content/public/browser/devtools_agent_host_registry.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 167 } |
167 | 168 |
168 | 169 |
169 DevToolsWindow* DevToolsWindow::Create( | 170 DevToolsWindow* DevToolsWindow::Create( |
170 Profile* profile, | 171 Profile* profile, |
171 RenderViewHost* inspected_rvh, | 172 RenderViewHost* inspected_rvh, |
172 bool docked, | 173 bool docked, |
173 bool shared_worker_frontend) { | 174 bool shared_worker_frontend) { |
174 // Create TabContents with devtools. | 175 // Create TabContents with devtools. |
175 TabContents* tab_contents = | 176 TabContents* tab_contents = |
176 Browser::TabContentsFactory(profile, NULL, MSG_ROUTING_NONE, NULL, NULL); | 177 chrome::TabContentsFactory(profile, NULL, MSG_ROUTING_NONE, NULL, NULL); |
177 tab_contents->web_contents()->GetRenderViewHost()->AllowBindings( | 178 tab_contents->web_contents()->GetRenderViewHost()->AllowBindings( |
178 content::BINDINGS_POLICY_WEB_UI); | 179 content::BINDINGS_POLICY_WEB_UI); |
179 tab_contents->web_contents()->GetController().LoadURL( | 180 tab_contents->web_contents()->GetController().LoadURL( |
180 GetDevToolsUrl(profile, docked, shared_worker_frontend), | 181 GetDevToolsUrl(profile, docked, shared_worker_frontend), |
181 content::Referrer(), | 182 content::Referrer(), |
182 content::PAGE_TRANSITION_START_PAGE, | 183 content::PAGE_TRANSITION_START_PAGE, |
183 std::string()); | 184 std::string()); |
184 return new DevToolsWindow(tab_contents, profile, inspected_rvh, docked); | 185 return new DevToolsWindow(tab_contents, profile, inspected_rvh, docked); |
185 } | 186 } |
186 | 187 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // In case of docked tab_contents we own it, so delete here. | 251 // In case of docked tab_contents we own it, so delete here. |
251 delete tab_contents_; | 252 delete tab_contents_; |
252 | 253 |
253 delete this; | 254 delete this; |
254 } else { | 255 } else { |
255 // First, initiate self-destruct to free all the registrars. | 256 // First, initiate self-destruct to free all the registrars. |
256 // Then close all tabs. Browser will take care of deleting tab_contents | 257 // Then close all tabs. Browser will take care of deleting tab_contents |
257 // for us. | 258 // for us. |
258 Browser* browser = browser_; | 259 Browser* browser = browser_; |
259 delete this; | 260 delete this; |
260 browser->CloseAllTabs(); | 261 chrome::CloseAllTabs(browser); |
261 } | 262 } |
262 } | 263 } |
263 | 264 |
264 void DevToolsWindow::ContentsReplaced(WebContents* new_contents) { | 265 void DevToolsWindow::ContentsReplaced(WebContents* new_contents) { |
265 TabContents* new_tab_contents = TabContents::FromWebContents(new_contents); | 266 TabContents* new_tab_contents = TabContents::FromWebContents(new_contents); |
266 DCHECK(new_tab_contents); | 267 DCHECK(new_tab_contents); |
267 if (!new_tab_contents) | 268 if (!new_tab_contents) |
268 return; | 269 return; |
269 DCHECK_EQ(profile_, new_tab_contents->profile()); | 270 DCHECK_EQ(profile_, new_tab_contents->profile()); |
270 inspected_tab_ = new_tab_contents; | 271 inspected_tab_ = new_tab_contents; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 browser_->tab_strip_model()->AddTabContents( | 382 browser_->tab_strip_model()->AddTabContents( |
382 tab_contents_, -1, content::PAGE_TRANSITION_START_PAGE, | 383 tab_contents_, -1, content::PAGE_TRANSITION_START_PAGE, |
383 TabStripModel::ADD_ACTIVE); | 384 TabStripModel::ADD_ACTIVE); |
384 } | 385 } |
385 | 386 |
386 bool DevToolsWindow::FindInspectedBrowserAndTabIndex(Browser** browser, | 387 bool DevToolsWindow::FindInspectedBrowserAndTabIndex(Browser** browser, |
387 int* tab) { | 388 int* tab) { |
388 if (!inspected_tab_) | 389 if (!inspected_tab_) |
389 return false; | 390 return false; |
390 | 391 |
391 const NavigationController& controller = | |
392 inspected_tab_->web_contents()->GetController(); | |
393 for (BrowserList::const_iterator it = BrowserList::begin(); | 392 for (BrowserList::const_iterator it = BrowserList::begin(); |
394 it != BrowserList::end(); ++it) { | 393 it != BrowserList::end(); ++it) { |
395 int tab_index = (*it)->GetIndexOfController(&controller); | 394 int tab_index = chrome::GetIndexOfTab(*it, inspected_tab_->web_contents()); |
396 if (tab_index != TabStripModel::kNoTab) { | 395 if (tab_index != TabStripModel::kNoTab) { |
397 *browser = *it; | 396 *browser = *it; |
398 *tab = tab_index; | 397 *tab = tab_index; |
399 return true; | 398 return true; |
400 } | 399 } |
401 } | 400 } |
402 return false; | 401 return false; |
403 } | 402 } |
404 | 403 |
405 BrowserWindow* DevToolsWindow::GetInspectedBrowserWindow() { | 404 BrowserWindow* DevToolsWindow::GetInspectedBrowserWindow() { |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 CallClientFunction("InspectorFrontendAPI.appendedToURL", &url_value); | 744 CallClientFunction("InspectorFrontendAPI.appendedToURL", &url_value); |
746 } | 745 } |
747 | 746 |
748 content::JavaScriptDialogCreator* DevToolsWindow::GetJavaScriptDialogCreator() { | 747 content::JavaScriptDialogCreator* DevToolsWindow::GetJavaScriptDialogCreator() { |
749 if (inspected_tab_ && inspected_tab_->web_contents()->GetDelegate()) { | 748 if (inspected_tab_ && inspected_tab_->web_contents()->GetDelegate()) { |
750 return inspected_tab_->web_contents()->GetDelegate()-> | 749 return inspected_tab_->web_contents()->GetDelegate()-> |
751 GetJavaScriptDialogCreator(); | 750 GetJavaScriptDialogCreator(); |
752 } | 751 } |
753 return content::WebContentsDelegate::GetJavaScriptDialogCreator(); | 752 return content::WebContentsDelegate::GetJavaScriptDialogCreator(); |
754 } | 753 } |
OLD | NEW |