-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A link to a source is now displayed in the element properties panel. Clicking on the link opens the source panel where the header file is loaded. Right clicking on the link gives the option to open in new tab, which opens the header file in Chromium code search. Change-Id: I0314ff285e727bdcc7a9a58201cb6f9089a4c718 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1719164 Commit-Queue: Kristyn Hamasaki <khamasaki@google.com> Reviewed-by: Wei Li <weili@chromium.org> Cr-Commit-Position: refs/heads/master@{#686116}
- Loading branch information
Kristyn Hamasaki
authored and
Commit Bot
committed
Aug 12, 2019
1 parent
0869f48
commit 4de3d0a
Showing
24 changed files
with
565 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// This file is for testing GetSource. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "components/ui_devtools/agent_util.h" | ||
|
||
#include "base/command_line.h" | ||
#include "base/files/file_path.h" | ||
#include "base/files/file_util.h" | ||
#include "base/path_service.h" | ||
#include "base/run_loop.h" | ||
#include "base/task/post_task.h" | ||
#include "base/task/task_traits.h" | ||
|
||
namespace ui_devtools { | ||
|
||
namespace { | ||
|
||
void OnSourceFile(base::OnceClosure quit_closure, | ||
bool* return_value, | ||
bool read_file_result) { | ||
*return_value = read_file_result; | ||
std::move(quit_closure).Run(); | ||
} | ||
|
||
} // namespace | ||
|
||
const char kChromiumCodeSearchURL[] = "https://cs.chromium.org/"; | ||
const char kChromiumCodeSearchSrcURL[] = | ||
"https://cs.chromium.org/chromium/src/"; | ||
|
||
bool GetSourceCode(std::string path, std::string* source_code) { | ||
base::FilePath src_dir; | ||
base::PathService::Get(base::DIR_SOURCE_ROOT, &src_dir); | ||
src_dir = src_dir.AppendASCII(path); | ||
|
||
base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed); | ||
|
||
bool return_value; | ||
base::PostTaskAndReplyWithResult( | ||
FROM_HERE, | ||
{base::MayBlock(), base::TaskPriority::USER_VISIBLE, | ||
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}, | ||
base::BindOnce(&base::ReadFileToString, src_dir, source_code), | ||
base::BindOnce(&OnSourceFile, run_loop.QuitClosure(), &return_value)); | ||
|
||
run_loop.Run(); | ||
|
||
if (!return_value) | ||
DLOG(ERROR) << "Could not get source file of " << src_dir.value() << "."; | ||
|
||
return return_value; | ||
} | ||
|
||
} // namespace ui_devtools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef COMPONENTS_UI_DEVTOOLS_AGENT_UTIL_H_ | ||
#define COMPONENTS_UI_DEVTOOLS_AGENT_UTIL_H_ | ||
|
||
#include "base/files/file_path.h" | ||
#include "components/ui_devtools/devtools_export.h" | ||
|
||
namespace ui_devtools { | ||
|
||
UI_DEVTOOLS_EXPORT extern const char kChromiumCodeSearchURL[]; | ||
UI_DEVTOOLS_EXPORT extern const char kChromiumCodeSearchSrcURL[]; | ||
|
||
// Synchonously gets source code and returns true if successful. | ||
bool UI_DEVTOOLS_EXPORT GetSourceCode(std::string path, | ||
std::string* source_code); | ||
|
||
} // namespace ui_devtools | ||
|
||
#endif // COMPONENTS_UI_DEVTOOLS_AGENT_UTIL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.