| OLD | NEW |
| 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/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #endif // OS_WIN | 10 #endif // OS_WIN |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 browser::NavigateParams params(browser, extension_url, | 762 browser::NavigateParams params(browser, extension_url, |
| 763 content::PAGE_TRANSITION_START_PAGE); | 763 content::PAGE_TRANSITION_START_PAGE); |
| 764 params.tabstrip_add_types = add_type; | 764 params.tabstrip_add_types = add_type; |
| 765 params.disposition = disposition; | 765 params.disposition = disposition; |
| 766 | 766 |
| 767 if (disposition == CURRENT_TAB) { | 767 if (disposition == CURRENT_TAB) { |
| 768 TabContents* existing_tab = browser->GetSelectedTabContents(); | 768 TabContents* existing_tab = browser->GetSelectedTabContents(); |
| 769 TabStripModel* model = browser->tabstrip_model(); | 769 TabStripModel* model = browser->tabstrip_model(); |
| 770 int tab_index = model->GetWrapperIndex(existing_tab); | 770 int tab_index = model->GetWrapperIndex(existing_tab); |
| 771 | 771 |
| 772 existing_tab->OpenURL(extension_url, existing_tab->GetURL(), | 772 existing_tab->OpenURL(OpenURLParams( |
| 773 disposition, content::PAGE_TRANSITION_LINK); | 773 extension_url, |
| 774 content::Referrer(existing_tab->GetURL(), |
| 775 WebKit::WebReferrerPolicyDefault), |
| 776 disposition, content::PAGE_TRANSITION_LINK, false)); |
| 774 if (params.tabstrip_add_types & TabStripModel::ADD_PINNED) { | 777 if (params.tabstrip_add_types & TabStripModel::ADD_PINNED) { |
| 775 model->SetTabPinned(tab_index, true); | 778 model->SetTabPinned(tab_index, true); |
| 776 tab_index = model->GetWrapperIndex(existing_tab); | 779 tab_index = model->GetWrapperIndex(existing_tab); |
| 777 } | 780 } |
| 778 if (params.tabstrip_add_types & TabStripModel::ADD_ACTIVE) | 781 if (params.tabstrip_add_types & TabStripModel::ADD_ACTIVE) |
| 779 model->ActivateTabAt(tab_index, true); | 782 model->ActivateTabAt(tab_index, true); |
| 780 | 783 |
| 781 contents = existing_tab; | 784 contents = existing_tab; |
| 782 } else { | 785 } else { |
| 783 browser::Navigate(¶ms); | 786 browser::Navigate(¶ms); |
| (...skipping 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2960 } | 2963 } |
| 2961 | 2964 |
| 2962 /////////////////////////////////////////////////////////////////////////////// | 2965 /////////////////////////////////////////////////////////////////////////////// |
| 2963 // Browser, PageNavigator implementation: | 2966 // Browser, PageNavigator implementation: |
| 2964 | 2967 |
| 2965 // TODO(adriansc): Remove this method once refactoring changed all call sites. | 2968 // TODO(adriansc): Remove this method once refactoring changed all call sites. |
| 2966 TabContents* Browser::OpenURL(const GURL& url, | 2969 TabContents* Browser::OpenURL(const GURL& url, |
| 2967 const GURL& referrer, | 2970 const GURL& referrer, |
| 2968 WindowOpenDisposition disposition, | 2971 WindowOpenDisposition disposition, |
| 2969 content::PageTransition transition) { | 2972 content::PageTransition transition) { |
| 2970 return OpenURLFromTab(NULL, | 2973 // For specifying a referrer, use the version of OpenURL taking OpenURLParams. |
| 2971 OpenURLParams(url, referrer, disposition, transition, | 2974 DCHECK(referrer.is_empty()); |
| 2972 false)); | 2975 return OpenURLFromTab(NULL, OpenURLParams( |
| 2976 url, content::Referrer(), disposition, transition, false)); |
| 2973 } | 2977 } |
| 2974 | 2978 |
| 2975 TabContents* Browser::OpenURL(const OpenURLParams& params) { | 2979 TabContents* Browser::OpenURL(const OpenURLParams& params) { |
| 2976 return OpenURLFromTab(NULL, params); | 2980 return OpenURLFromTab(NULL, params); |
| 2977 } | 2981 } |
| 2978 | 2982 |
| 2979 /////////////////////////////////////////////////////////////////////////////// | 2983 /////////////////////////////////////////////////////////////////////////////// |
| 2980 // Browser, CommandUpdater::CommandUpdaterDelegate implementation: | 2984 // Browser, CommandUpdater::CommandUpdaterDelegate implementation: |
| 2981 | 2985 |
| 2982 void Browser::ExecuteCommand(int id) { | 2986 void Browser::ExecuteCommand(int id) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3039 browser->LoadingStateChanged(detached_contents->tab_contents()); | 3043 browser->LoadingStateChanged(detached_contents->tab_contents()); |
| 3040 return browser; | 3044 return browser; |
| 3041 } | 3045 } |
| 3042 | 3046 |
| 3043 int Browser::GetDragActions() const { | 3047 int Browser::GetDragActions() const { |
| 3044 return TabStripModelDelegate::TAB_TEAROFF_ACTION | (tab_count() > 1 ? | 3048 return TabStripModelDelegate::TAB_TEAROFF_ACTION | (tab_count() > 1 ? |
| 3045 TabStripModelDelegate::TAB_MOVE_ACTION : 0); | 3049 TabStripModelDelegate::TAB_MOVE_ACTION : 0); |
| 3046 } | 3050 } |
| 3047 | 3051 |
| 3048 TabContentsWrapper* Browser::CreateTabContentsForURL( | 3052 TabContentsWrapper* Browser::CreateTabContentsForURL( |
| 3049 const GURL& url, const GURL& referrer, Profile* profile, | 3053 const GURL& url, const content::Referrer& referrer, Profile* profile, |
| 3050 content::PageTransition transition, bool defer_load, | 3054 content::PageTransition transition, bool defer_load, |
| 3051 SiteInstance* instance) const { | 3055 SiteInstance* instance) const { |
| 3052 TabContentsWrapper* contents = TabContentsFactory(profile, instance, | 3056 TabContentsWrapper* contents = TabContentsFactory(profile, instance, |
| 3053 MSG_ROUTING_NONE, | 3057 MSG_ROUTING_NONE, |
| 3054 GetSelectedTabContents(), NULL); | 3058 GetSelectedTabContents(), NULL); |
| 3055 if (!defer_load) { | 3059 if (!defer_load) { |
| 3056 // Load the initial URL before adding the new tab contents to the tab strip | 3060 // Load the initial URL before adding the new tab contents to the tab strip |
| 3057 // so that the tab contents has navigation state. | 3061 // so that the tab contents has navigation state. |
| 3058 contents->controller().LoadURL(url, referrer, transition, std::string()); | 3062 contents->controller().LoadURL(url, referrer, transition, std::string()); |
| 3059 } | 3063 } |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3367 // still present. | 3371 // still present. |
| 3368 // NOTE: If you change to be immediate (no invokeLater) then you'll need to | 3372 // NOTE: If you change to be immediate (no invokeLater) then you'll need to |
| 3369 // update BrowserList::CloseAllBrowsers. | 3373 // update BrowserList::CloseAllBrowsers. |
| 3370 MessageLoop::current()->PostTask( | 3374 MessageLoop::current()->PostTask( |
| 3371 FROM_HERE, base::Bind(&Browser::CloseFrame, weak_factory_.GetWeakPtr())); | 3375 FROM_HERE, base::Bind(&Browser::CloseFrame, weak_factory_.GetWeakPtr())); |
| 3372 } | 3376 } |
| 3373 | 3377 |
| 3374 /////////////////////////////////////////////////////////////////////////////// | 3378 /////////////////////////////////////////////////////////////////////////////// |
| 3375 // Browser, TabContentsDelegate implementation: | 3379 // Browser, TabContentsDelegate implementation: |
| 3376 | 3380 |
| 3377 // TODO(adriansc): Remove this method once refactoring changed all call sites. | |
| 3378 TabContents* Browser::OpenURLFromTab(TabContents* source, | |
| 3379 const GURL& url, | |
| 3380 const GURL& referrer, | |
| 3381 WindowOpenDisposition disposition, | |
| 3382 content::PageTransition transition) { | |
| 3383 return OpenURLFromTab(source, OpenURLParams(url, referrer, disposition, | |
| 3384 transition, false)); | |
| 3385 } | |
| 3386 | |
| 3387 TabContents* Browser::OpenURLFromTab(TabContents* source, | 3381 TabContents* Browser::OpenURLFromTab(TabContents* source, |
| 3388 const OpenURLParams& params) { | 3382 const OpenURLParams& params) { |
| 3389 browser::NavigateParams nav_params(this, params.url, params.transition); | 3383 browser::NavigateParams nav_params(this, params.url, params.transition); |
| 3390 nav_params.source_contents = | 3384 nav_params.source_contents = |
| 3391 tabstrip_model()->GetTabContentsAt( | 3385 tabstrip_model()->GetTabContentsAt( |
| 3392 tabstrip_model()->GetWrapperIndex(source)); | 3386 tabstrip_model()->GetWrapperIndex(source)); |
| 3393 nav_params.referrer = params.referrer; | 3387 nav_params.referrer = params.referrer; |
| 3394 nav_params.disposition = params.disposition; | 3388 nav_params.disposition = params.disposition; |
| 3395 nav_params.tabstrip_add_types = TabStripModel::ADD_NONE; | 3389 nav_params.tabstrip_add_types = TabStripModel::ADD_NONE; |
| 3396 nav_params.window_action = browser::NavigateParams::SHOW_WINDOW; | 3390 nav_params.window_action = browser::NavigateParams::SHOW_WINDOW; |
| (...skipping 1929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5326 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); | 5320 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); |
| 5327 } else { | 5321 } else { |
| 5328 GlobalErrorService* service = | 5322 GlobalErrorService* service = |
| 5329 GlobalErrorServiceFactory::GetForProfile(profile()); | 5323 GlobalErrorServiceFactory::GetForProfile(profile()); |
| 5330 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); | 5324 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); |
| 5331 if (error) { | 5325 if (error) { |
| 5332 error->ShowBubbleView(this); | 5326 error->ShowBubbleView(this); |
| 5333 } | 5327 } |
| 5334 } | 5328 } |
| 5335 } | 5329 } |
| OLD | NEW |