toolbar_border_(NULL),
browser_(browser),
state_(GDK_WINDOW_STATE_WITHDRAWN),
- devtools_dock_side_(DEVTOOLS_DOCK_SIDE_BOTTOM),
devtools_window_(NULL),
- contents_hsplit_(NULL),
- contents_vsplit_(NULL),
+ devtools_floating_container_(NULL),
frame_cursor_(NULL),
is_active_(false),
show_state_after_show_(ui::SHOW_STATE_DEFAULT),
// If we have sized the window by setting a size request for the render
// area, then undo it so that the render view can later adjust its own
// size.
- gtk_widget_set_size_request(contents_container_->widget(), -1, -1);
+ gtk_widget_set_size_request(devtools_floating_container_, -1, -1);
- bool update_devtools = !window_has_shown_ && devtools_window_;
window_has_shown_ = true;
browser()->OnWindowDidShow();
- if (update_devtools)
- UpdateDevToolsSplitPosition();
}
void BrowserWindowGtk::ShowInactive() {
if (exterior) {
gtk_window_util::SetWindowSize(window_, gfx::Size(width, height));
} else {
- gtk_widget_set_size_request(contents_container_->widget(),
+ gtk_widget_set_size_request(devtools_floating_container_,
width, height);
}
}
render_area_floating_container_ = NULL;
render_area_event_box_ = NULL;
toolbar_border_ = NULL;
- contents_vsplit_ = NULL;
- contents_hsplit_ = NULL;
+ devtools_floating_container_ = NULL;
window_has_shown_ = false;
titlebar_->set_window(NULL);
void BrowserWindowGtk::UpdateTitleBar() {
TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::UpdateTitleBar");
- string16 title = browser_->GetWindowTitleForCurrentTab();
- gtk_window_set_title(window_, UTF16ToUTF8(title).c_str());
+ base::string16 title = browser_->GetWindowTitleForCurrentTab();
+ gtk_window_set_title(window_, base::UTF16ToUTF8(title).c_str());
if (ShouldShowWindowIcon())
titlebar_->UpdateTitleAndIcon();
}
toolbar_->GetLocationBarView()->SetStarred(is_starred);
}
+void BrowserWindowGtk::SetTranslateIconToggled(bool is_lit) {
+ NOTIMPLEMENTED();
+}
+
void BrowserWindowGtk::OnActiveTabChanged(WebContents* old_contents,
WebContents* new_contents,
int index,
// Update various elements that are interested in knowing the current
// WebContents.
- UpdateDevToolsForContents(new_contents);
infobar_container_->ChangeInfoBarService(
InfoBarService::FromWebContents(new_contents));
contents_container_->SetTab(new_contents);
+ UpdateDevToolsForContents(new_contents);
// TODO(estade): after we manage browser activation, add a check to make sure
// we are the active browser before calling RestoreFocus().
toolbar_->GetLocationBarView()->ShowStarBubble(url, !already_bookmarked);
}
+void BrowserWindowGtk::ShowBookmarkAppBubble(
+ const WebApplicationInfo& web_app_info,
+ const std::string& extension_id) {
+ NOTIMPLEMENTED();
+}
+
void BrowserWindowGtk::ShowTranslateBubble(
content::WebContents* contents,
- TranslateBubbleModel::ViewState view_state) {
+ TranslateTabHelper::TranslateStep step,
+ TranslateErrors::Type error_type) {
+ NOTIMPLEMENTED();
}
#if defined(ENABLE_ONE_CLICK_SIGNIN)
void BrowserWindowGtk::ShowOneClickSigninBubble(
OneClickSigninBubbleType type,
- const string16& email,
- const string16& error_message,
+ const base::string16& email,
+ const base::string16& error_message,
const StartSyncCallback& start_sync_callback) {
new OneClickSigninBubbleGtk(this, type, email,
const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) {
GdkEventKey* os_event = &event.os_event->key;
- if (!os_event || event.type != WebKit::WebInputEvent::RawKeyDown)
+ if (!os_event || event.type != blink::WebInputEvent::RawKeyDown)
return false;
if (ExtensionKeybindingRegistryGtk::shortcut_handling_suspended())
const NativeWebKeyboardEvent& event) {
GdkEventKey* os_event = &event.os_event->key;
- if (!os_event || event.type != WebKit::WebInputEvent::RawKeyDown)
+ if (!os_event || event.type != blink::WebInputEvent::RawKeyDown)
return;
// Handles a key event in following sequence:
if (bounds == configure_bounds_)
return FALSE;
- GetLocationBar()->GetLocationEntry()->CloseOmniboxPopup();
+ GetLocationBar()->GetOmniboxView()->CloseOmniboxPopup();
WebContents* tab = GetDisplayedTab();
if (tab)
implicit_cast<content::WebContentsDelegate*>(browser_.get())->
EmbedsFullscreenWidget()));
devtools_container_.reset(new TabContentsContainerGtk(NULL, false));
+ // DevTools container should only have DevTools-specific view ID.
+ ViewIDUtil::SetDelegateForWidget(devtools_container_->widget(), NULL);
ViewIDUtil::SetID(devtools_container_->widget(), VIEW_ID_DEV_TOOLS_DOCKED);
- contents_hsplit_ = gtk_hpaned_new();
- gtk_paned_pack1(GTK_PANED(contents_hsplit_), contents_container_->widget(),
- TRUE, TRUE);
- contents_vsplit_ = gtk_vpaned_new();
- gtk_paned_pack1(GTK_PANED(contents_vsplit_), contents_hsplit_, TRUE, TRUE);
-
+ devtools_floating_container_ = gtk_floating_container_new();
+ gtk_container_add(GTK_CONTAINER(devtools_floating_container_),
+ devtools_container_->widget());
+ gtk_floating_container_add_floating(
+ GTK_FLOATING_CONTAINER(devtools_floating_container_),
+ contents_container_->widget());
+ g_signal_connect(devtools_floating_container_, "set-floating-position",
+ G_CALLBACK(OnDevToolsContainerSetFloatingPosition), this);
gtk_box_pack_end(GTK_BOX(render_area_vbox_),
- contents_vsplit_, TRUE, TRUE, 0);
+ devtools_floating_container_, TRUE, TRUE, 0);
gtk_widget_show_all(render_area_floating_container_);
+
render_area_event_box_ = gtk_event_box_new();
// Set a white background so during startup the user sees white in the
// content area before we get a WebContents in place.
gtk_widget_modify_bg(GTK_WIDGET(window_), GTK_STATE_NORMAL,
&frame_color_gdk);
- // Set the color of the dev tools divider.
- gtk_widget_modify_bg(contents_vsplit_, GTK_STATE_NORMAL, &frame_color_gdk);
- gtk_widget_modify_bg(contents_hsplit_, GTK_STATE_NORMAL, &frame_color_gdk);
-
- // When the cursor is over the divider, GTK+ normally lightens the background
- // color by 1.3 (see LIGHTNESS_MULT in gtkstyle.c). Since we're setting the
- // color, override the prelight also.
- color_utils::HSL hsl = { -1, 0.5, 0.65 };
- SkColor frame_prelight_color = color_utils::HSLShift(frame_color, hsl);
- GdkColor frame_prelight_color_gdk =
- gfx::SkColorToGdkColor(frame_prelight_color);
- gtk_widget_modify_bg(contents_hsplit_, GTK_STATE_PRELIGHT,
- &frame_prelight_color_gdk);
- gtk_widget_modify_bg(contents_vsplit_, GTK_STATE_PRELIGHT,
- &frame_prelight_color_gdk);
-
GdkColor border_color = theme_provider->GetBorderColor();
gtk_widget_modify_bg(toolbar_border_, GTK_STATE_NORMAL, &border_color);
}
std::string window_name = chrome::GetWindowPlacementKey(browser_.get());
DictionaryPrefUpdate update(browser_->profile()->GetPrefs(),
window_name.c_str());
- DictionaryValue* window_preferences = update.Get();
+ base::DictionaryValue* window_preferences = update.Get();
// Note that we store left/top for consistency with Windows, but that we
// *don't* obey them; we only use them for computing width/height. See
// comments in SetGeometryHints().
DevToolsWindow* new_devtools_window = contents ?
DevToolsWindow::GetDockedInstanceForInspectedTab(contents) : NULL;
- // Fast return in case of the same window having same orientation.
- if (devtools_window_ == new_devtools_window && (!new_devtools_window ||
- new_devtools_window->dock_side() == devtools_dock_side_)) {
- return;
- }
-
// Replace tab contents.
if (devtools_window_ != new_devtools_window) {
if (devtools_window_)
}
}
- // Store last used position.
- if (devtools_window_) {
- GtkAllocation contents_rect;
- gtk_widget_get_allocation(contents_vsplit_, &contents_rect);
- int split_size;
- if (devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_RIGHT) {
- gtk_widget_style_get(contents_hsplit_, "handle-size", &split_size, NULL);
- devtools_window_->SetWidth(
- contents_rect.width - split_size -
- gtk_paned_get_position(GTK_PANED(contents_hsplit_)));
- } else if (devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_BOTTOM) {
- gtk_widget_style_get(contents_vsplit_, "handle-size", &split_size, NULL);
- devtools_window_->SetHeight(
- contents_rect.height - split_size -
- gtk_paned_get_position(GTK_PANED(contents_vsplit_)));
- }
- }
-
- // Show / hide container if necessary. Changing dock orientation is
- // hide + show.
- bool should_hide = devtools_window_ && (!new_devtools_window ||
- devtools_dock_side_ != new_devtools_window->dock_side());
- bool should_show = new_devtools_window && (!devtools_window_ || should_hide);
+ // Show / hide container if necessary.
+ bool should_hide = devtools_window_ && !new_devtools_window;
+ bool should_show = new_devtools_window && !devtools_window_;
if (should_hide)
HideDevToolsContainer();
devtools_window_ = new_devtools_window;
+ if (devtools_window_) {
+ contents_resizing_strategy_.CopyFrom(
+ devtools_window_->GetContentsResizingStrategy());
+ } else {
+ contents_resizing_strategy_.CopyFrom(DevToolsContentsResizingStrategy());
+ }
- if (should_show) {
- devtools_dock_side_ = new_devtools_window->dock_side();
+ if (should_show)
ShowDevToolsContainer();
- } else if (new_devtools_window) {
- UpdateDevToolsSplitPosition();
- }
+
+ gtk_widget_queue_resize(devtools_floating_container_);
+ gtk_widget_queue_draw(devtools_floating_container_);
}
void BrowserWindowGtk::ShowDevToolsContainer() {
- if (devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_MINIMIZED) {
- gtk_box_pack_end(GTK_BOX(render_area_vbox_),
- devtools_container_->widget(), FALSE, FALSE, 0);
- gtk_box_reorder_child(GTK_BOX(render_area_vbox_),
- devtools_container_->widget(), 0);
- } else {
- gtk_widget_set_size_request(devtools_container_->widget(),
- devtools_window_->GetMinimumWidth(),
- devtools_window_->GetMinimumHeight());
- bool to_right = devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_RIGHT;
- gtk_paned_pack2(GTK_PANED(to_right ? contents_hsplit_ : contents_vsplit_),
- devtools_container_->widget(),
- FALSE,
- FALSE);
- }
- UpdateDevToolsSplitPosition();
- gtk_widget_show(devtools_container_->widget());
+ // Move devtools below contents.
+ GdkWindow* const devtools_gdk_window =
+ gtk_widget_get_window(devtools_container_->widget());
+ if (devtools_gdk_window)
+ gdk_window_lower(devtools_gdk_window);
}
void BrowserWindowGtk::HideDevToolsContainer() {
- gtk_container_remove(GTK_CONTAINER(
- devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_RIGHT ? contents_hsplit_ :
- devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_BOTTOM ? contents_vsplit_ :
- render_area_vbox_),
- devtools_container_->widget());
- gtk_widget_hide(devtools_container_->widget());
+ // This method is left intentionally blank.
}
-void BrowserWindowGtk::UpdateDevToolsSplitPosition() {
- if (!window_has_shown_)
- return;
-
- // This is required if infobar appears/disappears, or devtools container is
- // moved between |render_area_vbox_| and |contents_{v,h}split_|.
- gtk_container_check_resize(GTK_CONTAINER(render_area_vbox_));
-
- GtkAllocation contents_rect;
- gtk_widget_get_allocation(contents_vsplit_, &contents_rect);
- int split_size;
-
- if (devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_RIGHT) {
- gtk_widget_style_get(contents_hsplit_, "handle-size", &split_size, NULL);
- int split_offset = contents_rect.width -
- devtools_window_->GetWidth(contents_rect.width) - split_size;
- gtk_paned_set_position(GTK_PANED(contents_hsplit_), split_offset);
- } else if (devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_BOTTOM) {
- gtk_widget_style_get(contents_vsplit_, "handle-size", &split_size, NULL);
- int split_offset = contents_rect.height -
- devtools_window_->GetHeight(contents_rect.height) - split_size;
- gtk_paned_set_position(GTK_PANED(contents_vsplit_), split_offset);
- } else {
- gtk_widget_set_size_request(devtools_container_->widget(),
- 0, devtools_window_->GetMinimizedHeight());
- }
+// static
+void BrowserWindowGtk::OnDevToolsContainerSetFloatingPosition(
+ GtkFloatingContainer* container, GtkAllocation* allocation,
+ BrowserWindowGtk* browser_window) {
+ GtkAllocation contents_allocation;
+ gtk_widget_get_allocation(browser_window->contents_container_->widget(),
+ &contents_allocation);
+
+ gfx::Size container_size(allocation->width, allocation->height);
+ gfx::Rect old_devtools_bounds(0, 0, allocation->width, allocation->height);
+ gfx::Rect old_contents_bounds(contents_allocation.x, contents_allocation.y,
+ contents_allocation.width, contents_allocation.height);
+ gfx::Rect new_devtools_bounds;
+ gfx::Rect new_contents_bounds;
+
+ ApplyDevToolsContentsResizingStrategy(
+ browser_window->contents_resizing_strategy_, container_size,
+ old_devtools_bounds, old_contents_bounds,
+ &new_devtools_bounds, &new_contents_bounds);
+
+ gtk_widget_set_size_request(browser_window->contents_container_->widget(),
+ new_contents_bounds.width(), new_contents_bounds.height());
+
+ GValue value = { 0, };
+ g_value_init(&value, G_TYPE_INT);
+ g_value_set_int(&value, new_contents_bounds.x());
+ gtk_container_child_set_property(GTK_CONTAINER(container),
+ browser_window->contents_container_->widget(), "x", &value);
+ g_value_set_int(&value, new_contents_bounds.y());
+ gtk_container_child_set_property(GTK_CONTAINER(container),
+ browser_window->contents_container_->widget(), "y", &value);
+ g_value_unset(&value);
}
void BrowserWindowGtk::OnUseCustomChromeFrameChanged() {
browser_window_gtk->Init();
return browser_window_gtk;
}
+
+// static
+chrome::HostDesktopType BrowserWindow::AdjustHostDesktopType(
+ chrome::HostDesktopType desktop_type) {
+ return desktop_type;
+}