| 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 "extensions/browser/api/app_window/app_window_api.h" | 5 #include "extensions/browser/api/app_window/app_window_api.h" |
| 6 | 6 |
| 7 #include <memory> |
| 8 #include <utility> |
| 9 |
| 7 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 11 #include "base/macros.h" |
| 9 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 11 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 12 #include "base/values.h" | 15 #include "base/values.h" |
| 13 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 15 #include "content/public/browser/notification_types.h" | 18 #include "content/public/browser/notification_types.h" |
| 16 #include "content/public/browser/render_frame_host.h" | 19 #include "content/public/browser/render_frame_host.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 frame_id = existing_frame->GetRoutingID(); | 187 frame_id = existing_frame->GetRoutingID(); |
| 185 } | 188 } |
| 186 | 189 |
| 187 if (!options->hidden.get() || !*options->hidden.get()) { | 190 if (!options->hidden.get() || !*options->hidden.get()) { |
| 188 if (options->focused.get() && !*options->focused.get()) | 191 if (options->focused.get() && !*options->focused.get()) |
| 189 existing_window->Show(AppWindow::SHOW_INACTIVE); | 192 existing_window->Show(AppWindow::SHOW_INACTIVE); |
| 190 else | 193 else |
| 191 existing_window->Show(AppWindow::SHOW_ACTIVE); | 194 existing_window->Show(AppWindow::SHOW_ACTIVE); |
| 192 } | 195 } |
| 193 | 196 |
| 194 base::DictionaryValue* result = new base::DictionaryValue; | 197 std::unique_ptr<base::DictionaryValue> result( |
| 198 new base::DictionaryValue); |
| 195 result->Set("frameId", new base::FundamentalValue(frame_id)); | 199 result->Set("frameId", new base::FundamentalValue(frame_id)); |
| 196 existing_window->GetSerializedState(result); | 200 existing_window->GetSerializedState(result.get()); |
| 197 result->SetBoolean("existingWindow", true); | 201 result->SetBoolean("existingWindow", true); |
| 198 SetResult(result); | 202 SetResult(std::move(result)); |
| 199 SendResponse(true); | 203 SendResponse(true); |
| 200 return true; | 204 return true; |
| 201 } | 205 } |
| 202 } | 206 } |
| 203 } | 207 } |
| 204 | 208 |
| 205 if (!GetBoundsSpec(*options, &create_params, &error_)) | 209 if (!GetBoundsSpec(*options, &create_params, &error_)) |
| 206 return false; | 210 return false; |
| 207 | 211 |
| 208 if (options->type == app_window::WINDOW_TYPE_PANEL) { | 212 if (options->type == app_window::WINDOW_TYPE_PANEL) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 !app_window->is_ime_window()) { | 351 !app_window->is_ime_window()) { |
| 348 app_window->ForcedFullscreen(); | 352 app_window->ForcedFullscreen(); |
| 349 } | 353 } |
| 350 | 354 |
| 351 content::RenderFrameHost* created_frame = | 355 content::RenderFrameHost* created_frame = |
| 352 app_window->web_contents()->GetMainFrame(); | 356 app_window->web_contents()->GetMainFrame(); |
| 353 int frame_id = MSG_ROUTING_NONE; | 357 int frame_id = MSG_ROUTING_NONE; |
| 354 if (create_params.creator_process_id == created_frame->GetProcess()->GetID()) | 358 if (create_params.creator_process_id == created_frame->GetProcess()->GetID()) |
| 355 frame_id = created_frame->GetRoutingID(); | 359 frame_id = created_frame->GetRoutingID(); |
| 356 | 360 |
| 357 base::DictionaryValue* result = new base::DictionaryValue; | 361 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue); |
| 358 result->Set("frameId", new base::FundamentalValue(frame_id)); | 362 result->Set("frameId", new base::FundamentalValue(frame_id)); |
| 359 result->Set("id", new base::StringValue(app_window->window_key())); | 363 result->Set("id", new base::StringValue(app_window->window_key())); |
| 360 app_window->GetSerializedState(result); | 364 app_window->GetSerializedState(result.get()); |
| 361 SetResult(result); | 365 SetResult(std::move(result)); |
| 362 | 366 |
| 363 if (AppWindowRegistry::Get(browser_context()) | 367 if (AppWindowRegistry::Get(browser_context()) |
| 364 ->HadDevToolsAttached(app_window->web_contents())) { | 368 ->HadDevToolsAttached(app_window->web_contents())) { |
| 365 AppWindowClient::Get()->OpenDevToolsWindow( | 369 AppWindowClient::Get()->OpenDevToolsWindow( |
| 366 app_window->web_contents(), | 370 app_window->web_contents(), |
| 367 base::Bind(&AppWindowCreateFunction::SendResponse, this, true)); | 371 base::Bind(&AppWindowCreateFunction::SendResponse, this, true)); |
| 368 return true; | 372 return true; |
| 369 } | 373 } |
| 370 | 374 |
| 371 // PlzNavigate: delay sending the response until the newly created window has | 375 // PlzNavigate: delay sending the response until the newly created window has |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 | 553 |
| 550 if (options.frame->as_frame_options->inactive_color.get()) { | 554 if (options.frame->as_frame_options->inactive_color.get()) { |
| 551 error_ = app_window_constants::kInactiveColorWithoutColor; | 555 error_ = app_window_constants::kInactiveColorWithoutColor; |
| 552 return false; | 556 return false; |
| 553 } | 557 } |
| 554 | 558 |
| 555 return true; | 559 return true; |
| 556 } | 560 } |
| 557 | 561 |
| 558 } // namespace extensions | 562 } // namespace extensions |
| OLD | NEW |