| 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" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 bool docked, | 119 bool docked, |
| 120 bool shared_worker_frontend) { | 120 bool shared_worker_frontend) { |
| 121 // Create TabContents with devtools. | 121 // Create TabContents with devtools. |
| 122 TabContentsWrapper* tab_contents = | 122 TabContentsWrapper* tab_contents = |
| 123 Browser::TabContentsFactory(profile, NULL, MSG_ROUTING_NONE, NULL, NULL); | 123 Browser::TabContentsFactory(profile, NULL, MSG_ROUTING_NONE, NULL, NULL); |
| 124 tab_contents->render_view_host()->AllowBindings( | 124 tab_contents->render_view_host()->AllowBindings( |
| 125 content::BINDINGS_POLICY_WEB_UI); | 125 content::BINDINGS_POLICY_WEB_UI); |
| 126 tab_contents->controller().LoadURL( | 126 tab_contents->controller().LoadURL( |
| 127 GetDevToolsUrl(profile, docked, shared_worker_frontend), | 127 GetDevToolsUrl(profile, docked, shared_worker_frontend), |
| 128 GURL(), | 128 GURL(), |
| 129 PageTransition::START_PAGE, | 129 content::PAGE_TRANSITION_START_PAGE, |
| 130 std::string()); | 130 std::string()); |
| 131 return new DevToolsWindow(tab_contents, profile, inspected_rvh, docked); | 131 return new DevToolsWindow(tab_contents, profile, inspected_rvh, docked); |
| 132 } | 132 } |
| 133 | 133 |
| 134 DevToolsWindow::DevToolsWindow(TabContentsWrapper* tab_contents, | 134 DevToolsWindow::DevToolsWindow(TabContentsWrapper* tab_contents, |
| 135 Profile* profile, | 135 Profile* profile, |
| 136 RenderViewHost* inspected_rvh, | 136 RenderViewHost* inspected_rvh, |
| 137 bool docked) | 137 bool docked) |
| 138 : RenderViewHostObserver(tab_contents->render_view_host()), | 138 : RenderViewHostObserver(tab_contents->render_view_host()), |
| 139 profile_(profile), | 139 profile_(profile), |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 defaults->SetInteger("left", 100); | 334 defaults->SetInteger("left", 100); |
| 335 defaults->SetInteger("top", 100); | 335 defaults->SetInteger("top", 100); |
| 336 defaults->SetInteger("right", 740); | 336 defaults->SetInteger("right", 740); |
| 337 defaults->SetInteger("bottom", 740); | 337 defaults->SetInteger("bottom", 740); |
| 338 defaults->SetBoolean("maximized", false); | 338 defaults->SetBoolean("maximized", false); |
| 339 defaults->SetBoolean("always_on_top", false); | 339 defaults->SetBoolean("always_on_top", false); |
| 340 } | 340 } |
| 341 | 341 |
| 342 browser_ = Browser::CreateForDevTools(profile_); | 342 browser_ = Browser::CreateForDevTools(profile_); |
| 343 browser_->tabstrip_model()->AddTabContents( | 343 browser_->tabstrip_model()->AddTabContents( |
| 344 tab_contents_, -1, PageTransition::START_PAGE, TabStripModel::ADD_ACTIVE); | 344 tab_contents_, -1, content::PAGE_TRANSITION_START_PAGE, |
| 345 TabStripModel::ADD_ACTIVE); |
| 345 } | 346 } |
| 346 | 347 |
| 347 bool DevToolsWindow::FindInspectedBrowserAndTabIndex(Browser** browser, | 348 bool DevToolsWindow::FindInspectedBrowserAndTabIndex(Browser** browser, |
| 348 int* tab) { | 349 int* tab) { |
| 349 if (!inspected_tab_) | 350 if (!inspected_tab_) |
| 350 return false; | 351 return false; |
| 351 | 352 |
| 352 const NavigationController& controller = inspected_tab_->controller(); | 353 const NavigationController& controller = inspected_tab_->controller(); |
| 353 for (BrowserList::const_iterator it = BrowserList::begin(); | 354 for (BrowserList::const_iterator it = BrowserList::begin(); |
| 354 it != BrowserList::end(); ++it) { | 355 it != BrowserList::end(); ++it) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 DictionaryValue* extension_info = new DictionaryValue(); | 408 DictionaryValue* extension_info = new DictionaryValue(); |
| 408 extension_info->Set("startPage", | 409 extension_info->Set("startPage", |
| 409 new StringValue((*extension)->devtools_url().spec())); | 410 new StringValue((*extension)->devtools_url().spec())); |
| 410 extension_info->Set("name", new StringValue((*extension)->name())); | 411 extension_info->Set("name", new StringValue((*extension)->name())); |
| 411 results.Append(extension_info); | 412 results.Append(extension_info); |
| 412 } | 413 } |
| 413 CallClientFunction(ASCIIToUTF16("WebInspector.addExtensions"), results); | 414 CallClientFunction(ASCIIToUTF16("WebInspector.addExtensions"), results); |
| 414 } | 415 } |
| 415 | 416 |
| 416 // TODO(adriansc): Remove this method once refactoring changed all call sites. | 417 // TODO(adriansc): Remove this method once refactoring changed all call sites. |
| 417 TabContents* DevToolsWindow::OpenURLFromTab(TabContents* source, | 418 TabContents* DevToolsWindow::OpenURLFromTab( |
| 418 const GURL& url, | 419 TabContents* source, |
| 419 const GURL& referrer, | 420 const GURL& url, |
| 420 WindowOpenDisposition disposition, | 421 const GURL& referrer, |
| 421 PageTransition::Type transition) { | 422 WindowOpenDisposition disposition, |
| 423 content::PageTransition transition) { |
| 422 return OpenURLFromTab(source, | 424 return OpenURLFromTab(source, |
| 423 OpenURLParams(url, referrer, disposition, transition)); | 425 OpenURLParams(url, referrer, disposition, transition)); |
| 424 } | 426 } |
| 425 | 427 |
| 426 TabContents* DevToolsWindow::OpenURLFromTab(TabContents* source, | 428 TabContents* DevToolsWindow::OpenURLFromTab(TabContents* source, |
| 427 const OpenURLParams& params) { | 429 const OpenURLParams& params) { |
| 428 if (inspected_tab_) { | 430 if (inspected_tab_) { |
| 429 OpenURLParams forward_params = params; | 431 OpenURLParams forward_params = params; |
| 430 forward_params.disposition = NEW_FOREGROUND_TAB; | 432 forward_params.disposition = NEW_FOREGROUND_TAB; |
| 431 forward_params.transition = PageTransition::LINK; | 433 forward_params.transition = content::PAGE_TRANSITION_LINK; |
| 432 return inspected_tab_->tab_contents()->OpenURL(forward_params); | 434 return inspected_tab_->tab_contents()->OpenURL(forward_params); |
| 433 } | 435 } |
| 434 return NULL; | 436 return NULL; |
| 435 } | 437 } |
| 436 | 438 |
| 437 void DevToolsWindow::CallClientFunction(const string16& function_name, | 439 void DevToolsWindow::CallClientFunction(const string16& function_name, |
| 438 const Value& arg) { | 440 const Value& arg) { |
| 439 std::string json; | 441 std::string json; |
| 440 base::JSONWriter::Write(&arg, false, &json); | 442 base::JSONWriter::Write(&arg, false, &json); |
| 441 string16 javascript = function_name + char16('(') + UTF8ToUTF16(json) + | 443 string16 javascript = function_name + char16('(') + UTF8ToUTF16(json) + |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 RequestSetDocked(false); | 649 RequestSetDocked(false); |
| 648 } | 650 } |
| 649 | 651 |
| 650 content::JavaScriptDialogCreator* DevToolsWindow::GetJavaScriptDialogCreator() { | 652 content::JavaScriptDialogCreator* DevToolsWindow::GetJavaScriptDialogCreator() { |
| 651 if (inspected_tab_ && inspected_tab_->tab_contents()->delegate()) { | 653 if (inspected_tab_ && inspected_tab_->tab_contents()->delegate()) { |
| 652 return inspected_tab_->tab_contents()->delegate()-> | 654 return inspected_tab_->tab_contents()->delegate()-> |
| 653 GetJavaScriptDialogCreator(); | 655 GetJavaScriptDialogCreator(); |
| 654 } | 656 } |
| 655 return TabContentsDelegate::GetJavaScriptDialogCreator(); | 657 return TabContentsDelegate::GetJavaScriptDialogCreator(); |
| 656 } | 658 } |
| OLD | NEW |