Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Side by Side Diff: chrome/browser/ui/webui/devtools_ui.cc

Issue 985073003: [DevTools] Pass remoteBase query param to frontend. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/devtools_ui.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/ui/webui/devtools_ui.h" 5 #include "chrome/browser/ui/webui/devtools_ui.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/ref_counted_memory.h" 10 #include "base/memory/ref_counted_memory.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "chrome/browser/devtools/device/devtools_android_bridge.h" 14 #include "chrome/browser/devtools/device/devtools_android_bridge.h"
15 #include "chrome/browser/devtools/devtools_target_impl.h" 15 #include "chrome/browser/devtools/devtools_target_impl.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/devtools_http_handler.h" 20 #include "content/public/browser/devtools_http_handler.h"
21 #include "content/public/browser/navigation_controller.h" 21 #include "content/public/browser/navigation_controller.h"
22 #include "content/public/browser/navigation_details.h" 22 #include "content/public/browser/navigation_details.h"
23 #include "content/public/browser/navigation_entry.h" 23 #include "content/public/browser/navigation_entry.h"
24 #include "content/public/browser/url_data_source.h" 24 #include "content/public/browser/url_data_source.h"
25 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
26 #include "content/public/browser/web_ui.h" 26 #include "content/public/browser/web_ui.h"
27 #include "content/public/common/user_agent.h"
27 #include "net/url_request/url_fetcher.h" 28 #include "net/url_request/url_fetcher.h"
28 #include "net/url_request/url_fetcher_delegate.h" 29 #include "net/url_request/url_fetcher_delegate.h"
29 #include "net/url_request/url_request_context_getter.h" 30 #include "net/url_request/url_request_context_getter.h"
30 #include "ui/base/resource/resource_bundle.h" 31 #include "ui/base/resource/resource_bundle.h"
31 32
32 using content::BrowserThread; 33 using content::BrowserThread;
33 using content::WebContents; 34 using content::WebContents;
34 35
35 namespace { 36 namespace {
36 37
37 std::string PathWithoutParams(const std::string& path) { 38 std::string PathWithoutParams(const std::string& path) {
38 return GURL(std::string("chrome-devtools://devtools/") + path) 39 return GURL(std::string("chrome-devtools://devtools/") + path)
39 .path().substr(1); 40 .path().substr(1);
40 } 41 }
41 42
42 const char kRemoteFrontendDomain[] = "chrome-devtools-frontend.appspot.com"; 43 const char kRemoteFrontendDomain[] = "chrome-devtools-frontend.appspot.com";
43 const char kRemoteFrontendBase[] = 44 const char kRemoteFrontendBase[] =
44 "https://chrome-devtools-frontend.appspot.com/"; 45 "https://chrome-devtools-frontend.appspot.com/";
46 const char kRemoteFrontendPath[] = "serve_file";
45 const char kHttpNotFound[] = "HTTP/1.1 404 Not Found\n\n"; 47 const char kHttpNotFound[] = "HTTP/1.1 404 Not Found\n\n";
46 48
47 #if defined(DEBUG_DEVTOOLS) 49 #if defined(DEBUG_DEVTOOLS)
48 // Local frontend url provided by InspectUI. 50 // Local frontend url provided by InspectUI.
49 const char kFallbackFrontendURL[] = 51 const char kFallbackFrontendURL[] =
50 "chrome-devtools://devtools/bundled/inspector.html"; 52 "chrome-devtools://devtools/bundled/inspector.html";
51 #else 53 #else
52 // URL causing the DevTools window to display a plain text warning. 54 // URL causing the DevTools window to display a plain text warning.
53 const char kFallbackFrontendURL[] = 55 const char kFallbackFrontendURL[] =
54 "data:text/plain,Cannot load DevTools frontend from an untrusted origin"; 56 "data:text/plain,Cannot load DevTools frontend from an untrusted origin";
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 GURL url(frontend_url); 348 GURL url(frontend_url);
347 if (!url.is_valid() || url.host() != kRemoteFrontendDomain) 349 if (!url.is_valid() || url.host() != kRemoteFrontendDomain)
348 return GURL(kFallbackFrontendURL); 350 return GURL(kFallbackFrontendURL);
349 return GURL(base::StringPrintf("%s://%s/%s/%s", 351 return GURL(base::StringPrintf("%s://%s/%s/%s",
350 content::kChromeDevToolsScheme, 352 content::kChromeDevToolsScheme,
351 chrome::kChromeUIDevToolsHost, 353 chrome::kChromeUIDevToolsHost,
352 chrome::kChromeUIDevToolsRemotePath, 354 chrome::kChromeUIDevToolsRemotePath,
353 url.path().substr(1).c_str())); 355 url.path().substr(1).c_str()));
354 } 356 }
355 357
358 // static
359 GURL DevToolsUI::GetRemoteBaseURL() {
360 return GURL(base::StringPrintf(
361 "%s%s/%s/",
362 kRemoteFrontendBase,
363 kRemoteFrontendPath,
364 content::GetWebKitRevision().c_str()));
365 }
366
356 DevToolsUI::DevToolsUI(content::WebUI* web_ui) 367 DevToolsUI::DevToolsUI(content::WebUI* web_ui)
357 : WebUIController(web_ui), 368 : WebUIController(web_ui),
358 content::WebContentsObserver(web_ui->GetWebContents()), 369 content::WebContentsObserver(web_ui->GetWebContents()),
359 bindings_(web_ui->GetWebContents()), 370 bindings_(web_ui->GetWebContents()),
360 weak_factory_(this) { 371 weak_factory_(this) {
361 web_ui->SetBindings(0); 372 web_ui->SetBindings(0);
362 Profile* profile = Profile::FromWebUI(web_ui); 373 Profile* profile = Profile::FromWebUI(web_ui);
363 content::URLDataSource::Add( 374 content::URLDataSource::Add(
364 profile, 375 profile,
365 new DevToolsDataSource(profile->GetRequestContext())); 376 new DevToolsDataSource(profile->GetRequestContext()));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 params.should_replace_current_entry = true; 424 params.should_replace_current_entry = true;
414 remote_frontend_loading_url_ = virtual_url; 425 remote_frontend_loading_url_ = virtual_url;
415 navigation_controller.LoadURLWithParams(params); 426 navigation_controller.LoadURLWithParams(params);
416 navigation_controller.GetPendingEntry()->SetVirtualURL(virtual_url); 427 navigation_controller.GetPendingEntry()->SetVirtualURL(virtual_url);
417 428
418 DevToolsAndroidBridge* bridge = 429 DevToolsAndroidBridge* bridge =
419 DevToolsAndroidBridge::Factory::GetForProfile(profile); 430 DevToolsAndroidBridge::Factory::GetForProfile(profile);
420 scoped_ptr<DevToolsTargetImpl> target(bridge->CreatePageTarget(page)); 431 scoped_ptr<DevToolsTargetImpl> target(bridge->CreatePageTarget(page));
421 bindings_.AttachTo(target->GetAgentHost()); 432 bindings_.AttachTo(target->GetAgentHost());
422 } 433 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/devtools_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698