Chromium Code Reviews| Index: chrome/browser/ui/app_list/start_page_service.cc |
| diff --git a/chrome/browser/ui/app_list/start_page_service.cc b/chrome/browser/ui/app_list/start_page_service.cc |
| index 9977fba3528f49650a877b49cb8f0339870f989f..027641a6de87ec62dc92eaf48900fed17f72c101 100644 |
| --- a/chrome/browser/ui/app_list/start_page_service.cc |
| +++ b/chrome/browser/ui/app_list/start_page_service.cc |
| @@ -25,6 +25,7 @@ |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/common/pref_names.h" |
| #include "chrome/common/url_constants.h" |
| +#include "components/ui/zoom/zoom_controller.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/notification_details.h" |
| #include "content/public/browser/notification_observer.h" |
| @@ -447,6 +448,21 @@ void StartPageService::Shutdown() { |
| network_change_observer_.reset(); |
| } |
| +// Set the zoom level in DidNavigateMainFrame, as this is the earliest point |
| +// at which it can be done and not be affected by the ZoomController's |
| +// DidNavigateMainFrame handler. |
|
Matt Giuca
2015/01/20 07:15:01
Weird place for a comment (don't usually document
benwells
2015/01/20 07:31:09
Done.
|
| +void StartPageService::DidNavigateMainFrame( |
| + const content::LoadCommittedDetails& /* details */, |
| + const content::FrameNavigateParams& /* params */ ) { |
|
Matt Giuca
2015/01/20 07:15:01
Nit: No spaces in between the /* and */ (see style
benwells
2015/01/20 07:31:09
Done.
|
| + // Use a temporary zoom level for this web contents (aka isolated zoom |
| + // mode) so changes to its zoom aren't reflected in any preferences. |
| + ui_zoom::ZoomController::FromWebContents(contents_.get())->SetZoomMode( |
| + ui_zoom::ZoomController::ZOOM_MODE_ISOLATED); |
| + // Set to have a zoom level of '0', which corresponds to 100%, so the |
|
Matt Giuca
2015/01/20 07:15:01
Nit: Remove quotes around '0' (it is a number, not
benwells
2015/01/20 07:31:09
Done.
|
| + // contents aren't affected by the browser's default zoom level. |
| + ui_zoom::ZoomController::FromWebContents(contents_.get())->SetZoomLevel(0); |
| +} |
| + |
| void StartPageService::WebUILoaded() { |
| // There's a race condition between the WebUI loading, and calling its JS |
| // functions. Specifically, calling LoadContents() doesn't mean that the page |
| @@ -465,6 +481,12 @@ void StartPageService::LoadContents() { |
| contents_delegate_.reset(new StartPageWebContentsDelegate()); |
| contents_->SetDelegate(contents_delegate_.get()); |
| + // The ZoomController needs to be created before the web contents is observed |
| + // by this object. Otherwise it will react to DidNavigateMainFrame after this |
| + // object does, resetting the zoom mode in the process. |
| + ui_zoom::ZoomController::CreateForWebContents(contents_.get()); |
| + Observe(contents_.get()); |
| + |
| contents_->GetController().LoadURL( |
| GURL(chrome::kChromeUIAppListStartPageURL), |
| content::Referrer(), |