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

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

Issue 2891963002: reland: 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 #include "extensions/common/message_bundle.h" 88 #include "extensions/common/message_bundle.h"
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)
99 #include "chrome/browser/extensions/api/tabs/ash_panel_contents.h" // nogncheck
100 #include "extensions/browser/app_window/app_window_registry.h" // nogncheck
101 #endif
102
103 using content::BrowserThread; 98 using content::BrowserThread;
104 using content::NavigationController; 99 using content::NavigationController;
105 using content::NavigationEntry; 100 using content::NavigationEntry;
106 using content::OpenURLParams; 101 using content::OpenURLParams;
107 using content::Referrer; 102 using content::Referrer;
108 using content::WebContents; 103 using content::WebContents;
109 using zoom::ZoomController; 104 using zoom::ZoomController;
110 105
111 namespace extensions { 106 namespace extensions {
112 107
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 473
479 if (source_browser->profile() != window_profile) 474 if (source_browser->profile() != window_profile)
480 return RespondNow(Error(keys::kCanOnlyMoveTabsWithinSameProfileError)); 475 return RespondNow(Error(keys::kCanOnlyMoveTabsWithinSameProfileError));
481 } 476 }
482 477
483 if (!IsValidStateForWindowsCreateFunction(create_data)) 478 if (!IsValidStateForWindowsCreateFunction(create_data))
484 return RespondNow(Error(keys::kInvalidWindowStateError)); 479 return RespondNow(Error(keys::kInvalidWindowStateError));
485 480
486 Browser::Type window_type = Browser::TYPE_TABBED; 481 Browser::Type window_type = Browser::TYPE_TABBED;
487 482
488 #if defined(USE_ASH)
489 bool create_ash_panel = false;
490 bool saw_focus_key = false;
491 #endif // defined(USE_ASH)
492
493 gfx::Rect window_bounds; 483 gfx::Rect window_bounds;
494 bool focused = true; 484 bool focused = true;
495 std::string extension_id; 485 std::string extension_id;
496 486
497 if (create_data) { 487 if (create_data) {
498 // Report UMA stats to decide when to remove the deprecated "docked" windows 488 // Report UMA stats to decide when to remove the deprecated "docked" windows
499 // state (crbug.com/703733). 489 // state (crbug.com/703733).
500 ReportRequestedWindowState(create_data->state); 490 ReportRequestedWindowState(create_data->state);
501 491
502 // Figure out window type before figuring out bounds so that default 492 // Figure out window type before figuring out bounds so that default
503 // bounds can be set according to the window type. 493 // bounds can be set according to the window type.
504 switch (create_data->type) { 494 switch (create_data->type) {
505 case windows::CREATE_TYPE_POPUP: 495 case windows::CREATE_TYPE_POPUP:
506 window_type = Browser::TYPE_POPUP; 496 window_type = Browser::TYPE_POPUP;
507 extension_id = extension()->id(); 497 extension_id = extension()->id();
508 break; 498 break;
509 499
510 case windows::CREATE_TYPE_PANEL: { 500 case windows::CREATE_TYPE_PANEL: {
511 extension_id = extension()->id(); 501 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 502 // TODO(dimich): Eventually, remove the 'panel' values form valid
525 // window.create parameters. However, this is a more breaking change, so 503 // window.create parameters. However, this is a more breaking change, so
526 // for now simply treat it as a POPUP. 504 // for now simply treat it as a POPUP.
527 window_type = Browser::TYPE_POPUP; 505 window_type = Browser::TYPE_POPUP;
528 break; 506 break;
529 } 507 }
530 508
531 case windows::CREATE_TYPE_NONE: 509 case windows::CREATE_TYPE_NONE:
532 case windows::CREATE_TYPE_NORMAL: 510 case windows::CREATE_TYPE_NORMAL:
533 break; 511 break;
(...skipping 24 matching lines...) Expand all
558 536
559 if (create_data->top) 537 if (create_data->top)
560 window_bounds.set_y(*create_data->top); 538 window_bounds.set_y(*create_data->top);
561 539
562 if (create_data->width) 540 if (create_data->width)
563 window_bounds.set_width(*create_data->width); 541 window_bounds.set_width(*create_data->width);
564 542
565 if (create_data->height) 543 if (create_data->height)
566 window_bounds.set_height(*create_data->height); 544 window_bounds.set_height(*create_data->height);
567 545
568 if (create_data->focused) { 546 if (create_data->focused)
569 focused = *create_data->focused; 547 focused = *create_data->focused;
570 #if defined(USE_ASH)
571 saw_focus_key = true;
572 #endif
573 }
574 } 548 }
575 549
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. 550 // Create a new BrowserWindow.
602 Browser::CreateParams create_params(window_type, window_profile, 551 Browser::CreateParams create_params(window_type, window_profile,
603 user_gesture()); 552 user_gesture());
604 if (extension_id.empty()) { 553 if (extension_id.empty()) {
605 create_params.initial_bounds = window_bounds; 554 create_params.initial_bounds = window_bounds;
606 } else { 555 } else {
607 create_params = Browser::CreateParams::CreateForApp( 556 create_params = Browser::CreateParams::CreateForApp(
608 web_app::GenerateApplicationNameFromExtensionId(extension_id), 557 web_app::GenerateApplicationNameFromExtensionId(extension_id),
609 false /* trusted_source */, window_bounds, window_profile, 558 false /* trusted_source */, window_bounds, window_profile,
610 user_gesture()); 559 user_gesture());
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 for (int i = 0; i < tab_strip->count(); ++i) { 884 for (int i = 0; i < tab_strip->count(); ++i) {
936 WebContents* web_contents = tab_strip->GetWebContentsAt(i); 885 WebContents* web_contents = tab_strip->GetWebContentsAt(i);
937 memory::TabManager* tab_manager = g_browser_process->GetTabManager(); 886 memory::TabManager* tab_manager = g_browser_process->GetTabManager();
938 887
939 if (index > -1 && i != index) 888 if (index > -1 && i != index)
940 continue; 889 continue;
941 890
942 if (!web_contents) { 891 if (!web_contents) {
943 continue; 892 continue;
944 } 893 }
945 894
946 if (!MatchesBool(params->query_info.highlighted.get(), 895 if (!MatchesBool(params->query_info.highlighted.get(),
947 tab_strip->IsTabSelected(i))) { 896 tab_strip->IsTabSelected(i))) {
948 continue; 897 continue;
949 } 898 }
950 899
951 if (!MatchesBool(params->query_info.active.get(), 900 if (!MatchesBool(params->query_info.active.get(),
952 i == tab_strip->active_index())) { 901 i == tab_strip->active_index())) {
953 continue; 902 continue;
954 } 903 }
955 904
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2149 params->tab_id 2098 params->tab_id
2150 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, 2099 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab,
2151 base::IntToString(*params->tab_id)) 2100 base::IntToString(*params->tab_id))
2152 : keys::kCannotFindTabToDiscard)); 2101 : keys::kCannotFindTabToDiscard));
2153 } 2102 }
2154 2103
2155 TabsDiscardFunction::TabsDiscardFunction() {} 2104 TabsDiscardFunction::TabsDiscardFunction() {}
2156 TabsDiscardFunction::~TabsDiscardFunction() {} 2105 TabsDiscardFunction::~TabsDiscardFunction() {}
2157 2106
2158 } // namespace extensions 2107 } // 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