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

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

Issue 863603003: Keep the app list start page isolated from the browser's default zoom. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formatting Created 5 years, 11 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
« no previous file with comments | « chrome/browser/ui/app_list/start_page_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/memory/singleton.h" 11 #include "base/memory/singleton.h"
12 #include "base/metrics/user_metrics.h" 12 #include "base/metrics/user_metrics.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/media/media_stream_infobar_delegate.h" 16 #include "chrome/browser/media/media_stream_infobar_delegate.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/search/hotword_service.h" 18 #include "chrome/browser/search/hotword_service.h"
19 #include "chrome/browser/search/hotword_service_factory.h" 19 #include "chrome/browser/search/hotword_service_factory.h"
20 #include "chrome/browser/ui/app_list/recommended_apps.h" 20 #include "chrome/browser/ui/app_list/recommended_apps.h"
21 #include "chrome/browser/ui/app_list/speech_auth_helper.h" 21 #include "chrome/browser/ui/app_list/speech_auth_helper.h"
22 #include "chrome/browser/ui/app_list/speech_recognizer.h" 22 #include "chrome/browser/ui/app_list/speech_recognizer.h"
23 #include "chrome/browser/ui/app_list/start_page_observer.h" 23 #include "chrome/browser/ui/app_list/start_page_observer.h"
24 #include "chrome/browser/ui/app_list/start_page_service_factory.h" 24 #include "chrome/browser/ui/app_list/start_page_service_factory.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
28 #include "components/ui/zoom/zoom_controller.h"
28 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/notification_details.h" 30 #include "content/public/browser/notification_details.h"
30 #include "content/public/browser/notification_observer.h" 31 #include "content/public/browser/notification_observer.h"
31 #include "content/public/browser/notification_registrar.h" 32 #include "content/public/browser/notification_registrar.h"
32 #include "content/public/browser/notification_service.h" 33 #include "content/public/browser/notification_service.h"
33 #include "content/public/browser/notification_source.h" 34 #include "content/public/browser/notification_source.h"
34 #include "content/public/browser/speech_recognition_session_preamble.h" 35 #include "content/public/browser/speech_recognition_session_preamble.h"
35 #include "content/public/browser/web_contents.h" 36 #include "content/public/browser/web_contents.h"
36 #include "content/public/browser/web_contents_delegate.h" 37 #include "content/public/browser/web_contents_delegate.h"
37 #include "extensions/browser/extension_system_provider.h" 38 #include "extensions/browser/extension_system_provider.h"
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 void StartPageService::Shutdown() { 441 void StartPageService::Shutdown() {
441 UnloadContents(); 442 UnloadContents();
442 #if defined(OS_CHROMEOS) 443 #if defined(OS_CHROMEOS)
443 audio_status_.reset(); 444 audio_status_.reset();
444 #endif 445 #endif
445 446
446 speech_auth_helper_.reset(); 447 speech_auth_helper_.reset();
447 network_change_observer_.reset(); 448 network_change_observer_.reset();
448 } 449 }
449 450
451 void StartPageService::DidNavigateMainFrame(
452 const content::LoadCommittedDetails& /*details*/,
453 const content::FrameNavigateParams& /*params*/) {
454 // Set the zoom level in DidNavigateMainFrame, as this is the earliest point
455 // at which it can be done and not be affected by the ZoomController's
456 // DidNavigateMainFrame handler.
457 //
458 // Use a temporary zoom level for this web contents (aka isolated zoom
459 // mode) so changes to its zoom aren't reflected in any preferences.
460 ui_zoom::ZoomController::FromWebContents(contents_.get())
461 ->SetZoomMode(ui_zoom::ZoomController::ZOOM_MODE_ISOLATED);
462 // Set to have a zoom level of 0, which corresponds to 100%, so the
463 // contents aren't affected by the browser's default zoom level.
464 ui_zoom::ZoomController::FromWebContents(contents_.get())->SetZoomLevel(0);
465 }
466
450 void StartPageService::WebUILoaded() { 467 void StartPageService::WebUILoaded() {
451 // There's a race condition between the WebUI loading, and calling its JS 468 // There's a race condition between the WebUI loading, and calling its JS
452 // functions. Specifically, calling LoadContents() doesn't mean that the page 469 // functions. Specifically, calling LoadContents() doesn't mean that the page
453 // has loaded, but several code paths make this assumption. This function 470 // has loaded, but several code paths make this assumption. This function
454 // allows us to defer calling JS functions until after the page has finished 471 // allows us to defer calling JS functions until after the page has finished
455 // loading. 472 // loading.
456 webui_finished_loading_ = true; 473 webui_finished_loading_ = true;
457 for (const auto& cb : pending_webui_callbacks_) 474 for (const auto& cb : pending_webui_callbacks_)
458 cb.Run(); 475 cb.Run();
459 pending_webui_callbacks_.clear(); 476 pending_webui_callbacks_.clear();
460 } 477 }
461 478
462 void StartPageService::LoadContents() { 479 void StartPageService::LoadContents() {
463 contents_.reset(content::WebContents::Create( 480 contents_.reset(content::WebContents::Create(
464 content::WebContents::CreateParams(profile_))); 481 content::WebContents::CreateParams(profile_)));
465 contents_delegate_.reset(new StartPageWebContentsDelegate()); 482 contents_delegate_.reset(new StartPageWebContentsDelegate());
466 contents_->SetDelegate(contents_delegate_.get()); 483 contents_->SetDelegate(contents_delegate_.get());
467 484
485 // The ZoomController needs to be created before the web contents is observed
486 // by this object. Otherwise it will react to DidNavigateMainFrame after this
487 // object does, resetting the zoom mode in the process.
488 ui_zoom::ZoomController::CreateForWebContents(contents_.get());
489 Observe(contents_.get());
490
468 contents_->GetController().LoadURL( 491 contents_->GetController().LoadURL(
469 GURL(chrome::kChromeUIAppListStartPageURL), 492 GURL(chrome::kChromeUIAppListStartPageURL),
470 content::Referrer(), 493 content::Referrer(),
471 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, 494 ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
472 std::string()); 495 std::string());
473 } 496 }
474 497
475 void StartPageService::UnloadContents() { 498 void StartPageService::UnloadContents() {
476 contents_.reset(); 499 contents_.reset();
477 webui_finished_loading_ = false; 500 webui_finished_loading_ = false;
478 } 501 }
479 502
480 } // namespace app_list 503 } // namespace app_list
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/start_page_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698