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/tabs_api.cc

Issue 2886293002: Remove WINDOW_TYPE_V1_PANEL AppWindow type (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 #include "extensions/common/permissions/permissions_data.h" 89 #include "extensions/common/permissions/permissions_data.h"
90 #include "extensions/common/user_script.h" 90 #include "extensions/common/user_script.h"
91 #include "net/base/escape.h" 91 #include "net/base/escape.h"
92 #include "skia/ext/image_operations.h" 92 #include "skia/ext/image_operations.h"
93 #include "skia/ext/platform_canvas.h" 93 #include "skia/ext/platform_canvas.h"
94 #include "third_party/skia/include/core/SkBitmap.h" 94 #include "third_party/skia/include/core/SkBitmap.h"
95 #include "ui/base/models/list_selection_model.h" 95 #include "ui/base/models/list_selection_model.h"
96 #include "ui/base/ui_base_types.h" 96 #include "ui/base/ui_base_types.h"
97 97
98 #if defined(USE_ASH) 98 #if defined(USE_ASH)
99 #include "chrome/browser/extensions/api/tabs/ash_panel_contents.h" // nogncheck 99 #include "chrome/browser/extensions/api/tabs/ash_panel_contents.h" // nogncheck
benwells 2017/05/18 01:30:46 I think this include can be removed. Maybe others
Qiang(Joe) Xu 2017/05/18 02:24:18 yes, both of them can be removed. Thanks for catch
100 #include "extensions/browser/app_window/app_window_registry.h" // nogncheck 100 #include "extensions/browser/app_window/app_window_registry.h" // nogncheck
101 #endif 101 #endif
102 102
103 using content::BrowserThread; 103 using content::BrowserThread;
104 using content::NavigationController; 104 using content::NavigationController;
105 using content::NavigationEntry; 105 using content::NavigationEntry;
106 using content::OpenURLParams; 106 using content::OpenURLParams;
107 using content::Referrer; 107 using content::Referrer;
108 using content::WebContents; 108 using content::WebContents;
109 using zoom::ZoomController; 109 using zoom::ZoomController;
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 if (source_browser->profile() != window_profile) 479 if (source_browser->profile() != window_profile)
480 return RespondNow(Error(keys::kCanOnlyMoveTabsWithinSameProfileError)); 480 return RespondNow(Error(keys::kCanOnlyMoveTabsWithinSameProfileError));
481 } 481 }
482 482
483 if (!IsValidStateForWindowsCreateFunction(create_data)) 483 if (!IsValidStateForWindowsCreateFunction(create_data))
484 return RespondNow(Error(keys::kInvalidWindowStateError)); 484 return RespondNow(Error(keys::kInvalidWindowStateError));
485 485
486 Browser::Type window_type = Browser::TYPE_TABBED; 486 Browser::Type window_type = Browser::TYPE_TABBED;
487 487
488 #if defined(USE_ASH) 488 #if defined(USE_ASH)
489 bool create_ash_panel = false;
490 bool saw_focus_key = false; 489 bool saw_focus_key = false;
491 #endif // defined(USE_ASH) 490 #endif // defined(USE_ASH)
492 491
493 gfx::Rect window_bounds; 492 gfx::Rect window_bounds;
494 bool focused = true; 493 bool focused = true;
495 std::string extension_id; 494 std::string extension_id;
496 495
497 if (create_data) { 496 if (create_data) {
498 // Report UMA stats to decide when to remove the deprecated "docked" windows 497 // Report UMA stats to decide when to remove the deprecated "docked" windows
499 // state (crbug.com/703733). 498 // state (crbug.com/703733).
500 ReportRequestedWindowState(create_data->state); 499 ReportRequestedWindowState(create_data->state);
501 500
502 // Figure out window type before figuring out bounds so that default 501 // Figure out window type before figuring out bounds so that default
503 // bounds can be set according to the window type. 502 // bounds can be set according to the window type.
504 switch (create_data->type) { 503 switch (create_data->type) {
505 case windows::CREATE_TYPE_POPUP: 504 case windows::CREATE_TYPE_POPUP:
506 window_type = Browser::TYPE_POPUP; 505 window_type = Browser::TYPE_POPUP;
507 extension_id = extension()->id(); 506 extension_id = extension()->id();
508 break; 507 break;
509 508
510 case windows::CREATE_TYPE_PANEL: { 509 case windows::CREATE_TYPE_PANEL: {
511 extension_id = extension()->id(); 510 extension_id = extension()->id();
512 #if defined(USE_ASH)
513 // Only ChromeOS' version of chrome.windows.create would create a panel
514 // window. It is whitelisted to Hangouts extension for limited time until
515 // it transitioned to other types of windows.
516 for (const char* id : extension_misc::kHangoutsExtensionIds) {
517 if (extension_id == id) {
518 create_ash_panel = true;
519 break;
520 }
521 }
522 #endif // defined(USE_ASH)
523 // Everything else gets POPUP instead of PANEL.
524 // TODO(dimich): Eventually, remove the 'panel' values form valid 511 // TODO(dimich): Eventually, remove the 'panel' values form valid
525 // window.create parameters. However, this is a more breaking change, so 512 // window.create parameters. However, this is a more breaking change, so
526 // for now simply treat it as a POPUP. 513 // for now simply treat it as a POPUP.
527 window_type = Browser::TYPE_POPUP; 514 window_type = Browser::TYPE_POPUP;
528 break; 515 break;
529 } 516 }
530 517
531 case windows::CREATE_TYPE_NONE: 518 case windows::CREATE_TYPE_NONE:
532 case windows::CREATE_TYPE_NORMAL: 519 case windows::CREATE_TYPE_NORMAL:
533 break; 520 break;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 window_bounds.set_height(*create_data->height); 553 window_bounds.set_height(*create_data->height);
567 554
568 if (create_data->focused) { 555 if (create_data->focused) {
569 focused = *create_data->focused; 556 focused = *create_data->focused;
570 #if defined(USE_ASH) 557 #if defined(USE_ASH)
571 saw_focus_key = true; 558 saw_focus_key = true;
572 #endif 559 #endif
573 } 560 }
574 } 561 }
575 562
576 #if defined(USE_ASH)
577 if (create_ash_panel) {
578 if (urls.empty())
579 urls.push_back(GURL(chrome::kChromeUINewTabURL));
580
581 AppWindow::CreateParams create_params;
582 create_params.window_type = AppWindow::WINDOW_TYPE_V1_PANEL;
583 create_params.window_key = extension_id;
584 create_params.window_spec.bounds = window_bounds;
585 create_params.focused = saw_focus_key && focused;
586 AppWindow* app_window =
587 new AppWindow(window_profile, new ChromeAppDelegate(true), extension());
588 AshPanelContents* ash_panel_contents = new AshPanelContents(app_window);
589 app_window->Init(urls[0], ash_panel_contents, render_frame_host(),
590 create_params);
591 WindowController* window_controller =
592 WindowControllerList::GetInstance()->FindWindowById(
593 app_window->session_id().id());
594 if (!window_controller)
595 return RespondNow(Error(kUnknownErrorDoNotUse));
596 return RespondNow(
597 OneArgument(window_controller->CreateWindowValueWithTabs(extension())));
598 }
599 #endif // defined(USE_ASH)
600
601 // Create a new BrowserWindow. 563 // Create a new BrowserWindow.
602 Browser::CreateParams create_params(window_type, window_profile, 564 Browser::CreateParams create_params(window_type, window_profile,
603 user_gesture()); 565 user_gesture());
604 if (extension_id.empty()) { 566 if (extension_id.empty()) {
605 create_params.initial_bounds = window_bounds; 567 create_params.initial_bounds = window_bounds;
606 } else { 568 } else {
607 create_params = Browser::CreateParams::CreateForApp( 569 create_params = Browser::CreateParams::CreateForApp(
608 web_app::GenerateApplicationNameFromExtensionId(extension_id), 570 web_app::GenerateApplicationNameFromExtensionId(extension_id),
609 false /* trusted_source */, window_bounds, window_profile, 571 false /* trusted_source */, window_bounds, window_profile,
610 user_gesture()); 572 user_gesture());
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after
2149 params->tab_id 2111 params->tab_id
2150 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, 2112 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab,
2151 base::IntToString(*params->tab_id)) 2113 base::IntToString(*params->tab_id))
2152 : keys::kCannotFindTabToDiscard)); 2114 : keys::kCannotFindTabToDiscard));
2153 } 2115 }
2154 2116
2155 TabsDiscardFunction::TabsDiscardFunction() {} 2117 TabsDiscardFunction::TabsDiscardFunction() {}
2156 TabsDiscardFunction::~TabsDiscardFunction() {} 2118 TabsDiscardFunction::~TabsDiscardFunction() {}
2157 2119
2158 } // namespace extensions 2120 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698