| Index: chrome/browser/devtools/devtools_window.cc
|
| diff --git a/chrome/browser/devtools/devtools_window.cc b/chrome/browser/devtools/devtools_window.cc
|
| index c47389dee853a4aeb1ed0a91ee9b0991e136f5bc..608ac7a7a65cfd2fcc4c76bae20292f2b57ce19e 100644
|
| --- a/chrome/browser/devtools/devtools_window.cc
|
| +++ b/chrome/browser/devtools/devtools_window.cc
|
| @@ -39,6 +39,7 @@
|
| #include "content/public/browser/native_web_keyboard_event.h"
|
| #include "content/public/browser/navigation_controller.h"
|
| #include "content/public/browser/navigation_entry.h"
|
| +#include "content/public/browser/notification_source.h"
|
| #include "content/public/browser/render_frame_host.h"
|
| #include "content/public/browser/render_process_host.h"
|
| #include "content/public/browser/render_view_host.h"
|
| @@ -48,6 +49,7 @@
|
| #include "content/public/common/content_client.h"
|
| #include "content/public/common/page_transition_types.h"
|
| #include "content/public/common/url_constants.h"
|
| +#include "content/public/test/test_utils.h"
|
| #include "third_party/WebKit/public/web/WebInputEvent.h"
|
| #include "ui/events/keycodes/keyboard_codes.h"
|
|
|
| @@ -316,11 +318,6 @@
|
| std::find(instances->begin(), instances->end(), this));
|
| DCHECK(it != instances->end());
|
| instances->erase(it);
|
| -
|
| - if (!close_callback_.is_null()) {
|
| - close_callback_.Run();
|
| - close_callback_ = base::Closure();
|
| - }
|
| }
|
|
|
| // static
|
| @@ -406,16 +403,7 @@
|
|
|
| // static
|
| bool DevToolsWindow::IsDevToolsWindow(content::WebContents* web_contents) {
|
| - if (!web_contents || g_instances == NULL)
|
| - return false;
|
| - DevToolsWindows* instances = g_instances.Pointer();
|
| - for (DevToolsWindows::iterator it(instances->begin()); it != instances->end();
|
| - ++it) {
|
| - if ((*it)->main_web_contents_ == web_contents ||
|
| - (*it)->toolbox_web_contents_ == web_contents)
|
| - return true;
|
| - }
|
| - return false;
|
| + return AsDevToolsWindow(web_contents) != NULL;
|
| }
|
|
|
| // static
|
| @@ -437,21 +425,40 @@
|
| DevToolsWindow* DevToolsWindow::CreateDevToolsWindowForWorker(
|
| Profile* profile) {
|
| content::RecordAction(base::UserMetricsAction("DevTools_InspectWorker"));
|
| - return Create(profile, GURL(), NULL, true, false, false, "");
|
| + return Create(profile, GURL(), NULL, true, false, false);
|
| }
|
|
|
| // static
|
| DevToolsWindow* DevToolsWindow::OpenDevToolsWindow(
|
| content::RenderViewHost* inspected_rvh) {
|
| return ToggleDevToolsWindow(
|
| - inspected_rvh, true, DevToolsToggleAction::Show(), "");
|
| + inspected_rvh, true, DevToolsToggleAction::Show());
|
| }
|
|
|
| // static
|
| DevToolsWindow* DevToolsWindow::OpenDevToolsWindow(
|
| content::RenderViewHost* inspected_rvh,
|
| const DevToolsToggleAction& action) {
|
| - return ToggleDevToolsWindow(inspected_rvh, true, action, "");
|
| + return ToggleDevToolsWindow(
|
| + inspected_rvh, true, action);
|
| +}
|
| +
|
| +// static
|
| +DevToolsWindow* DevToolsWindow::OpenDevToolsWindowForTest(
|
| + content::RenderViewHost* inspected_rvh,
|
| + bool is_docked) {
|
| + DevToolsWindow* window = OpenDevToolsWindow(inspected_rvh);
|
| + window->SetIsDockedAndShowImmediatelyForTest(is_docked);
|
| + return window;
|
| +}
|
| +
|
| +// static
|
| +DevToolsWindow* DevToolsWindow::OpenDevToolsWindowForTest(
|
| + Browser* browser,
|
| + bool is_docked) {
|
| + return OpenDevToolsWindowForTest(
|
| + browser->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(),
|
| + is_docked);
|
| }
|
|
|
| // static
|
| @@ -466,7 +473,7 @@
|
|
|
| return ToggleDevToolsWindow(
|
| browser->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(),
|
| - action.type() == DevToolsToggleAction::kInspect, action, "");
|
| + action.type() == DevToolsToggleAction::kInspect, action);
|
| }
|
|
|
| // static
|
| @@ -477,7 +484,7 @@
|
| DevToolsWindow* window = FindDevToolsWindow(agent_host);
|
| if (!window) {
|
| window = Create(profile, DevToolsUI::GetProxyURL(frontend_url), NULL,
|
| - false, true, false, "");
|
| + false, true, false);
|
| content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(
|
| agent_host, window->bindings_->frontend_host());
|
| }
|
| @@ -488,8 +495,7 @@
|
| DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow(
|
| content::RenderViewHost* inspected_rvh,
|
| bool force_open,
|
| - const DevToolsToggleAction& action,
|
| - const std::string& settings) {
|
| + const DevToolsToggleAction& action) {
|
| scoped_refptr<DevToolsAgentHost> agent(
|
| DevToolsAgentHost::GetOrCreateFor(inspected_rvh));
|
| content::DevToolsManager* manager = content::DevToolsManager::GetInstance();
|
| @@ -500,8 +506,7 @@
|
| inspected_rvh->GetProcess()->GetBrowserContext());
|
| content::RecordAction(
|
| base::UserMetricsAction("DevTools_InspectRenderer"));
|
| - window = Create(
|
| - profile, GURL(), inspected_rvh, false, false, true, settings);
|
| + window = Create(profile, GURL(), inspected_rvh, false, false, true);
|
| manager->RegisterDevToolsClientHostFor(agent.get(),
|
| window->bindings_->frontend_host());
|
| do_open = true;
|
| @@ -695,6 +700,7 @@
|
| // Passing "dockSide=undocked" parameter ensures proper UI.
|
| life_stage_(can_dock ? kNotLoaded : kIsDockedSet),
|
| action_on_load_(DevToolsToggleAction::NoOp()),
|
| + ignore_set_is_docked_(false),
|
| intercepted_page_beforeunload_(false) {
|
| // Set up delegate, so we get fully-functional window immediately.
|
| // It will not appear in UI though until |life_stage_ == kLoadCompleted|.
|
| @@ -726,8 +732,7 @@
|
| content::RenderViewHost* inspected_rvh,
|
| bool shared_worker_frontend,
|
| bool external_frontend,
|
| - bool can_dock,
|
| - const std::string& settings) {
|
| + bool can_dock) {
|
| if (inspected_rvh) {
|
| // Check for a place to dock.
|
| Browser* browser = NULL;
|
| @@ -746,7 +751,7 @@
|
| GURL url(GetDevToolsURL(profile, frontend_url,
|
| shared_worker_frontend,
|
| external_frontend,
|
| - can_dock, settings));
|
| + can_dock));
|
| return new DevToolsWindow(profile, url, inspected_rvh, can_dock);
|
| }
|
|
|
| @@ -755,8 +760,7 @@
|
| const GURL& base_url,
|
| bool shared_worker_frontend,
|
| bool external_frontend,
|
| - bool can_dock,
|
| - const std::string& settings) {
|
| + bool can_dock) {
|
| // Compatibility errors are encoded with data urls, pass them
|
| // through with no decoration.
|
| if (base_url.SchemeIs("data"))
|
| @@ -773,8 +777,6 @@
|
| url_string += "&remoteFrontend=true";
|
| if (can_dock)
|
| url_string += "&can_dock=true";
|
| - if (settings.size())
|
| - url_string += "&settings=" + settings;
|
| return GURL(url_string);
|
| }
|
|
|
| @@ -1028,8 +1030,27 @@
|
| }
|
| }
|
|
|
| +void DevToolsWindow::SetIsDockedAndShowImmediatelyForTest(bool is_docked) {
|
| + DCHECK(!is_docked || can_dock_);
|
| + DCHECK(life_stage_ != kClosing);
|
| + if (life_stage_ == kLoadCompleted) {
|
| + SetIsDocked(is_docked);
|
| + } else {
|
| + is_docked_ = is_docked;
|
| + // Load is completed when both kIsDockedSet and kOnLoadFired happened.
|
| + // Note that kIsDockedSet may be already set when can_dock_ is false.
|
| + life_stage_ = life_stage_ == kOnLoadFired ? kLoadCompleted : kIsDockedSet;
|
| + // Note that action_on_load_ will be performed after the load is actually
|
| + // completed. For now, just show the window.
|
| + Show(DevToolsToggleAction::Show());
|
| + if (life_stage_ == kLoadCompleted)
|
| + LoadCompleted();
|
| + }
|
| + ignore_set_is_docked_ = true;
|
| +}
|
| +
|
| void DevToolsWindow::SetIsDocked(bool dock_requested) {
|
| - if (life_stage_ == kClosing)
|
| + if (ignore_set_is_docked_ || life_stage_ == kClosing)
|
| return;
|
|
|
| DCHECK(can_dock_ || !dock_requested);
|
| @@ -1240,7 +1261,7 @@
|
| }
|
|
|
| void DevToolsWindow::SetLoadCompletedCallback(const base::Closure& closure) {
|
| - if (life_stage_ == kLoadCompleted || life_stage_ == kClosing) {
|
| + if (life_stage_ == kLoadCompleted) {
|
| if (!closure.is_null())
|
| closure.Run();
|
| return;
|
|
|