| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/panels/panel_host.h" | 5 #include "chrome/browser/ui/panels/panel_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 SessionTabHelper::CreateForWebContents(web_contents_.get()); | 65 SessionTabHelper::CreateForWebContents(web_contents_.get()); |
| 66 SessionTabHelper::FromWebContents(web_contents_.get())->SetWindowID( | 66 SessionTabHelper::FromWebContents(web_contents_.get())->SetWindowID( |
| 67 panel_->session_id()); | 67 panel_->session_id()); |
| 68 | 68 |
| 69 FaviconTabHelper::CreateForWebContents(web_contents_.get()); | 69 FaviconTabHelper::CreateForWebContents(web_contents_.get()); |
| 70 PrefsTabHelper::CreateForWebContents(web_contents_.get()); | 70 PrefsTabHelper::CreateForWebContents(web_contents_.get()); |
| 71 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( | 71 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( |
| 72 web_contents_.get()); | 72 web_contents_.get()); |
| 73 | 73 |
| 74 web_contents_->GetController().LoadURL( | 74 web_contents_->GetController().LoadURL( |
| 75 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); | 75 url, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void PanelHost::DestroyWebContents() { | 78 void PanelHost::DestroyWebContents() { |
| 79 // Cannot do a web_contents_.reset() because web_contents_.get() will | 79 // Cannot do a web_contents_.reset() because web_contents_.get() will |
| 80 // still return the pointer when we CHECK in WebContentsDestroyed (or if | 80 // still return the pointer when we CHECK in WebContentsDestroyed (or if |
| 81 // we get called back in the middle of web contents destruction, which | 81 // we get called back in the middle of web contents destruction, which |
| 82 // WebView might do when it detects the web contents is destroyed). | 82 // WebView might do when it detects the web contents is destroyed). |
| 83 content::WebContents* contents = web_contents_.release(); | 83 content::WebContents* contents = web_contents_.release(); |
| 84 delete contents; | 84 delete contents; |
| 85 } | 85 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 97 content::WebContents* PanelHost::OpenURLFromTab( | 97 content::WebContents* PanelHost::OpenURLFromTab( |
| 98 content::WebContents* source, | 98 content::WebContents* source, |
| 99 const content::OpenURLParams& params) { | 99 const content::OpenURLParams& params) { |
| 100 // These dispositions aren't really navigations. | 100 // These dispositions aren't really navigations. |
| 101 if (params.disposition == SUPPRESS_OPEN || | 101 if (params.disposition == SUPPRESS_OPEN || |
| 102 params.disposition == SAVE_TO_DISK || | 102 params.disposition == SAVE_TO_DISK || |
| 103 params.disposition == IGNORE_ACTION) | 103 params.disposition == IGNORE_ACTION) |
| 104 return NULL; | 104 return NULL; |
| 105 | 105 |
| 106 // Only allow clicks on links. | 106 // Only allow clicks on links. |
| 107 if (params.transition != content::PAGE_TRANSITION_LINK) | 107 if (params.transition != ui::PAGE_TRANSITION_LINK) |
| 108 return NULL; | 108 return NULL; |
| 109 | 109 |
| 110 // Force all links to open in a new tab. | 110 // Force all links to open in a new tab. |
| 111 chrome::NavigateParams navigate_params(profile_, | 111 chrome::NavigateParams navigate_params(profile_, |
| 112 params.url, | 112 params.url, |
| 113 params.transition); | 113 params.transition); |
| 114 switch (params.disposition) { | 114 switch (params.disposition) { |
| 115 case NEW_BACKGROUND_TAB: | 115 case NEW_BACKGROUND_TAB: |
| 116 case NEW_WINDOW: | 116 case NEW_WINDOW: |
| 117 case OFF_THE_RECORD: | 117 case OFF_THE_RECORD: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 135 panel_->UpdateTitleBar(); | 135 panel_->UpdateTitleBar(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void PanelHost::AddNewContents(content::WebContents* source, | 138 void PanelHost::AddNewContents(content::WebContents* source, |
| 139 content::WebContents* new_contents, | 139 content::WebContents* new_contents, |
| 140 WindowOpenDisposition disposition, | 140 WindowOpenDisposition disposition, |
| 141 const gfx::Rect& initial_pos, | 141 const gfx::Rect& initial_pos, |
| 142 bool user_gesture, | 142 bool user_gesture, |
| 143 bool* was_blocked) { | 143 bool* was_blocked) { |
| 144 chrome::NavigateParams navigate_params(profile_, new_contents->GetURL(), | 144 chrome::NavigateParams navigate_params(profile_, new_contents->GetURL(), |
| 145 content::PAGE_TRANSITION_LINK); | 145 ui::PAGE_TRANSITION_LINK); |
| 146 navigate_params.target_contents = new_contents; | 146 navigate_params.target_contents = new_contents; |
| 147 | 147 |
| 148 // Force all links to open in a new tab, even if they were trying to open a | 148 // Force all links to open in a new tab, even if they were trying to open a |
| 149 // window. | 149 // window. |
| 150 navigate_params.disposition = | 150 navigate_params.disposition = |
| 151 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB; | 151 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB; |
| 152 | 152 |
| 153 navigate_params.window_bounds = initial_pos; | 153 navigate_params.window_bounds = initial_pos; |
| 154 navigate_params.user_gesture = user_gesture; | 154 navigate_params.user_gesture = user_gesture; |
| 155 navigate_params.extension_app_id = panel_->extension_id(); | 155 navigate_params.extension_app_id = panel_->extension_id(); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 } | 264 } |
| 265 | 265 |
| 266 void PanelHost::StopLoading() { | 266 void PanelHost::StopLoading() { |
| 267 content::RecordAction(UserMetricsAction("Stop")); | 267 content::RecordAction(UserMetricsAction("Stop")); |
| 268 web_contents_->Stop(); | 268 web_contents_->Stop(); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void PanelHost::Zoom(content::PageZoom zoom) { | 271 void PanelHost::Zoom(content::PageZoom zoom) { |
| 272 chrome_page_zoom::Zoom(web_contents_.get(), zoom); | 272 chrome_page_zoom::Zoom(web_contents_.get(), zoom); |
| 273 } | 273 } |
| OLD | NEW |