#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/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_layout_manager.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"
#if defined(OS_WIN)
#include "base/win/windows_version.h"
#include "chrome/browser/jumplist_win.h"
-#include "ui/views/widget/native_widget_win.h"
#include "ui/views/win/scoped_fullscreen_visibility.h"
#include "win8/util/win8_util.h"
#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();
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();
}
contents_web_view_->SetStatusBubble(status_bubble_.get());
}
+void BrowserView::InitPermissionBubbleView() {
+ permission_bubble_view_.reset(new PermissionBubbleViewViews(
+ GetLocationBarView()->GetLocationIconView()));
+}
+
gfx::Rect BrowserView::GetToolbarBounds() const {
gfx::Rect toolbar_bounds(toolbar_->bounds());
if (toolbar_bounds.IsEmpty())
}
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(),
}
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)
LocationBarView* location_bar = GetLocationBarView();
if (location_bar->omnibox_view()->IsFocusable()) {
// Location bar got focus.
- if (chrome::ShouldDisplayOriginChip())
+ //
+ // 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);
!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,
- TranslateErrors::Type error_type) {
+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->GetLanguageState();
language_state.SetTranslateEnabled(true);
- TranslateBubbleView::ShowBubble(GetToolbarView()->GetTranslateBubbleAnchor(),
- web_contents, view_state, error_type);
+ TranslateBubbleView::ShowBubble(
+ GetToolbarView()->GetTranslateBubbleAnchor(), web_contents, step,
+ error_type);
}
#if defined(ENABLE_ONE_CLICK_SIGNIN)
// 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.
}
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.
AddChildView(contents_container_);
set_contents_view(contents_container_);
- InitStatusBubble();
-
// Top container holds tab strip and toolbar and lives at the front of the
// view hierarchy.
top_container_ = new TopContainerView(this);
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 (devtools_window_) {
devtools_web_view_->SetPreferredSize(devtools_window_->GetMinimumSize());
devtools_web_view_->SetVisible(true);
- GetContentsLayoutManager()->SetContentsViewInsets(
- devtools_window_->GetContentsInsets());
+ GetContentsLayoutManager()->SetContentsResizingStrategy(
+ devtools_window_->GetContentsResizingStrategy());
} else {
devtools_web_view_->SetVisible(false);
- GetContentsLayoutManager()->SetContentsViewInsets(gfx::Insets());
+ GetContentsLayoutManager()->SetContentsResizingStrategy(
+ DevToolsContentsResizingStrategy());
}
contents_container_->Layout();
}
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);