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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 8068020: Converts usage of GetBrowserViewForNativeWindow to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporate review feedback, and make ShowPageInfo platform specific Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/frame/browser_view.h" 5 #include "chrome/browser/ui/views/frame/browser_view.h"
6 6
7 #if defined(TOOLKIT_USES_GTK) 7 #if defined(TOOLKIT_USES_GTK)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" 21 #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
22 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" 22 #include "chrome/browser/autocomplete/autocomplete_popup_view.h"
23 #include "chrome/browser/automation/ui_controls.h" 23 #include "chrome/browser/automation/ui_controls.h"
24 #include "chrome/browser/bookmarks/bookmark_utils.h" 24 #include "chrome/browser/bookmarks/bookmark_utils.h"
25 #include "chrome/browser/browser_process.h" 25 #include "chrome/browser/browser_process.h"
26 #include "chrome/browser/debugger/devtools_window.h" 26 #include "chrome/browser/debugger/devtools_window.h"
27 #include "chrome/browser/extensions/extension_tab_helper.h" 27 #include "chrome/browser/extensions/extension_tab_helper.h"
28 #include "chrome/browser/extensions/extension_tts_api.h" 28 #include "chrome/browser/extensions/extension_tts_api.h"
29 #include "chrome/browser/instant/instant_controller.h" 29 #include "chrome/browser/instant/instant_controller.h"
30 #include "chrome/browser/ntp_background_util.h" 30 #include "chrome/browser/ntp_background_util.h"
31 #include "chrome/browser/page_info_window.h"
32 #include "chrome/browser/prefs/pref_service.h" 31 #include "chrome/browser/prefs/pref_service.h"
33 #include "chrome/browser/profiles/profile.h" 32 #include "chrome/browser/profiles/profile.h"
34 #include "chrome/browser/profiles/profile_info_cache.h" 33 #include "chrome/browser/profiles/profile_info_cache.h"
35 #include "chrome/browser/profiles/profile_manager.h" 34 #include "chrome/browser/profiles/profile_manager.h"
36 #include "chrome/browser/sessions/tab_restore_service.h" 35 #include "chrome/browser/sessions/tab_restore_service.h"
37 #include "chrome/browser/sessions/tab_restore_service_factory.h" 36 #include "chrome/browser/sessions/tab_restore_service_factory.h"
38 #include "chrome/browser/sidebar/sidebar_container.h" 37 #include "chrome/browser/sidebar/sidebar_container.h"
39 #include "chrome/browser/sidebar/sidebar_manager.h" 38 #include "chrome/browser/sidebar/sidebar_manager.h"
40 #include "chrome/browser/tabs/tab_strip_model.h" 39 #include "chrome/browser/tabs/tab_strip_model.h"
41 #include "chrome/browser/themes/theme_service.h" 40 #include "chrome/browser/themes/theme_service.h"
42 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" 41 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
43 #include "chrome/browser/ui/browser.h" 42 #include "chrome/browser/ui/browser.h"
44 #include "chrome/browser/ui/browser_dialogs.h" 43 #include "chrome/browser/ui/browser_dialogs.h"
45 #include "chrome/browser/ui/browser_list.h" 44 #include "chrome/browser/ui/browser_list.h"
46 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 45 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
47 #include "chrome/browser/ui/tabs/tab_menu_model.h" 46 #include "chrome/browser/ui/tabs/tab_menu_model.h"
48 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" 47 #include "chrome/browser/ui/toolbar/wrench_menu_model.h"
49 #include "chrome/browser/ui/view_ids.h" 48 #include "chrome/browser/ui/view_ids.h"
50 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 49 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
51 #include "chrome/browser/ui/views/browser_dialogs.h" 50 #include "chrome/browser/ui/views/browser_dialogs.h"
52 #include "chrome/browser/ui/views/default_search_view.h" 51 #include "chrome/browser/ui/views/default_search_view.h"
53 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" 52 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h"
54 #include "chrome/browser/ui/views/frame/browser_view_layout.h" 53 #include "chrome/browser/ui/views/frame/browser_view_layout.h"
55 #include "chrome/browser/ui/views/frame/contents_container.h" 54 #include "chrome/browser/ui/views/frame/contents_container.h"
56 #include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h" 55 #include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h"
57 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" 56 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
58 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" 57 #include "chrome/browser/ui/views/location_bar/location_icon_view.h"
58 #include "chrome/browser/ui/views/page_info_window.h"
59 #include "chrome/browser/ui/views/status_bubble_views.h" 59 #include "chrome/browser/ui/views/status_bubble_views.h"
60 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" 60 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h"
61 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" 61 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h"
62 #include "chrome/browser/ui/views/tabs/tab_strip_factory.h" 62 #include "chrome/browser/ui/views/tabs/tab_strip_factory.h"
63 #include "chrome/browser/ui/views/theme_install_bubble_view.h" 63 #include "chrome/browser/ui/views/theme_install_bubble_view.h"
64 #include "chrome/browser/ui/views/toolbar_view.h" 64 #include "chrome/browser/ui/views/toolbar_view.h"
65 #include "chrome/browser/ui/views/update_recommended_message_box.h" 65 #include "chrome/browser/ui/views/update_recommended_message_box.h"
66 #include "chrome/browser/ui/views/window.h" 66 #include "chrome/browser/ui/views/window.h"
67 #include "chrome/browser/ui/webui/bug_report_ui.h" 67 #include "chrome/browser/ui/webui/bug_report_ui.h"
68 #include "chrome/browser/ui/webui/task_manager_dialog.h" 68 #include "chrome/browser/ui/webui/task_manager_dialog.h"
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 delete tabstrip_; 376 delete tabstrip_;
377 tabstrip_ = NULL; 377 tabstrip_ = NULL;
378 } 378 }
379 // Child views maintain PrefMember attributes that point to 379 // Child views maintain PrefMember attributes that point to
380 // OffTheRecordProfile's PrefService which gets deleted by ~Browser. 380 // OffTheRecordProfile's PrefService which gets deleted by ~Browser.
381 RemoveAllChildViews(true); 381 RemoveAllChildViews(true);
382 // Explicitly set browser_ to NULL. 382 // Explicitly set browser_ to NULL.
383 browser_.reset(); 383 browser_.reset();
384 } 384 }
385 385
386 // Tab dragging code on windows needs this.
387 #if defined(OS_WIN) && !defined(USE_AURA)
386 // static 388 // static
387 BrowserView* BrowserView::GetBrowserViewForNativeWindow( 389 BrowserView* BrowserView::GetBrowserViewForNativeWindow(
388 gfx::NativeWindow window) { 390 gfx::NativeWindow window) {
389 #if defined(USE_AURA) 391 return IsWindow(window) ? reinterpret_cast<BrowserView*>(
390 // TODO(beng): 392 ui::ViewProp::GetValue(window, kBrowserViewKey)) : NULL;
391 NOTIMPLEMENTED(); 393 }
392 #elif defined(OS_WIN) 394 #endif
393 if (IsWindow(window)) {
394 return reinterpret_cast<BrowserView*>(
395 ui::ViewProp::GetValue(window, kBrowserViewKey));
396 }
397 #else
398 BrowserView* browser_view = NULL;
399 if (window) {
400 browser_view = static_cast<BrowserView*>(
401 g_object_get_data(G_OBJECT(window), kBrowserViewKey));
402 395
403 #if defined(TOUCH_UI) 396 // static
404 if (!browser_view) { 397 BrowserView* BrowserView::GetBrowserViewForBrowser(Browser* browser) {
405 // With views-desktop, we cannot determine the BrowserView from the 398 return static_cast<BrowserView*>(browser->window());
406 // NativeWindow. So do the next best thing, and assume the last active
407 // BrowserView is what we want.
408 Browser* browser = BrowserList::GetLastActive();
409 if (browser && !browser->is_type_popup() && !browser->is_type_panel())
410 browser_view = reinterpret_cast<BrowserView*>(browser->window());
411 }
412 #endif
413 }
414 return browser_view;
415 #endif
416 return NULL;
417 } 399 }
418 400
419 gfx::Rect BrowserView::GetToolbarBounds() const { 401 gfx::Rect BrowserView::GetToolbarBounds() const {
420 gfx::Rect toolbar_bounds(toolbar_->bounds()); 402 gfx::Rect toolbar_bounds(toolbar_->bounds());
421 if (toolbar_bounds.IsEmpty()) 403 if (toolbar_bounds.IsEmpty())
422 return toolbar_bounds; 404 return toolbar_bounds;
423 // When using vertical tabs, the toolbar appears to extend behind the tab 405 // When using vertical tabs, the toolbar appears to extend behind the tab
424 // column. 406 // column.
425 if (UseVerticalTabs()) 407 if (UseVerticalTabs())
426 toolbar_bounds.Inset(tabstrip_->x() - toolbar_bounds.x(), 0, 0, 0); 408 toolbar_bounds.Inset(tabstrip_->x() - toolbar_bounds.x(), 0, 0, 0);
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 } 1147 }
1166 1148
1167 void BrowserView::TabContentsFocused(TabContents* tab_contents) { 1149 void BrowserView::TabContentsFocused(TabContents* tab_contents) {
1168 contents_container_->TabContentsFocused(tab_contents); 1150 contents_container_->TabContentsFocused(tab_contents);
1169 } 1151 }
1170 1152
1171 void BrowserView::ShowPageInfo(Profile* profile, 1153 void BrowserView::ShowPageInfo(Profile* profile,
1172 const GURL& url, 1154 const GURL& url,
1173 const NavigationEntry::SSLStatus& ssl, 1155 const NavigationEntry::SSLStatus& ssl,
1174 bool show_history) { 1156 bool show_history) {
1175 gfx::NativeWindow parent = GetWidget()->GetNativeWindow(); 1157 browser::ShowPageInfoBubble(this, profile, url, ssl, show_history);
1176
1177 browser::ShowPageInfoBubble(parent, profile, url, ssl, show_history);
1178 } 1158 }
1179 1159
1180 void BrowserView::ShowAppMenu() { 1160 void BrowserView::ShowAppMenu() {
1181 toolbar_->app_menu()->Activate(); 1161 toolbar_->app_menu()->Activate();
1182 } 1162 }
1183 1163
1184 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, 1164 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
1185 bool* is_keyboard_shortcut) { 1165 bool* is_keyboard_shortcut) {
1186 if (event.type != WebKit::WebInputEvent::RawKeyDown) 1166 if (event.type != WebKit::WebInputEvent::RawKeyDown)
1187 return false; 1167 return false;
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after
2617 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { 2597 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
2618 // Create the view and the frame. The frame will attach itself via the view 2598 // Create the view and the frame. The frame will attach itself via the view
2619 // so we don't need to do anything with the pointer. 2599 // so we don't need to do anything with the pointer.
2620 BrowserView* view = new BrowserView(browser); 2600 BrowserView* view = new BrowserView(browser);
2621 (new BrowserFrame(view))->InitBrowserFrame(); 2601 (new BrowserFrame(view))->InitBrowserFrame();
2622 view->GetWidget()->non_client_view()->SetAccessibleName( 2602 view->GetWidget()->non_client_view()->SetAccessibleName(
2623 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 2603 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
2624 return view; 2604 return view;
2625 } 2605 }
2626 #endif 2606 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698