Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: chrome/browser/extensions/api/tabs/tabs_api.cc

Issue 2051663003: base::ListValue::Append cleanup: pass unique_ptr instead of the released pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 !url_patterns.MatchesURL(web_contents->GetURL())) { 1018 !url_patterns.MatchesURL(web_contents->GetURL())) {
1019 continue; 1019 continue;
1020 } 1020 }
1021 } 1021 }
1022 1022
1023 if (loading_status_set && loading != web_contents->IsLoading()) 1023 if (loading_status_set && loading != web_contents->IsLoading())
1024 continue; 1024 continue;
1025 1025
1026 result->Append(ExtensionTabUtil::CreateTabObject(web_contents, tab_strip, 1026 result->Append(ExtensionTabUtil::CreateTabObject(web_contents, tab_strip,
1027 i, extension()) 1027 i, extension())
1028 ->ToValue() 1028 ->ToValue());
1029 .release());
1030 } 1029 }
1031 } 1030 }
1032 1031
1033 SetResult(std::move(result)); 1032 SetResult(std::move(result));
1034 return true; 1033 return true;
1035 } 1034 }
1036 1035
1037 bool TabsCreateFunction::RunSync() { 1036 bool TabsCreateFunction::RunSync() {
1038 std::unique_ptr<tabs::Create::Params> params( 1037 std::unique_ptr<tabs::Create::Params> params(
1039 tabs::Create::Params::Create(*args_)); 1038 tabs::Create::Params::Create(*args_));
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 if (*new_index > target_tab_strip->count() || *new_index < 0) 1529 if (*new_index > target_tab_strip->count() || *new_index < 0)
1531 *new_index = target_tab_strip->count(); 1530 *new_index = target_tab_strip->count();
1532 1531
1533 target_tab_strip->InsertWebContentsAt( 1532 target_tab_strip->InsertWebContentsAt(
1534 *new_index, web_contents, TabStripModel::ADD_NONE); 1533 *new_index, web_contents, TabStripModel::ADD_NONE);
1535 1534
1536 if (has_callback()) { 1535 if (has_callback()) {
1537 tab_values->Append( 1536 tab_values->Append(
1538 ExtensionTabUtil::CreateTabObject(web_contents, target_tab_strip, 1537 ExtensionTabUtil::CreateTabObject(web_contents, target_tab_strip,
1539 *new_index, extension()) 1538 *new_index, extension())
1540 ->ToValue() 1539 ->ToValue());
1541 .release());
1542 } 1540 }
1543 1541
1544 return true; 1542 return true;
1545 } 1543 }
1546 } 1544 }
1547 1545
1548 // Perform a simple within-window move. 1546 // Perform a simple within-window move.
1549 // Clamp move location to the last position. 1547 // Clamp move location to the last position.
1550 // This is ">=" because the move must be to an existing location. 1548 // This is ">=" because the move must be to an existing location.
1551 // -1 means set the move location to the last position. 1549 // -1 means set the move location to the last position.
1552 if (*new_index >= source_tab_strip->count() || *new_index < 0) 1550 if (*new_index >= source_tab_strip->count() || *new_index < 0)
1553 *new_index = source_tab_strip->count() - 1; 1551 *new_index = source_tab_strip->count() - 1;
1554 1552
1555 if (*new_index != tab_index) 1553 if (*new_index != tab_index)
1556 source_tab_strip->MoveWebContentsAt(tab_index, *new_index, false); 1554 source_tab_strip->MoveWebContentsAt(tab_index, *new_index, false);
1557 1555
1558 if (has_callback()) { 1556 if (has_callback()) {
1559 tab_values->Append(ExtensionTabUtil::CreateTabObject( 1557 tab_values->Append(ExtensionTabUtil::CreateTabObject(
1560 contents, source_tab_strip, *new_index, extension()) 1558 contents, source_tab_strip, *new_index, extension())
1561 ->ToValue() 1559 ->ToValue());
1562 .release());
1563 } 1560 }
1564 1561
1565 return true; 1562 return true;
1566 } 1563 }
1567 1564
1568 bool TabsReloadFunction::RunSync() { 1565 bool TabsReloadFunction::RunSync() {
1569 std::unique_ptr<tabs::Reload::Params> params( 1566 std::unique_ptr<tabs::Reload::Params> params(
1570 tabs::Reload::Params::Create(*args_)); 1567 tabs::Reload::Params::Create(*args_));
1571 EXTENSION_FUNCTION_VALIDATE(params.get()); 1568 EXTENSION_FUNCTION_VALIDATE(params.get());
1572 1569
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 ZoomModeToZoomSettings(zoom_mode, &zoom_settings); 2154 ZoomModeToZoomSettings(zoom_mode, &zoom_settings);
2158 zoom_settings.default_zoom_factor.reset(new double( 2155 zoom_settings.default_zoom_factor.reset(new double(
2159 content::ZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel()))); 2156 content::ZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel())));
2160 2157
2161 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); 2158 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings);
2162 SendResponse(true); 2159 SendResponse(true);
2163 return true; 2160 return true;
2164 } 2161 }
2165 2162
2166 } // namespace extensions 2163 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698