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

Side by Side Diff: chrome/browser/ui/apps/chrome_app_delegate.cc

Issue 1550053002: Convert Pass()→std::move() in //chrome/browser/ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/apps/chrome_app_delegate.h" 5 #include "chrome/browser/ui/apps/chrome_app_delegate.h"
6 6
7 #include <utility>
8
7 #include "base/macros.h" 9 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
10 #include "chrome/browser/app_mode/app_mode_utils.h" 12 #include "chrome/browser/app_mode/app_mode_utils.h"
11 #include "chrome/browser/apps/scoped_keep_alive.h" 13 #include "chrome/browser/apps/scoped_keep_alive.h"
12 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" 15 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
14 #include "chrome/browser/favicon/favicon_utils.h" 16 #include "chrome/browser/favicon/favicon_utils.h"
15 #include "chrome/browser/file_select_helper.h" 17 #include "chrome/browser/file_select_helper.h"
16 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 18 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 79 }
78 80
79 // Helper class that opens a URL based on if this browser instance is the 81 // Helper class that opens a URL based on if this browser instance is the
80 // default system browser. If it is the default, open the URL directly instead 82 // default system browser. If it is the default, open the URL directly instead
81 // of asking the system to open it. 83 // of asking the system to open it.
82 class OpenURLFromTabBasedOnBrowserDefault 84 class OpenURLFromTabBasedOnBrowserDefault
83 : public ShellIntegration::DefaultWebClientObserver { 85 : public ShellIntegration::DefaultWebClientObserver {
84 public: 86 public:
85 OpenURLFromTabBasedOnBrowserDefault(scoped_ptr<content::WebContents> source, 87 OpenURLFromTabBasedOnBrowserDefault(scoped_ptr<content::WebContents> source,
86 const content::OpenURLParams& params) 88 const content::OpenURLParams& params)
87 : source_(source.Pass()), params_(params) {} 89 : source_(std::move(source)), params_(params) {}
88 90
89 // Opens a URL when called with the result of if this is the default system 91 // Opens a URL when called with the result of if this is the default system
90 // browser or not. 92 // browser or not.
91 void SetDefaultWebClientUIState( 93 void SetDefaultWebClientUIState(
92 ShellIntegration::DefaultWebClientUIState state) override { 94 ShellIntegration::DefaultWebClientUIState state) override {
93 Profile* profile = 95 Profile* profile =
94 Profile::FromBrowserContext(source_->GetBrowserContext()); 96 Profile::FromBrowserContext(source_->GetBrowserContext());
95 DCHECK(profile); 97 DCHECK(profile);
96 if (!profile) 98 if (!profile)
97 return; 99 return;
(...skipping 19 matching lines...) Expand all
117 119
118 } // namespace 120 } // namespace
119 121
120 // static 122 // static
121 void ChromeAppDelegate::RelinquishKeepAliveAfterTimeout( 123 void ChromeAppDelegate::RelinquishKeepAliveAfterTimeout(
122 const base::WeakPtr<ChromeAppDelegate>& chrome_app_delegate) { 124 const base::WeakPtr<ChromeAppDelegate>& chrome_app_delegate) {
123 // Resetting the ScopedKeepAlive may cause nested destruction of the 125 // Resetting the ScopedKeepAlive may cause nested destruction of the
124 // ChromeAppDelegate which also resets the ScopedKeepAlive. To avoid this, 126 // ChromeAppDelegate which also resets the ScopedKeepAlive. To avoid this,
125 // move the ScopedKeepAlive out to here and let it fall out of scope. 127 // move the ScopedKeepAlive out to here and let it fall out of scope.
126 if (chrome_app_delegate.get() && chrome_app_delegate->is_hidden_) 128 if (chrome_app_delegate.get() && chrome_app_delegate->is_hidden_)
127 scoped_ptr<ScopedKeepAlive>(chrome_app_delegate->keep_alive_.Pass()); 129 scoped_ptr<ScopedKeepAlive>(std::move(chrome_app_delegate->keep_alive_));
128 } 130 }
129 131
130 class ChromeAppDelegate::NewWindowContentsDelegate 132 class ChromeAppDelegate::NewWindowContentsDelegate
131 : public content::WebContentsDelegate { 133 : public content::WebContentsDelegate {
132 public: 134 public:
133 NewWindowContentsDelegate() {} 135 NewWindowContentsDelegate() {}
134 ~NewWindowContentsDelegate() override {} 136 ~NewWindowContentsDelegate() override {}
135 137
136 content::WebContents* OpenURLFromTab( 138 content::WebContents* OpenURLFromTab(
137 content::WebContents* source, 139 content::WebContents* source,
(...skipping 10 matching lines...) Expand all
148 if (source) { 150 if (source) {
149 // This NewWindowContentsDelegate was given ownership of the incoming 151 // This NewWindowContentsDelegate was given ownership of the incoming
150 // WebContents by being assigned as its delegate within 152 // WebContents by being assigned as its delegate within
151 // ChromeAppDelegate::AddNewContents, but this is the first time 153 // ChromeAppDelegate::AddNewContents, but this is the first time
152 // NewWindowContentsDelegate actually sees the WebContents. 154 // NewWindowContentsDelegate actually sees the WebContents.
153 // Here it is captured for deletion. 155 // Here it is captured for deletion.
154 scoped_ptr<content::WebContents> owned_source(source); 156 scoped_ptr<content::WebContents> owned_source(source);
155 scoped_refptr<ShellIntegration::DefaultWebClientWorker> 157 scoped_refptr<ShellIntegration::DefaultWebClientWorker>
156 check_if_default_browser_worker = 158 check_if_default_browser_worker =
157 new ShellIntegration::DefaultBrowserWorker( 159 new ShellIntegration::DefaultBrowserWorker(
158 new OpenURLFromTabBasedOnBrowserDefault(owned_source.Pass(), 160 new OpenURLFromTabBasedOnBrowserDefault(std::move(owned_source),
159 params)); 161 params));
160 // Object lifetime notes: The OpenURLFromTabBasedOnBrowserDefault is owned 162 // Object lifetime notes: The OpenURLFromTabBasedOnBrowserDefault is owned
161 // by check_if_default_browser_worker. StartCheckIsDefault() takes lifetime 163 // by check_if_default_browser_worker. StartCheckIsDefault() takes lifetime
162 // ownership of check_if_default_browser_worker and will clean up after 164 // ownership of check_if_default_browser_worker and will clean up after
163 // the asynchronous tasks. 165 // the asynchronous tasks.
164 check_if_default_browser_worker->StartCheckIsDefault(); 166 check_if_default_browser_worker->StartCheckIsDefault();
165 } 167 }
166 return NULL; 168 return NULL;
167 } 169 }
168 170
169 ChromeAppDelegate::ChromeAppDelegate(scoped_ptr<ScopedKeepAlive> keep_alive) 171 ChromeAppDelegate::ChromeAppDelegate(scoped_ptr<ScopedKeepAlive> keep_alive)
170 : has_been_shown_(false), 172 : has_been_shown_(false),
171 is_hidden_(true), 173 is_hidden_(true),
172 keep_alive_(keep_alive.Pass()), 174 keep_alive_(std::move(keep_alive)),
173 new_window_contents_delegate_(new NewWindowContentsDelegate()), 175 new_window_contents_delegate_(new NewWindowContentsDelegate()),
174 weak_factory_(this) { 176 weak_factory_(this) {
175 registrar_.Add(this, 177 registrar_.Add(this,
176 chrome::NOTIFICATION_APP_TERMINATING, 178 chrome::NOTIFICATION_APP_TERMINATING,
177 content::NotificationService::AllSources()); 179 content::NotificationService::AllSources());
178 } 180 }
179 181
180 ChromeAppDelegate::~ChromeAppDelegate() { 182 ChromeAppDelegate::~ChromeAppDelegate() {
181 // Unregister now to prevent getting notified if |keep_alive_| is the last. 183 // Unregister now to prevent getting notified if |keep_alive_| is the last.
182 terminating_callback_.Reset(); 184 terminating_callback_.Reset();
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 const content::NotificationDetails& details) { 354 const content::NotificationDetails& details) {
353 switch (type) { 355 switch (type) {
354 case chrome::NOTIFICATION_APP_TERMINATING: 356 case chrome::NOTIFICATION_APP_TERMINATING:
355 if (!terminating_callback_.is_null()) 357 if (!terminating_callback_.is_null())
356 terminating_callback_.Run(); 358 terminating_callback_.Run();
357 break; 359 break;
358 default: 360 default:
359 NOTREACHED() << "Received unexpected notification"; 361 NOTREACHED() << "Received unexpected notification";
360 } 362 }
361 } 363 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/test/fast_show_pickler_unittest.cc ('k') | chrome/browser/ui/ash/ash_init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698