OLD | NEW |
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/extensions/api/app_window/app_window_api.h" | 5 #include "chrome/browser/extensions/api/app_window/app_window_api.h" |
6 | 6 |
7 #include "apps/app_window.h" | 7 #include "apps/app_window.h" |
8 #include "apps/app_window_contents.h" | 8 #include "apps/app_window_contents.h" |
9 #include "apps/app_window_registry.h" | 9 #include "apps/app_window_registry.h" |
10 #include "apps/ui/apps_client.h" | 10 #include "apps/ui/apps_client.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 const char kHtmlFrameOption[] = "experimental-html"; | 61 const char kHtmlFrameOption[] = "experimental-html"; |
62 | 62 |
63 namespace { | 63 namespace { |
64 | 64 |
65 // Opens an inspector window and delays the response to the | 65 // Opens an inspector window and delays the response to the |
66 // AppWindowCreateFunction until the DevToolsWindow has finished loading, and is | 66 // AppWindowCreateFunction until the DevToolsWindow has finished loading, and is |
67 // ready to stop on breakpoints in the callback. | 67 // ready to stop on breakpoints in the callback. |
68 class DevToolsRestorer : public base::RefCounted<DevToolsRestorer> { | 68 class DevToolsRestorer : public base::RefCounted<DevToolsRestorer> { |
69 public: | 69 public: |
70 DevToolsRestorer(AppWindowCreateFunction* delayed_create_function, | 70 DevToolsRestorer(AppWindowCreateFunction* delayed_create_function, |
71 content::RenderViewHost* created_view) | 71 content::WebContents* web_contents) |
72 : delayed_create_function_(delayed_create_function) { | 72 : delayed_create_function_(delayed_create_function) { |
73 AddRef(); // Balanced in LoadCompleted. | 73 AddRef(); // Balanced in LoadCompleted. |
74 DevToolsWindow* devtools_window = | 74 DevToolsWindow* devtools_window = DevToolsWindow::OpenDevToolsWindow( |
75 DevToolsWindow::OpenDevToolsWindow( | 75 web_contents, |
76 created_view, | 76 DevToolsToggleAction::ShowConsole()); |
77 DevToolsToggleAction::ShowConsole()); | |
78 devtools_window->SetLoadCompletedCallback( | 77 devtools_window->SetLoadCompletedCallback( |
79 base::Bind(&DevToolsRestorer::LoadCompleted, this)); | 78 base::Bind(&DevToolsRestorer::LoadCompleted, this)); |
80 } | 79 } |
81 | 80 |
82 private: | 81 private: |
83 friend class base::RefCounted<DevToolsRestorer>; | 82 friend class base::RefCounted<DevToolsRestorer>; |
84 ~DevToolsRestorer() {} | 83 ~DevToolsRestorer() {} |
85 | 84 |
86 void LoadCompleted() { | 85 void LoadCompleted() { |
87 delayed_create_function_->SendDelayedResponse(); | 86 delayed_create_function_->SendDelayedResponse(); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 base::DictionaryValue* result = new base::DictionaryValue; | 299 base::DictionaryValue* result = new base::DictionaryValue; |
301 result->Set("viewId", new base::FundamentalValue(view_id)); | 300 result->Set("viewId", new base::FundamentalValue(view_id)); |
302 result->Set("injectTitlebar", | 301 result->Set("injectTitlebar", |
303 new base::FundamentalValue(inject_html_titlebar_)); | 302 new base::FundamentalValue(inject_html_titlebar_)); |
304 result->Set("id", new base::StringValue(app_window->window_key())); | 303 result->Set("id", new base::StringValue(app_window->window_key())); |
305 app_window->GetSerializedState(result); | 304 app_window->GetSerializedState(result); |
306 SetResult(result); | 305 SetResult(result); |
307 | 306 |
308 if (apps::AppWindowRegistry::Get(browser_context()) | 307 if (apps::AppWindowRegistry::Get(browser_context()) |
309 ->HadDevToolsAttached(created_view)) { | 308 ->HadDevToolsAttached(created_view)) { |
310 new DevToolsRestorer(this, created_view); | 309 new DevToolsRestorer(this, app_window->web_contents()); |
311 return true; | 310 return true; |
312 } | 311 } |
313 | 312 |
314 SendResponse(true); | 313 SendResponse(true); |
315 app_window->WindowEventsReady(); | 314 app_window->WindowEventsReady(); |
316 | 315 |
317 return true; | 316 return true; |
318 } | 317 } |
319 | 318 |
320 bool AppWindowCreateFunction::GetBoundsSpec( | 319 bool AppWindowCreateFunction::GetBoundsSpec( |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 | 491 |
493 if (options.frame->as_frame_options->inactive_color.get()) { | 492 if (options.frame->as_frame_options->inactive_color.get()) { |
494 error_ = app_window_constants::kInactiveColorWithoutColor; | 493 error_ = app_window_constants::kInactiveColorWithoutColor; |
495 return false; | 494 return false; |
496 } | 495 } |
497 | 496 |
498 return true; | 497 return true; |
499 } | 498 } |
500 | 499 |
501 } // namespace extensions | 500 } // namespace extensions |
OLD | NEW |