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

Side by Side Diff: chrome/browser/ui/webui/foreign_session_handler.cc

Issue 2812953002: Stop passing raw pointers to base::Value API in c/b/ui (Closed)
Patch Set: Rebased Created 3 years, 8 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/ui/webui/foreign_session_handler.h" 5 #include "chrome/browser/ui/webui/foreign_session_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 if (tab_value.get()) { 114 if (tab_value.get()) {
115 modification_time = std::max(modification_time, 115 modification_time = std::max(modification_time,
116 tab->timestamp); 116 tab->timestamp);
117 tab_values->Append(std::move(tab_value)); 117 tab_values->Append(std::move(tab_value));
118 } 118 }
119 } 119 }
120 if (tab_values->GetSize() == 0) 120 if (tab_values->GetSize() == 0)
121 return nullptr; 121 return nullptr;
122 std::unique_ptr<base::DictionaryValue> dictionary( 122 std::unique_ptr<base::DictionaryValue> dictionary(
123 BuildWindowData(window.timestamp, window.window_id.id())); 123 BuildWindowData(window.timestamp, window.window_id.id()));
124 dictionary->Set("tabs", tab_values.release()); 124 dictionary->Set("tabs", std::move(tab_values));
125 return dictionary; 125 return dictionary;
126 } 126 }
127 127
128 } // namespace 128 } // namespace
129 129
130 ForeignSessionHandler::ForeignSessionHandler() : scoped_observer_(this) { 130 ForeignSessionHandler::ForeignSessionHandler() : scoped_observer_(this) {
131 load_attempt_time_ = base::TimeTicks::Now(); 131 load_attempt_time_ = base::TimeTicks::Now();
132 } 132 }
133 133
134 ForeignSessionHandler::~ForeignSessionHandler() {} 134 ForeignSessionHandler::~ForeignSessionHandler() {}
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 std::unique_ptr<base::DictionaryValue> tab_value( 316 std::unique_ptr<base::DictionaryValue> tab_value(
317 SessionTabToValue(*tab)); 317 SessionTabToValue(*tab));
318 if (tab_value.get()) { 318 if (tab_value.get()) {
319 modification_time = std::max(modification_time, tab->timestamp); 319 modification_time = std::max(modification_time, tab->timestamp);
320 tab_values->Append(std::move(tab_value)); 320 tab_values->Append(std::move(tab_value));
321 } 321 }
322 } 322 }
323 if (tab_values->GetSize() != 0) { 323 if (tab_values->GetSize() != 0) {
324 std::unique_ptr<base::DictionaryValue> window_data( 324 std::unique_ptr<base::DictionaryValue> window_data(
325 BuildWindowData(modification_time, 1)); 325 BuildWindowData(modification_time, 1));
326 window_data->Set("tabs", tab_values.release()); 326 window_data->Set("tabs", std::move(tab_values));
327 window_list->Append(std::move(window_data)); 327 window_list->Append(std::move(window_data));
328 } 328 }
329 } 329 }
330 330
331 session_data->Set("windows", window_list.release()); 331 session_data->Set("windows", std::move(window_list));
332 session_list.Append(std::move(session_data)); 332 session_list.Append(std::move(session_data));
333 } 333 }
334 } 334 }
335 web_ui()->CallJavascriptFunctionUnsafe("setForeignSessions", session_list); 335 web_ui()->CallJavascriptFunctionUnsafe("setForeignSessions", session_list);
336 } 336 }
337 337
338 void ForeignSessionHandler::HandleOpenForeignSession( 338 void ForeignSessionHandler::HandleOpenForeignSession(
339 const base::ListValue* args) { 339 const base::ListValue* args) {
340 size_t num_args = args->GetSize(); 340 size_t num_args = args->GetSize();
341 // Expect either 1 or 8 args. For restoring an entire session, only 341 // Expect either 1 or 8 args. For restoring an entire session, only
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 // collapsed state persists. 427 // collapsed state persists.
428 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); 428 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
429 DictionaryPrefUpdate update(prefs, prefs::kNtpCollapsedForeignSessions); 429 DictionaryPrefUpdate update(prefs, prefs::kNtpCollapsedForeignSessions);
430 if (is_collapsed) 430 if (is_collapsed)
431 update.Get()->SetBoolean(session_tag, true); 431 update.Get()->SetBoolean(session_tag, true);
432 else 432 else
433 update.Get()->Remove(session_tag, NULL); 433 update.Get()->Remove(session_tag, NULL);
434 } 434 }
435 435
436 } // namespace browser_sync 436 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698