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

Unified Diff: mash/browser/browser.cc

Issue 2057023002: Adds support for new-tab targeted loads initiated from the renderer. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mash/webtest/webtest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mash/browser/browser.cc
diff --git a/mash/browser/browser.cc b/mash/browser/browser.cc
index 94a88f39c84bbd82d1fb4e2459de9b2e06386f86..06e9daa0325f2b64e5f43a7fa8d89f93c84a9299 100644
--- a/mash/browser/browser.cc
+++ b/mash/browser/browser.cc
@@ -93,7 +93,6 @@ class Tab : public views::LabelButton,
views::ButtonListener* listener)
: views::LabelButton(listener, base::ASCIIToUTF16("Blank")),
view_(std::move(view)) {
- view_->SetResizerSize(gfx::Size(16, 16));
view_->AddObserver(this);
set_background(new Background(this));
}
@@ -233,7 +232,8 @@ class TabStrip : public views::View,
int next_selected_index = selected_index_;
if (selected_index_ == static_cast<int>(tabs_.size()))
--next_selected_index;
- SelectTab(tabs_[next_selected_index]);
+ if (next_selected_index >= 0)
+ SelectTab(tabs_[next_selected_index]);
}
Layout();
FOR_EACH_OBSERVER(TabStripObserver, observers_, OnTabRemoved(tab));
@@ -721,22 +721,40 @@ class UI : public views::WidgetDelegateView,
bool is_popup,
const gfx::Rect& initial_rect,
bool user_gesture) override {
- if (is_popup) {
- views::Widget* window = views::Widget::CreateWindowWithContextAndBounds(
- new UI(browser_, is_popup ? UI::Type::POPUP : UI::Type::WINDOW,
- std::move(view)),
- nullptr, initial_rect);
- window->Show();
- browser_->AddWindow(window);
- } else {
+ if (is_popup)
+ CreateNewWindow(std::move(view), initial_rect, is_popup);
+ else
tab_strip_->AddTab(std::move(view));
- }
}
void Close(navigation::View* source) override {
tab_strip_->CloseTabForView(source);
if (tab_strip_->empty())
GetWidget()->Close();
}
+ void OpenURL(navigation::View* source,
+ navigation::mojom::OpenURLParamsPtr params) override {
+ switch (params->disposition) {
+ case navigation::mojom::WindowOpenDisposition::CURRENT_TAB:
+ selected_view()->NavigateToURL(params->url);
+ break;
+ case navigation::mojom::WindowOpenDisposition::NEW_FOREGROUND_TAB:
+ tab_strip_->AddTab(browser_->CreateView());
+ tab_strip_->selected_tab()->view()->NavigateToURL(params->url);
+ break;
+ case navigation::mojom::WindowOpenDisposition::NEW_POPUP:
+ case navigation::mojom::WindowOpenDisposition::NEW_WINDOW: {
+ std::unique_ptr<navigation::View> view = browser_->CreateView();
+ view->NavigateToURL(params->url);
+ CreateNewWindow(
+ std::move(view), gfx::Rect(),
+ params->disposition ==
+ navigation::mojom::WindowOpenDisposition::NEW_POPUP);
+ break;
+ }
+ default:
+ break;
+ }
+ }
// navigation::ViewObserver:
void LoadingStateChanged(navigation::View* view) override {
@@ -790,6 +808,20 @@ class UI : public views::WidgetDelegateView,
return tab_strip_->selected_tab()->view();
}
+ void CreateNewWindow(std::unique_ptr<navigation::View> view,
+ const gfx::Rect& initial_bounds,
+ bool is_popup) {
+ gfx::Rect bounds = initial_bounds;
+ if (bounds.IsEmpty())
+ bounds = gfx::Rect(10, 10, 400, 300);
+ views::Widget* window = views::Widget::CreateWindowWithContextAndBounds(
+ new UI(browser_, is_popup ? UI::Type::POPUP : UI::Type::WINDOW,
+ std::move(view)),
+ nullptr, bounds);
+ window->Show();
+ browser_->AddWindow(window);
+ }
+
void ToggleDebugView() {
showing_debug_view_ = !showing_debug_view_;
Layout();
« no previous file with comments | « no previous file | mash/webtest/webtest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698