#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/native_window_notification_source.h"
+#include "chrome/browser/password_manager/chrome_password_manager_client.h"
#include "chrome/browser/password_manager/password_manager.h"
#include "chrome/browser/profiles/avatar_menu.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/search/search.h"
#include "chrome/browser/sessions/tab_restore_service.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/browser/ui/views/browser_dialogs.h"
#include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h"
#include "chrome/browser/ui/views/download/download_shelf_view.h"
+#include "chrome/browser/ui/views/extensions/bookmark_app_bubble_view.h"
#include "chrome/browser/ui/views/frame/browser_view_layout.h"
#include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h"
-#include "chrome/browser/ui/views/frame/contents_container.h"
+#include "chrome/browser/ui/views/frame/contents_layout_manager.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
+#include "chrome/browser/ui/views/frame/native_browser_frame_factory.h"
#include "chrome/browser/ui/views/frame/top_container_view.h"
#include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h"
#include "chrome/browser/ui/views/infobars/infobar_container_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "chrome/browser/ui/views/location_bar/location_icon_view.h"
#include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
-#include "chrome/browser/ui/views/omnibox/omnibox_views.h"
#include "chrome/browser/ui/views/password_generation_bubble_view.h"
+#include "chrome/browser/ui/views/profile_chooser_view.h"
#include "chrome/browser/ui/views/status_bubble_views.h"
#include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h"
#include "chrome/browser/ui/views/tabs/tab.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h"
-#include "chrome/browser/ui/views/toolbar_view.h"
+#include "chrome/browser/ui/views/toolbar/reload_button.h"
+#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/browser/ui/views/translate/translate_bubble_view.h"
#include "chrome/browser/ui/views/update_recommended_message_box.h"
+#include "chrome/browser/ui/views/website_settings/permissions_bubble_view.h"
#include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h"
+#include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
#include "chrome/browser/ui/window_sizer/window_sizer.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
+#include "chrome/common/profile_management_switches.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "ui/events/event_utils.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_utils.h"
+#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/sys_color_change_listener.h"
#include "ui/views/controls/button/menu_button.h"
-#include "ui/views/controls/single_split_view.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/controls/webview/webview.h"
#include "ui/views/focus/external_focus_tracker.h"
#include "ui/views/window/dialog_delegate.h"
#if defined(USE_ASH)
-#include "ash/launcher/launcher.h"
-#include "ash/launcher/launcher_model.h"
+#include "ash/ash_switches.h"
+#include "ash/shelf/shelf.h"
+#include "ash/shelf/shelf_model.h"
#include "ash/shell.h"
#include "chrome/browser/ui/ash/ash_util.h"
#endif
#if defined(USE_AURA)
+#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/gfx/screen.h"
-#elif defined(OS_WIN) // !defined(USE_AURA)
-#include "chrome/browser/jumplist_win.h"
-#include "chrome/browser/ui/views/omnibox/omnibox_view_win.h"
-#include "ui/views/widget/native_widget_win.h"
-#include "ui/views/win/scoped_fullscreen_visibility.h"
#endif
#if defined(OS_WIN)
#include "base/win/windows_version.h"
+#include "chrome/browser/jumplist_win.h"
+#include "ui/views/win/scoped_fullscreen_visibility.h"
#include "win8/util/win8_util.h"
#endif
#endif
#if defined(OS_CHROMEOS)
-#include "chrome/browser/ui/ash/multi_user_window_manager.h"
+#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
#endif
using base::TimeDelta;
+using base::UserMetricsAction;
using content::NativeWebKeyboardEvent;
using content::SSLStatus;
-using content::UserMetricsAction;
using content::WebContents;
using views::ColumnSet;
using views::GridLayout;
virtual ~BrowserViewLayoutDelegateImpl() {}
// BrowserViewLayoutDelegate overrides:
+ virtual views::View* GetContentsWebView() const OVERRIDE {
+ return browser_view_->contents_web_view_;
+ }
+
virtual views::View* GetWindowSwitcherButton() const OVERRIDE {
return browser_view_->window_switcher_button();
}
return browser_view_->IsTabStripVisible();
}
- virtual gfx::Rect GetBoundsForTabStrip(
- views::View* tab_strip) const OVERRIDE {
- return browser_view_->frame()->GetBoundsForTabStrip(tab_strip);
+ virtual gfx::Rect GetBoundsForTabStripInBrowserView() const OVERRIDE {
+ gfx::RectF bounds_f(browser_view_->frame()->GetBoundsForTabStrip(
+ browser_view_->tabstrip()));
+ views::View::ConvertRectToTarget(browser_view_->parent(), browser_view_,
+ &bounds_f);
+ return gfx::ToEnclosingRect(bounds_f);
+ }
+
+ virtual int GetTopInsetInBrowserView() const OVERRIDE {
+ return browser_view_->frame()->GetTopInset() -
+ browser_view_->y();
+ }
+
+ virtual int GetThemeBackgroundXInset() const OVERRIDE {
+ // TODO(pkotwicz): Return the inset with respect to the left edge of the
+ // BrowserView.
+ return browser_view_->frame()->GetThemeBackgroundXInset();
}
virtual bool IsToolbarVisible() const OVERRIDE {
find_bar_host_view_(NULL),
infobar_container_(NULL),
contents_web_view_(NULL),
- devtools_container_(NULL),
contents_container_(NULL),
- contents_split_(NULL),
- devtools_dock_side_(DEVTOOLS_DOCK_SIDE_BOTTOM),
devtools_window_(NULL),
initialized_(false),
in_process_fullscreen_(false),
-#if defined(OS_WIN) && !defined(USE_AURA)
+#if defined(OS_WIN)
hung_window_detector_(&hung_plugin_action_),
ticker_(0),
#endif
}
BrowserView::~BrowserView() {
+ // All the tabs should have been destroyed already. If we were closed by the
+ // OS with some tabs than the NativeBrowserFrame should have destroyed them.
+ DCHECK_EQ(0, browser_->tab_strip_model()->count());
+
// Immersive mode may need to reparent views before they are removed/deleted.
immersive_mode_controller_.reset();
browser_->tab_strip_model()->RemoveObserver(this);
-#if defined(OS_WIN) && !defined(USE_AURA)
+#if defined(OS_WIN)
// Stop hung plugin monitoring.
ticker_.Stop();
ticker_.UnregisterTickHandler(&hung_window_detector_);
RemoveAllChildViews(true);
toolbar_ = NULL;
- // It is possible that we were forced-closed by the native view system and
- // that tabs remain in the browser. Close any such remaining tabs. Detach
- // before destroying in hopes of avoiding less callbacks trying to access
- // members since destroyed.
- {
- ScopedVector<content::WebContents> contents;
- while (browser_->tab_strip_model()->count())
- contents.push_back(browser_->tab_strip_model()->DetachWebContentsAt(0));
- }
-
// Explicitly set browser_ to NULL.
browser_.reset();
}
}
void BrowserView::InitStatusBubble() {
- status_bubble_.reset(new StatusBubbleViews(contents_container_));
+ status_bubble_.reset(new StatusBubbleViews(contents_web_view_));
+ contents_web_view_->SetStatusBubble(status_bubble_.get());
+}
+
+void BrowserView::InitPermissionBubbleView() {
+ permission_bubble_view_.reset(new PermissionBubbleViewViews(
+ GetLocationBarView()->GetLocationIconView()));
}
gfx::Rect BrowserView::GetToolbarBounds() const {
return toolbar_bounds;
}
-gfx::Rect BrowserView::GetClientAreaBounds() const {
- gfx::Rect container_bounds = contents_container_->bounds();
- gfx::Point container_origin = container_bounds.origin();
- ConvertPointToTarget(this, parent(), &container_origin);
- container_bounds.set_origin(container_origin);
- return container_bounds;
-}
-
gfx::Rect BrowserView::GetFindBarBoundingBox() const {
return GetBrowserViewLayout()->GetFindBarBoundingBox();
}
// be). We expect our parent's origin to be the window origin.
gfx::Point window_point(point + GetMirroredPosition().OffsetFromOrigin());
window_point.Offset(frame_->GetThemeBackgroundXInset(),
- -frame_->GetTabStripInsets(false).top);
+ -frame_->GetTopInset());
return window_point;
}
}
bool BrowserView::IsRegularOrGuestSession() const {
- Profile* profile = browser_->profile();
- return (profile->IsGuestSession() || !profile->IsOffTheRecord());
+ return profiles::IsRegularOrGuestSession(browser_.get());
}
int BrowserView::GetOTRIconResourceID() const {
}
int BrowserView::GetGuestIconResourceID() const {
- return IDR_GUEST_ICON;
+ return IDR_LOGIN_GUEST;
}
bool BrowserView::ShouldShowAvatar() const {
return true;
// Note: In case of the M-31 mode the window manager won't exist.
- chrome::MultiUserWindowManager* window_manager =
- chrome::MultiUserWindowManager::GetInstance();
- if (window_manager) {
+ if (chrome::MultiUserWindowManager::GetMultiProfileMode() ==
+ chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) {
// This function is called via BrowserNonClientFrameView::UpdateAvatarInfo
// during the creation of the BrowserWindow, so browser->window() will not
// yet be set. In this case we can safely return false.
// Note: When the window manager the window is either on it's owners desktop
// (and shows no icon) or it is now (in which it will show an icon). So we
// can return here.
+ chrome::MultiUserWindowManager* window_manager =
+ chrome::MultiUserWindowManager::GetInstance();
return !window_manager->IsWindowOnDesktopOfUser(
window,
window_manager->GetWindowOwner(window));
}
void BrowserView::UpdateDevTools() {
- UpdateDevToolsForContents(GetActiveWebContents());
+ UpdateDevToolsForContents(GetActiveWebContents(), true);
Layout();
}
GetLocationBarView()->SetStarToggled(is_starred);
}
+void BrowserView::SetTranslateIconToggled(bool is_lit) {
+ GetLocationBarView()->SetTranslateIconToggled(is_lit);
+}
+
void BrowserView::OnActiveTabChanged(content::WebContents* old_contents,
content::WebContents* new_contents,
int index,
// When we toggle the NTP floating bookmarks bar and/or the info bar,
// we don't want any WebContents to be attached, so that we
// avoid an unnecessary resize and re-layout of a WebContents.
- if (change_tab_contents)
+ if (change_tab_contents) {
contents_web_view_->SetWebContents(NULL);
+ devtools_web_view_->SetWebContents(NULL);
+ }
infobar_container_->ChangeInfoBarService(
InfoBarService::FromWebContents(new_contents));
+
+ if (old_contents && PermissionBubbleManager::FromWebContents(old_contents))
+ PermissionBubbleManager::FromWebContents(old_contents)->SetView(NULL);
+
+ if (new_contents && PermissionBubbleManager::FromWebContents(new_contents)) {
+ PermissionBubbleManager::FromWebContents(new_contents)->SetView(
+ permission_bubble_view_.get());
+ }
+
if (bookmark_bar_view_.get()) {
bookmark_bar_view_->SetBookmarkBarState(
browser_->bookmark_bar_state(),
}
UpdateUIForContents(new_contents);
- // Layout for DevTools _before_ setting the main WebContents to avoid
- // toggling the size of the main WebContents.
- UpdateDevToolsForContents(new_contents);
+ // Layout for DevTools _before_ setting the both main and devtools WebContents
+ // to avoid toggling the size of any of them.
+ UpdateDevToolsForContents(new_contents, !change_tab_contents);
- if (change_tab_contents)
+ if (change_tab_contents) {
contents_web_view_->SetWebContents(new_contents);
+ // The second layout update should be no-op. It will just set the
+ // DevTools WebContents.
+ UpdateDevToolsForContents(new_contents, true);
+ }
if (!browser_->tab_strip_model()->closing_all() && GetWidget()->IsActive() &&
GetWidget()->IsVisible()) {
}
bool BrowserView::IsInMetroSnapMode() const {
-#if defined(USE_AURA)
return false;
-#else
- return static_cast<views::NativeWidgetWin*>(
- frame_->native_widget())->IsInMetroSnapMode();
-#endif
}
#endif // defined(OS_WIN)
window_switcher_button_ = button;
}
+void BrowserView::FullscreenStateChanged() {
+ CHECK(!IsFullscreen());
+ ProcessFullscreen(false, FOR_DESKTOP, GURL(), FEB_TYPE_NONE);
+}
+
void BrowserView::ToolbarSizeChanged(bool is_animating) {
// The call to InfoBarContainer::SetMaxTopArrowHeight() below can result in
// reentrancy; |call_state| tracks whether we're reentrant. We can't just
// wrapping it will do it.
if ((call_state == NORMAL) && !is_animating) {
contents_web_view_->InvalidateLayout();
- contents_split_->Layout();
+ contents_container_->Layout();
}
}
ImmersiveModeController::ANIMATE_REVEAL_YES));
LocationBarView* location_bar = GetLocationBarView();
- if (location_bar->IsLocationEntryFocusableInRootView()) {
+ if (location_bar->omnibox_view()->IsFocusable()) {
// Location bar got focus.
- location_bar->FocusLocation(select_all);
+ //
+ // select_all is true when it's expected that the user may want to copy
+ // the URL to the clipboard. If the URL is not being shown because the
+ // origin chip is enabled, show it now to support the same functionality.
+ if (select_all &&
+ location_bar->GetToolbarModel()->WouldOmitURLDueToOriginChip())
+ location_bar->omnibox_view()->ShowURL();
+ else
+ location_bar->FocusLocation(select_all);
} else {
- // If none of location bar got focus,
- // then clear focus.
+ // If none of location bar got focus, then clear focus.
views::FocusManager* focus_manager = GetFocusManager();
DCHECK(focus_manager);
focus_manager->ClearFocus();
// the window now so that we are deleted immediately and aren't left holding
// references to deleted objects.
GetWidget()->RemoveObserver(this);
- GetLocationBar()->GetLocationEntry()->model()->popup_model()->RemoveObserver(
+ GetLocationBar()->GetOmniboxView()->model()->popup_model()->RemoveObserver(
this);
frame_->CloseNow();
}
return gfx::Rect();
}
-void BrowserView::DisableInactiveFrame() {
-#if defined(OS_WIN) && !defined(USE_AURA)
- frame_->DisableInactiveRendering();
-#endif // No tricks are needed to get the right behavior on Linux.
-}
-
void BrowserView::ConfirmAddSearchProvider(TemplateURL* template_url,
Profile* profile) {
chrome::EditSearchEngine(GetWidget()->GetNativeWindow(), template_url, NULL,
!already_bookmarked);
}
+void BrowserView::ShowBookmarkAppBubble(
+ const WebApplicationInfo& web_app_info,
+ const std::string& extension_id) {
+ BookmarkAppBubbleView::ShowBubble(GetToolbarView(),
+ browser_->profile(),
+ web_app_info,
+ extension_id);
+}
+
void BrowserView::ShowBookmarkPrompt() {
GetLocationBarView()->ShowBookmarkPrompt();
}
-void BrowserView::ShowTranslateBubble(
- content::WebContents* web_contents,
- TranslateBubbleModel::ViewState view_state) {
+void BrowserView::ShowTranslateBubble(content::WebContents* web_contents,
+ TranslateTabHelper::TranslateStep step,
+ TranslateErrors::Type error_type) {
TranslateTabHelper* translate_tab_helper =
TranslateTabHelper::FromWebContents(web_contents);
- LanguageState& language_state = translate_tab_helper->language_state();
+ LanguageState& language_state = translate_tab_helper->GetLanguageState();
language_state.SetTranslateEnabled(true);
- TranslateBubbleView::ShowBubble(GetToolbarView()->GetTranslateBubbleAnchor(),
- web_contents, view_state, browser_.get());
+ TranslateBubbleView::ShowBubble(
+ GetToolbarView()->GetTranslateBubbleAnchor(), web_contents, step,
+ error_type);
}
#if defined(ENABLE_ONE_CLICK_SIGNIN)
void BrowserView::ShowOneClickSigninBubble(
OneClickSigninBubbleType type,
- const string16& email,
- const string16& error_message,
+ const base::string16& email,
+ const base::string16& error_message,
const StartSyncCallback& start_sync_callback) {
scoped_ptr<OneClickSigninBubbleDelegate> delegate;
delegate.reset(new OneClickSigninBubbleLinksDelegate(browser()));
if (contents_web_view_->GetWebContents() == contents)
contents_web_view_->OnWebContentsFocused(contents);
else
- devtools_container_->OnWebContentsFocused(contents);
+ devtools_web_view_->OnWebContentsFocused(contents);
}
void BrowserView::ShowWebsiteSettings(Profile* profile,
const GURL& url,
const content::SSLStatus& ssl) {
WebsiteSettingsPopupView::ShowPopup(
- GetLocationBarView()->location_icon_view(), profile,
+ GetLocationBarView()->GetLocationIconView(), profile,
web_contents, url, ssl, browser_.get());
}
bool* is_keyboard_shortcut) {
*is_keyboard_shortcut = false;
- if ((event.type != WebKit::WebInputEvent::RawKeyDown) &&
- (event.type != WebKit::WebInputEvent::KeyUp)) {
+ if ((event.type != blink::WebInputEvent::RawKeyDown) &&
+ (event.type != blink::WebInputEvent::KeyUp)) {
return false;
}
-#if defined(OS_WIN) && !defined(USE_AURA)
- // As Alt+F4 is the close-app keyboard shortcut, it needs processing
- // immediately.
- if (event.windowsKeyCode == ui::VKEY_F4 &&
- event.type == WebKit::WebInputEvent::RawKeyDown &&
- event.modifiers == NativeWebKeyboardEvent::AltKey) {
- DefWindowProc(event.os_event.hwnd, event.os_event.message,
- event.os_event.wParam, event.os_event.lParam);
- return true;
- }
-#endif
-
views::FocusManager* focus_manager = GetFocusManager();
DCHECK(focus_manager);
ui::Accelerator accelerator(
static_cast<ui::KeyboardCode>(event.windowsKeyCode),
content::GetModifiersFromNativeWebKeyboardEvent(event));
- if (event.type == WebKit::WebInputEvent::KeyUp)
+ if (event.type == blink::WebInputEvent::KeyUp)
accelerator.set_type(ui::ET_KEY_RELEASED);
// What we have to do here is as follows:
if (id != -1) {
// |accelerator| is a non-reserved browser shortcut (e.g. Ctrl+f).
- if (event.type == WebKit::WebInputEvent::RawKeyDown)
+ if (event.type == blink::WebInputEvent::RawKeyDown)
*is_keyboard_shortcut = true;
} else if (processed) {
// |accelerator| is a non-browser shortcut (e.g. F4-F10 on Ash). Report
// Omnibox is focused, send a Ctrl+x key event to Chrome. Using RWH interface
// rather than the fake key event for a WebContent is important since the fake
// event might be consumed by the web content (crbug.com/137908).
- DoCutCopyPaste(&content::RenderWidgetHost::Cut,
-#if defined(OS_WIN)
- WM_CUT,
-#endif
- IDS_APP_CUT);
+ DoCutCopyPaste(&content::RenderWidgetHost::Cut, IDS_APP_CUT);
}
void BrowserView::Copy() {
- DoCutCopyPaste(&content::RenderWidgetHost::Copy,
-#if defined(OS_WIN)
- WM_COPY,
-#endif
- IDS_APP_COPY);
+ DoCutCopyPaste(&content::RenderWidgetHost::Copy, IDS_APP_COPY);
}
void BrowserView::Paste() {
- DoCutCopyPaste(&content::RenderWidgetHost::Paste,
-#if defined(OS_WIN)
- WM_PASTE,
-#endif
- IDS_APP_PASTE);
+ DoCutCopyPaste(&content::RenderWidgetHost::Paste, IDS_APP_PASTE);
}
WindowOpenDisposition BrowserView::GetDispositionForPopupBounds(
// BrowserView, TabStripModelObserver implementation:
void BrowserView::TabDetachedAt(WebContents* contents, int index) {
+ if (PermissionBubbleManager::FromWebContents(contents))
+ PermissionBubbleManager::FromWebContents(contents)->SetView(NULL);
+
// We use index here rather than comparing |contents| because by this time
// the model has already removed |contents| from its list, so
// browser_->GetActiveWebContents() will return NULL or something else.
// on the selected WebContents when it is removed.
contents_web_view_->SetWebContents(NULL);
infobar_container_->ChangeInfoBarService(NULL);
- UpdateDevToolsForContents(NULL);
+ UpdateDevToolsForContents(NULL, true);
}
}
void BrowserView::TabDeactivated(WebContents* contents) {
+ if (PermissionBubbleManager::FromWebContents(contents))
+ PermissionBubbleManager::FromWebContents(contents)->SetView(NULL);
+
// We do not store the focus when closing the tab to work-around bug 4633.
// Some reports seem to show that the focus manager and/or focused view can
// be garbage at that point, it is not clear why.
return false;
}
-string16 BrowserView::GetWindowTitle() const {
+base::string16 BrowserView::GetWindowTitle() const {
return browser_->GetWindowTitleForCurrentTab();
}
-string16 BrowserView::GetAccessibleWindowTitle() const {
+base::string16 BrowserView::GetAccessibleWindowTitle() const {
if (IsOffTheRecord()) {
return l10n_util::GetStringFUTF16(
IDS_ACCESSIBLE_INCOGNITO_WINDOW_TITLE_FORMAT,
// Close the omnibox popup, if any.
LocationBarView* location_bar_view = GetLocationBarView();
if (location_bar_view)
- location_bar_view->GetLocationEntry()->CloseOmniboxPopup();
+ location_bar_view->GetOmniboxView()->CloseOmniboxPopup();
}
views::Widget* BrowserView::GetWidget() {
if (download_shelf_.get())
panes->push_back(download_shelf_.get());
panes->push_back(GetTabContentsContainerView());
- if (devtools_container_->visible())
- panes->push_back(devtools_container_);
+ if (devtools_web_view_->visible())
+ panes->push_back(devtools_web_view_);
}
///////////////////////////////////////////////////////////////////////////////
views::View::Layout();
// TODO(jamescook): Why was this in the middle of layout code?
- toolbar_->location_bar()->SetLocationEntryFocusable(IsToolbarVisible());
-
- // The status bubble position requires that all other layout finish first.
- LayoutStatusBubble();
+ toolbar_->location_bar()->omnibox_view()->SetFocusable(IsToolbarVisible());
}
void BrowserView::PaintChildren(gfx::Canvas* canvas) {
}
///////////////////////////////////////////////////////////////////////////////
-// BrowserView, ImmersiveModeController::Delegate overrides:
-
-FullscreenController* BrowserView::GetFullscreenController() {
- // Cannot be injected into ImmersiveModeController because it is constructed
- // after BrowserView.
- return browser()->fullscreen_controller();
-}
-
-void BrowserView::FullscreenStateChanged() {
- if (IsFullscreen()) {
- ProcessFullscreen(true, FOR_DESKTOP, GURL(),
- FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION);
- } else {
- ProcessFullscreen(false, FOR_DESKTOP, GURL(), FEB_TYPE_NONE);
- }
-}
-
-void BrowserView::SetImmersiveStyle(bool immersive) {
- // Only the tab strip changes its painting style for immersive fullscreen.
- if (tabstrip_)
- tabstrip_->SetImmersiveStyle(immersive);
-}
-
-WebContents* BrowserView::GetWebContents() {
- return GetActiveWebContents();
-}
-
-///////////////////////////////////////////////////////////////////////////////
// BrowserView, InfoBarContainer::Delegate overrides:
SkColor BrowserView::GetInfoBarSeparatorColor() const {
bool BrowserView::DrawInfoBarArrows(int* x) const {
if (x) {
- const LocationIconView* location_icon_view =
- toolbar_->location_bar()->location_icon_view();
- gfx::Point icon_center(location_icon_view->GetImageBounds().CenterPoint());
- ConvertPointToTarget(location_icon_view, this, &icon_center);
- *x = icon_center.x();
+ gfx::Point anchor(toolbar_->location_bar()->GetLocationBarAnchorPoint());
+ ConvertPointToTarget(toolbar_->location_bar(), this, &anchor);
+ *x = anchor.x();
}
return true;
}
-bool BrowserView::SplitHandleMoved(views::SingleSplitView* sender) {
- for (int i = 0; i < sender->child_count(); ++i)
- sender->child_at(i)->InvalidateLayout();
- SchedulePaint();
- Layout();
- return false;
-}
-
void BrowserView::OnSysColorChange() {
chrome::MaybeShowInvertBubbleView(browser_.get(), contents_container_);
}
infobar_container_ = new InfoBarContainerView(this);
AddChildView(infobar_container_);
- contents_web_view_ = new views::WebView(browser_->profile());
+ contents_web_view_ = new ContentsWebView(browser_->profile());
contents_web_view_->set_id(VIEW_ID_TAB_CONTAINER);
contents_web_view_->SetEmbedFullscreenWidgetMode(
implicit_cast<content::WebContentsDelegate*>(browser_.get())->
EmbedsFullscreenWidget());
- contents_container_ = new ContentsContainer(contents_web_view_);
-
- SkColor bg_color = GetWidget()->GetThemeProvider()->
- GetColor(ThemeProperties::COLOR_TOOLBAR);
- devtools_container_ = new views::WebView(browser_->profile());
- devtools_container_->set_id(VIEW_ID_DEV_TOOLS_DOCKED);
- devtools_container_->SetVisible(false);
+ devtools_web_view_ = new views::WebView(browser_->profile());
+ devtools_web_view_->set_id(VIEW_ID_DEV_TOOLS_DOCKED);
+ devtools_web_view_->SetVisible(false);
- views::View* contents_container_view = contents_container_;
-
- contents_split_ = new views::SingleSplitView(
- contents_container_view,
- devtools_container_,
- views::SingleSplitView::VERTICAL_SPLIT,
- this);
- contents_split_->set_id(VIEW_ID_CONTENTS_SPLIT);
- contents_split_->SetAccessibleName(
- l10n_util::GetStringUTF16(IDS_ACCNAME_WEB_CONTENTS));
- contents_split_->set_background(
- views::Background::CreateSolidBackground(bg_color));
- AddChildView(contents_split_);
- set_contents_view(contents_split_);
-
- InitStatusBubble();
+ contents_container_ = new views::View();
+ contents_container_->set_background(views::Background::CreateSolidBackground(
+ ThemeProperties::GetDefaultColor(
+ ThemeProperties::COLOR_CONTROL_BACKGROUND)));
+ contents_container_->AddChildView(devtools_web_view_);
+ contents_container_->AddChildView(contents_web_view_);
+ contents_container_->SetLayoutManager(new ContentsLayoutManager(
+ devtools_web_view_, contents_web_view_));
+ AddChildView(contents_container_);
+ set_contents_view(contents_container_);
// Top container holds tab strip and toolbar and lives at the front of the
// view hierarchy.
top_container_->AddChildView(toolbar_);
toolbar_->Init();
+ InitStatusBubble();
+ InitPermissionBubbleView();
+
// Create do-nothing view for the sake of controlling the z-order of the find
// bar widget.
find_bar_host_view_ = new View();
if (window_switcher_button_)
AddChildView(window_switcher_button_);
- immersive_mode_controller_->Init(this, GetWidget(), top_container_);
+ immersive_mode_controller_->Init(this);
BrowserViewLayout* browser_view_layout = new BrowserViewLayout;
browser_view_layout->Init(new BrowserViewLayoutDelegateImpl(this),
tabstrip_,
toolbar_,
infobar_container_,
- contents_split_,
contents_container_,
+ GetContentsLayoutManager(),
immersive_mode_controller_.get());
SetLayoutManager(browser_view_layout);
-#if defined(OS_WIN) && !defined(USE_AURA)
+#if defined(OS_WIN)
// Create a custom JumpList and add it to an observer of TabRestoreService
// so we can update the custom JumpList when a tab is added or removed.
if (JumpList::Enabled()) {
}
#endif
- GetLocationBar()->GetLocationEntry()->model()->popup_model()->AddObserver(
- this);
+ GetLocationBar()->GetOmniboxView()->model()->popup_model()->AddObserver(this);
}
void BrowserView::LoadingAnimationCallback() {
}
void BrowserView::OnLoadCompleted() {
-#if defined(OS_WIN) && !defined(USE_AURA)
+#if defined(OS_WIN)
DCHECK(!jumplist_);
jumplist_ = new JumpList();
jumplist_->AddObserver(browser_->profile());
return static_cast<BrowserViewLayout*>(GetLayoutManager());
}
-void BrowserView::LayoutStatusBubble() {
- // In restored mode, the client area has a client edge between it and the
- // frame.
- int overlap = StatusBubbleViews::kShadowThickness;
- // The extra pixels defined by kClientEdgeThickness is only drawn in frame
- // content border on windows for non-aura build.
-#if !defined(USE_ASH)
- overlap +=
- IsMaximized() ? 0 : views::NonClientFrameView::kClientEdgeThickness;
-#endif
- int height = status_bubble_->GetPreferredSize().height();
- int contents_height = status_bubble_->base_view()->bounds().height();
- gfx::Point origin(-overlap, contents_height - height + overlap);
- status_bubble_->SetBounds(origin.x(), origin.y(), width() / 3, height);
+ContentsLayoutManager* BrowserView::GetContentsLayoutManager() const {
+ return static_cast<ContentsLayoutManager*>(
+ contents_container_->GetLayoutManager());
}
bool BrowserView::MaybeShowBookmarkBar(WebContents* contents) {
return true;
}
-void BrowserView::UpdateDevToolsForContents(WebContents* web_contents) {
+void BrowserView::UpdateDevToolsForContents(
+ WebContents* web_contents, bool update_devtools_web_contents) {
DevToolsWindow* new_devtools_window = web_contents ?
DevToolsWindow::GetDockedInstanceForInspectedTab(web_contents) : NULL;
- // Fast return in case of the same window having same orientation.
- if (devtools_window_ == new_devtools_window) {
- if (!new_devtools_window ||
- (new_devtools_window->dock_side() == devtools_dock_side_)) {
- return;
- }
- }
-
- // Replace tab contents.
- if (devtools_window_ != new_devtools_window) {
- devtools_container_->SetWebContents(
- new_devtools_window ? new_devtools_window->web_contents() : NULL);
- }
-
- // Store last used position.
- if (devtools_window_) {
- int split_size = contents_split_->GetDividerSize();
- if (devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_RIGHT) {
- devtools_window_->SetWidth(contents_split_->width() -
- split_size - contents_split_->divider_offset());
- } else if (devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_BOTTOM) {
- devtools_window_->SetHeight(contents_split_->height() -
- split_size - contents_split_->divider_offset());
- }
- }
-
- // 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);
-
- if (should_hide)
- HideDevToolsContainer();
-
- devtools_window_ = new_devtools_window;
- if (should_show) {
- devtools_dock_side_ = new_devtools_window->dock_side();
- ShowDevToolsContainer();
- } else if (new_devtools_window) {
- UpdateDevToolsSplitPosition();
- contents_split_->Layout();
+ // Replace devtools WebContents.
+ WebContents* new_contents = new_devtools_window ?
+ new_devtools_window->web_contents() : NULL;
+ if (devtools_web_view_->web_contents() != new_contents &&
+ update_devtools_web_contents) {
+ devtools_web_view_->SetWebContents(new_contents);
}
-}
-void BrowserView::ShowDevToolsContainer() {
- if (!devtools_focus_tracker_.get()) {
+ if (!devtools_window_ && new_devtools_window &&
+ !devtools_focus_tracker_.get()) {
// Install devtools focus tracker when dev tools window is shown for the
// first time.
devtools_focus_tracker_.reset(
- new views::ExternalFocusTracker(devtools_container_,
+ new views::ExternalFocusTracker(devtools_web_view_,
GetFocusManager()));
}
- gfx::Size min_devtools_size(devtools_window_->GetMinimumWidth(),
- devtools_window_->GetMinimumHeight());
- devtools_container_->SetPreferredSize(min_devtools_size);
-
- devtools_container_->SetVisible(true);
- devtools_dock_side_ = devtools_window_->dock_side();
- bool dock_to_right = devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_RIGHT;
- contents_split_->set_orientation(
- dock_to_right ? views::SingleSplitView::HORIZONTAL_SPLIT
- : views::SingleSplitView::VERTICAL_SPLIT);
- UpdateDevToolsSplitPosition();
- contents_split_->InvalidateLayout();
- Layout();
-}
-
-void BrowserView::HideDevToolsContainer() {
// Restore focus to the last focused view when hiding devtools window.
- devtools_focus_tracker_->FocusLastFocusedExternalView();
- devtools_container_->SetVisible(false);
- contents_split_->InvalidateLayout();
- Layout();
-}
+ if (devtools_window_ && !new_devtools_window &&
+ devtools_focus_tracker_.get()) {
+ devtools_focus_tracker_->FocusLastFocusedExternalView();
+ devtools_focus_tracker_.reset();
+ }
-void BrowserView::UpdateDevToolsSplitPosition() {
- contents_split_->set_resize_disabled(
- devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_MINIMIZED);
- int split_size = contents_split_->GetDividerSize();
- if (devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_RIGHT) {
- int split_offset = contents_split_->width() - split_size -
- devtools_window_->GetWidth(contents_split_->width());
- contents_split_->set_divider_offset(split_offset);
+ devtools_window_ = new_devtools_window;
+ if (devtools_window_) {
+ devtools_web_view_->SetPreferredSize(devtools_window_->GetMinimumSize());
+ devtools_web_view_->SetVisible(true);
+ GetContentsLayoutManager()->SetContentsResizingStrategy(
+ devtools_window_->GetContentsResizingStrategy());
} else {
- int height = devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_MINIMIZED ?
- devtools_window_->GetMinimizedHeight() :
- devtools_window_->GetHeight(contents_split_->height());
- int split_offset = contents_split_->height() - split_size - height;
- contents_split_->set_divider_offset(split_offset);
+ devtools_web_view_->SetVisible(false);
+ GetContentsLayoutManager()->SetContentsResizingStrategy(
+ DevToolsContentsResizingStrategy());
}
+ contents_container_->Layout();
}
void BrowserView::UpdateUIForContents(WebContents* contents) {
// * Ignoring all intervening Layout() calls, which resize the webpage and
// thus are slow and look ugly (enforced via |in_process_fullscreen_|).
LocationBarView* location_bar = GetLocationBarView();
-#if defined(OS_WIN) && !defined(USE_AURA)
- OmniboxViewWin* omnibox_win =
- GetOmniboxViewWin(location_bar->GetLocationEntry());
-#endif
if (type == FOR_METRO || !fullscreen) {
// Hide the fullscreen bubble as soon as possible, since the mode toggle can
// Look for focus in the location bar itself or any child view.
if (location_bar->Contains(focus_manager->GetFocusedView()))
focus_manager->ClearFocus();
-
-#if defined(OS_WIN) && !defined(USE_AURA)
- if (omnibox_win) {
- // If we don't hide the edit and force it to not show until we come out of
- // fullscreen, then if the user was on the New Tab Page, the edit contents
- // will appear atop the web contents once we go into fullscreen mode. This
- // has something to do with how we move the main window while it's hidden;
- // if we don't hide the main window below, we don't get this problem.
- omnibox_win->set_force_hidden(true);
- ShowWindow(omnibox_win->m_hWnd, SW_HIDE);
- }
-#endif
}
#if defined(OS_WIN) && !defined(USE_AURA)
views::ScopedFullscreenVisibility visibility(frame_->GetNativeView());
browser_->WindowFullscreenStateChanged();
- if (fullscreen) {
- if (!chrome::IsRunningInAppMode() && type != FOR_METRO)
- UpdateFullscreenExitBubbleContent(url, bubble_type);
- } else {
-#if defined(OS_WIN) && !defined(USE_AURA)
- if (omnibox_win) {
- // Show the edit again since we're no longer in fullscreen mode.
- omnibox_win->set_force_hidden(false);
- ShowWindow(omnibox_win->m_hWnd, SW_SHOW);
- }
-#endif
- }
+ if (fullscreen && !chrome::IsRunningInAppMode() && type != FOR_METRO)
+ UpdateFullscreenExitBubbleContent(url, bubble_type);
// Undo our anti-jankiness hacks and force a re-layout. We also need to
// recompute the height of the infobar top arrow because toggling in and out
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode))
return false;
bool is_browser_fullscreen = url.is_empty();
- return is_browser_fullscreen && IsBrowserTypeNormal();
+ if (ash::switches::UseImmersiveFullscreenForAllWindows())
+ return is_browser_fullscreen;
+ else
+ return is_browser_fullscreen && IsBrowserTypeNormal();
#else
return false;
#endif
}
void BrowserView::LoadAccelerators() {
-#if defined(OS_WIN) && !defined(USE_AURA)
- HACCEL accelerator_table = AtlLoadAccelerators(IDR_MAINFRAME);
- DCHECK(accelerator_table);
-
- // We have to copy the table to access its contents.
- int count = CopyAcceleratorTable(accelerator_table, 0, 0);
- if (count == 0) {
- // Nothing to do in that case.
- return;
- }
-
- ACCEL* accelerators = static_cast<ACCEL*>(malloc(sizeof(ACCEL) * count));
- CopyAcceleratorTable(accelerator_table, accelerators, count);
-
- views::FocusManager* focus_manager = GetFocusManager();
- DCHECK(focus_manager);
-
- // Let's fill our own accelerator table.
- for (int i = 0; i < count; ++i) {
- ui::Accelerator accelerator(
- static_cast<ui::KeyboardCode>(accelerators[i].key),
- ui::GetModifiersFromACCEL(accelerators[i]));
- accelerator_table_[accelerator] = accelerators[i].cmd;
-
- // Also register with the focus manager.
- focus_manager->RegisterAccelerator(
- accelerator, ui::AcceleratorManager::kNormalPriority, this);
- }
-
- // We don't need the Windows accelerator table anymore.
- free(accelerators);
-#else
views::FocusManager* focus_manager = GetFocusManager();
DCHECK(focus_manager);
focus_manager->RegisterAccelerator(
accelerator, ui::AcceleratorManager::kNormalPriority, this);
}
-#endif
}
int BrowserView::GetCommandIDForAppCommandID(int app_command_id) const {
}
void BrowserView::InitHangMonitor() {
-#if defined(OS_WIN) && !defined(USE_AURA)
+#if defined(OS_WIN)
PrefService* pref_service = g_browser_process->local_state();
if (!pref_service)
return;
pref_service->GetInteger(prefs::kPluginMessageResponseTimeout);
int hung_plugin_detect_freq =
pref_service->GetInteger(prefs::kHungPluginDetectFrequency);
+#if defined(USE_AURA)
+ HWND window = GetWidget()->GetNativeView()->GetDispatcher()->host()->
+ GetAcceleratedWidget();
+#else
+ HWND window = GetWidget()->GetNativeView();
+#endif
if ((hung_plugin_detect_freq > 0) &&
- hung_window_detector_.Initialize(GetWidget()->GetNativeView(),
+ hung_window_detector_.Initialize(window,
plugin_message_response_timeout)) {
ticker_.set_tick_interval(hung_plugin_detect_freq);
ticker_.RegisterTickHandler(&hung_window_detector_);
return view;
}
+// static
+chrome::HostDesktopType BrowserWindow::AdjustHostDesktopType(
+ chrome::HostDesktopType desktop_type) {
+ return NativeBrowserFrameFactory::AdjustHostDesktopType(desktop_type);
+}
+
void BrowserView::ShowAvatarBubble(WebContents* web_contents,
const gfx::Rect& rect) {
gfx::Point origin(rect.origin());
}
void BrowserView::ShowAvatarBubbleFromAvatarButton() {
- AvatarMenuButton* button = frame_->GetAvatarMenuButton();
- if (button)
- button->ShowAvatarBubble();
+ if (switches::IsNewProfileManagement()) {
+ NewAvatarButton* button = frame_->GetNewAvatarMenuButton();
+ if (button) {
+ gfx::Point origin;
+ views::View::ConvertPointToScreen(button, &origin);
+ gfx::Rect bounds(origin, size());
+
+ ProfileChooserView::ShowBubble(
+ button, views::BubbleBorder::TOP_RIGHT,
+ views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, bounds, browser());
+ }
+ } else {
+ AvatarMenuButton* button = frame_->GetAvatarMenuButton();
+ if (button)
+ button->ShowAvatarBubble();
+ }
}
void BrowserView::ShowPasswordGenerationBubble(
if (!web_contents)
return;
- PasswordGenerationBubbleView* bubble =
- new PasswordGenerationBubbleView(
- form,
- bounds,
- this,
- web_contents->GetRenderViewHost(),
- PasswordManager::FromWebContents(web_contents),
- password_generator,
- browser_.get(),
- GetWidget()->GetThemeProvider());
+ PasswordGenerationBubbleView* bubble = new PasswordGenerationBubbleView(
+ form,
+ bounds,
+ this,
+ web_contents->GetRenderViewHost(),
+ ChromePasswordManagerClient::GetManagerFromWebContents(web_contents),
+ password_generator,
+ browser_.get(),
+ GetWidget()->GetThemeProvider());
views::BubbleDelegateView::CreateBubble(bubble);
bubble->SetAlignment(views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR);
}
void BrowserView::DoCutCopyPaste(void (content::RenderWidgetHost::*method)(),
-#if defined(OS_WIN)
- int windows_msg_id,
-#endif
int command_id) {
WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents();
if (!contents)
!strcmp(focused->GetClassName(), OmniboxViewViews::kViewClassName))) {
views::Textfield* textfield = static_cast<views::Textfield*>(focused);
textfield->ExecuteCommand(command_id);
- return;
}
-
-#if defined(OS_WIN) && !defined(USE_AURA)
- OmniboxView* omnibox_view = GetLocationBarView()->GetLocationEntry();
- if (omnibox_view->model()->has_focus()) {
- OmniboxViewWin* omnibox_win = GetOmniboxViewWin(omnibox_view);
- ::SendMessage(omnibox_win->GetNativeView(), windows_msg_id, 0, 0);
- }
-#endif
}
bool BrowserView::DoCutCopyPasteForWebContents(
// Only show the arrows when not in fullscreen and when there's no omnibox
// popup.
if (!IsFullscreen() &&
- !GetLocationBar()->GetLocationEntry()->model()->popup_model()->IsOpen()) {
- const LocationIconView* location_icon_view =
- toolbar_->location_bar()->location_icon_view();
- // The +1 in the next line creates a 1-px gap between icon and arrow tip.
- gfx::Point icon_bottom(0, location_icon_view->GetImageBounds().bottom() -
- LocationBarView::kIconInternalPadding + 1);
- ConvertPointToTarget(location_icon_view, this, &icon_bottom);
+ !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) {
+ gfx::Point icon_bottom(
+ toolbar_->location_bar()->GetLocationBarAnchorPoint());
+ ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom);
gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL));
ConvertPointToTarget(infobar_container_, this, &infobar_top);
top_arrow_height = infobar_top.y() - icon_bottom.y();