X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fchrome%2Fbrowser%2Fui%2Fviews%2Fframe%2Fbrowser_view.cc;h=eaef4edd0f56998b9d6db46fbf143f72794bc27f;hb=ff3e2503a20db9193d323c1d19c38c68004dec4a;hp=543e6cb1ac5a7345b7d4980a83a3fc59f49a26c0;hpb=d1e23c6ec4202b125fc446349b2230d4cd978d86;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/chrome/browser/ui/views/frame/browser_view.cc b/src/chrome/browser/ui/views/frame/browser_view.cc index 543e6cb..eaef4ed 100644 --- a/src/chrome/browser/ui/views/frame/browser_view.cc +++ b/src/chrome/browser/ui/views/frame/browser_view.cc @@ -22,6 +22,7 @@ #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" @@ -66,6 +67,7 @@ #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" @@ -87,7 +89,9 @@ #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" @@ -148,7 +152,6 @@ #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 @@ -437,6 +440,10 @@ BrowserView::BrowserView() } 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(); @@ -477,16 +484,6 @@ BrowserView::~BrowserView() { 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 contents; - while (browser_->tab_strip_model()->count()) - contents.push_back(browser_->tab_strip_model()->DetachWebContentsAt(0)); - } - // Explicitly set browser_ to NULL. browser_.reset(); } @@ -515,6 +512,11 @@ void BrowserView::InitStatusBubble() { 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()) @@ -844,6 +846,15 @@ void BrowserView::OnActiveTabChanged(content::WebContents* old_contents, } 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(), @@ -968,12 +979,7 @@ void BrowserView::SetMetroSnapMode(bool enable) { } bool BrowserView::IsInMetroSnapMode() const { -#if defined(USE_AURA) return false; -#else - return static_cast( - frame_->native_widget())->IsInMetroSnapMode(); -#endif } #endif // defined(OS_WIN) @@ -1057,7 +1063,12 @@ void BrowserView::SetFocusToLocationBar(bool select_all) { 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); @@ -1198,21 +1209,30 @@ void BrowserView::ShowBookmarkBubble(const GURL& url, bool already_bookmarked) { !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) @@ -1455,6 +1475,9 @@ ToolbarView* BrowserView::GetToolbarView() const { // 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. @@ -1469,6 +1492,9 @@ void BrowserView::TabDetachedAt(WebContents* contents, int index) { } 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. @@ -1947,8 +1973,6 @@ void BrowserView::InitViews() { 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); @@ -1966,6 +1990,9 @@ void BrowserView::InitViews() { 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(); @@ -2143,11 +2170,12 @@ void BrowserView::UpdateDevToolsForContents( 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(); } @@ -2444,16 +2472,15 @@ 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);