| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/l10n_util.h" | 5 #include "app/l10n_util.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "chrome/browser/browser.h" | 7 #include "chrome/browser/browser.h" |
| 8 #include "chrome/browser/browser_list.h" | 8 #include "chrome/browser/browser_list.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/browser_window.h" | 10 #include "chrome/browser/browser_window.h" |
| 11 #include "chrome/browser/debugger/devtools_manager.h" | 11 #include "chrome/browser/debugger/devtools_manager.h" |
| 12 #include "chrome/browser/debugger/devtools_window.h" | 12 #include "chrome/browser/debugger/devtools_window.h" |
| 13 #include "chrome/browser/profile.h" | 13 #include "chrome/browser/profile.h" |
| 14 #include "chrome/browser/tab_contents/navigation_controller.h" | 14 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 15 #include "chrome/browser/tab_contents/navigation_entry.h" | 15 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 16 #include "chrome/browser/tab_contents/tab_contents.h" | 16 #include "chrome/browser/tab_contents/tab_contents.h" |
| 17 #include "chrome/browser/tab_contents/tab_contents_view.h" | 17 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 18 #include "chrome/browser/tabs/tab_strip_model.h" | 18 #include "chrome/browser/tabs/tab_strip_model.h" |
| 19 #include "chrome/common/bindings_policy.h" | 19 #include "chrome/common/bindings_policy.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/common/pref_service.h" | 22 #include "chrome/common/pref_service.h" |
| 23 #include "chrome/common/render_messages.h" | 23 #include "chrome/common/render_messages.h" |
| 24 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
| 25 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
| 26 | 26 |
| 27 const std::wstring DevToolsWindow::kDevToolsApp = L"DevToolsApp"; |
| 27 | 28 |
| 28 // static | 29 // static |
| 29 TabContents* DevToolsWindow::GetDevToolsContents(TabContents* inspected_tab) { | 30 TabContents* DevToolsWindow::GetDevToolsContents(TabContents* inspected_tab) { |
| 30 if (!inspected_tab) { | 31 if (!inspected_tab) { |
| 31 return NULL; | 32 return NULL; |
| 32 } | 33 } |
| 33 DevToolsClientHost* client_host = DevToolsManager::GetInstance()-> | 34 DevToolsClientHost* client_host = DevToolsManager::GetInstance()-> |
| 34 GetDevToolsClientHostFor(inspected_tab->render_view_host()); | 35 GetDevToolsClientHostFor(inspected_tab->render_view_host()); |
| 35 if (!client_host) { | 36 if (!client_host) { |
| 36 return NULL; | 37 return NULL; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 169 |
| 169 RenderViewHost* DevToolsWindow::GetRenderViewHost() { | 170 RenderViewHost* DevToolsWindow::GetRenderViewHost() { |
| 170 return tab_contents_->render_view_host(); | 171 return tab_contents_->render_view_host(); |
| 171 } | 172 } |
| 172 | 173 |
| 173 void DevToolsWindow::CreateDevToolsBrowser() { | 174 void DevToolsWindow::CreateDevToolsBrowser() { |
| 174 // TODO(pfeldman): Make browser's getter for this key static. | 175 // TODO(pfeldman): Make browser's getter for this key static. |
| 175 std::wstring wp_key = L""; | 176 std::wstring wp_key = L""; |
| 176 wp_key.append(prefs::kBrowserWindowPlacement); | 177 wp_key.append(prefs::kBrowserWindowPlacement); |
| 177 wp_key.append(L"_"); | 178 wp_key.append(L"_"); |
| 178 wp_key.append(L"DevToolsApp"); | 179 wp_key.append(kDevToolsApp); |
| 179 | 180 |
| 180 PrefService* prefs = g_browser_process->local_state(); | 181 PrefService* prefs = g_browser_process->local_state(); |
| 181 if (!prefs->FindPreference(wp_key.c_str())) { | 182 if (!prefs->FindPreference(wp_key.c_str())) { |
| 182 prefs->RegisterDictionaryPref(wp_key.c_str()); | 183 prefs->RegisterDictionaryPref(wp_key.c_str()); |
| 183 } | 184 } |
| 184 | 185 |
| 185 const DictionaryValue* wp_pref = prefs->GetDictionary(wp_key.c_str()); | 186 const DictionaryValue* wp_pref = prefs->GetDictionary(wp_key.c_str()); |
| 186 if (!wp_pref) { | 187 if (!wp_pref) { |
| 187 DictionaryValue* defaults = prefs->GetMutableDictionary(wp_key.c_str()); | 188 DictionaryValue* defaults = prefs->GetMutableDictionary(wp_key.c_str()); |
| 188 defaults->SetInteger(L"left", 100); | 189 defaults->SetInteger(L"left", 100); |
| 189 defaults->SetInteger(L"top", 100); | 190 defaults->SetInteger(L"top", 100); |
| 190 defaults->SetInteger(L"right", 740); | 191 defaults->SetInteger(L"right", 740); |
| 191 defaults->SetInteger(L"bottom", 740); | 192 defaults->SetInteger(L"bottom", 740); |
| 192 defaults->SetBoolean(L"maximized", false); | 193 defaults->SetBoolean(L"maximized", false); |
| 193 defaults->SetBoolean(L"always_on_top", false); | 194 defaults->SetBoolean(L"always_on_top", false); |
| 194 } | 195 } |
| 195 | 196 |
| 196 browser_ = Browser::CreateForApp(L"DevToolsApp", profile_, false); | 197 browser_ = Browser::CreateForDevTools(profile_); |
| 197 browser_->tabstrip_model()->AddTabContents( | 198 browser_->tabstrip_model()->AddTabContents( |
| 198 tab_contents_, -1, false, PageTransition::START_PAGE, true); | 199 tab_contents_, -1, false, PageTransition::START_PAGE, true); |
| 199 } | 200 } |
| 200 | 201 |
| 201 BrowserWindow* DevToolsWindow::GetInspectedBrowserWindow() { | 202 BrowserWindow* DevToolsWindow::GetInspectedBrowserWindow() { |
| 202 for (BrowserList::const_iterator it = BrowserList::begin(); | 203 for (BrowserList::const_iterator it = BrowserList::begin(); |
| 203 it != BrowserList::end(); ++it) { | 204 it != BrowserList::end(); ++it) { |
| 204 Browser* browser = *it; | 205 Browser* browser = *it; |
| 205 for (int i = 0; i < browser->tab_count(); ++i) { | 206 for (int i = 0; i < browser->tab_count(); ++i) { |
| 206 TabContents* tab_contents = browser->GetTabContentsAt(i); | 207 TabContents* tab_contents = browser->GetTabContentsAt(i); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 235 NotifyCloseListener(); | 236 NotifyCloseListener(); |
| 236 delete this; | 237 delete this; |
| 237 } | 238 } |
| 238 } | 239 } |
| 239 } | 240 } |
| 240 | 241 |
| 241 void DevToolsWindow::OpenConsole() { | 242 void DevToolsWindow::OpenConsole() { |
| 242 tab_contents_->render_view_host()-> | 243 tab_contents_->render_view_host()-> |
| 243 ExecuteJavascriptInWebFrame(L"", L"WebInspector.showConsole();"); | 244 ExecuteJavascriptInWebFrame(L"", L"WebInspector.showConsole();"); |
| 244 } | 245 } |
| OLD | NEW |