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

Side by Side Diff: chrome/browser/printing/print_dialog_cloud.cc

Issue 2665303003: Convert print_dialog_cloud::SignInObserver to use the new navigation callbacks. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | 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 (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 "chrome/browser/printing/print_dialog_cloud.h" 5 #include "chrome/browser/printing/print_dialog_cloud.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_window.h" 13 #include "chrome/browser/ui/browser_window.h"
14 #include "components/cloud_devices/common/cloud_devices_urls.h" 14 #include "components/cloud_devices/common/cloud_devices_urls.h"
15 #include "components/google/core/browser/google_util.h" 15 #include "components/google/core/browser/google_util.h"
16 #include "components/signin/core/browser/signin_header_helper.h" 16 #include "components/signin/core/browser/signin_header_helper.h"
17 #include "components/signin/core/browser/signin_metrics.h" 17 #include "components/signin/core/browser/signin_metrics.h"
18 #include "components/signin/core/common/profile_management_switches.h" 18 #include "components/signin/core/common/profile_management_switches.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/navigation_handle.h"
20 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
21 #include "content/public/browser/web_contents_observer.h" 22 #include "content/public/browser/web_contents_observer.h"
22 23
23 namespace print_dialog_cloud { 24 namespace print_dialog_cloud {
24 25
25 namespace { 26 namespace {
26 27
27 class SignInObserver : public content::WebContentsObserver { 28 class SignInObserver : public content::WebContentsObserver {
28 public: 29 public:
29 SignInObserver(content::WebContents* web_contents, 30 SignInObserver(content::WebContents* web_contents,
30 const base::Closure& callback) 31 const base::Closure& callback)
31 : WebContentsObserver(web_contents), 32 : WebContentsObserver(web_contents),
32 callback_(callback), 33 callback_(callback),
33 weak_ptr_factory_(this) { 34 weak_ptr_factory_(this) {
34 } 35 }
35 36
36 private: 37 private:
37 // Overridden from content::WebContentsObserver: 38 // Overridden from content::WebContentsObserver:
38 void DidNavigateMainFrame( 39 void DidFinishNavigation(
39 const content::LoadCommittedDetails& details, 40 content::NavigationHandle* navigation_handle) override {
40 const content::FrameNavigateParams& params) override { 41 if (!navigation_handle->IsInMainFrame() ||
41 if (cloud_devices::IsCloudPrintURL(params.url)) { 42 !navigation_handle->HasCommitted()) {
43 return;
44 }
45
46 if (cloud_devices::IsCloudPrintURL(navigation_handle->GetURL())) {
42 base::ThreadTaskRunnerHandle::Get()->PostTask( 47 base::ThreadTaskRunnerHandle::Get()->PostTask(
43 FROM_HERE, base::Bind(&SignInObserver::OnSignIn, 48 FROM_HERE, base::Bind(&SignInObserver::OnSignIn,
44 weak_ptr_factory_.GetWeakPtr())); 49 weak_ptr_factory_.GetWeakPtr()));
45 } 50 }
46 } 51 }
47 52
48 void WebContentsDestroyed() override { delete this; } 53 void WebContentsDestroyed() override { delete this; }
49 54
50 void OnSignIn() { 55 void OnSignIn() {
51 callback_.Run(); 56 callback_.Run();
(...skipping 28 matching lines...) Expand all
80 browser->OpenURL(content::OpenURLParams( 85 browser->OpenURL(content::OpenURLParams(
81 google_util::AppendGoogleLocaleParam( 86 google_util::AppendGoogleLocaleParam(
82 url, g_browser_process->GetApplicationLocale()), 87 url, g_browser_process->GetApplicationLocale()),
83 content::Referrer(), WindowOpenDisposition::NEW_FOREGROUND_TAB, 88 content::Referrer(), WindowOpenDisposition::NEW_FOREGROUND_TAB,
84 ui::PAGE_TRANSITION_AUTO_BOOKMARK, false)); 89 ui::PAGE_TRANSITION_AUTO_BOOKMARK, false));
85 new SignInObserver(web_contents, callback); 90 new SignInObserver(web_contents, callback);
86 } 91 }
87 } 92 }
88 93
89 } // namespace print_dialog_cloud 94 } // namespace print_dialog_cloud
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698