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 <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" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 namespace { | 51 namespace { |
52 base::LazyInstance<DevToolsWindowList, | 52 base::LazyInstance<DevToolsWindowList, |
53 base::LeakyLazyInstanceTraits<DevToolsWindowList> > | 53 base::LeakyLazyInstanceTraits<DevToolsWindowList> > |
54 g_instances = LAZY_INSTANCE_INITIALIZER; | 54 g_instances = LAZY_INSTANCE_INITIALIZER; |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 using content::DevToolsAgentHost; | 57 using content::DevToolsAgentHost; |
58 using content::DevToolsAgentHostRegistry; | 58 using content::DevToolsAgentHostRegistry; |
59 using content::DevToolsClientHost; | 59 using content::DevToolsClientHost; |
60 using content::DevToolsManager; | 60 using content::DevToolsManager; |
| 61 using content::NavigationController; |
61 using content::NavigationEntry; | 62 using content::NavigationEntry; |
62 using content::OpenURLParams; | 63 using content::OpenURLParams; |
63 using content::WebContents; | 64 using content::WebContents; |
64 | 65 |
65 const char DevToolsWindow::kDevToolsApp[] = "DevToolsApp"; | 66 const char DevToolsWindow::kDevToolsApp[] = "DevToolsApp"; |
66 | 67 |
67 const char kDockSideBottom[] = "bottom"; | 68 const char kDockSideBottom[] = "bottom"; |
68 const char kDockSideRight[] = "right"; | 69 const char kDockSideRight[] = "right"; |
69 | 70 |
70 // static | 71 // static |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // Wipe out page icon so that the default application icon is used. | 200 // Wipe out page icon so that the default application icon is used. |
200 NavigationEntry* entry = | 201 NavigationEntry* entry = |
201 tab_contents_->tab_contents()->GetController().GetActiveEntry(); | 202 tab_contents_->tab_contents()->GetController().GetActiveEntry(); |
202 entry->GetFavicon().bitmap = SkBitmap(); | 203 entry->GetFavicon().bitmap = SkBitmap(); |
203 entry->GetFavicon().valid = true; | 204 entry->GetFavicon().valid = true; |
204 | 205 |
205 // Register on-load actions. | 206 // Register on-load actions. |
206 registrar_.Add( | 207 registrar_.Add( |
207 this, | 208 this, |
208 content::NOTIFICATION_LOAD_STOP, | 209 content::NOTIFICATION_LOAD_STOP, |
209 content::Source<content::NavigationController>( | 210 content::Source<NavigationController>( |
210 &tab_contents_->web_contents()->GetController())); | 211 &tab_contents_->web_contents()->GetController())); |
211 registrar_.Add( | 212 registrar_.Add( |
212 this, | 213 this, |
213 content::NOTIFICATION_TAB_CLOSING, | 214 content::NOTIFICATION_TAB_CLOSING, |
214 content::Source<content::NavigationController>( | 215 content::Source<NavigationController>( |
215 &tab_contents_->web_contents()->GetController())); | 216 &tab_contents_->web_contents()->GetController())); |
216 registrar_.Add( | 217 registrar_.Add( |
217 this, | 218 this, |
218 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 219 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
219 content::Source<ThemeService>( | 220 content::Source<ThemeService>( |
220 ThemeServiceFactory::GetForProfile(profile_))); | 221 ThemeServiceFactory::GetForProfile(profile_))); |
221 // There is no inspected_rvh in case of shared workers. | 222 // There is no inspected_rvh in case of shared workers. |
222 if (inspected_rvh) { | 223 if (inspected_rvh) { |
223 TabContents* tab = inspected_rvh->delegate()->GetAsTabContents(); | 224 TabContents* tab = inspected_rvh->delegate()->GetAsTabContents(); |
224 if (tab) | 225 if (tab) |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 browser_->tabstrip_model()->AddTabContents( | 377 browser_->tabstrip_model()->AddTabContents( |
377 tab_contents_, -1, content::PAGE_TRANSITION_START_PAGE, | 378 tab_contents_, -1, content::PAGE_TRANSITION_START_PAGE, |
378 TabStripModel::ADD_ACTIVE); | 379 TabStripModel::ADD_ACTIVE); |
379 } | 380 } |
380 | 381 |
381 bool DevToolsWindow::FindInspectedBrowserAndTabIndex(Browser** browser, | 382 bool DevToolsWindow::FindInspectedBrowserAndTabIndex(Browser** browser, |
382 int* tab) { | 383 int* tab) { |
383 if (!inspected_tab_) | 384 if (!inspected_tab_) |
384 return false; | 385 return false; |
385 | 386 |
386 const content::NavigationController& controller = | 387 const NavigationController& controller = |
387 inspected_tab_->tab_contents()->GetController(); | 388 inspected_tab_->tab_contents()->GetController(); |
388 for (BrowserList::const_iterator it = BrowserList::begin(); | 389 for (BrowserList::const_iterator it = BrowserList::begin(); |
389 it != BrowserList::end(); ++it) { | 390 it != BrowserList::end(); ++it) { |
390 int tab_index = (*it)->GetIndexOfController(&controller); | 391 int tab_index = (*it)->GetIndexOfController(&controller); |
391 if (tab_index != TabStripModel::kNoTab) { | 392 if (tab_index != TabStripModel::kNoTab) { |
392 *browser = *it; | 393 *browser = *it; |
393 *tab = tab_index; | 394 *tab = tab_index; |
394 return true; | 395 return true; |
395 } | 396 } |
396 } | 397 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 | 477 |
477 void DevToolsWindow::Observe(int type, | 478 void DevToolsWindow::Observe(int type, |
478 const content::NotificationSource& source, | 479 const content::NotificationSource& source, |
479 const content::NotificationDetails& details) { | 480 const content::NotificationDetails& details) { |
480 if (type == content::NOTIFICATION_LOAD_STOP && !is_loaded_) { | 481 if (type == content::NOTIFICATION_LOAD_STOP && !is_loaded_) { |
481 is_loaded_ = true; | 482 is_loaded_ = true; |
482 UpdateTheme(); | 483 UpdateTheme(); |
483 DoAction(); | 484 DoAction(); |
484 AddDevToolsExtensionsToClient(); | 485 AddDevToolsExtensionsToClient(); |
485 } else if (type == content::NOTIFICATION_TAB_CLOSING) { | 486 } else if (type == content::NOTIFICATION_TAB_CLOSING) { |
486 if (content::Source<content::NavigationController>(source).ptr() == | 487 if (content::Source<NavigationController>(source).ptr() == |
487 &tab_contents_->web_contents()->GetController()) { | 488 &tab_contents_->web_contents()->GetController()) { |
488 // This happens when browser closes all of its tabs as a result | 489 // This happens when browser closes all of its tabs as a result |
489 // of window.Close event. | 490 // of window.Close event. |
490 // Notify manager that this DevToolsClientHost no longer exists and | 491 // Notify manager that this DevToolsClientHost no longer exists and |
491 // initiate self-destuct here. | 492 // initiate self-destuct here. |
492 DevToolsManager::GetInstance()->ClientHostClosing(frontend_host_); | 493 DevToolsManager::GetInstance()->ClientHostClosing(frontend_host_); |
493 delete this; | 494 delete this; |
494 } | 495 } |
495 } else if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { | 496 } else if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { |
496 UpdateTheme(); | 497 UpdateTheme(); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 content); | 723 content); |
723 } | 724 } |
724 | 725 |
725 content::JavaScriptDialogCreator* DevToolsWindow::GetJavaScriptDialogCreator() { | 726 content::JavaScriptDialogCreator* DevToolsWindow::GetJavaScriptDialogCreator() { |
726 if (inspected_tab_ && inspected_tab_->tab_contents()->GetDelegate()) { | 727 if (inspected_tab_ && inspected_tab_->tab_contents()->GetDelegate()) { |
727 return inspected_tab_->tab_contents()->GetDelegate()-> | 728 return inspected_tab_->tab_contents()->GetDelegate()-> |
728 GetJavaScriptDialogCreator(); | 729 GetJavaScriptDialogCreator(); |
729 } | 730 } |
730 return content::WebContentsDelegate::GetJavaScriptDialogCreator(); | 731 return content::WebContentsDelegate::GetJavaScriptDialogCreator(); |
731 } | 732 } |
OLD | NEW |