| 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/instant/instant_loader.h" | 5 #include "chrome/browser/instant/instant_loader.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 void UnregisterForPaintNotifications(); | 174 void UnregisterForPaintNotifications(); |
| 175 | 175 |
| 176 // NotificationObserver: | 176 // NotificationObserver: |
| 177 virtual void Observe(int type, | 177 virtual void Observe(int type, |
| 178 const NotificationSource& source, | 178 const NotificationSource& source, |
| 179 const NotificationDetails& details) OVERRIDE; | 179 const NotificationDetails& details) OVERRIDE; |
| 180 | 180 |
| 181 // TabContentsDelegate: | 181 // TabContentsDelegate: |
| 182 virtual void NavigationStateChanged(const TabContents* source, | 182 virtual void NavigationStateChanged(const TabContents* source, |
| 183 unsigned changed_flags) OVERRIDE; | 183 unsigned changed_flags) OVERRIDE; |
| 184 virtual std::string GetNavigationHeaders(const GURL& url) OVERRIDE; | 184 virtual void AddNavigationHeaders(const GURL& url, |
| 185 std::string* headers) OVERRIDE; |
| 185 virtual bool ShouldFocusConstrainedWindow() OVERRIDE; | 186 virtual bool ShouldFocusConstrainedWindow() OVERRIDE; |
| 186 virtual void WillShowConstrainedWindow(TabContents* source) OVERRIDE; | 187 virtual void WillShowConstrainedWindow(TabContents* source) OVERRIDE; |
| 187 virtual bool ShouldSuppressDialogs() OVERRIDE; | 188 virtual bool ShouldSuppressDialogs() OVERRIDE; |
| 188 virtual void BeforeUnloadFired(TabContents* tab, | 189 virtual void BeforeUnloadFired(TabContents* tab, |
| 189 bool proceed, | 190 bool proceed, |
| 190 bool* proceed_to_fire_unload) OVERRIDE; | 191 bool* proceed_to_fire_unload) OVERRIDE; |
| 191 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE; | 192 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE; |
| 192 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; | 193 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; |
| 193 virtual void LostCapture() OVERRIDE; | 194 virtual void LostCapture() OVERRIDE; |
| 194 // If the user drags, we won't get a mouse up (at least on Linux). Commit the | 195 // If the user drags, we won't get a mouse up (at least on Linux). Commit the |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 // when a new renderer is created from the resize so that if we showed the | 406 // when a new renderer is created from the resize so that if we showed the |
| 406 // preview after the first paint we would end up with a white rect. | 407 // preview after the first paint we would end up with a white rect. |
| 407 RenderWidgetHostView *rwhv = source->GetRenderWidgetHostView(); | 408 RenderWidgetHostView *rwhv = source->GetRenderWidgetHostView(); |
| 408 if (rwhv) | 409 if (rwhv) |
| 409 RegisterForPaintNotifications(rwhv->GetRenderWidgetHost()); | 410 RegisterForPaintNotifications(rwhv->GetRenderWidgetHost()); |
| 410 } else if (source->is_crashed()) { | 411 } else if (source->is_crashed()) { |
| 411 PreviewPainted(); | 412 PreviewPainted(); |
| 412 } | 413 } |
| 413 } | 414 } |
| 414 | 415 |
| 415 std::string InstantLoader::TabContentsDelegateImpl::GetNavigationHeaders( | 416 void InstantLoader::TabContentsDelegateImpl::AddNavigationHeaders( |
| 416 const GURL& url) { | 417 const GURL& url, |
| 417 std::string header; | 418 std::string* headers) { |
| 418 net::HttpUtil::AppendHeaderIfMissing(kPreviewHeader, kPreviewHeaderValue, | 419 net::HttpUtil::AppendHeaderIfMissing(kPreviewHeader, kPreviewHeaderValue, |
| 419 &header); | 420 headers); |
| 420 return header; | |
| 421 } | 421 } |
| 422 | 422 |
| 423 bool InstantLoader::TabContentsDelegateImpl::ShouldFocusConstrainedWindow() { | 423 bool InstantLoader::TabContentsDelegateImpl::ShouldFocusConstrainedWindow() { |
| 424 // Return false so that constrained windows are not initially focused. If | 424 // Return false so that constrained windows are not initially focused. If |
| 425 // we did otherwise the preview would prematurely get committed when focus | 425 // we did otherwise the preview would prematurely get committed when focus |
| 426 // goes to the constrained window. | 426 // goes to the constrained window. |
| 427 return false; | 427 return false; |
| 428 } | 428 } |
| 429 | 429 |
| 430 void InstantLoader::TabContentsDelegateImpl::WillShowConstrainedWindow( | 430 void InstantLoader::TabContentsDelegateImpl::WillShowConstrainedWindow( |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 CommandLine* cl = CommandLine::ForCurrentProcess(); | 1028 CommandLine* cl = CommandLine::ForCurrentProcess(); |
| 1029 if (cl->HasSwitch(switches::kInstantURL)) | 1029 if (cl->HasSwitch(switches::kInstantURL)) |
| 1030 instant_url = GURL(cl->GetSwitchValueASCII(switches::kInstantURL)); | 1030 instant_url = GURL(cl->GetSwitchValueASCII(switches::kInstantURL)); |
| 1031 preview_contents_->controller().LoadURL(instant_url, GURL(), transition_type); | 1031 preview_contents_->controller().LoadURL(instant_url, GURL(), transition_type); |
| 1032 RenderViewHost* host = preview_contents_->render_view_host(); | 1032 RenderViewHost* host = preview_contents_->render_view_host(); |
| 1033 host->Send(new ChromeViewMsg_SearchBoxChange( | 1033 host->Send(new ChromeViewMsg_SearchBoxChange( |
| 1034 host->routing_id(), user_text, verbatim, 0, 0)); | 1034 host->routing_id(), user_text, verbatim, 0, 0)); |
| 1035 frame_load_observer_.reset(new FrameLoadObserver( | 1035 frame_load_observer_.reset(new FrameLoadObserver( |
| 1036 this, preview_contents()->tab_contents(), user_text, verbatim)); | 1036 this, preview_contents()->tab_contents(), user_text, verbatim)); |
| 1037 } | 1037 } |
| OLD | NEW |