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/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
16 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 16 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/sessions/restore_tab_helper.h" | 18 #include "chrome/browser/sessions/restore_tab_helper.h" |
19 #include "chrome/browser/tabs/tab_strip_model.h" | 19 #include "chrome/browser/tabs/tab_strip_model.h" |
20 #include "chrome/browser/themes/theme_service.h" | 20 #include "chrome/browser/themes/theme_service.h" |
21 #include "chrome/browser/themes/theme_service_factory.h" | 21 #include "chrome/browser/themes/theme_service_factory.h" |
22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
23 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
24 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
25 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 25 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 26 #include "chrome/common/chrome_notification_types.h" |
26 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
27 #include "chrome/common/render_messages.h" | 28 #include "chrome/common/render_messages.h" |
28 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
29 #include "content/browser/browsing_instance.h" | 30 #include "content/browser/browsing_instance.h" |
30 #include "content/browser/debugger/devtools_manager.h" | 31 #include "content/browser/debugger/devtools_manager.h" |
31 #include "content/browser/debugger/devtools_window.h" | 32 #include "content/browser/debugger/devtools_window.h" |
32 #include "content/browser/in_process_webkit/session_storage_namespace.h" | 33 #include "content/browser/in_process_webkit/session_storage_namespace.h" |
33 #include "content/browser/load_notification_details.h" | 34 #include "content/browser/load_notification_details.h" |
34 #include "content/browser/renderer_host/render_view_host.h" | 35 #include "content/browser/renderer_host/render_view_host.h" |
35 #include "content/browser/tab_contents/navigation_controller.h" | 36 #include "content/browser/tab_contents/navigation_controller.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 tab_contents_->controller().LoadURL( | 115 tab_contents_->controller().LoadURL( |
115 GetDevToolsUrl(), GURL(), PageTransition::START_PAGE); | 116 GetDevToolsUrl(), GURL(), PageTransition::START_PAGE); |
116 | 117 |
117 // Wipe out page icon so that the default application icon is used. | 118 // Wipe out page icon so that the default application icon is used. |
118 NavigationEntry* entry = tab_contents_->controller().GetActiveEntry(); | 119 NavigationEntry* entry = tab_contents_->controller().GetActiveEntry(); |
119 entry->favicon().set_bitmap(SkBitmap()); | 120 entry->favicon().set_bitmap(SkBitmap()); |
120 entry->favicon().set_is_valid(true); | 121 entry->favicon().set_is_valid(true); |
121 | 122 |
122 // Register on-load actions. | 123 // Register on-load actions. |
123 registrar_.Add(this, | 124 registrar_.Add(this, |
124 NotificationType::LOAD_STOP, | 125 content::NOTIFICATION_LOAD_STOP, |
125 Source<NavigationController>(&tab_contents_->controller())); | 126 Source<NavigationController>(&tab_contents_->controller())); |
126 registrar_.Add(this, | 127 registrar_.Add(this, |
127 NotificationType::TAB_CLOSING, | 128 content::NOTIFICATION_TAB_CLOSING, |
128 Source<NavigationController>(&tab_contents_->controller())); | 129 Source<NavigationController>(&tab_contents_->controller())); |
129 registrar_.Add( | 130 registrar_.Add( |
130 this, | 131 this, |
131 NotificationType::BROWSER_THEME_CHANGED, | 132 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
132 Source<ThemeService>(ThemeServiceFactory::GetForProfile(profile_))); | 133 Source<ThemeService>(ThemeServiceFactory::GetForProfile(profile_))); |
133 TabContents* tab = inspected_rvh->delegate()->GetAsTabContents(); | 134 TabContents* tab = inspected_rvh->delegate()->GetAsTabContents(); |
134 if (tab) | 135 if (tab) |
135 inspected_tab_ = TabContentsWrapper::GetCurrentWrapperForContents(tab); | 136 inspected_tab_ = TabContentsWrapper::GetCurrentWrapperForContents(tab); |
136 | 137 |
137 instances_.push_back(this); | 138 instances_.push_back(this); |
138 } | 139 } |
139 | 140 |
140 DevToolsWindow::~DevToolsWindow() { | 141 DevToolsWindow::~DevToolsWindow() { |
141 DevToolsWindowList::iterator it = std::find(instances_.begin(), | 142 DevToolsWindowList::iterator it = std::find(instances_.begin(), |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 void DevToolsWindow::CallClientFunction(const string16& function_name, | 388 void DevToolsWindow::CallClientFunction(const string16& function_name, |
388 const Value& arg) { | 389 const Value& arg) { |
389 std::string json; | 390 std::string json; |
390 base::JSONWriter::Write(&arg, false, &json); | 391 base::JSONWriter::Write(&arg, false, &json); |
391 string16 javascript = function_name + char16('(') + UTF8ToUTF16(json) + | 392 string16 javascript = function_name + char16('(') + UTF8ToUTF16(json) + |
392 ASCIIToUTF16(");"); | 393 ASCIIToUTF16(");"); |
393 tab_contents_->render_view_host()-> | 394 tab_contents_->render_view_host()-> |
394 ExecuteJavascriptInWebFrame(string16(), javascript); | 395 ExecuteJavascriptInWebFrame(string16(), javascript); |
395 } | 396 } |
396 | 397 |
397 void DevToolsWindow::Observe(NotificationType type, | 398 void DevToolsWindow::Observe(int type, |
398 const NotificationSource& source, | 399 const NotificationSource& source, |
399 const NotificationDetails& details) { | 400 const NotificationDetails& details) { |
400 if (type == NotificationType::LOAD_STOP && !is_loaded_) { | 401 if (type == content::NOTIFICATION_LOAD_STOP && !is_loaded_) { |
401 is_loaded_ = true; | 402 is_loaded_ = true; |
402 UpdateTheme(); | 403 UpdateTheme(); |
403 DoAction(); | 404 DoAction(); |
404 AddDevToolsExtensionsToClient(); | 405 AddDevToolsExtensionsToClient(); |
405 } else if (type == NotificationType::TAB_CLOSING) { | 406 } else if (type == content::NOTIFICATION_TAB_CLOSING) { |
406 if (Source<NavigationController>(source).ptr() == | 407 if (Source<NavigationController>(source).ptr() == |
407 &tab_contents_->controller()) { | 408 &tab_contents_->controller()) { |
408 // This happens when browser closes all of its tabs as a result | 409 // This happens when browser closes all of its tabs as a result |
409 // of window.Close event. | 410 // of window.Close event. |
410 // Notify manager that this DevToolsClientHost no longer exists and | 411 // Notify manager that this DevToolsClientHost no longer exists and |
411 // initiate self-destuct here. | 412 // initiate self-destuct here. |
412 NotifyCloseListener(); | 413 NotifyCloseListener(); |
413 delete this; | 414 delete this; |
414 } | 415 } |
415 } else if (type == NotificationType::BROWSER_THEME_CHANGED) { | 416 } else if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { |
416 UpdateTheme(); | 417 UpdateTheme(); |
417 } | 418 } |
418 } | 419 } |
419 | 420 |
420 void DevToolsWindow::ScheduleAction(DevToolsToggleAction action) { | 421 void DevToolsWindow::ScheduleAction(DevToolsToggleAction action) { |
421 action_on_load_ = action; | 422 action_on_load_ = action; |
422 if (is_loaded_) | 423 if (is_loaded_) |
423 DoAction(); | 424 DoAction(); |
424 } | 425 } |
425 | 426 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 DevToolsClientHost* client_host) { | 562 DevToolsClientHost* client_host) { |
562 if (!client_host) | 563 if (!client_host) |
563 return NULL; | 564 return NULL; |
564 DevToolsWindowList::iterator it = std::find(instances_.begin(), | 565 DevToolsWindowList::iterator it = std::find(instances_.begin(), |
565 instances_.end(), | 566 instances_.end(), |
566 client_host); | 567 client_host); |
567 if (it == instances_.end()) | 568 if (it == instances_.end()) |
568 return NULL; | 569 return NULL; |
569 return *it; | 570 return *it; |
570 } | 571 } |
OLD | NEW |