| 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 "base/logging.h" | 5 #include "base/logging.h" | 
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" | 
| 7 #include "content/browser/frame_host/cross_site_transferring_request.h" | 7 #include "content/browser/frame_host/cross_site_transferring_request.h" | 
| 8 #include "content/browser/frame_host/interstitial_page_impl.h" | 8 #include "content/browser/frame_host/interstitial_page_impl.h" | 
| 9 #include "content/browser/frame_host/navigation_entry_impl.h" | 9 #include "content/browser/frame_host/navigation_entry_impl.h" | 
| 10 #include "content/browser/media/audio_stream_monitor.h" | 10 #include "content/browser/media/audio_stream_monitor.h" | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 38 | 38 | 
| 39 namespace content { | 39 namespace content { | 
| 40 namespace { | 40 namespace { | 
| 41 | 41 | 
| 42 const char kTestWebUIUrl[] = "chrome://blah"; | 42 const char kTestWebUIUrl[] = "chrome://blah"; | 
| 43 | 43 | 
| 44 class WebContentsImplTestWebUIControllerFactory | 44 class WebContentsImplTestWebUIControllerFactory | 
| 45     : public WebUIControllerFactory { | 45     : public WebUIControllerFactory { | 
| 46  public: | 46  public: | 
| 47   virtual WebUIController* CreateWebUIControllerForURL( | 47   virtual WebUIController* CreateWebUIControllerForURL( | 
| 48       WebUI* web_ui, const GURL& url) const OVERRIDE { | 48       WebUI* web_ui, const GURL& url) const override { | 
| 49     if (!UseWebUI(url)) | 49     if (!UseWebUI(url)) | 
| 50       return NULL; | 50       return NULL; | 
| 51     return new WebUIController(web_ui); | 51     return new WebUIController(web_ui); | 
| 52   } | 52   } | 
| 53 | 53 | 
| 54   virtual WebUI::TypeID GetWebUIType(BrowserContext* browser_context, | 54   virtual WebUI::TypeID GetWebUIType(BrowserContext* browser_context, | 
| 55       const GURL& url) const OVERRIDE { | 55       const GURL& url) const override { | 
| 56     return WebUI::kNoWebUI; | 56     return WebUI::kNoWebUI; | 
| 57   } | 57   } | 
| 58 | 58 | 
| 59   virtual bool UseWebUIForURL(BrowserContext* browser_context, | 59   virtual bool UseWebUIForURL(BrowserContext* browser_context, | 
| 60                               const GURL& url) const OVERRIDE { | 60                               const GURL& url) const override { | 
| 61     return UseWebUI(url); | 61     return UseWebUI(url); | 
| 62   } | 62   } | 
| 63 | 63 | 
| 64   virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context, | 64   virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context, | 
| 65                                       const GURL& url) const OVERRIDE { | 65                                       const GURL& url) const override { | 
| 66     return UseWebUI(url); | 66     return UseWebUI(url); | 
| 67   } | 67   } | 
| 68 | 68 | 
| 69  private: | 69  private: | 
| 70   bool UseWebUI(const GURL& url) const { | 70   bool UseWebUI(const GURL& url) const { | 
| 71     return url == GURL(kTestWebUIUrl); | 71     return url == GURL(kTestWebUIUrl); | 
| 72   } | 72   } | 
| 73 }; | 73 }; | 
| 74 | 74 | 
| 75 class TestInterstitialPage; | 75 class TestInterstitialPage; | 
| 76 | 76 | 
| 77 class TestInterstitialPageDelegate : public InterstitialPageDelegate { | 77 class TestInterstitialPageDelegate : public InterstitialPageDelegate { | 
| 78  public: | 78  public: | 
| 79   explicit TestInterstitialPageDelegate(TestInterstitialPage* interstitial_page) | 79   explicit TestInterstitialPageDelegate(TestInterstitialPage* interstitial_page) | 
| 80       : interstitial_page_(interstitial_page) {} | 80       : interstitial_page_(interstitial_page) {} | 
| 81   virtual void CommandReceived(const std::string& command) OVERRIDE; | 81   virtual void CommandReceived(const std::string& command) override; | 
| 82   virtual std::string GetHTMLContents() OVERRIDE { return std::string(); } | 82   virtual std::string GetHTMLContents() override { return std::string(); } | 
| 83   virtual void OnDontProceed() OVERRIDE; | 83   virtual void OnDontProceed() override; | 
| 84   virtual void OnProceed() OVERRIDE; | 84   virtual void OnProceed() override; | 
| 85  private: | 85  private: | 
| 86   TestInterstitialPage* interstitial_page_; | 86   TestInterstitialPage* interstitial_page_; | 
| 87 }; | 87 }; | 
| 88 | 88 | 
| 89 class TestInterstitialPage : public InterstitialPageImpl { | 89 class TestInterstitialPage : public InterstitialPageImpl { | 
| 90  public: | 90  public: | 
| 91   enum InterstitialState { | 91   enum InterstitialState { | 
| 92     INVALID = 0,    // Hasn't yet been initialized. | 92     INVALID = 0,    // Hasn't yet been initialized. | 
| 93     UNDECIDED,      // Initialized, but no decision taken yet. | 93     UNDECIDED,      // Initialized, but no decision taken yet. | 
| 94     OKED,           // Proceed was called. | 94     OKED,           // Proceed was called. | 
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 179 | 179 | 
| 180   void CommandReceived() { | 180   void CommandReceived() { | 
| 181     command_received_count_++; | 181     command_received_count_++; | 
| 182   } | 182   } | 
| 183 | 183 | 
| 184   void set_delegate(Delegate* delegate) { | 184   void set_delegate(Delegate* delegate) { | 
| 185     delegate_ = delegate; | 185     delegate_ = delegate; | 
| 186   } | 186   } | 
| 187 | 187 | 
| 188  protected: | 188  protected: | 
| 189   virtual WebContentsView* CreateWebContentsView() OVERRIDE { | 189   virtual WebContentsView* CreateWebContentsView() override { | 
| 190     return NULL; | 190     return NULL; | 
| 191   } | 191   } | 
| 192 | 192 | 
| 193  private: | 193  private: | 
| 194   InterstitialState* state_; | 194   InterstitialState* state_; | 
| 195   bool* deleted_; | 195   bool* deleted_; | 
| 196   int command_received_count_; | 196   int command_received_count_; | 
| 197   Delegate* delegate_; | 197   Delegate* delegate_; | 
| 198 }; | 198 }; | 
| 199 | 199 | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 216       : interstitial_page_(interstitial_page) { | 216       : interstitial_page_(interstitial_page) { | 
| 217     DCHECK(interstitial_page_); | 217     DCHECK(interstitial_page_); | 
| 218     interstitial_page_->set_delegate(this); | 218     interstitial_page_->set_delegate(this); | 
| 219   } | 219   } | 
| 220   virtual ~TestInterstitialPageStateGuard() { | 220   virtual ~TestInterstitialPageStateGuard() { | 
| 221     if (interstitial_page_) | 221     if (interstitial_page_) | 
| 222       interstitial_page_->ClearStates(); | 222       interstitial_page_->ClearStates(); | 
| 223   } | 223   } | 
| 224 | 224 | 
| 225   virtual void TestInterstitialPageDeleted( | 225   virtual void TestInterstitialPageDeleted( | 
| 226       TestInterstitialPage* interstitial) OVERRIDE { | 226       TestInterstitialPage* interstitial) override { | 
| 227     DCHECK(interstitial_page_ == interstitial); | 227     DCHECK(interstitial_page_ == interstitial); | 
| 228     interstitial_page_ = NULL; | 228     interstitial_page_ = NULL; | 
| 229   } | 229   } | 
| 230 | 230 | 
| 231  private: | 231  private: | 
| 232   TestInterstitialPage* interstitial_page_; | 232   TestInterstitialPage* interstitial_page_; | 
| 233 }; | 233 }; | 
| 234 | 234 | 
| 235 class WebContentsImplTestBrowserClient : public TestContentBrowserClient { | 235 class WebContentsImplTestBrowserClient : public TestContentBrowserClient { | 
| 236  public: | 236  public: | 
| 237   WebContentsImplTestBrowserClient() | 237   WebContentsImplTestBrowserClient() | 
| 238       : assign_site_for_url_(false) {} | 238       : assign_site_for_url_(false) {} | 
| 239 | 239 | 
| 240   virtual ~WebContentsImplTestBrowserClient() {} | 240   virtual ~WebContentsImplTestBrowserClient() {} | 
| 241 | 241 | 
| 242   virtual bool ShouldAssignSiteForURL(const GURL& url) OVERRIDE { | 242   virtual bool ShouldAssignSiteForURL(const GURL& url) override { | 
| 243     return assign_site_for_url_; | 243     return assign_site_for_url_; | 
| 244   } | 244   } | 
| 245 | 245 | 
| 246   void set_assign_site_for_url(bool assign) { | 246   void set_assign_site_for_url(bool assign) { | 
| 247     assign_site_for_url_ = assign; | 247     assign_site_for_url_ = assign; | 
| 248   } | 248   } | 
| 249 | 249 | 
| 250  private: | 250  private: | 
| 251   bool assign_site_for_url_; | 251   bool assign_site_for_url_; | 
| 252 }; | 252 }; | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 268 }; | 268 }; | 
| 269 | 269 | 
| 270 class TestWebContentsObserver : public WebContentsObserver { | 270 class TestWebContentsObserver : public WebContentsObserver { | 
| 271  public: | 271  public: | 
| 272   explicit TestWebContentsObserver(WebContents* contents) | 272   explicit TestWebContentsObserver(WebContents* contents) | 
| 273       : WebContentsObserver(contents) { | 273       : WebContentsObserver(contents) { | 
| 274   } | 274   } | 
| 275   virtual ~TestWebContentsObserver() {} | 275   virtual ~TestWebContentsObserver() {} | 
| 276 | 276 | 
| 277   virtual void DidFinishLoad(RenderFrameHost* render_frame_host, | 277   virtual void DidFinishLoad(RenderFrameHost* render_frame_host, | 
| 278                              const GURL& validated_url) OVERRIDE { | 278                              const GURL& validated_url) override { | 
| 279     last_url_ = validated_url; | 279     last_url_ = validated_url; | 
| 280   } | 280   } | 
| 281   virtual void DidFailLoad(RenderFrameHost* render_frame_host, | 281   virtual void DidFailLoad(RenderFrameHost* render_frame_host, | 
| 282                            const GURL& validated_url, | 282                            const GURL& validated_url, | 
| 283                            int error_code, | 283                            int error_code, | 
| 284                            const base::string16& error_description) OVERRIDE { | 284                            const base::string16& error_description) override { | 
| 285     last_url_ = validated_url; | 285     last_url_ = validated_url; | 
| 286   } | 286   } | 
| 287 | 287 | 
| 288   const GURL& last_url() const { return last_url_; } | 288   const GURL& last_url() const { return last_url_; } | 
| 289 | 289 | 
| 290  private: | 290  private: | 
| 291   GURL last_url_; | 291   GURL last_url_; | 
| 292 | 292 | 
| 293   DISALLOW_COPY_AND_ASSIGN(TestWebContentsObserver); | 293   DISALLOW_COPY_AND_ASSIGN(TestWebContentsObserver); | 
| 294 }; | 294 }; | 
| 295 | 295 | 
| 296 // Pretends to be a normal browser that receives toggles and transitions to/from | 296 // Pretends to be a normal browser that receives toggles and transitions to/from | 
| 297 // a fullscreened state. | 297 // a fullscreened state. | 
| 298 class FakeFullscreenDelegate : public WebContentsDelegate { | 298 class FakeFullscreenDelegate : public WebContentsDelegate { | 
| 299  public: | 299  public: | 
| 300   FakeFullscreenDelegate() : fullscreened_contents_(NULL) {} | 300   FakeFullscreenDelegate() : fullscreened_contents_(NULL) {} | 
| 301   virtual ~FakeFullscreenDelegate() {} | 301   virtual ~FakeFullscreenDelegate() {} | 
| 302 | 302 | 
| 303   virtual void ToggleFullscreenModeForTab(WebContents* web_contents, | 303   virtual void ToggleFullscreenModeForTab(WebContents* web_contents, | 
| 304                                           bool enter_fullscreen) OVERRIDE { | 304                                           bool enter_fullscreen) override { | 
| 305     fullscreened_contents_ = enter_fullscreen ? web_contents : NULL; | 305     fullscreened_contents_ = enter_fullscreen ? web_contents : NULL; | 
| 306   } | 306   } | 
| 307 | 307 | 
| 308   virtual bool IsFullscreenForTabOrPending(const WebContents* web_contents) | 308   virtual bool IsFullscreenForTabOrPending(const WebContents* web_contents) | 
| 309       const OVERRIDE { | 309       const override { | 
| 310     return fullscreened_contents_ && web_contents == fullscreened_contents_; | 310     return fullscreened_contents_ && web_contents == fullscreened_contents_; | 
| 311   } | 311   } | 
| 312 | 312 | 
| 313  private: | 313  private: | 
| 314   WebContents* fullscreened_contents_; | 314   WebContents* fullscreened_contents_; | 
| 315 | 315 | 
| 316   DISALLOW_COPY_AND_ASSIGN(FakeFullscreenDelegate); | 316   DISALLOW_COPY_AND_ASSIGN(FakeFullscreenDelegate); | 
| 317 }; | 317 }; | 
| 318 | 318 | 
| 319 class FakeValidationMessageDelegate : public WebContentsDelegate { | 319 class FakeValidationMessageDelegate : public WebContentsDelegate { | 
| 320  public: | 320  public: | 
| 321   FakeValidationMessageDelegate() | 321   FakeValidationMessageDelegate() | 
| 322       : hide_validation_message_was_called_(false) {} | 322       : hide_validation_message_was_called_(false) {} | 
| 323   virtual ~FakeValidationMessageDelegate() {} | 323   virtual ~FakeValidationMessageDelegate() {} | 
| 324 | 324 | 
| 325   virtual void HideValidationMessage(WebContents* web_contents) OVERRIDE { | 325   virtual void HideValidationMessage(WebContents* web_contents) override { | 
| 326     hide_validation_message_was_called_ = true; | 326     hide_validation_message_was_called_ = true; | 
| 327   } | 327   } | 
| 328 | 328 | 
| 329   bool hide_validation_message_was_called() const { | 329   bool hide_validation_message_was_called() const { | 
| 330     return hide_validation_message_was_called_; | 330     return hide_validation_message_was_called_; | 
| 331   } | 331   } | 
| 332 | 332 | 
| 333  private: | 333  private: | 
| 334   bool hide_validation_message_was_called_; | 334   bool hide_validation_message_was_called_; | 
| 335 | 335 | 
| (...skipping 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2446     int count = contents_zoom_changed_call_count_; | 2446     int count = contents_zoom_changed_call_count_; | 
| 2447     contents_zoom_changed_call_count_ = 0; | 2447     contents_zoom_changed_call_count_ = 0; | 
| 2448     return count; | 2448     return count; | 
| 2449   } | 2449   } | 
| 2450 | 2450 | 
| 2451   bool last_zoom_in() const { | 2451   bool last_zoom_in() const { | 
| 2452     return last_zoom_in_; | 2452     return last_zoom_in_; | 
| 2453   } | 2453   } | 
| 2454 | 2454 | 
| 2455   // WebContentsDelegate: | 2455   // WebContentsDelegate: | 
| 2456   virtual void ContentsZoomChange(bool zoom_in) OVERRIDE { | 2456   virtual void ContentsZoomChange(bool zoom_in) override { | 
| 2457     contents_zoom_changed_call_count_++; | 2457     contents_zoom_changed_call_count_++; | 
| 2458     last_zoom_in_ = zoom_in; | 2458     last_zoom_in_ = zoom_in; | 
| 2459   } | 2459   } | 
| 2460 | 2460 | 
| 2461  private: | 2461  private: | 
| 2462   int contents_zoom_changed_call_count_; | 2462   int contents_zoom_changed_call_count_; | 
| 2463   bool last_zoom_in_; | 2463   bool last_zoom_in_; | 
| 2464 | 2464 | 
| 2465   DISALLOW_COPY_AND_ASSIGN(ContentsZoomChangedDelegate); | 2465   DISALLOW_COPY_AND_ASSIGN(ContentsZoomChangedDelegate); | 
| 2466 }; | 2466 }; | 
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2774 | 2774 | 
| 2775   // Destroy the video only player.  No power save blockers should remain. | 2775   // Destroy the video only player.  No power save blockers should remain. | 
| 2776   rfh->OnMessageReceived( | 2776   rfh->OnMessageReceived( | 
| 2777       FrameHostMsg_MediaPausedNotification(0, kPlayerVideoOnlyId)); | 2777       FrameHostMsg_MediaPausedNotification(0, kPlayerVideoOnlyId)); | 
| 2778   EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); | 2778   EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); | 
| 2779   EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); | 2779   EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); | 
| 2780 } | 2780 } | 
| 2781 #endif | 2781 #endif | 
| 2782 | 2782 | 
| 2783 }  // namespace content | 2783 }  // namespace content | 
| OLD | NEW | 
|---|