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

Side by Side Diff: chrome/browser/ui/app_list/start_page_service.cc

Issue 2662503002: Convert StartPageService and ZoomController to use the new navigation callbacks. (Closed)
Patch Set: fix unittest Created 3 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/app_list/start_page_service.h" 5 #include "chrome/browser/ui/app_list/start_page_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 22 matching lines...) Expand all
33 #include "chrome/browser/ui/browser_navigator_params.h" 33 #include "chrome/browser/ui/browser_navigator_params.h"
34 #include "chrome/browser/ui/browser_tabstrip.h" 34 #include "chrome/browser/ui/browser_tabstrip.h"
35 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 35 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
36 #include "chrome/common/chrome_switches.h" 36 #include "chrome/common/chrome_switches.h"
37 #include "chrome/common/pref_names.h" 37 #include "chrome/common/pref_names.h"
38 #include "chrome/common/url_constants.h" 38 #include "chrome/common/url_constants.h"
39 #include "components/prefs/pref_service.h" 39 #include "components/prefs/pref_service.h"
40 #include "components/search_engines/template_url_service.h" 40 #include "components/search_engines/template_url_service.h"
41 #include "components/zoom/zoom_controller.h" 41 #include "components/zoom/zoom_controller.h"
42 #include "content/public/browser/browser_thread.h" 42 #include "content/public/browser/browser_thread.h"
43 #include "content/public/browser/navigation_handle.h"
43 #include "content/public/browser/notification_details.h" 44 #include "content/public/browser/notification_details.h"
44 #include "content/public/browser/notification_observer.h" 45 #include "content/public/browser/notification_observer.h"
45 #include "content/public/browser/notification_registrar.h" 46 #include "content/public/browser/notification_registrar.h"
46 #include "content/public/browser/notification_service.h" 47 #include "content/public/browser/notification_service.h"
47 #include "content/public/browser/notification_source.h" 48 #include "content/public/browser/notification_source.h"
48 #include "content/public/browser/render_view_host.h" 49 #include "content/public/browser/render_view_host.h"
49 #include "content/public/browser/render_widget_host.h" 50 #include "content/public/browser/render_widget_host.h"
50 #include "content/public/browser/render_widget_host_view.h" 51 #include "content/public/browser/render_widget_host_view.h"
51 #include "content/public/browser/speech_recognition_session_preamble.h" 52 #include "content/public/browser/speech_recognition_session_preamble.h"
52 #include "content/public/browser/web_contents.h" 53 #include "content/public/browser/web_contents.h"
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 void StartPageService::Shutdown() { 551 void StartPageService::Shutdown() {
551 UnloadContents(); 552 UnloadContents();
552 #if defined(OS_CHROMEOS) 553 #if defined(OS_CHROMEOS)
553 audio_status_.reset(); 554 audio_status_.reset();
554 #endif 555 #endif
555 556
556 speech_auth_helper_.reset(); 557 speech_auth_helper_.reset();
557 network_change_observer_.reset(); 558 network_change_observer_.reset();
558 } 559 }
559 560
560 void StartPageService::DidNavigateMainFrame( 561 void StartPageService::DidFinishNavigation(
561 const content::LoadCommittedDetails& /*details*/, 562 content::NavigationHandle* navigation_handle) {
562 const content::FrameNavigateParams& /*params*/) { 563 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted())
Dan Beam 2017/01/27 20:33:21 should this !IsInMainFrame() be after the error ch
jam 2017/01/27 21:28:57 per the other comment, these two methods realy onl
563 // Set the zoom level in DidNavigateMainFrame, as this is the earliest point 564 return;
565
566 if (navigation_handle->IsErrorPage()) {
567 // This avoids displaying a "Webpage Blocked" error or similar (which can
568 // happen if the URL is blacklisted by enterprise policy).
569 content::BrowserThread::PostTask(
570 content::BrowserThread::UI, FROM_HERE,
571 base::Bind(&StartPageService::UnloadContents,
572 weak_factory_.GetWeakPtr()));
573 return;
574 }
575
576 // Set the zoom level in DidFinishNavigation, as this is the earliest point
564 // at which it can be done and not be affected by the ZoomController's 577 // at which it can be done and not be affected by the ZoomController's
565 // DidNavigateMainFrame handler. 578 // DidFinishNavigation handler.
566 // 579 //
567 // Use a temporary zoom level for this web contents (aka isolated zoom 580 // Use a temporary zoom level for this web contents (aka isolated zoom
568 // mode) so changes to its zoom aren't reflected in any preferences. 581 // mode) so changes to its zoom aren't reflected in any preferences.
569 zoom::ZoomController::FromWebContents(contents_.get()) 582 zoom::ZoomController::FromWebContents(contents_.get())
570 ->SetZoomMode(zoom::ZoomController::ZOOM_MODE_ISOLATED); 583 ->SetZoomMode(zoom::ZoomController::ZOOM_MODE_ISOLATED);
571 // Set to have a zoom level of 0, which corresponds to 100%, so the 584 // Set to have a zoom level of 0, which corresponds to 100%, so the
572 // contents aren't affected by the browser's default zoom level. 585 // contents aren't affected by the browser's default zoom level.
573 zoom::ZoomController::FromWebContents(contents_.get())->SetZoomLevel(0); 586 zoom::ZoomController::FromWebContents(contents_.get())->SetZoomLevel(0);
574 } 587 }
575 588
576 void StartPageService::DidFailProvisionalLoad(
Dan Beam 2017/01/27 20:33:21 did this only apply to the main page? did this ge
jam 2017/01/27 21:28:57 The chrome apps page has no frames, so the IsInMai
577 content::RenderFrameHost* render_frame_host,
578 const GURL& validated_url,
579 int error_code,
580 const base::string16& error_description,
581 bool was_ignored_by_handler) {
582 // This avoids displaying a "Webpage Blocked" error or similar (which can
583 // happen if the URL is blacklisted by enterprise policy).
584 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
585 base::Bind(&StartPageService::UnloadContents,
586 weak_factory_.GetWeakPtr()));
587 }
588
589 void StartPageService::WebUILoaded() { 589 void StartPageService::WebUILoaded() {
590 // There's a race condition between the WebUI loading, and calling its JS 590 // There's a race condition between the WebUI loading, and calling its JS
591 // functions. Specifically, calling LoadContents() doesn't mean that the page 591 // functions. Specifically, calling LoadContents() doesn't mean that the page
592 // has loaded, but several code paths make this assumption. This function 592 // has loaded, but several code paths make this assumption. This function
593 // allows us to defer calling JS functions until after the page has finished 593 // allows us to defer calling JS functions until after the page has finished
594 // loading. 594 // loading.
595 webui_finished_loading_ = true; 595 webui_finished_loading_ = true;
596 for (const auto& cb : pending_webui_callbacks_) 596 for (const auto& cb : pending_webui_callbacks_)
597 cb.Run(); 597 cb.Run();
598 pending_webui_callbacks_.clear(); 598 pending_webui_callbacks_.clear();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 684
685 // Check for a new doodle. 685 // Check for a new doodle.
686 content::BrowserThread::PostDelayedTask( 686 content::BrowserThread::PostDelayedTask(
687 content::BrowserThread::UI, FROM_HERE, 687 content::BrowserThread::UI, FROM_HERE,
688 base::Bind(&StartPageService::FetchDoodleJson, 688 base::Bind(&StartPageService::FetchDoodleJson,
689 weak_factory_.GetWeakPtr()), 689 weak_factory_.GetWeakPtr()),
690 recheck_delay); 690 recheck_delay);
691 } 691 }
692 692
693 } // namespace app_list 693 } // namespace app_list
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/start_page_service.h ('k') | chrome/browser/ui/zoom/zoom_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698