| Index: chrome/browser/extensions/api/app_window/app_window_api.cc
|
| diff --git a/chrome/browser/extensions/api/app_window/app_window_api.cc b/chrome/browser/extensions/api/app_window/app_window_api.cc
|
| index 34e855581da5ec160f0edbce45c32c6757d2c38b..efe0d16e4e3332d499632aa63b4cec3a8a18d1e5 100644
|
| --- a/chrome/browser/extensions/api/app_window/app_window_api.cc
|
| +++ b/chrome/browser/extensions/api/app_window/app_window_api.cc
|
| @@ -7,10 +7,15 @@
|
| #include "base/command_line.h"
|
| #include "base/time.h"
|
| #include "base/values.h"
|
| +#include "chrome/browser/debugger/devtools_window.h"
|
| +#include "chrome/browser/extensions/shell_window_registry.h"
|
| #include "chrome/browser/extensions/window_controller.h"
|
| #include "chrome/browser/ui/extensions/shell_window.h"
|
| +#include "chrome/browser/ui/tab_contents/tab_contents.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/extensions/api/app_window.h"
|
| +#include "content/public/browser/notification_registrar.h"
|
| +#include "content/public/browser/notification_types.h"
|
| #include "content/public/browser/render_process_host.h"
|
| #include "content/public/browser/render_view_host.h"
|
| #include "content/public/browser/web_contents.h"
|
| @@ -26,11 +31,55 @@ namespace extensions {
|
| namespace app_window_constants {
|
| const char kInvalidWindowId[] =
|
| "The window id can not be more than 256 characters long.";
|
| -};
|
| +}
|
|
|
| const char kNoneFrameOption[] = "none";
|
| const char kHtmlFrameOption[] = "experimental-html";
|
|
|
| +namespace {
|
| +
|
| +// Opens an inspector window and delays the response to the
|
| +// AppWindowCreateFunction until the DevToolsWindow has finished loading, and is
|
| +// ready to stop on breakpoints in the callback.
|
| +class DevToolsRestorer : public content::NotificationObserver {
|
| + public:
|
| + DevToolsRestorer(AppWindowCreateFunction* delayed_create_function,
|
| + content::RenderViewHost* created_view)
|
| + : delayed_create_function_(delayed_create_function) {
|
| + DevToolsWindow* devtools_window =
|
| + DevToolsWindow::ToggleDevToolsWindow(
|
| + created_view,
|
| + true /* force_open */,
|
| + DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE);
|
| +
|
| + registrar_.Add(
|
| + this,
|
| + content::NOTIFICATION_LOAD_STOP,
|
| + content::Source<content::NavigationController>(
|
| + &devtools_window->tab_contents()->web_contents()->GetController()));
|
| + }
|
| +
|
| + protected:
|
| + // content::NotificationObserver:
|
| + virtual void Observe(int type,
|
| + const content::NotificationSource& source,
|
| + const content::NotificationDetails& details) OVERRIDE {
|
| + DCHECK(type == content::NOTIFICATION_LOAD_STOP);
|
| + delayed_create_function_->SendDelayedResponse();
|
| + delete this;
|
| + }
|
| +
|
| + private:
|
| + scoped_refptr<AppWindowCreateFunction> delayed_create_function_;
|
| + content::NotificationRegistrar registrar_;
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +void AppWindowCreateFunction::SendDelayedResponse() {
|
| + SendResponse(true);
|
| +}
|
| +
|
| bool AppWindowCreateFunction::RunImpl() {
|
| scoped_ptr<Create::Params> params(Create::Params::Create(*args_));
|
| EXTENSION_FUNCTION_VALIDATE(params.get());
|
| @@ -151,6 +200,13 @@ bool AppWindowCreateFunction::RunImpl() {
|
| base::Value::CreateBooleanValue(inject_html_titlebar));
|
| result->Set("id", base::Value::CreateStringValue(shell_window->window_key()));
|
| SetResult(result);
|
| +
|
| + if (ShellWindowRegistry::Get(profile())->HadDevToolsAttached(created_view)) {
|
| + new DevToolsRestorer(this, created_view);
|
| + return true;
|
| + }
|
| +
|
| + SendResponse(true);
|
| return true;
|
| }
|
|
|
|
|