| 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..0dae79049790337a0e9121dac5a0448bc4f44a41 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,51 @@ 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";
|
|
|
| +// 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 AppWindowCreateFunction::DevToolsRestorer
|
| + : public content::NotificationObserver {
|
| + public:
|
| + DevToolsRestorer(AppWindowCreateFunction* parent,
|
| + content::RenderViewHost* created_view)
|
| + : parent_(parent) {
|
| + 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);
|
| + parent_->SendResponse(true);
|
| + parent_ = NULL;
|
| + }
|
| + private:
|
| + scoped_refptr<AppWindowCreateFunction> parent_;
|
| + content::NotificationRegistrar registrar_;
|
| +};
|
| +
|
| +AppWindowCreateFunction::AppWindowCreateFunction() {
|
| +}
|
| +
|
| +AppWindowCreateFunction::~AppWindowCreateFunction() {
|
| +}
|
| +
|
| bool AppWindowCreateFunction::RunImpl() {
|
| scoped_ptr<Create::Params> params(Create::Params::Create(*args_));
|
| EXTENSION_FUNCTION_VALIDATE(params.get());
|
| @@ -151,6 +196,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)) {
|
| + delay_response_.reset(new DevToolsRestorer(this, created_view));
|
| + return true;
|
| + }
|
| +
|
| + SendResponse(true);
|
| return true;
|
| }
|
|
|
|
|