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

Side by Side Diff: extensions/browser/api/app_window/app_window_api.cc

Issue 1211003006: [Extensions OOPI] Update app window bindings for OOPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 "extensions/browser/api/app_window/app_window_api.h" 5 #include "extensions/browser/api/app_window/app_window_api.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "content/public/browser/notification_registrar.h" 12 #include "content/public/browser/notification_registrar.h"
13 #include "content/public/browser/notification_types.h" 13 #include "content/public/browser/notification_types.h"
14 #include "content/public/browser/render_frame_host.h" 14 #include "content/public/browser/render_frame_host.h"
15 #include "content/public/browser/render_process_host.h" 15 #include "content/public/browser/render_process_host.h"
16 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
18 #include "content/public/common/url_constants.h" 17 #include "content/public/common/url_constants.h"
19 #include "extensions/browser/app_window/app_window.h" 18 #include "extensions/browser/app_window/app_window.h"
20 #include "extensions/browser/app_window/app_window_client.h" 19 #include "extensions/browser/app_window/app_window_client.h"
21 #include "extensions/browser/app_window/app_window_contents.h" 20 #include "extensions/browser/app_window/app_window_contents.h"
22 #include "extensions/browser/app_window/app_window_registry.h" 21 #include "extensions/browser/app_window/app_window_registry.h"
23 #include "extensions/browser/app_window/native_app_window.h" 22 #include "extensions/browser/app_window/native_app_window.h"
24 #include "extensions/browser/extensions_browser_client.h" 23 #include "extensions/browser/extensions_browser_client.h"
25 #include "extensions/common/api/app_window.h" 24 #include "extensions/common/api/app_window.h"
26 #include "extensions/common/features/simple_feature.h" 25 #include "extensions/common/features/simple_feature.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 content::CONSOLE_MESSAGE_LEVEL_WARNING, 167 content::CONSOLE_MESSAGE_LEVEL_WARNING,
169 "The 'singleton' option in chrome.apps.window.create() is deprecated!" 168 "The 'singleton' option in chrome.apps.window.create() is deprecated!"
170 " Change your code to no longer rely on this."); 169 " Change your code to no longer rely on this.");
171 } 170 }
172 171
173 if (!options->singleton || *options->singleton) { 172 if (!options->singleton || *options->singleton) {
174 AppWindow* window = AppWindowRegistry::Get(browser_context()) 173 AppWindow* window = AppWindowRegistry::Get(browser_context())
175 ->GetAppWindowForAppAndKey( 174 ->GetAppWindowForAppAndKey(
176 extension_id(), create_params.window_key); 175 extension_id(), create_params.window_key);
177 if (window) { 176 if (window) {
178 content::RenderViewHost* created_view = 177 content::RenderFrameHost* created_frame =
not at google - send to devlin 2015/07/08 21:34:29 "created_frame" is actually a lie. The whole point
Devlin 2015/07/08 21:47:01 Done.
179 window->web_contents()->GetRenderViewHost(); 178 window->web_contents()->GetMainFrame();
180 int view_id = MSG_ROUTING_NONE; 179 int frame_id = MSG_ROUTING_NONE;
181 if (render_frame_host()->GetProcess()->GetID() == 180 if (render_frame_host()->GetProcess()->GetID() ==
182 created_view->GetProcess()->GetID()) { 181 created_frame->GetProcess()->GetID()) {
not at google - send to devlin 2015/07/08 20:22:19 Why does the API do this? Why not unconditionally
Devlin 2015/07/08 21:08:46 My guess is because if they are in different proce
not at google - send to devlin 2015/07/08 21:34:29 Yeah I feel like this should be a CHECK that they'
Devlin 2015/07/08 21:47:01 As discovered offline, this was added because comp
183 view_id = created_view->GetRoutingID(); 182 frame_id = created_frame->GetRoutingID();
184 } 183 }
185 184
186 if (!options->hidden.get() || !*options->hidden.get()) { 185 if (!options->hidden.get() || !*options->hidden.get()) {
187 if (options->focused.get() && !*options->focused.get()) 186 if (options->focused.get() && !*options->focused.get())
188 window->Show(AppWindow::SHOW_INACTIVE); 187 window->Show(AppWindow::SHOW_INACTIVE);
189 else 188 else
190 window->Show(AppWindow::SHOW_ACTIVE); 189 window->Show(AppWindow::SHOW_ACTIVE);
191 } 190 }
192 191
193 base::DictionaryValue* result = new base::DictionaryValue; 192 base::DictionaryValue* result = new base::DictionaryValue;
194 result->Set("viewId", new base::FundamentalValue(view_id)); 193 result->Set("frameId", new base::FundamentalValue(frame_id));
195 window->GetSerializedState(result); 194 window->GetSerializedState(result);
196 result->SetBoolean("existingWindow", true); 195 result->SetBoolean("existingWindow", true);
197 // TODO(benwells): Remove HTML titlebar injection. 196 // TODO(benwells): Remove HTML titlebar injection.
198 result->SetBoolean("injectTitlebar", false); 197 result->SetBoolean("injectTitlebar", false);
199 SetResult(result); 198 SetResult(result);
200 SendResponse(true); 199 SendResponse(true);
201 return true; 200 return true;
202 } 201 }
203 } 202 }
204 } 203 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 336
338 AppWindow* app_window = 337 AppWindow* app_window =
339 AppWindowClient::Get()->CreateAppWindow(browser_context(), extension()); 338 AppWindowClient::Get()->CreateAppWindow(browser_context(), extension());
340 app_window->Init(url, new AppWindowContentsImpl(app_window), create_params); 339 app_window->Init(url, new AppWindowContentsImpl(app_window), create_params);
341 340
342 if (ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode() && 341 if (ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode() &&
343 !app_window->is_ime_window()) { 342 !app_window->is_ime_window()) {
344 app_window->ForcedFullscreen(); 343 app_window->ForcedFullscreen();
345 } 344 }
346 345
347 content::RenderViewHost* created_view = 346 content::RenderFrameHost* created_frame =
348 app_window->web_contents()->GetRenderViewHost(); 347 app_window->web_contents()->GetMainFrame();
349 int view_id = MSG_ROUTING_NONE; 348 int frame_id = MSG_ROUTING_NONE;
350 if (create_params.creator_process_id == created_view->GetProcess()->GetID()) 349 if (create_params.creator_process_id == created_frame->GetProcess()->GetID())
351 view_id = created_view->GetRoutingID(); 350 frame_id = created_frame->GetRoutingID();
352 351
353 base::DictionaryValue* result = new base::DictionaryValue; 352 base::DictionaryValue* result = new base::DictionaryValue;
354 result->Set("viewId", new base::FundamentalValue(view_id)); 353 result->Set("frameId", new base::FundamentalValue(frame_id));
355 result->Set("injectTitlebar", 354 result->Set("injectTitlebar",
356 new base::FundamentalValue(inject_html_titlebar_)); 355 new base::FundamentalValue(inject_html_titlebar_));
357 result->Set("id", new base::StringValue(app_window->window_key())); 356 result->Set("id", new base::StringValue(app_window->window_key()));
358 app_window->GetSerializedState(result); 357 app_window->GetSerializedState(result);
359 SetResult(result); 358 SetResult(result);
360 359
361 if (AppWindowRegistry::Get(browser_context()) 360 if (AppWindowRegistry::Get(browser_context())
362 ->HadDevToolsAttached(created_view)) { 361 ->HadDevToolsAttached(app_window->web_contents())) {
363 AppWindowClient::Get()->OpenDevToolsWindow( 362 AppWindowClient::Get()->OpenDevToolsWindow(
364 app_window->web_contents(), 363 app_window->web_contents(),
365 base::Bind(&AppWindowCreateFunction::SendResponse, this, true)); 364 base::Bind(&AppWindowCreateFunction::SendResponse, this, true));
366 return true; 365 return true;
367 } 366 }
368 367
369 SendResponse(true); 368 SendResponse(true);
370 app_window->WindowEventsReady(); 369 app_window->WindowEventsReady();
371 370
372 return true; 371 return true;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 546
548 if (options.frame->as_frame_options->inactive_color.get()) { 547 if (options.frame->as_frame_options->inactive_color.get()) {
549 error_ = app_window_constants::kInactiveColorWithoutColor; 548 error_ = app_window_constants::kInactiveColorWithoutColor;
550 return false; 549 return false;
551 } 550 }
552 551
553 return true; 552 return true;
554 } 553 }
555 554
556 } // namespace extensions 555 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698