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

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

Issue 2030013003: Remove ListValue::Append(new {Fundamental,String}Value(...)) pattern in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/windows_event_router.h" 5 #include "chrome/browser/extensions/api/tabs/windows_event_router.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 bool cant_cross_incognito = new_active_context && 110 bool cant_cross_incognito = new_active_context &&
111 new_active_context != context && 111 new_active_context != context &&
112 !util::CanCrossIncognito(extension, context); 112 !util::CanCrossIncognito(extension, context);
113 // If the window is not visible by the listener, we also need to 113 // If the window is not visible by the listener, we also need to
114 // clear out the window id from the event. 114 // clear out the window id from the event.
115 bool visible_to_listener = ControllerVisibleToListener( 115 bool visible_to_listener = ControllerVisibleToListener(
116 window_controller, extension, listener_filter); 116 window_controller, extension, listener_filter);
117 117
118 if (cant_cross_incognito || !visible_to_listener) { 118 if (cant_cross_incognito || !visible_to_listener) {
119 event->event_args->Clear(); 119 event->event_args->Clear();
120 event->event_args->Append( 120 event->event_args->AppendInteger(extension_misc::kUnknownWindowId);
121 new base::FundamentalValue(extension_misc::kUnknownWindowId));
122 } else { 121 } else {
123 event->event_args->Clear(); 122 event->event_args->Clear();
124 event->event_args->Append(new base::FundamentalValue(window_id)); 123 event->event_args->AppendInteger(window_id);
125 } 124 }
126 return true; 125 return true;
127 } 126 }
128 127
129 } // namespace 128 } // namespace
130 129
131 WindowsEventRouter::WindowsEventRouter(Profile* profile) 130 WindowsEventRouter::WindowsEventRouter(Profile* profile)
132 : profile_(profile), 131 : profile_(profile),
133 focused_profile_(nullptr), 132 focused_profile_(nullptr),
134 focused_window_id_(extension_misc::kUnknownWindowId), 133 focused_window_id_(extension_misc::kUnknownWindowId),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 202
204 void WindowsEventRouter::OnWindowControllerRemoved( 203 void WindowsEventRouter::OnWindowControllerRemoved(
205 WindowController* window_controller) { 204 WindowController* window_controller) {
206 if (!HasEventListener(windows::OnRemoved::kEventName)) 205 if (!HasEventListener(windows::OnRemoved::kEventName))
207 return; 206 return;
208 if (!profile_->IsSameProfile(window_controller->profile())) 207 if (!profile_->IsSameProfile(window_controller->profile()))
209 return; 208 return;
210 209
211 int window_id = window_controller->GetWindowId(); 210 int window_id = window_controller->GetWindowId();
212 std::unique_ptr<base::ListValue> args(new base::ListValue()); 211 std::unique_ptr<base::ListValue> args(new base::ListValue());
213 args->Append(new base::FundamentalValue(window_id)); 212 args->AppendInteger(window_id);
214 DispatchEvent(events::WINDOWS_ON_REMOVED, windows::OnRemoved::kEventName, 213 DispatchEvent(events::WINDOWS_ON_REMOVED, windows::OnRemoved::kEventName,
215 window_controller, std::move(args)); 214 window_controller, std::move(args));
216 } 215 }
217 216
218 #if !defined(OS_MACOSX) 217 #if !defined(OS_MACOSX)
219 void WindowsEventRouter::OnNativeFocusChanged(gfx::NativeView focused_now) { 218 void WindowsEventRouter::OnNativeFocusChanged(gfx::NativeView focused_now) {
220 if (!focused_now) 219 if (!focused_now)
221 OnActiveWindowChanged(nullptr); 220 OnActiveWindowChanged(nullptr);
222 } 221 }
223 #endif 222 #endif
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 return EventRouter::Get(profile_)->HasEventListener(event_name); 278 return EventRouter::Get(profile_)->HasEventListener(event_name);
280 } 279 }
281 280
282 void WindowsEventRouter::AddAppWindow(extensions::AppWindow* app_window) { 281 void WindowsEventRouter::AddAppWindow(extensions::AppWindow* app_window) {
283 std::unique_ptr<AppWindowController> controller(new AppWindowController( 282 std::unique_ptr<AppWindowController> controller(new AppWindowController(
284 app_window, base::WrapUnique(new AppBaseWindow(app_window)), profile_)); 283 app_window, base::WrapUnique(new AppBaseWindow(app_window)), profile_));
285 app_windows_[app_window->session_id().id()] = std::move(controller); 284 app_windows_[app_window->session_id().id()] = std::move(controller);
286 } 285 }
287 286
288 } // namespace extensions 287 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698