OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 worker_agent, | 157 worker_agent, |
158 window->frontend_host_.get()); | 158 window->frontend_host_.get()); |
159 } | 159 } |
160 window->Show(DEVTOOLS_TOGGLE_ACTION_SHOW); | 160 window->Show(DEVTOOLS_TOGGLE_ACTION_SHOW); |
161 return window; | 161 return window; |
162 } | 162 } |
163 | 163 |
164 // static | 164 // static |
165 DevToolsWindow* DevToolsWindow::CreateDevToolsWindowForWorker( | 165 DevToolsWindow* DevToolsWindow::CreateDevToolsWindowForWorker( |
166 Profile* profile) { | 166 Profile* profile) { |
167 return Create(profile, NULL, DEVTOOLS_DOCK_SIDE_UNDOCKED, true); | 167 return Create(profile, DEVTOOLS_DOCK_SIDE_UNDOCKED, true); |
168 } | 168 } |
169 | 169 |
170 // static | 170 // static |
171 DevToolsWindow* DevToolsWindow::OpenDevToolsWindow( | 171 DevToolsWindow* DevToolsWindow::OpenDevToolsWindow( |
172 RenderViewHost* inspected_rvh) { | 172 RenderViewHost* inspected_rvh) { |
173 return ToggleDevToolsWindow(inspected_rvh, true, | 173 return ToggleDevToolsWindow(inspected_rvh, true, |
174 DEVTOOLS_TOGGLE_ACTION_SHOW); | 174 DEVTOOLS_TOGGLE_ACTION_SHOW); |
175 } | 175 } |
176 | 176 |
177 // static | 177 // static |
(...skipping 18 matching lines...) Expand all Loading... | |
196 scoped_refptr<DevToolsAgentHost> agent( | 196 scoped_refptr<DevToolsAgentHost> agent( |
197 DevToolsAgentHost::GetFor(inspected_rvh)); | 197 DevToolsAgentHost::GetFor(inspected_rvh)); |
198 DevToolsManager::GetInstance()->InspectElement(agent, x, y); | 198 DevToolsManager::GetInstance()->InspectElement(agent, x, y); |
199 // TODO(loislo): we should initiate DevTools window opening from within | 199 // TODO(loislo): we should initiate DevTools window opening from within |
200 // renderer. Otherwise, we still can hit a race condition here. | 200 // renderer. Otherwise, we still can hit a race condition here. |
201 OpenDevToolsWindow(inspected_rvh); | 201 OpenDevToolsWindow(inspected_rvh); |
202 } | 202 } |
203 | 203 |
204 DevToolsWindow* DevToolsWindow::Create( | 204 DevToolsWindow* DevToolsWindow::Create( |
205 Profile* profile, | 205 Profile* profile, |
206 RenderViewHost* inspected_rvh, | |
207 DevToolsDockSide dock_side, | 206 DevToolsDockSide dock_side, |
208 bool shared_worker_frontend) { | 207 bool shared_worker_frontend) { |
209 // Create WebContents with devtools. | 208 // Create WebContents with devtools. |
210 WebContents* web_contents = | 209 WebContents* web_contents = |
211 WebContents::Create(WebContents::CreateParams(profile)); | 210 WebContents::Create(WebContents::CreateParams(profile)); |
212 web_contents->GetController().LoadURL( | 211 web_contents->GetController().LoadURL( |
213 GetDevToolsUrl(profile, dock_side, shared_worker_frontend), | 212 GetDevToolsUrl(profile, dock_side, shared_worker_frontend), |
214 content::Referrer(), | 213 content::Referrer(), |
215 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 214 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
216 std::string()); | 215 std::string()); |
217 | 216 |
218 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); | 217 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); |
219 int process_id = render_view_host->GetProcess()->GetID(); | 218 int process_id = render_view_host->GetProcess()->GetID(); |
220 content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( | 219 content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( |
221 process_id, chrome::kFileScheme); | 220 process_id, chrome::kFileScheme); |
222 content::DevToolsClientHost::SetupDevToolsFrontendClient(render_view_host); | 221 content::DevToolsClientHost::SetupDevToolsFrontendClient(render_view_host); |
223 return new DevToolsWindow(web_contents, profile, inspected_rvh, dock_side); | 222 return new DevToolsWindow(web_contents, profile, dock_side); |
224 } | 223 } |
225 | 224 |
226 DevToolsWindow::DevToolsWindow(WebContents* web_contents, | 225 DevToolsWindow::DevToolsWindow(WebContents* web_contents, |
227 Profile* profile, | 226 Profile* profile, |
228 RenderViewHost* inspected_rvh, | |
229 DevToolsDockSide dock_side) | 227 DevToolsDockSide dock_side) |
230 : profile_(profile), | 228 : profile_(profile), |
231 inspected_web_contents_(NULL), | |
232 web_contents_(web_contents), | 229 web_contents_(web_contents), |
233 browser_(NULL), | 230 browser_(NULL), |
234 dock_side_(dock_side), | 231 dock_side_(dock_side), |
235 is_loaded_(false), | 232 is_loaded_(false), |
236 action_on_load_(DEVTOOLS_TOGGLE_ACTION_SHOW), | 233 action_on_load_(DEVTOOLS_TOGGLE_ACTION_SHOW), |
237 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 234 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
238 width_(-1), | 235 width_(-1), |
239 height_(-1) { | 236 height_(-1) { |
240 frontend_host_.reset( | 237 frontend_host_.reset( |
241 DevToolsClientHost::CreateDevToolsFrontendHost(web_contents, this)); | 238 DevToolsClientHost::CreateDevToolsFrontendHost(web_contents, this)); |
(...skipping 12 matching lines...) Expand all Loading... | |
254 content::Source<NavigationController>(&web_contents->GetController())); | 251 content::Source<NavigationController>(&web_contents->GetController())); |
255 registrar_.Add( | 252 registrar_.Add( |
256 this, | 253 this, |
257 chrome::NOTIFICATION_TAB_CLOSING, | 254 chrome::NOTIFICATION_TAB_CLOSING, |
258 content::Source<NavigationController>(&web_contents->GetController())); | 255 content::Source<NavigationController>(&web_contents->GetController())); |
259 registrar_.Add( | 256 registrar_.Add( |
260 this, | 257 this, |
261 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 258 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
262 content::Source<ThemeService>( | 259 content::Source<ThemeService>( |
263 ThemeServiceFactory::GetForProfile(profile_))); | 260 ThemeServiceFactory::GetForProfile(profile_))); |
264 // There is no inspected_rvh in case of shared workers. | |
265 if (inspected_rvh) | |
266 inspected_web_contents_ = WebContents::FromRenderViewHost(inspected_rvh); | |
267 } | 261 } |
268 | 262 |
269 DevToolsWindow::~DevToolsWindow() { | 263 DevToolsWindow::~DevToolsWindow() { |
270 DevToolsWindowList& instances = g_instances.Get(); | 264 DevToolsWindowList& instances = g_instances.Get(); |
271 DevToolsWindowList::iterator it = std::find(instances.begin(), | 265 DevToolsWindowList::iterator it = std::find(instances.begin(), |
272 instances.end(), | 266 instances.end(), |
273 this); | 267 this); |
274 DCHECK(it != instances.end()); | 268 DCHECK(it != instances.end()); |
275 instances.erase(it); | 269 instances.erase(it); |
276 } | 270 } |
277 | 271 |
272 content::WebContents* DevToolsWindow::GetInspectedWebContents() { | |
273 DevToolsAgentHost* agent_host = DevToolsManager::GetInstance()-> | |
274 GetDevToolsAgentHostFor(frontend_host_.get()); | |
275 if (!agent_host) | |
276 return NULL; | |
277 | |
278 RenderViewHost* rvh = agent_host->GetRenderViewHost(); | |
279 if (!rvh) | |
280 return NULL; | |
281 | |
282 return WebContents::FromRenderViewHost(rvh); | |
283 } | |
284 | |
278 void DevToolsWindow::InspectedContentsClosing() { | 285 void DevToolsWindow::InspectedContentsClosing() { |
279 if (IsDocked()) { | 286 if (IsDocked()) { |
280 // Update dev tools to reflect removed dev tools window. | 287 // Update dev tools to reflect removed dev tools window. |
281 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); | 288 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); |
282 if (inspected_window) | 289 if (inspected_window) |
283 inspected_window->UpdateDevTools(); | 290 inspected_window->UpdateDevTools(); |
284 // In case of docked web_contents_, we own it so delete here. | 291 // In case of docked web_contents_, we own it so delete here. |
285 delete web_contents_; | 292 delete web_contents_; |
286 | 293 |
287 delete this; | 294 delete this; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 | 421 |
415 browser_ = new Browser(Browser::CreateParams::CreateForDevTools( | 422 browser_ = new Browser(Browser::CreateParams::CreateForDevTools( |
416 profile_, host_desktop_type)); | 423 profile_, host_desktop_type)); |
417 browser_->tab_strip_model()->AddWebContents( | 424 browser_->tab_strip_model()->AddWebContents( |
418 web_contents_, -1, content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 425 web_contents_, -1, content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
419 TabStripModel::ADD_ACTIVE); | 426 TabStripModel::ADD_ACTIVE); |
420 } | 427 } |
421 | 428 |
422 bool DevToolsWindow::FindInspectedBrowserAndTabIndex(Browser** browser, | 429 bool DevToolsWindow::FindInspectedBrowserAndTabIndex(Browser** browser, |
423 int* tab) { | 430 int* tab) { |
424 if (!inspected_web_contents_) | 431 if (!GetInspectedWebContents()) |
yurys
2013/03/07 13:24:49
Consider using local variable for the result here
| |
425 return false; | 432 return false; |
426 | 433 |
427 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 434 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
428 int tab_index = it->tab_strip_model()->GetIndexOfWebContents( | 435 int tab_index = it->tab_strip_model()->GetIndexOfWebContents( |
429 inspected_web_contents_); | 436 GetInspectedWebContents()); |
430 if (tab_index != TabStripModel::kNoTab) { | 437 if (tab_index != TabStripModel::kNoTab) { |
431 *browser = *it; | 438 *browser = *it; |
432 *tab = tab_index; | 439 *tab = tab_index; |
433 return true; | 440 return true; |
434 } | 441 } |
435 } | 442 } |
436 return false; | 443 return false; |
437 } | 444 } |
438 | 445 |
439 BrowserWindow* DevToolsWindow::GetInspectedBrowserWindow() { | 446 BrowserWindow* DevToolsWindow::GetInspectedBrowserWindow() { |
(...skipping 14 matching lines...) Expand all Loading... | |
454 | 461 |
455 void DevToolsWindow::UpdateFrontendDockSide() { | 462 void DevToolsWindow::UpdateFrontendDockSide() { |
456 base::StringValue dock_side(SideToString(dock_side_)); | 463 base::StringValue dock_side(SideToString(dock_side_)); |
457 CallClientFunction("InspectorFrontendAPI.setDockSide", &dock_side); | 464 CallClientFunction("InspectorFrontendAPI.setDockSide", &dock_side); |
458 base::FundamentalValue docked(IsDocked()); | 465 base::FundamentalValue docked(IsDocked()); |
459 CallClientFunction("InspectorFrontendAPI.setAttachedWindow", &docked); | 466 CallClientFunction("InspectorFrontendAPI.setAttachedWindow", &docked); |
460 } | 467 } |
461 | 468 |
462 | 469 |
463 void DevToolsWindow::AddDevToolsExtensionsToClient() { | 470 void DevToolsWindow::AddDevToolsExtensionsToClient() { |
464 if (inspected_web_contents_) { | 471 if (GetInspectedWebContents()) { |
465 SessionTabHelper* session_tab_helper = | 472 SessionTabHelper* session_tab_helper = |
466 SessionTabHelper::FromWebContents(inspected_web_contents_); | 473 SessionTabHelper::FromWebContents(GetInspectedWebContents()); |
467 if (session_tab_helper) { | 474 if (session_tab_helper) { |
468 base::FundamentalValue tabId(session_tab_helper->session_id().id()); | 475 base::FundamentalValue tabId(session_tab_helper->session_id().id()); |
469 CallClientFunction("WebInspector.setInspectedTabId", &tabId); | 476 CallClientFunction("WebInspector.setInspectedTabId", &tabId); |
470 } | 477 } |
471 } | 478 } |
472 ListValue results; | 479 ListValue results; |
473 Profile* profile = | 480 Profile* profile = |
474 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 481 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
475 const ExtensionService* extension_service = extensions::ExtensionSystem::Get( | 482 const ExtensionService* extension_service = extensions::ExtensionSystem::Get( |
476 profile->GetOriginalProfile())->extension_service(); | 483 profile->GetOriginalProfile())->extension_service(); |
(...skipping 25 matching lines...) Expand all Loading... | |
502 chrome::NavigateParams nav_params(profile_, params.url, params.transition); | 509 chrome::NavigateParams nav_params(profile_, params.url, params.transition); |
503 FillNavigateParamsFromOpenURLParams(&nav_params, params); | 510 FillNavigateParamsFromOpenURLParams(&nav_params, params); |
504 nav_params.source_contents = source; | 511 nav_params.source_contents = source; |
505 nav_params.tabstrip_add_types = TabStripModel::ADD_NONE; | 512 nav_params.tabstrip_add_types = TabStripModel::ADD_NONE; |
506 nav_params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 513 nav_params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
507 nav_params.user_gesture = true; | 514 nav_params.user_gesture = true; |
508 chrome::Navigate(&nav_params); | 515 chrome::Navigate(&nav_params); |
509 return nav_params.target_contents; | 516 return nav_params.target_contents; |
510 } | 517 } |
511 | 518 |
512 if (inspected_web_contents_) | 519 if (GetInspectedWebContents()) |
513 return inspected_web_contents_->OpenURL(params); | 520 return GetInspectedWebContents()->OpenURL(params); |
514 return NULL; | 521 return NULL; |
515 } | 522 } |
516 | 523 |
517 void DevToolsWindow::CallClientFunction(const std::string& function_name, | 524 void DevToolsWindow::CallClientFunction(const std::string& function_name, |
518 const Value* arg1, | 525 const Value* arg1, |
519 const Value* arg2) { | 526 const Value* arg2) { |
520 std::string params; | 527 std::string params; |
521 if (arg1) { | 528 if (arg1) { |
522 std::string json; | 529 std::string json; |
523 base::JSONWriter::Write(arg1, &json); | 530 base::JSONWriter::Write(arg1, &json); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
630 web_contents_->GetRenderViewHost()-> | 637 web_contents_->GetRenderViewHost()-> |
631 ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16(command)); | 638 ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16(command)); |
632 } | 639 } |
633 | 640 |
634 void DevToolsWindow::AddNewContents(WebContents* source, | 641 void DevToolsWindow::AddNewContents(WebContents* source, |
635 WebContents* new_contents, | 642 WebContents* new_contents, |
636 WindowOpenDisposition disposition, | 643 WindowOpenDisposition disposition, |
637 const gfx::Rect& initial_pos, | 644 const gfx::Rect& initial_pos, |
638 bool user_gesture, | 645 bool user_gesture, |
639 bool* was_blocked) { | 646 bool* was_blocked) { |
640 if (inspected_web_contents_) { | 647 if (GetInspectedWebContents()) { |
641 inspected_web_contents_->GetDelegate()->AddNewContents( | 648 GetInspectedWebContents()->GetDelegate()->AddNewContents( |
642 source, new_contents, disposition, initial_pos, user_gesture, | 649 source, new_contents, disposition, initial_pos, user_gesture, |
643 was_blocked); | 650 was_blocked); |
644 } | 651 } |
645 } | 652 } |
646 | 653 |
647 bool DevToolsWindow::PreHandleKeyboardEvent( | 654 bool DevToolsWindow::PreHandleKeyboardEvent( |
648 WebContents* source, | 655 WebContents* source, |
649 const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) { | 656 const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) { |
650 if (IsDocked()) { | 657 if (IsDocked()) { |
651 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); | 658 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
683 // Break remote debugging / extension debugging session. | 690 // Break remote debugging / extension debugging session. |
684 host->ReplacedWithAnotherClient(); | 691 host->ReplacedWithAnotherClient(); |
685 manager->UnregisterDevToolsClientHostFor(agent); | 692 manager->UnregisterDevToolsClientHostFor(agent); |
686 } | 693 } |
687 | 694 |
688 bool do_open = force_open; | 695 bool do_open = force_open; |
689 if (!window) { | 696 if (!window) { |
690 Profile* profile = Profile::FromBrowserContext( | 697 Profile* profile = Profile::FromBrowserContext( |
691 inspected_rvh->GetProcess()->GetBrowserContext()); | 698 inspected_rvh->GetProcess()->GetBrowserContext()); |
692 DevToolsDockSide dock_side = GetDockSideFromPrefs(profile); | 699 DevToolsDockSide dock_side = GetDockSideFromPrefs(profile); |
693 window = Create(profile, inspected_rvh, dock_side, false); | 700 window = Create(profile, dock_side, false); |
694 manager->RegisterDevToolsClientHostFor(agent, window->frontend_host_.get()); | 701 manager->RegisterDevToolsClientHostFor(agent, window->frontend_host_.get()); |
695 do_open = true; | 702 do_open = true; |
696 } | 703 } |
697 | 704 |
698 // Update toolbar to reflect DevTools changes. | 705 // Update toolbar to reflect DevTools changes. |
699 window->UpdateBrowserToolbar(); | 706 window->UpdateBrowserToolbar(); |
700 | 707 |
701 // If window is docked and visible, we hide it on toggle. If window is | 708 // If window is docked and visible, we hide it on toggle. If window is |
702 // undocked, we show (activate) it. | 709 // undocked, we show (activate) it. |
703 if (!window->IsDocked() || do_open) | 710 if (!window->IsDocked() || do_open) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
770 bounds.Offset(x, y); | 777 bounds.Offset(x, y); |
771 browser_->window()->SetBounds(bounds); | 778 browser_->window()->SetBounds(bounds); |
772 } | 779 } |
773 } | 780 } |
774 | 781 |
775 void DevToolsWindow::SetDockSide(const std::string& side) { | 782 void DevToolsWindow::SetDockSide(const std::string& side) { |
776 DevToolsDockSide requested_side = SideFromString(side); | 783 DevToolsDockSide requested_side = SideFromString(side); |
777 bool dock_requested = requested_side != DEVTOOLS_DOCK_SIDE_UNDOCKED; | 784 bool dock_requested = requested_side != DEVTOOLS_DOCK_SIDE_UNDOCKED; |
778 bool is_docked = IsDocked(); | 785 bool is_docked = IsDocked(); |
779 | 786 |
780 if (dock_requested && (!inspected_web_contents_ || | 787 if (dock_requested && (!GetInspectedWebContents() || |
781 !GetInspectedBrowserWindow() || IsInspectedBrowserPopupOrPanel())) { | 788 !GetInspectedBrowserWindow() || IsInspectedBrowserPopupOrPanel())) { |
782 // Cannot dock, avoid window flashing due to close-reopen cycle. | 789 // Cannot dock, avoid window flashing due to close-reopen cycle. |
783 return; | 790 return; |
784 } | 791 } |
785 | 792 |
786 dock_side_ = requested_side; | 793 dock_side_ = requested_side; |
787 if (dock_requested) { | 794 if (dock_requested) { |
788 if (!is_docked) { | 795 if (!is_docked) { |
789 // Detach window from the external devtools browser. It will lead to | 796 // Detach window from the external devtools browser. It will lead to |
790 // the browser object's close and delete. Remove observer first. | 797 // the browser object's close and delete. Remove observer first. |
(...skipping 25 matching lines...) Expand all Loading... | |
816 | 823 |
817 Show(DEVTOOLS_TOGGLE_ACTION_SHOW); | 824 Show(DEVTOOLS_TOGGLE_ACTION_SHOW); |
818 } | 825 } |
819 | 826 |
820 void DevToolsWindow::OpenInNewTab(const std::string& url) { | 827 void DevToolsWindow::OpenInNewTab(const std::string& url) { |
821 OpenURLParams params(GURL(url), | 828 OpenURLParams params(GURL(url), |
822 content::Referrer(), | 829 content::Referrer(), |
823 NEW_FOREGROUND_TAB, | 830 NEW_FOREGROUND_TAB, |
824 content::PAGE_TRANSITION_LINK, | 831 content::PAGE_TRANSITION_LINK, |
825 false /* is_renderer_initiated */); | 832 false /* is_renderer_initiated */); |
826 if (inspected_web_contents_) { | 833 if (GetInspectedWebContents()) { |
827 inspected_web_contents_->OpenURL(params); | 834 GetInspectedWebContents()->OpenURL(params); |
828 } else { | 835 } else { |
829 chrome::HostDesktopType host_desktop_type; | 836 chrome::HostDesktopType host_desktop_type; |
830 if (browser_) { | 837 if (browser_) { |
831 host_desktop_type = browser_->host_desktop_type(); | 838 host_desktop_type = browser_->host_desktop_type(); |
832 } else { | 839 } else { |
833 // There should always be a browser when there are no inspected web | 840 // There should always be a browser when there are no inspected web |
834 // contents. | 841 // contents. |
835 NOTREACHED(); | 842 NOTREACHED(); |
836 host_desktop_type = chrome::GetActiveDesktop(); | 843 host_desktop_type = chrome::GetActiveDesktop(); |
837 } | 844 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
924 if (!file_system.file_system_path.empty()) | 931 if (!file_system.file_system_path.empty()) |
925 file_system_value = CreateFileSystemValue(file_system); | 932 file_system_value = CreateFileSystemValue(file_system); |
926 CallClientFunction("InspectorFrontendAPI.fileSystemAdded", | 933 CallClientFunction("InspectorFrontendAPI.fileSystemAdded", |
927 &error_string_value, | 934 &error_string_value, |
928 file_system_value); | 935 file_system_value); |
929 if (file_system_value) | 936 if (file_system_value) |
930 delete file_system_value; | 937 delete file_system_value; |
931 } | 938 } |
932 | 939 |
933 content::JavaScriptDialogManager* DevToolsWindow::GetJavaScriptDialogManager() { | 940 content::JavaScriptDialogManager* DevToolsWindow::GetJavaScriptDialogManager() { |
934 if (inspected_web_contents_ && inspected_web_contents_->GetDelegate()) { | 941 if (GetInspectedWebContents() && GetInspectedWebContents()->GetDelegate()) { |
935 return inspected_web_contents_->GetDelegate()-> | 942 return GetInspectedWebContents()->GetDelegate()-> |
936 GetJavaScriptDialogManager(); | 943 GetJavaScriptDialogManager(); |
937 } | 944 } |
938 return content::WebContentsDelegate::GetJavaScriptDialogManager(); | 945 return content::WebContentsDelegate::GetJavaScriptDialogManager(); |
939 } | 946 } |
940 | 947 |
941 void DevToolsWindow::RunFileChooser(WebContents* web_contents, | 948 void DevToolsWindow::RunFileChooser(WebContents* web_contents, |
942 const FileChooserParams& params) { | 949 const FileChooserParams& params) { |
943 FileSelectHelper::RunFileChooser(web_contents, params); | 950 FileSelectHelper::RunFileChooser(web_contents, params); |
944 } | 951 } |
945 | 952 |
946 void DevToolsWindow::WebContentsFocused(WebContents* contents) { | 953 void DevToolsWindow::WebContentsFocused(WebContents* contents) { |
947 Browser* inspected_browser = NULL; | 954 Browser* inspected_browser = NULL; |
948 int inspected_tab_index = -1; | 955 int inspected_tab_index = -1; |
949 | 956 |
950 if (IsDocked() && FindInspectedBrowserAndTabIndex(&inspected_browser, | 957 if (IsDocked() && FindInspectedBrowserAndTabIndex(&inspected_browser, |
951 &inspected_tab_index)) { | 958 &inspected_tab_index)) { |
952 inspected_browser->window()->WebContentsFocused(contents); | 959 inspected_browser->window()->WebContentsFocused(contents); |
953 } | 960 } |
954 } | 961 } |
955 | 962 |
956 void DevToolsWindow::UpdateBrowserToolbar() { | 963 void DevToolsWindow::UpdateBrowserToolbar() { |
957 if (!inspected_web_contents_) | 964 if (!GetInspectedWebContents()) |
958 return; | 965 return; |
959 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); | 966 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); |
960 if (inspected_window) | 967 if (inspected_window) |
961 inspected_window->UpdateToolbar(inspected_web_contents_, false); | 968 inspected_window->UpdateToolbar(GetInspectedWebContents(), false); |
962 } | 969 } |
963 | 970 |
964 bool DevToolsWindow::IsDocked() { | 971 bool DevToolsWindow::IsDocked() { |
965 return dock_side_ != DEVTOOLS_DOCK_SIDE_UNDOCKED; | 972 return dock_side_ != DEVTOOLS_DOCK_SIDE_UNDOCKED; |
966 } | 973 } |
967 | 974 |
968 // static | 975 // static |
969 DevToolsDockSide DevToolsWindow::GetDockSideFromPrefs(Profile* profile) { | 976 DevToolsDockSide DevToolsWindow::GetDockSideFromPrefs(Profile* profile) { |
970 std::string dock_side = | 977 std::string dock_side = |
971 profile->GetPrefs()->GetString(prefs::kDevToolsDockSide); | 978 profile->GetPrefs()->GetString(prefs::kDevToolsDockSide); |
(...skipping 28 matching lines...) Expand all Loading... | |
1000 | 1007 |
1001 // static | 1008 // static |
1002 DevToolsDockSide DevToolsWindow::SideFromString( | 1009 DevToolsDockSide DevToolsWindow::SideFromString( |
1003 const std::string& dock_side) { | 1010 const std::string& dock_side) { |
1004 if (dock_side == kDockSideRight) | 1011 if (dock_side == kDockSideRight) |
1005 return DEVTOOLS_DOCK_SIDE_RIGHT; | 1012 return DEVTOOLS_DOCK_SIDE_RIGHT; |
1006 if (dock_side == kDockSideBottom) | 1013 if (dock_side == kDockSideBottom) |
1007 return DEVTOOLS_DOCK_SIDE_BOTTOM; | 1014 return DEVTOOLS_DOCK_SIDE_BOTTOM; |
1008 return DEVTOOLS_DOCK_SIDE_UNDOCKED; | 1015 return DEVTOOLS_DOCK_SIDE_UNDOCKED; |
1009 } | 1016 } |
OLD | NEW |