OLD | NEW |
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 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/json/json_writer.h" | 6 #include "base/json/json_writer.h" |
7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/extensions/extension_service.h" | |
13 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
14 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 13 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
15 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/sessions/restore_tab_helper.h" | 15 #include "chrome/browser/sessions/restore_tab_helper.h" |
17 #include "chrome/browser/tabs/tab_strip_model.h" | 16 #include "chrome/browser/tabs/tab_strip_model.h" |
18 #include "chrome/browser/themes/theme_service.h" | 17 #include "chrome/browser/themes/theme_service.h" |
19 #include "chrome/browser/themes/theme_service_factory.h" | 18 #include "chrome/browser/themes/theme_service_factory.h" |
20 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_list.h" |
22 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
23 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
24 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
25 #include "chrome/common/render_messages.h" | 24 #include "chrome/common/render_messages.h" |
26 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
| 26 #include "content/browser/content_browser_client.h" |
27 #include "content/browser/debugger/devtools_manager.h" | 27 #include "content/browser/debugger/devtools_manager.h" |
28 #include "content/browser/debugger/devtools_window.h" | 28 #include "content/browser/debugger/devtools_window.h" |
29 #include "content/browser/in_process_webkit/session_storage_namespace.h" | 29 #include "content/browser/in_process_webkit/session_storage_namespace.h" |
30 #include "content/browser/load_notification_details.h" | 30 #include "content/browser/load_notification_details.h" |
31 #include "content/browser/renderer_host/render_view_host.h" | 31 #include "content/browser/renderer_host/render_view_host.h" |
32 #include "content/browser/tab_contents/navigation_controller.h" | 32 #include "content/browser/tab_contents/navigation_controller.h" |
33 #include "content/browser/tab_contents/navigation_entry.h" | 33 #include "content/browser/tab_contents/navigation_entry.h" |
34 #include "content/browser/tab_contents/tab_contents.h" | 34 #include "content/browser/tab_contents/tab_contents.h" |
35 #include "content/browser/tab_contents/tab_contents_view.h" | 35 #include "content/browser/tab_contents/tab_contents_view.h" |
36 #include "content/common/bindings_policy.h" | 36 #include "content/common/bindings_policy.h" |
| 37 #include "content/common/content_client.h" |
37 #include "content/common/notification_service.h" | 38 #include "content/common/notification_service.h" |
38 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
39 | 40 |
40 const char DevToolsWindow::kDevToolsApp[] = "DevToolsApp"; | 41 const char DevToolsWindow::kDevToolsApp[] = "DevToolsApp"; |
41 | 42 |
42 // static | 43 // static |
43 TabContentsWrapper* DevToolsWindow::GetDevToolsContents( | 44 TabContentsWrapper* DevToolsWindow::GetDevToolsContents( |
44 TabContents* inspected_tab) { | 45 TabContents* inspected_tab) { |
45 if (!inspected_tab) { | 46 if (!inspected_tab) { |
46 return NULL; | 47 return NULL; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 } | 297 } |
297 | 298 |
298 | 299 |
299 void DevToolsWindow::AddDevToolsExtensionsToClient() { | 300 void DevToolsWindow::AddDevToolsExtensionsToClient() { |
300 if (inspected_tab_) { | 301 if (inspected_tab_) { |
301 FundamentalValue tabId( | 302 FundamentalValue tabId( |
302 inspected_tab_->restore_tab_helper()->session_id().id()); | 303 inspected_tab_->restore_tab_helper()->session_id().id()); |
303 CallClientFunction(ASCIIToUTF16("WebInspector.setInspectedTabId"), tabId); | 304 CallClientFunction(ASCIIToUTF16("WebInspector.setInspectedTabId"), tabId); |
304 } | 305 } |
305 ListValue results; | 306 ListValue results; |
306 const ExtensionService* extension_service = | 307 content::GetContentClient()->browser()->GetAdditionalStartPagesForDevTools( |
307 tab_contents_->tab_contents()->profile()-> | 308 tab_contents_->tab_contents(), &results); |
308 GetOriginalProfile()->GetExtensionService(); | |
309 if (!extension_service) | |
310 return; | |
311 | |
312 const ExtensionList* extensions = extension_service->extensions(); | |
313 | |
314 for (ExtensionList::const_iterator extension = extensions->begin(); | |
315 extension != extensions->end(); ++extension) { | |
316 if ((*extension)->devtools_url().is_empty()) | |
317 continue; | |
318 DictionaryValue* extension_info = new DictionaryValue(); | |
319 extension_info->Set("startPage", | |
320 new StringValue((*extension)->devtools_url().spec())); | |
321 results.Append(extension_info); | |
322 } | |
323 CallClientFunction(ASCIIToUTF16("WebInspector.addExtensions"), results); | 309 CallClientFunction(ASCIIToUTF16("WebInspector.addExtensions"), results); |
324 } | 310 } |
325 | 311 |
326 void DevToolsWindow::OpenURLFromTab(TabContents* source, | 312 void DevToolsWindow::OpenURLFromTab(TabContents* source, |
327 const GURL& url, | 313 const GURL& url, |
328 const GURL& referrer, | 314 const GURL& referrer, |
329 WindowOpenDisposition disposition, | 315 WindowOpenDisposition disposition, |
330 PageTransition::Type transition) { | 316 PageTransition::Type transition) { |
331 if (inspected_tab_) { | 317 if (inspected_tab_) { |
332 inspected_tab_->tab_contents()->OpenURL( | 318 inspected_tab_->tab_contents()->OpenURL( |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 if (docked_) { | 451 if (docked_) { |
466 if (event.windowsKeyCode == 0x08) { | 452 if (event.windowsKeyCode == 0x08) { |
467 // Do not navigate back in history on Windows (http://crbug.com/74156). | 453 // Do not navigate back in history on Windows (http://crbug.com/74156). |
468 return; | 454 return; |
469 } | 455 } |
470 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); | 456 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); |
471 if (inspected_window) | 457 if (inspected_window) |
472 inspected_window->HandleKeyboardEvent(event); | 458 inspected_window->HandleKeyboardEvent(event); |
473 } | 459 } |
474 } | 460 } |
OLD | NEW |