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/tabs/tabs_api.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <limits> | 9 #include <limits> |
10 #include <memory> | 10 #include <memory> |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 WindowControllerList::GetInstance()->FindWindowById( | 582 WindowControllerList::GetInstance()->FindWindowById( |
583 app_window->session_id().id()); | 583 app_window->session_id().id()); |
584 if (!window_controller) | 584 if (!window_controller) |
585 return RespondNow(Error(kUnknownErrorDoNotUse)); | 585 return RespondNow(Error(kUnknownErrorDoNotUse)); |
586 return RespondNow( | 586 return RespondNow( |
587 OneArgument(window_controller->CreateWindowValueWithTabs(extension()))); | 587 OneArgument(window_controller->CreateWindowValueWithTabs(extension()))); |
588 } | 588 } |
589 #endif // defined(USE_ASH) | 589 #endif // defined(USE_ASH) |
590 | 590 |
591 // Create a new BrowserWindow. | 591 // Create a new BrowserWindow. |
592 Browser::CreateParams create_params(window_type, window_profile); | 592 Browser::CreateParams create_params(window_type, window_profile, |
| 593 user_gesture()); |
593 if (extension_id.empty()) { | 594 if (extension_id.empty()) { |
594 create_params.initial_bounds = window_bounds; | 595 create_params.initial_bounds = window_bounds; |
595 } else { | 596 } else { |
596 create_params = Browser::CreateParams::CreateForApp( | 597 create_params = Browser::CreateParams::CreateForApp( |
597 web_app::GenerateApplicationNameFromExtensionId(extension_id), | 598 web_app::GenerateApplicationNameFromExtensionId(extension_id), |
598 false /* trusted_source */, window_bounds, window_profile); | 599 false /* trusted_source */, window_bounds, window_profile, |
| 600 user_gesture()); |
599 } | 601 } |
600 create_params.initial_show_state = ui::SHOW_STATE_NORMAL; | 602 create_params.initial_show_state = ui::SHOW_STATE_NORMAL; |
601 if (create_data && create_data->state) { | 603 if (create_data && create_data->state) { |
602 create_params.initial_show_state = | 604 create_params.initial_show_state = |
603 ConvertToWindowShowState(create_data->state); | 605 ConvertToWindowShowState(create_data->state); |
604 } | 606 } |
605 | 607 |
606 Browser* new_window = new Browser(create_params); | 608 Browser* new_window = new Browser(create_params); |
607 | 609 |
608 for (const GURL& url : urls) { | 610 for (const GURL& url : urls) { |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 options.opener_tab_id); | 999 options.opener_tab_id); |
998 AssignOptionalValue(params->create_properties.selected, options.active); | 1000 AssignOptionalValue(params->create_properties.selected, options.active); |
999 // The 'active' property has replaced the 'selected' property. | 1001 // The 'active' property has replaced the 'selected' property. |
1000 AssignOptionalValue(params->create_properties.active, options.active); | 1002 AssignOptionalValue(params->create_properties.active, options.active); |
1001 AssignOptionalValue(params->create_properties.pinned, options.pinned); | 1003 AssignOptionalValue(params->create_properties.pinned, options.pinned); |
1002 AssignOptionalValue(params->create_properties.index, options.index); | 1004 AssignOptionalValue(params->create_properties.index, options.index); |
1003 AssignOptionalValue(params->create_properties.url, options.url); | 1005 AssignOptionalValue(params->create_properties.url, options.url); |
1004 | 1006 |
1005 std::string error; | 1007 std::string error; |
1006 std::unique_ptr<base::DictionaryValue> result( | 1008 std::unique_ptr<base::DictionaryValue> result( |
1007 ExtensionTabUtil::OpenTab(this, options, &error)); | 1009 ExtensionTabUtil::OpenTab(this, options, user_gesture(), &error)); |
1008 if (!result) | 1010 if (!result) |
1009 return RespondNow(Error(error)); | 1011 return RespondNow(Error(error)); |
1010 | 1012 |
1011 // Return data about the newly created tab. | 1013 // Return data about the newly created tab. |
1012 return RespondNow(has_callback() ? OneArgument(std::move(result)) | 1014 return RespondNow(has_callback() ? OneArgument(std::move(result)) |
1013 : NoArguments()); | 1015 : NoArguments()); |
1014 } | 1016 } |
1015 | 1017 |
1016 ExtensionFunction::ResponseAction TabsDuplicateFunction::Run() { | 1018 ExtensionFunction::ResponseAction TabsDuplicateFunction::Run() { |
1017 std::unique_ptr<tabs::Duplicate::Params> params( | 1019 std::unique_ptr<tabs::Duplicate::Params> params( |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2115 params->tab_id | 2117 params->tab_id |
2116 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, | 2118 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, |
2117 base::IntToString(*params->tab_id)) | 2119 base::IntToString(*params->tab_id)) |
2118 : keys::kCannotFindTabToDiscard)); | 2120 : keys::kCannotFindTabToDiscard)); |
2119 } | 2121 } |
2120 | 2122 |
2121 TabsDiscardFunction::TabsDiscardFunction() {} | 2123 TabsDiscardFunction::TabsDiscardFunction() {} |
2122 TabsDiscardFunction::~TabsDiscardFunction() {} | 2124 TabsDiscardFunction::~TabsDiscardFunction() {} |
2123 | 2125 |
2124 } // namespace extensions | 2126 } // namespace extensions |
OLD | NEW |